flyTo After Morphing Scene Mode

Hi,

I’m trying to start in 2D mode, then fly to a particular location after morphing to 3D (via the scene mode selection button in the standard cesium toolbar).

Using the following code in SandCastle (Win7, Chrome 54.0.2840.87):

  1. The flyTo does not occur
  2. Only ‘morph complete’ is logged
  3. Input is disabled

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

var scene = viewer.scene;
var camera = viewer.camera;

scene.morphComplete.addEventListener(function() {
console.log(‘morph complete’);
camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-74.0, 41.0, 15000.0),
complete: function() {
console.log(‘flyto complete’);
},
cancel: function() {
console.log(‘flyto cancelled’);
}
});
});

``

Hello,

This looks like a bug. I’ve submitted an issue here: https://github.com/AnalyticalGraphicsInc/cesium/issues/4742

Meanwhile, you can fix this by adding a small setTimeout. Here is an example:

scene.morphComplete.addEventListener(function() {
setTimeout(function(){
camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-74.0, 41.0, 15000.0)
});
}, 300);
});

``

Best,

Hannah

Thanks, I was about to report that it appears to be some sort of race condition and as such also found that using a setTimeout delay was a workaround.

More info:

With the default setting of completeMorphOnUserInput=true, clicking the map during the morph completes it and initiates the flyTo correctly even without the setTimeout.