Big camera.maxZ will cause registered actions to not work

Hello, I’m trying to use a very large number on the maxz property of an ArcRotateCamera, but it seems values above a certain value (> 100.000.000) will stop firing the callbacks. It seems values around 10.000.000 still allow the actions to fire.

I’ve found an issue referring to the same problem way back in 2017, and the playground is still replicable in the latest version of BabylonJS.

Original issue: Big camera.maxZ will cause registered actions not working · Issue #2676 · BabylonJS/Babylon.js · GitHub
Playground: Babylon.js Playground

I can think of ways of getting around this issue for some of my scenes, I’m just wondering if there’s an actual limitation on the implementation, or maybe a workaround?

Cheers!

This is more of a precision issue than anything. When the maxZ of the camera is this very large value and you click on the screen, the engine has to “figure out” which 3D position on the world was clicked based on this 2D position. But since the range of values is so big, values that are close together end up “indistinguishable” due to precision limitations. I tried to draw this to illustrate:

Let’s say a sphere was in position z=1 and the sphere in a position z = 6. If my maxZ were 10, the range of possible values would be small and 1 and 6 would be very distinguishable. But if it were 1000 (I’m of course exaggerating here, the issues happen in a way larger range than that), then 1 and 6 end up looking a bit too similar, and if we have a limited number of bits for precision, then we can’t really distinguish them. This is a bit similar to what happens in Z-fighting too.

I hope this explanation made sense! :sweat_smile:

4 Likes