Camera world coordinates in Columbus mode

When not tracking anything (or tracking the Earth) these should match, and they do in 3D ellipsoid mode
var viewer = new Cesium.Viewer(‘cesiumContainer’);

Sandcastle.addToolbarButton(‘camera up’, function()

{

console.log("up "+viewer.scene.camera.up);

console.log("upWC "+viewer.scene.camera.upWC);

});

``

However in Columbus mode they do not match. I believe this is a bug, but I thought I’d post here first to make sure.

Thanks for bringing this up. At face value this looks like a bug, but I think there’s a chance that the properties are just swizzled in Columbus View. Since this isn’t my area, I’ll check with Dan and find out for sure.

Ya, the order is changed, or swizzled. ZXY instead of XYZ for all of these properties in Columbus mode. If not a bug, I wonder why this is done.
var viewer = new Cesium.Viewer(‘cesiumContainer’);

Sandcastle.addToolbarButton(‘camera up’, function()

{

console.log("pos "+viewer.scene.camera.position);

console.log("posWC "+viewer.scene.camera.positionWC);

console.log("dir "+viewer.scene.camera.direction);

console.log("dirWC "+viewer.scene.camera.directionWC);

console.log("rig "+viewer.scene.camera.right);

console.log("rigWC "+viewer.scene.camera.rightWC);

console.log("up "+viewer.scene.camera.up);

console.log("upWC "+viewer.scene.camera.upWC);

});

``

https://github.com/AnalyticalGraphicsInc/cesium/blob/1.8/Source/Scene/Camera.js#L448
if (mode === SceneMode.SCENE3D || mode === SceneMode.MORPHING) {
camera._positionCartographic = camera._projection.ellipsoid.cartesianToCartographic(camera._positionWC, camera._positionCartographic);
} else {
// The camera position is expressed in the 2D coordinate system where the Y axis is to the East,
// the Z axis is to the North, and the X axis is out of the map. Express them instead in the ENU axes where
// X is to the East, Y is to the North, and Z is out of the local horizontal plane.
var positionENU = scratchCartesian;
positionENU.x = camera._positionWC.y;
positionENU.y = camera._positionWC.z;
positionENU.z = camera._positionWC.x;

``

Why isn’t the coordinate system the same as the ENU system?

https://github.com/AnalyticalGraphicsInc/cesium/blob/1.8/Source/Scene/Camera.js#L215

Camera.TRANSFORM_2D = new Matrix4(
0.0, 0.0, 1.0, 0.0,
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0);

``

That explains the X<->Y swap, the Y<->Z swap, and the Z<->X swap. Why not just make the TRANSFORM_2D the same as Matrix4.IDENTITY ?
https://github.com/AnalyticalGraphicsInc/cesium/blob/1.8/Source/Core/Matrix4.js#L2493

Matrix4.IDENTITY = freezeObject(new Matrix4(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0));

``

The reason for the swizzle of the coordinates is the morph from 3D to 2D/Columbus view. If you watch the morph from 3D to 2D, you could see that the world coordinate axes would be z - north, y - east and x - out of the screen. So we swap the axes to be like the more familiar 2D cartesian graph where y is north, x is east, and z is out of the screen.

Thanks for the explanation. Ya when the camera is over 0 lon 0 lat looking toward the center of the Earth z - north, y - east and x - out of the screen. Though after the morph one could view the flat Earth as in the round Earth’s equatorial plane with east facing round Earth’s Africa and north facing round Earth’s India and up facing round Earth’s north pole. So the only reason is morphing? What about after morphing is complete, could it be set back? When setting the camera’s reference frame to a target in Columbus mode one might want WC coordinates without having to transform it back and get confused by the swizzled results. Though I suppose it’s no big deal to un-swizzle them.