Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera lookAtTransform Breaks Zoom Limit #12462

Open
NateRex opened this issue Feb 4, 2025 · 2 comments
Open

Camera lookAtTransform Breaks Zoom Limit #12462

NateRex opened this issue Feb 4, 2025 · 2 comments

Comments

@NateRex
Copy link

NateRex commented Feb 4, 2025

What happened?

Calling camera.lookAtTransform with a matrix that does not equal the identity matrix, the camera is capable of zooming past the Earth's surface. I discovered that this is because of this check in ScreenSpaceCameraController

  • Since the camera transform is no longer the identity matrix, the controller's ellipsoid is replaced with the UNIT_SPHERE (where I was previously using the default WGS84 ellipsoid).
  • On zoom, we therefore end up using the wrong ellipsoid to compute the camera height here.
  • This makes the controller think the camera is higher than it actually is, and therefore the zoom speed doesn't scale properly.

Reproduction steps

  • Open the Camera Sandcastle Demo (linked to below as well)
  • From the dropdown, select "View in ICRF". This applies a camera transform on every post-scene update to simulate the Earth's rotation.
  • Zoom in. You should find that the camera can zoom past the surface of the Earth.

Sandcastle example

https://sandcastle.cesium.com/?src=Camera.html


Environment

Browser: Chrome
CesiumJS Version: 1.121.0
Operating System: Windows

@NateRex
Copy link
Author

NateRex commented Feb 4, 2025

In ScreenSpaceCameraController.update, if I replace

if (!Matrix4.equals(camera.transform, Matrix4.IDENTITY)) {
    this._globe = undefined;
    this._ellipsoid = Ellipsoid.UNIT_SPHERE;
  } else {
    this._globe = globe;
    this._ellipsoid = defaultValue(scene.ellipsoid, Ellipsoid.default);
}

with

if (!Matrix4.equals(camera.transform, Matrix4.IDENTITY)) {
    this._globe = undefined;
  } else {
    this._globe = globe;
}
this._ellipsoid = defaultValue(scene.ellipsoid, Ellipsoid.default);

that appears to fix the issue, but at first glance I'm not sure what other unintended side-effects this change might have.

@ggetz
Copy link
Contributor

ggetz commented Feb 6, 2025

@NateRex The camera controller definitely seems to assume certain use case for adjusting the camera transform... Not great.

To me, it looks like that first condition is used for tracked entity views. I assume the ellipsoid is being set to the unit sphere there to make any ellipsoid calculations faster–Calculations on a sphere are faster than an oblate ellipsoid like what's used for the earth.

In my opinion, it would be better if ScreenSpaceCameraController did not change the ellipsoid or globe internally. Instead it would be up to EntityView.js to set the ellipsoid to controller's ellipsoid to something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants