ArcRotateCamera does not respect upperRadiusLimit after passing (0,0,0)

If ArcRotateCamera.upperRadiusLimit is set, then it is not possible to zoom out beyond the limit. But you can zoom in, until you pass (0,0,0), and then start zooming out. Then the limit is no longer applicable.

To reproduce:

  1. Go to https://playground.babylonjs.com/#SRZRWV#510
  2. Zoom in until you pass red plane
  3. and then start zooming out.

You will notice that you can zoom out beyond the upperRadiusLimit (set to 20)

This is because once you’ve passed zero, you’re now decreasing the number.

image

Notice how as I pass zero and keep going the radius becomes a negative number.

You would also need to set the lowerRadiusLimit to -20 to have the same affect once you pass the red plane.

You can see it fixed here:
https://playground.babylonjs.com/#SRZRWV#511

Hope this makes sense.

1 Like

It does. However I did not expect negative values.

But I checked that indeed it is possible (Spherical coordinate system - Wikipedia):

It is also convenient, in many contexts, to allow negative radial distances, with the convention that {isplaystyle (-r,heta ,arphi )} is equivalent to (r,heta ,arphi ) for any r, θ, and φ. Moreover, {isplaystyle (r,-heta ,arphi )} is equivalent to {isplaystyle (r,heta ,arphi {+}180^{irc })}.

I learned something new. Thank you @PirateJC .

PS. Perhaps it is worth to mention this in the documentation to ArcRotateCamera.upperRadiusLimit?

1 Like

Good call, I’ll look for a place to add it in as a special note.

1 Like