CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.94k stars 3.49k forks source link

viewer.flyTo and viewer.zoomTo give different results in 2D and CV #2473

Open mramato opened 9 years ago

mramato commented 9 years ago

flyTo always orients north, but zoomTo applies the specified heading. The doc seems to indicate this is by design (at least for 2D). But it also happens for CV. Why do it at all? I think flyTo should take the heading into account, just like zoomTo does.

While the below example uses the viewer commands, the actual behavior is defined in the camera.flyToBoundingSphere method.

var viewer = new Cesium.Viewer('cesiumContainer', { sceneMode : Cesium.SceneMode.SCENE2D });

var redRectangle = viewer.entities.add({
    name : 'Red translucent rectangle with outline',
    rectangle : {
        coordinates : Cesium.Rectangle.fromDegrees(-110.0, 20.0, -80.0, 25.0),
        material : Cesium.Color.RED.withAlpha(0.5),
        outline : true,
        outlineColor : Cesium.Color.RED
    }
});

Sandcastle.addToolbarButton('zoomTo', function() {
    viewer.zoomTo(redRectangle, new Cesium.HeadingPitchRange(Math.PI / 2, -Math.PI / 4, 4000000));
});

Sandcastle.addToolbarButton('flyTo', function() {
    viewer.flyTo(redRectangle, {
        offset : new Cesium.HeadingPitchRange(Math.PI / 2, -Math.PI / 4, 4000000)
    });
});
hpinkos commented 7 years ago

This came up on the forum: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/EbCim-p6jmI

hpinkos commented 7 years ago

We need different behavior for mapMode2D: Cesium.MapMode2D.ROTATE. Right now, zoomTo rotates the map but flyTo does not. It should rotate the map for both if Cesium.MapMode2D.ROTATE and neither otherwise

hpinkos commented 7 years ago

Also reported here: https://groups.google.com/forum/?hl=en#!searchin/cesium-dev/wrong$20viewpoint%7Csort:date/cesium-dev/MSPOj17Iqcg/dtbDsrUdBgAJ