Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cesium Fly Camera to Location but Maintain Camera Height

I would like to use flyTo() and provide a lat long co-ordinate but keep the camera at the same height / zoom / distance from the surface as it currently is.

I've tried to use the camera.position.z in my call to flyTo but this seems to zoom in further and further on each call to flyTo().

Does anyone know how to achieve this?

like image 358
Rob Evans Avatar asked Oct 23 '25 15:10

Rob Evans


2 Answers

I found the way to solve the problem.

You need to take the camera's cartographic position via:

var currentPosition = viewer.camera.positionCartographic;

viewer.camera.setView({
    destination: Cesium.Cartesian3.fromDegrees(50.0, 5.0, currentPosition.height)
});
like image 138
Rob Evans Avatar answered Oct 25 '25 03:10

Rob Evans


have you tried setting maximumHeight?

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

viewer.camera.setView({
    destination: Cesium.Cartesian3.fromDegrees(50.0, 5.0, height)
});

setTimeout(function() {
    viewer.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(-117.16, 32.71, height),
        maximumHeight: height
    });
}, 2000);

http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=674299ee1a1bffffdc3a042018aadd2a

like image 21
kindoflike Avatar answered Oct 25 '25 04:10

kindoflike