I am casting a ray from a mesh toward the camera, once the ray hits the ground the camera radius is changed to the hit point distance, then a check for intersections is done between a sphere (which has the same position as the camera but it’s distant from the ray) and all the meshes of the scene.
It seems to work fine if I move the camera slowly with the mouse, however, if I move the camera too fast, sometimes, the sphere and the ground will actually intersect.
What can be done to have the sphere always aligned with the ray, so that the sphere wouldn’t actually hit the ground before the ray?
Here’s the PG:
Try to move the camera toward the ground by moving the mouse slowly/quickly, intersections will be logged in the console.
I am quite new to any of this. I am sorry if this was already covered in another question.
Many thanks for any help you can provide.