Hello,
I thing there is an issue with the layer masks and the selection of meshes.
Here’s my PG : https://playground.babylonjs.com/#C77SMH#58
I have 3 spheres and 3 cameras with layers, each camera showing a sphere. If i click on a sphere, the hit mesh under the click is always the first sphere (sphere1), even if it is not visible because of the mask.
Thanks for your answer.
Boris
Picking is not related to layerMask. The system can pick even hidden objects.
This is where picking predicate enters the game.
Inside the onPointerObservable, you can call scene.pick():
1 Like
Ok, thank you very much for your answer, but i think that does not work. Even with your promise, sphere1 is under the click instead of sphere 4 (because camera4 is the active camera)
The activeCamera is used just for the POV (where is the user) not to filter. This is the role of the predicate
So a more complete answer:
const pickInfo = scene.pick(scene.pointerX, scene.pointerY, (m) => {
return ((m.layerMask & scene.activeCamera.layerMask) !== 0);
}, false, scene.activeCamera);
Babylon.js Playground
3 Likes