The room is in glb imported . can we hide wall mesh on rotation like sideOrientation: BABYLON.Mesh.DOUBLESIDE, works, It hides the front walls.
i tried wall.sideOrientation = BABYLON.Mesh.BACKSIDE; but didnt work. i think i m missing somthing. In below images wall 1 and 2 need to hide. on room rotation like https://www.babylonjs-playground.com/#4AJ16M#50
Hi @Evgeni_Popov, i resume this old post because i’ve a similar question.
I’ve a box used like a room with sideOrientation: BABYLON.Mesh.BACKSIDE.
What i need is to hide also some mesh near the wall: is there some parameter to set like sideOrientation or am i supposed to do it by myself according to the camera position and rotation?
I was thinking that maybe is enough to know which wall is hiding: if the wall is hidden, then i hide all the mesh related to it.
This is my PG: https://playground.babylonjs.com/#HBRF92#40
Another way would be to use the stencil buffer: for each wall of the room, render it in the stencil buffer with a specific reference value, then render the objects of this wall only where the stencil has the value corresponding to this object. It would be a bit more involved, you would notably need to create separate planes for your walls instead of using a box.
Use a dot product between the camera view direction (more precisely with the reverse of this direction) and the normal of the wall. If it’s negative (meaning the angle between both vectors is not within [-90°, +90°]), the box should be hidden.
My bad, with the perspective projection the angle can be >90° or <-90° and the wall still be visible (in the PG, the object disappears too soon, the wall is still visible when that happens).
You should use the direction from the object to the camera instead of the camera direction: