I’ve encountered an issue when using an ArcRotateCamera with both angular limits and collisions enabled. Here is a playground which reproduces the issue: https://playground.babylonjs.com/#N1PHX8#4
The issue is that when the collision handler calls setPosition on the camera, the spherical coordinates are recalculated from the new position, and the resulting alpha coordinate is in the range [0, 2*Pi), which may be outside the current alpha limits, which will clamp the alpha value to the limit. This causes the camera to move unexpectedly to one of the limits.
I see two ways of avoiding this behaviour:
- Set the new alpha value to the rotation closest to the old value by adding 2 * N * Pi, with appropriate N.
- When we rebuild the angles, update the angle limits so that they are effectively the same. (Also by adding 2 * N * Pi).
- Do you think this issue is worth fixing? If so, I can submit a PR.
- Do you see any alternative way of fixing the issue?
- Is there any way of avoiding this issue in the current version of Babylon?