How to exclude some meshs with "scene.Pick"

Hi everyone!

I’ve been trying for a while to make a condition that excludes some meshes from generating positions for the mouse pointer. I have several “isPickable” meshes in my scene, but I want it to only take the position of one mesh, which is the floor with the name “col_floor_lounge” and not any mesh that has the pickable true.

Here my code to take mouse position:

I can remove the Y axis to prevent it from “climbing” on some meshes, but i need the Y axis.

Instead of using the browser events, try using the events and observables babylon has to offer. Here is a doc page about picking:

1 Like

Also, adding as a direct answer to your question - the scene.pick method received a predicate, which is a simple function that returns true to meshes that should be picked and false to meshes that aren’t. See here - Scene | Babylon.js Documentation

1 Like

I was trying this:

But no sucess…

your three line setting the disc position should be out of the predicate, also if there are no pick point it should not set anything cause here you are putting undefined in position.x y and z in this case.


Solved, thank you very much!