CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.98k stars 3.5k forks source link

View rotation gets stuck near ground #12137

Open voj opened 2 months ago

voj commented 2 months ago

What happened?

When rotating a 3D scene with enableCollisionDetection = false, the camera often gets stuck near the ground and does not move anymore. Releasing the middle mouse button and re-initiating the drag movement restarts the camera movement, but with a new rotation center.

We want to visualize earthquake faults up to 30 km underground, and so it is important for us to be able to move freely between underground and above ground without getting stuck.

Here is an example of the camera getting stuck during the rotation. At the end of the video the mouse button is released and rotation is initiated again: https://www.youtube.com/watch?v=XsdpiWnEDow

I believe this bug is different from https://github.com/CesiumGS/cesium/issues/11985 which is about panning - although it might be related.

Reproduction steps

  1. Set viewer.scene.screenSpaceCameraController.enableCollisionDetection = false;
  2. See the sandcastle for a complete setup.
  3. Rotate the camera around the yellow polygon so that we repeatedly go underground, trying to be close to the ground.
  4. The camera should get stuck at some stage.

Sandcastle example

https://sandcastle.cesium.com/#c=1VZtc+I2EP4rGj7BjGP8AhgHLtMp4fqW9jJNpx9a7oOQF1AjSx5JJqU3/PeusBOcC+FgOjediA9Y0rOr3WdXqyWEEKaksWTN4QE0eUckPJAJGF7m/u+7tfasxXbziZKWcgl61vLIp5kk9aCS59RyJS/JggoD3n5rTg3c0A3oW87uQb8EGAYSflYZvAZYqRy+La112q0um1tLUAwlDwgtSiEM0wDyFdE9YCogB2kvySEv9wKW5yBw9eVZ3S4RVC8BiVsiC2sgaypKIFYRDRLNIxlAQUr3udQK/4lBa5gtNZi9mgwKu7oVVMJUCF4YxbMPi4UBtOyiH+Dwg/rQbWc0k+7nJlXYfEZz0NRHuItZ+1NTr7Fc1uGp4zqh2uIXlbG/0Cq/hiUyYdph0vf7SRIO4kE6iIZpMPDIRS/0434YBUkSeyR1lnSadjRs2EfKdysuqMJnKs+pzPw5LJSG6d/ASgs+zbLpGlm/4cZi/DHFGpGRzBnbhk4zx9wAdFMyEJikLpyj57u1FbuEeuRjITa/qfZnar4uK4/jiZ3dpPrsPOOrsrTKwruCMpjsjHb5p5UQiABJ5wImOOEGLb0GCztukIBdFtZ5gBl4jtac430t8z8U+oj8O0pR4UXkkmz0X7T9Sq3TFPeD2rCqsuA1/cvsjH4i5EBEZi27KWDWchfxPVB3O5zjlcPPruJeYlHhjJP68yXglZOOnHjwnD2+0KoAbXl14hHVFfw9LYX94dphoyjpeyfhf0GCK5u+5/elpnLJPfIT6JxmwFxRuVElN2uO1BDNsyV4JA7uc3JBHrhdEYO1A7N7wRm3xORK2RVkWJqoJlOKwZjQArBgZ0QorLf1jsVCxVb+CJ8CcUmGHtHq4ZLER9nYHmUKY56D1ZuTeNqH4VaJzfKVcD+XYUrpzN3go9FvjhMgZ8DcOFAZThdulpA47PfioHeOdOhqzmn4j95X8Twa9odhHEeDIO3FvTM9D9MkRObCKE3R+7N4C9P/23MM2TAJemkUx4NBcqbnvRCFkzhB8eDNeR4nQRQMk14Qxb14eKbn/SRMw8BlDWb728r1t3DLvwz7AuTI9vbw1tb7uK2f+rpfyKild6rU2Eq7Jq9dt1bfgfoRW4Drp11fKJq1686g0xm1vNbY2I2Aq8eTvuF5obQlpRZt3+9ayAvhqn13XuLDZX1mzGOHNe42RccZXxOevTvQzxMmqDG449r/O/4PvjpX4y7iX4g687hcfliDFnTjYKvw6qZa9H1/3MXpYUmrlJhT/ZnmfwE

Environment

Browser: Chrome 127.0.6533.120 (Official Build) (64-bit), Firefox 129.0.1 (64-bit) CesiumJS Version: 1.120 Operating System: MS Windows 11 Home 10.0.22631

ggetz commented 2 months ago

Thanks for the report @voj. If I understand correctly, this is similar to https://github.com/CesiumGS/cesium/issues/9689, but it sounds like the maximumTilt property will not be a sufficient fix for your case.

voj commented 2 months ago

@ggetz Thanks for looking into this. Yes, it looks very similar to #9689. The maximumTilt property would indeed not be sufficient as we do want to travel underground and look at the geometry from the side rather than from above.

voj commented 2 months ago

I've implemented my own camera controller as a workaround. Note that right-drag now rotates the camera.

ggetz commented 2 months ago

Glad you found a solution @voj! And thanks for posting it.

I'll leave this issue open, as I think this is something we'd like to address in the default camera controller as well.