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 moveStart and moveEnd events don't work when camera is very close to the ground #4753

Open
hpinkos opened this issue Dec 14, 2016 · 4 comments

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Dec 14, 2016

Reported on the forum: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/SwoFMPNm5_g

This is particularly noticeable in 2D

var viewer = new Cesium.Viewer('cesiumContainer', {
    sceneMode: Cesium.SceneMode.SCENE2D
});

var camera = viewer.camera;
camera.moveStart.addEventListener(function() {
    console.log('start');
});
camera.moveEnd.addEventListener(function() {
    console.log('end');
});
  1. Zoom in all the way (you should see start/end print out to the console)
  2. Use the scroll wheel to zoom out one click at a time (start/end don't print out to the console until you're zoomed out a bit)

It looks like we are using EPSILON6, which is not significant enough when the camera is very close to the ground: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Scene.js#L2349

The camera changed event does a much better job because it takes the camera height into consideration: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Camera.js#L336

@hpinkos
Copy link
Contributor Author

hpinkos commented Dec 14, 2016

@bagnell is there a reason the camera.moveStart and camera.moveEnd events are raised in Scene and camera.changed is raised in Camera? It seems like these should use the same logic

@DannyLebel
Copy link

To add to the description of this issue. The same behavior is even more obvious with camera.changed event. In fact, the event is not triggered at all when the camera is below the ellipsoid. This is very clearly noticeable when using a terrain provider since it is possible to navigate under the level of the ellipsoid. And to be more specific, this issue occurs with the zoom and the translation navigation but not with the rotation.

Steps to reproduce

  1. Copy the example code in Sandcastle and execute it.
  2. Select the STK World Terrain Meshes in the imagery provider dropdown. (the camera is located at a position near the surface of the ellipsoid)
  3. Rotate the camera with middle click and cross the surface of the ellipsoid multiple times.
  4. Notice that the height is printed whether positive or negative.
  5. Now, zoom in and out so that the camera crosses the surface of the ellipsoid.
  6. Notice that the height is only printed when positive and never negative.
  7. Place the camera so that it is at a negative height.
  8. Move the camera with left click.
  9. Notice that the height is never printed out since the camera is below the ellipsoid.

Expected Behavrior

The moveStart, moveEnd and changed events are triggered whether the camera is above or below the ellipsoid. (In our use cases we navigate near the surface of the terrain and very often under the ellipsoid.)

Example code

var viewer = new Cesium.Viewer('cesiumContainer');

var camera = viewer.camera;

camera.position = new Cesium.Cartesian3(1408166.1338912349, -4136627.945644175, 4630485.211009045);

camera.percentageChanged = 0.001;
camera.changed.addEventListener(
    function()
                               {
    var height = Cesium.Cartographic.fromCartesian(camera.position).height;
    console.log(height);
}.bind(camera));

@hpinkos
Copy link
Contributor Author

hpinkos commented Dec 15, 2017

Thanks for expanding on this @DannyLebel!

@hpinkos
Copy link
Contributor Author

hpinkos commented Jan 24, 2018

This event is almost never triggered when navigating an indoor 3D tileset. camera.changed has the same problem.

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

3 participants