webglearth / webglearth2

[UNMAINTAINED] WebGL Earth 2 - the source code of the project
Apache License 2.0
884 stars 212 forks source link

Stop the animation #120

Open Scippy opened 5 years ago

Scippy commented 5 years ago

Hi, very thanks for this great and flexible project! I'm initializating globe with simple rotation animation (the same of the official example), but I'd like to stop it when I click and manual rotate on the globe. Is it possible?

Manthika commented 4 years ago

Yes, Try this.

var interval = setInterval(function() {
    var c = earth.getPosition();
    earth.setCenter([c[0], c[1] + 0.9]);
}, 50);
···
earth.on('click', function(){
    clearInterval(interval);
});