-
A concise explanation of the problem you’re experiencing.
Stop Globe rotation function not working -
A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var scene = viewer.scene;
function spinGlobe( dynamicRate ){
var previousTime = Date.now();
viewer.scene.postRender.addEventListener(function (scene, time){
var spinRate = dynamicRate;
var currentTime = Date.now();
var delta = ( currentTime - previousTime ) / 1000;
previousTime = currentTime;
viewer.scene.camera.rotate(Cesium.Cartesian3.UNIT_Z, spinRate * delta);
});
}
function stopglobe() {
//console.log(‘hjhggh’);
spinGlobe(0.0);
viewer.scene.postRender.removeEventListener(spinGlobe);
}
Sandcastle.addToolbarMenu([
{
text : 'Select',
},
{
text : 'Spin Globe',
onselect : function() {
spinGlobe(0.08);
}
}, {
text : ‘Stop GlobeRotation’,
onselect : function() {
stopglobe(0.0);
viewer.scene.postRender.removeEventListener(spinGlobe);
}
}]);
Sandcastle.reset = function() {
viewer.entities.removeAll();
};
-
Context. Why do you need to do this? We might know a better way to accomplish your goal.
Project requirement -
The Cesium version you’re using, your operating system and browser.
1.68