Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
Rotate globe in cesium map

I'm rotating my Cesium globe through this code:

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

    this.viewer.scene.postRender.addEventListener(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);
    });
}

Now I want to stop it, so how I can I stop this globe rotation on a particular event?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There's a removeEventListener that needs to be passed a reference to the same function that you provided to addEventListener.

Here's a Sandcastle Demo. Note that this demo does not protect against the user clicking "Spin" multiple times, so the user will need to hit "Stop" an equal number of times. Real (non-demo) code should take care not to add multiple event listeners for the same event.

var viewer = new Cesium.Viewer("cesiumContainer");

var previousTime = Date.now();
var spinRate = 1.0;

function applyGlobeSpin() {
    var currentTime = Date.now();
    var delta = ( currentTime - previousTime ) / 1000;
    previousTime = currentTime;
    viewer.scene.camera.rotate(Cesium.Cartesian3.UNIT_Z, -spinRate * delta);
}

function startSpinGlobe() {
    previousTime = Date.now();
    viewer.clock.onTick.addEventListener(applyGlobeSpin);
}

function stopSpinGlobe() {
    viewer.clock.onTick.removeEventListener(applyGlobeSpin);
}

Sandcastle.addToolbarButton("Spin", startSpinGlobe);
Sandcastle.addToolbarButton("Stop", stopSpinGlobe);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda