Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera flight path in 2D tries to fly through the map #804

Closed
hpinkos opened this issue May 29, 2013 · 2 comments
Closed

Camera flight path in 2D tries to fly through the map #804

hpinkos opened this issue May 29, 2013 · 2 comments
Assignees

Comments

@hpinkos
Copy link
Contributor

hpinkos commented May 29, 2013

If the current camera position is closer to the globe than the destination, and the current position is not directly in front of destination (the path isn't a straight zoom-out, it is offset in some direction), the camera flies through the map and generates an error of "right must be greater than left."

Sandcastle Example: Click 'Vew Extent' then 'Fly To Extent'

require([
    'Cesium', 'dijit/form/Button'
], function(
    Cesium, Button)
{
    "use strict";
    var ellipsoid = Cesium.Ellipsoid.WGS84;
    function flyToExtent(scene) {
        var west = Cesium.Math.toRadians(-90.0);
        var south = Cesium.Math.toRadians(38.0);
        var east = Cesium.Math.toRadians(-87.0);
        var north = Cesium.Math.toRadians(40.0);

        var extent = new Cesium.Extent(west, south, east, north);

        var flight = Cesium.CameraFlightPath.createAnimationExtent(scene.getFrameState(), {
            destination : extent,
            onComplete : function() {
            }
        });
        scene.getAnimations().add(flight);
    }

    function viewAnExtent(scene) {
        var west = Cesium.Math.toRadians(-89.0);
        var south = Cesium.Math.toRadians(38.5);
        var east = Cesium.Math.toRadians(-88.0);
        var north = Cesium.Math.toRadians(39.5);

        var extent = new Cesium.Extent(west, south, east, north);
        scene.getCamera().controller.viewExtent(extent, ellipsoid);
    }

    function createButtons(scene) {
        new Button({
            label : "View Extent",
            onClick : function() {
                viewAnExtent(scene);
            }
        }).placeAt('toolbar');
        
        new Button({
            label : "Fly to Extent",
            onClick : function() {
                flyToExtent(scene);
            }
        }).placeAt('toolbar');
    }

    var widget = new Cesium.CesiumWidget('cesiumContainer');
    
    var transitioner = new Cesium.SceneTransitioner(widget.scene, ellipsoid);
    transitioner.morphTo2D();

    createButtons(widget.scene);

    Sandcastle.finishedLoading();
});
@emackey
Copy link
Contributor

emackey commented May 29, 2013

Discovered while testing #803.

@pjcozzi pjcozzi mentioned this issue Apr 8, 2014
19 tasks
@bagnell
Copy link
Contributor

bagnell commented Jun 22, 2015

Updated code example:

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

function flyToExtent() {
    var west = Cesium.Math.toRadians(-90.0);
    var south = Cesium.Math.toRadians(38.0);
    var east = Cesium.Math.toRadians(-87.0);
    var north = Cesium.Math.toRadians(40.0);

    var extent = new Cesium.Rectangle(west, south, east, north);

    scene.camera.flyTo({
        destination : extent
    });
}

function viewAnExtent() {
    var west = Cesium.Math.toRadians(-89.0);
    var south = Cesium.Math.toRadians(38.5);
    var east = Cesium.Math.toRadians(-88.0);
    var north = Cesium.Math.toRadians(39.5);

    var extent = new Cesium.Rectangle(west, south, east, north);
    scene.camera.viewRectangle(extent, ellipsoid);
}

Sandcastle.addToolbarButton('View Extent', function() {viewAnExtent();});
Sandcastle.addToolbarButton('Fly to Extent', function() {flyToExtent();});

@bagnell bagnell mentioned this issue Jun 22, 2015
4 tasks
@pjcozzi pjcozzi closed this as completed Jun 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants