Coordinate frame confusion?

I’m trying to store the camera’s position and orientation right before a user starts tracking an entity so we can set it back when the user stops tracking the entity. However, while the orientation seems to update to the previous orientation properly, the position does not. Attached is a sandcastle edit that shows the issue.

If you click on the “View aircraft” button, it stores the existing camera position/orientation. Then if you hit the “Back” button, it should fly the camera to the original location. But you’ll see that it doesn’t appear to change the position.

Is it possible that my issue is one of coordinate frames? ie … that I’m recording the camera position in one frame of reference and setting that value in a different frame of reference?

If so, could someone give me a run-down of what coordinate frames each of these values is in?

entity.position.getValue( )

As in … are the ECEF or ENU, with respect to some sort of parent, etc, etc?

It would be awesome if that information was reflected in the documentation (maybe it is, and I haven’t found it)?

Interpolation.html (6.69 KB)

All coordinates are in ECEF.

There are a few minor changes you have to make to your example to get the camera back to the previous position.
First, you want to clone the position before saving it. Otherwise, both camera.position and _cameraPositionBeforeFollow.destination point to the same Cartesian3 reference, so when camera.position changes, your saved position changes too, negating the point of saving the old position.

You want to use camera.positionWC. This stands for position in world coordinates. Camera.position is the actual position of the camera, which might be different than what you expect it to be if you’re in 2D or Columbus view modes. (In 3D, I’m pretty sure position and positionWC are the same, but I always use positionWC.)

Finally, when an entity is tracked, it changes the camera transform. So to go back to your old view, you need to set the camera transform back too.

Here are the parts of your example that I modified:

Sandcastle.addToolbarButton(‘View Aircraft’, function() {
// Test Code --------------------
var camera =;
_cameraPositionBeforeFollow = {
destination: Cesium.Cartesian3.clone(camera.positionWC),
orientation: {
heading: camera.heading,
pitch: camera.pitch,
roll: camera.roll
transform: Cesium.Matrix4.clone(camera.transform)
// Test Code --------------------

viewer.trackedEntity = entity;



Sandcastle.addToolbarButton(‘Back’, function() {
viewer.trackedEntity = undefined;;



Hope this helps!