layerMask issue

Hello,

I have an issue with layerMask. From what I read in this former thread: [solved] make mesh, sprite invisible for just one camera - Questions & Answers - HTML5 Game Devs Forum

Where it is said:

For instance let’s say that camera1.layerMask == 1 and camera2.LayerMask == 2

  • a mesh with a layerMask == 1 will only be on camera1
  • a mesh with a layerMask == 2 will only be on camera2
  • a mesh with a layerMask == 3 will be on both

If I put any layerMask value on mesh different from the real camera layerMask, the mesh should be visible by every camera right?

But it doesn’t seem to work. See in this playground (https://playground.babylonjs.com/#2GXKNW#53) line 15 where I put a different layerMask value from any camera and actually the sphere is not visible by any camera. How can I make an object visible by two camera which have a layerMask?

Nope. They are masks so the mesh is visible only if mesh.layerMash & camera.layerMask !== 0. The "
&" is a bitwise operator

Just set mesh.layerMask = camera.layerMask | camera2.layerMask

Oh yeah it works! :cowboy_hat_face: