Search code examples
javascriptcoordinatescartesiancesiumjs

Cesium: How to use LookAt to view a set of coordinates while in Columbus View?


How can I use LookAt to view a set of coordinates while in Columbus View? This method works in 3d or globe view but when in columbus view the coordinates must not convert correctly because it should send me to the united states but it actually sends me to the coast of africa. How can I make it work in columbus view?

problem can be recreated here https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html

var viewer = new Cesium.Viewer('cesiumContainer', {
        sceneMode: Cesium.SceneMode.COLUMBUS_VIEW,
//Hide the base layer picker
baseLayerPicker : false,
//Use BingMaps
imageryProvider : new Cesium.BingMapsImageryProvider({
        url: '//dev.virtualearth.net',
        mapStyle: Cesium.BingMapsStyle.ROAD
    })
    });
var scene = viewer.scene;
Sandcastle.addDefaultToolbarButton('test', function() {
var center = Cesium.Cartesian3.fromDegrees(-111, 41);
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(center);

// View in east-north-up frame
var camera = scene.camera;
Cesium.Matrix4.clone(transform, camera.transform);
camera.constrainedAxis = Cesium.Cartesian3.UNIT_Z;

// Zoom in
camera.lookAt(
    new Cesium.Cartesian3(-120000.0, -120000.0, 120000.0),
    Cesium.Cartesian3.ZERO,
    Cesium.Cartesian3.UNIT_Z);
});

Fixed View Works but then my view is fixed:

var viewer = new Cesium.Viewer('cesiumContainer', {
        sceneMode: Cesium.SceneMode.COLUMBUS_VIEW,
//Hide the base layer picker
baseLayerPicker : false,
//Use BingMaps
imageryProvider : new Cesium.BingMapsImageryProvider({
        url: '//dev.virtualearth.net',
        mapStyle: Cesium.BingMapsStyle.ROAD
    })
    });
var scene = viewer.scene;
Sandcastle.addDefaultToolbarButton('test', function() {
var center = Cesium.Cartesian3.fromDegrees(-111, 41);
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(center);

// View in east-north-up frame
var camera = scene.camera;
Cesium.Matrix4.clone(transform, camera.transform);
camera.constrainedAxis = Cesium.Cartesian3.UNIT_Z;

// Zoom in
camera.lookAt(
    new Cesium.Cartesian3(-120000.0, -120000.0, 120000.0),
    Cesium.Cartesian3.ZERO,
    Cesium.Cartesian3.UNIT_Z);
});

Solution

  • This looks like a bug. I've submitted an issue here. One thing you can try in the mean time is use Camera.flyTo with a duration of 0.