Creating a flight animation


I’m trying to create a flight animation as per the Camera tutorial, but the call Cesium.CameraFlightPath.createAnimationCartographic() causes a TypeError in CameraFlightPath.js:553.

The error occurs in the follow bit of code, `projection’ is undefined so the getEllipsoid() call fails.

var projection = frameState.scene2D.projection;

if (frameState.mode === SceneMode.SCENE3D) {

var ellipsoid = projection.getEllipsoid();

My code is as follows. I am using Cesium build from the git repository rather than the b18 build.

“use strict”;

function flyToCoords( scene, coords ) {

console.log('scene: ’ + scene);

disableInput(scene); // function same as in Camera tutorial

var flight = Cesium.CameraFlightPath.createAnimationCartographic(scene.getFrameState(), {

destination : destination,

onComplete : function() {

enableInput(scene); // function same as in Camera tutorial





// Display default Cesium globe.

var widget = new Cesium.Viewer(‘cesiumContainer’);

// Load GeoJSON file.

var url = ‘P5_part.json’;

//renderGeoJson(widget, url);

// fly to polygon from geojson

var destination = Cesium.Cartographic.fromDegrees(101.685901, 2.906312, 500.0);

flyToCoords(widget.scene, destination);



This may be a bug, but I’m not positive. There are two things to try.

  1. Add the below right after you create the Viewer:



My guess is that you are starting a flight before the first render every happens, exposing the bug.

If that doesn’t work, try adding the below code to the same spot.

widget.scene.scene2D.projection = new Cesium.WebMercatorProjection(Cesium.Ellipsoid.WGS84);

Let me know if either of these fixes it, or if it’s still broken.

The first option fixes it, I still get the same error with the second option.



Good to know, I’ll file an issue.

The fix for this is now in master and will be released with b19 on Thursday.

See for details.