Skip to content
New issue

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

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

Already on GitHub? # to your account

The camera jumps hundred of meters up after the terrain has finished loading #5999

Closed
gberaudo opened this issue Nov 23, 2017 · 2 comments · Fixed by #8504
Closed

The camera jumps hundred of meters up after the terrain has finished loading #5999

gberaudo opened this issue Nov 23, 2017 · 2 comments · Fixed by #8504

Comments

@gberaudo
Copy link
Contributor

gberaudo commented Nov 23, 2017

With recent versions of Cesium, the camera can jump all of a sudden once the terrain has finished loading.
This new behaviour may have been caused by f401d277b#diff-6298b280e4e0977bedd881b65b769863R352 (see the suspendTerrainAdjustment) from #4105.

(edit: I commented the suspendTerrainAdjustment property and the issues are fixed (going under terrain and camera jump).)

Contrary to what the commit title suggest, suspending terrain adjustment occurs not only during flights, but also on any action calling Camera.setView (notably screen controls).

Previously, the camera was adjust continuously while the terrain was loading.

Current behaviour is disturbing because it can take a lot of time before all the terrain has finished loading, so the user as already started working on the globe when the globe unexpectingly moves.

Here is a Sandcastle example with an exagerated 3000m minimum zoom distance. Moving close enough to the terrain and waiting exhibits the issue:

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

var controller = scene.screenSpaceCameraController;
controller.minimumZoomDistance = 3000;

var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
    url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles'
});
viewer.terrainProvider = cesiumTerrainProviderMeshes;

setInterval(function() {
    var carto = Cesium.Cartographic.fromCartesian(scene.camera.position);
    console.log(carto.height - globe.getHeight(carto));
}, 10)

For example, here the user was at 860m while the terrain loaded and was jumped to 3000m afterwards:

860.13518398939
3017.5562165755505

I also noticed it is now much easier to go under the terrain (with the default minimumZoomDistance of 1m of Cesium and even with a fair margin of 300m). I think it is also related to the change above:

image

Are this new behaviours: jumping camera and go under terrain expected?

gberaudo added a commit to camptocamp/cesium that referenced this issue Nov 24, 2017
gberaudo added a commit to openlayers/ol-cesium that referenced this issue Nov 24, 2017
@mramato
Copy link
Contributor

mramato commented Nov 28, 2017

I believe the current/desired behavior is that:

  1. If terrain is loading, we allow the camera to go under the terrain. As you stated, setView or other camera functions/flights might place the camera under lower-resolution terrain but the camera ends up above the terrain once the higher resolution tiles are loaded.
  2. Once all terrain is loaded, the camera can no longer go under the terrain.
  3. Once all terrain is loaded, if the camera is under terrain, it is moved to be above the terrain.

I could be wrong about 3, but we definitely need 1 and 2. If you're seeing camera height being adjusted even when the camera is already above terrain then that might be an bug. We should only adjust the height if the camera would end up under terrain.

@gberaudo
Copy link
Contributor Author

Yes @mramato, 3. is behaving as you describe.

I undestand there are cases when the suspendTerrainAdjustment functionality is useful (application initialisation, fly to a destination).
But there are other cases where it leads to a bad user experience (mouse navigation).

What about allowing applications to activate/desactivate that functionality?
After all, the application has much more information about the intent of the user than Cesium, so it can take better decisions. The current behaviour could stay the default.

I can contribute a pull request to do that.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
3 participants