Over the past two weeks there has been more improvements to the camera API. Specifically, flyTo and lookAt have changed. The changes to flyTo are as follows:
//Fly to a position with a top-down view
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0)
});
// Fly to a Rectangle with a top-down view
viewer.camera.flyTo({
destination : Cesium.Rectangle.fromDegrees(west, south, east, north)
});
// Fly to a position with an orientation using unit vectors.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
orientation : {
direction : new Cesium.Cartesian3(-0.04231243104240401, -0.20123236049443421, -0.97862924300734),
up : new Cesium.Cartesian3(-0.47934589305293746, -0.8553216253114552, 0.1966022179118339)
}
});
// Fly to a position with an orientation using heading, pitch and roll.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
orientation : {
heading : Cesium.Math.toRadians(175.0),
pitch : Cesium.Math.toRadians(-35.0),
roll : 0.0
}
});
The eye, target and up parameters to lookAt have been deprecated. There is now only a target and an offset. The offset can be either an instance of Cartesian3 or an instance of HeadingPitchRange. The heading and pitch angles are defined the same way as for setView. The range is the distance from the target in meters. The Cartesian3 offset is defined in the east-north-up frame centered at the target. The x-axis is east, the y-axis is north, and up is the geodetic normal. The camera up direction will always be aligned with the local up direction. Here's some examples:
// Using a cartesian offset
var center = Cesium.Cartesian3.fromDegrees(-98.0, 40.0);
viewer.camera.lookAt(center, new Cesium.Cartesian3(0.0, -4790000.0, 3930000.0));
// Using a HeadingPitchRange offset
var center = Cartesian3.fromDegrees(-72.0, 40.0);
var heading = Cesium.Math.toRadians(50.0);
var pitch = Cesium.Math.toRadians(-20.0);
var range = 5000.0;
viewer.camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, range));
This sets the camera reference frame to be the local east-north-up frame at the target. So after calling lookAt the default left mouse click would rotate around the target. To set it back to the default, call camera.lookAtTransform(Matrix4.IDENTITY). This will reset the camera to be in the reference frame centered at the earth. The lookAtTransform function is a little more advanced. Its parameters are a 4x4 matrix that defined a reference frame and a Cartesian3/HeadingPitchRange offset. For example, you would use this to view a satellite in orbit or the Earth in the inertial frame. The offset is optional and is defined in the given frame. If the offset is undefined, it sets the camera reference frame and transforms the position and orientation to be in that new frame.
Regards,
Dan