I’ve spent most of today trying to work out why I can’t get the correct mesh pick 100% of the time - here’s a simplified PG which illustrates the problem: https://playground.babylonjs.com/#0AG68Y#10
Open a developer console and try clicking on the sphere - without zooming/reorienting the view, the picked mesh is sometimes blueLine, sometimes redLine and sometimes sphere. Why is this???
I don’t know why it was designed this way, but it seems the pointer event only contains one mesh that intersected with the ray (maybe the first one hit by the ray, I don’t know).
To pick all the meshes intersected with the ray, you can use scene.multiPickWithRay:
And you decide the priority of which mesh should be considered as picked.
I still don’t understand why the expected behaviour which is ‘pixels associated with object under the tip of the mouse pointer’ doesn’t return the correct object. This is standard in every software library I’ve bumped into in the past 40 yrs of programming.
So as a line is a single pixel and dpi is getting higher and higher single line pixel picking is really hard to click on or ray cast to. For convenience there is a bit of threshold around to ensure and easy interaction.
Thanks - the threshold does help, but it still picks the red or blue line inside the sphere when I click in the corresponding position. How do I get the intuitive pick - e.g. the outer mesh (in this case the sphere) gets picked when clicking on the sphere (despite the fact there’s a red or blue line underneath)?