Hi,
I just started developing with cesium. I fiddled around with a lot of examples and tutorials, but can't find a solution for my problem. The interpolation sandcastle example I used as a starting point. My entity also follows a given path (position list with time values), just like computeCirclularFlight in the example do. Now I want to adjust the camera to stay behind the moving entity. To demonstrate it just replace the "Sandcastle.addToolbarButton('View Aircraft', function() " function in the sandcastle demo (http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Interpolation.html&label=Showcases) with the following code snippet:
Sandcastle.addToolbarButton('View Aircraft', function() {
viewer.trackedEntity = undefined;
viewer.clock.onTick.addEventListener(function (clock) {
var direction = entity.orientation.getValue(clock.currentTime);
var angle = Cesium.Quaternion.computeAngle(direction);
var pitch = -Cesium.Math.toRadians(10.0);
var range = Cesium.Cartesian3.magnitude(new Cesium.Cartesian3(30.0, 0.0, 10.0));
viewer.scene.camera.lookAt(entity.position.getValue(clock.currentTime), new Cesium.HeadingPitchRange(angle, pitch, range));
});
});
Unfortunately the camera doesn't stay behind the aircraft. Is the entity.orientation approach right or is there any other property to get the movement direction of an entity?
Can anyone help me with this problem?
Thanks a lot, Matthias