Wall mesh need to hide on scene rotation

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. Try

material.sideOrientation = 0;
material.backFaceCulling = true;

Not working, is the same for mesh instead of material.

Is there a chance that you provide the playground with your room loaded?

I cannot say much more without some tests.

side orientation = backside does work: Create a Virtual Room

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

Thanks

Yes, I guess it’s the simplest way to do it.

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.

Ok, and how do i know if a box wall is hidden? I miss that :blush:

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.

1 Like

Great, it works!
Thank you.

https://playground.babylonjs.com/#HBRF92#41

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:

https://playground.babylonjs.com/#HBRF92#42

1 Like

Perfect! Thank you so much :wink: