I want to know if a sphere is visible at the screen.
I’m using rays between camera and my sphere, then I calculate if my sphere is the first mesh picked.
One other mesh can be in front, and this mesh can be cutted by a clipping plane or not…
So I made this playground to test that, but the “sphere1” is never logged as picked mesh, even if I disable clipping plane…
Is there something that I’ve made wrong ? Maybe on the ray direction ?
This is because you updated positions but world matrices are not yet updated (this will happen during next frame)
So you can simply force it this way:
Ray and clipping plane | Babylon.js Playground (babylonjs.com)
Thank you !!
So now, when I uncomment my clipPlane, the ray collide the sphere on the cutted part…
Is it normal ? Is there a solution to do what I want ?
I don’t understand matrices very well, maybe it’s the same problem…
If someone have a learning ressource about that, it will be very appreciated
The clipPlane is unfortunately not for that usage. It is only a visual clipPlane (meaning the GPU will use it to not render some pixels). The picking is happening on the geometry side of the fence so it is happening on the CPU (where clipPlane is not used)
Ok, I understand, knowing that will save me a lot of time thank you !!
So I have to find another way