Camera speed and path editable?

Hey,

So I can do a Cesium.CameraFlightPath and make the camera fly from one place to another fine - but it does the whole Zoom out, pan and zoom in thing. Nice for somethings, not so good for what I am trying to do… is there any way I can just slowly pan from one location to another without changing the elevation level of the camera?

On b19 currently.

Thanks

Toby

Hi Toby,

You would need to create a custom animation and its quite a bit of code, sorry. Here’s some code that would work in 3D only:

// create a quaternion from basis

function createQuaternion(direction, up) {

var right = Cartesian3.cross(direction, up);

var orthoUp = Cartesian3.cross(right, direction);

viewMat[0] = right.x;

viewMat[1] = orthoUp.x;

viewMat[2] = -direction.x;

viewMat[3] = right.y;

viewMat[4] = orthoUp.y;

viewMat[5] = -direction.y;

viewMat[6] = right.z;

viewMat[7] = orthoUp.z;

viewMat[8] = -direction.z;

return Quaternion.fromRotationMatrix(viewMat);

}

// save start and end camera position and orientation

// endPosition, endDirection, and endUp are assumed to exist

var startPosition = Cartesian3.clone(camera.position);

var startOrientation = createQuaternion(camera.direction, camera.up);

var endOrientation = createQuaternion(endDirection, endUp);

// animation update function

// time assumed to be in [0.0, 1.0]

var update = function(value) {

var time = value.time;

var orientation = Quaternion.slerp(startOrientation, endOrientation, time);

var rotMatrix = Matrix3.fromQuaternion(orientation);

Cartesian3.lerp(startPosition, endPosition, time, camera.position);

Matrix3.getRow(rotMatrix, 0, camera.right);

Matrix3.getRow(rotMatrix, 1, camera.up);

Matrix3.getRow(rotMatrix, 2, camera.direction);

Cartesian3.negate(camera.direction, camera.direction);

};

var animation = {

duration : duration,

easingFunction : Tween.Easing.Sinusoidal.InOut,

startValue : {

time : 0.0

},

stopValue : {

time : 1.0

},

onUpdate : update

};

animation is an object like that returned from the CameraFlightPath.createAnimation* functions.

Dan