Zoom Event

I have a typical spin globe function to rotate the globe on page load like so:

function spinGlobe( dynamicRate ){
        var previousTime = Date.now();

        this.viewer.scene.postRender.addEventListener(spinning = function (scene, time){
            var spinRate = dynamicRate;
            var currentTime = Date.now();
            var delta = ( currentTime - previousTime ) / 1000;
            previousTime = currentTime;
            this.viewer.scene.camera.rotate(Cesium.Cartesian3.UNIT_Z, -spinRate * delta);
        });
}
spinGlobe(0.02);

Is there a zoom in/out event that can be used to stop the globe spinning when the user zooms in or out?

I tried something based on a change in camera height, however camera height naturally changes a small amount as the globe rotates.

Hi Damien,

There is a generic cameraChanged event, but since you are updating the camera location each frame, I don’t think that will help much. Each time you update the spin, you could check to see if the camera’s distance to the globe has changed with camera,getMagnitutde. Or another solution you could try is adding a ScreenSpaceEventHandler for the zoom event types.

Thanks,

Gabby

Hi Gabby,

Thanks for the suggestion! Zoom event types might be an option.

Thanks,

Damien