vasturiano / globe.gl

UI component for Globe Data Visualization using ThreeJS/WebGL
https://vasturiano.github.io/globe.gl/example/world-population/
MIT License
1.99k stars 298 forks source link

[Question] Best way way to automatically rotate the globe #73

Closed ian-whitestone closed 2 years ago

ian-whitestone commented 2 years ago

I'm curious about the best way to automatically rotate the globe, in order to achieve a similar effect to the Github globe.

Right now I have this code, which appears to be doing the trick.

function animate() {
    let pov = globe.pointOfView();
    pov['lng'] -= 0.05
    globe.pointOfView(pov)
};
animate()

But I'm wondering if this is the best approach? Another option would be modifying the underlying three-globe object's rotation (i.e. globeObj.rotation.y += desiredRotationAmount), but I couldn't find a way to access that object with globe.gl (I'm a JS noob, so maybe there is a way?)).

Any advice would be greatly appreciated!

Note, if you'd prefer me to ask questions elsewhere, like stackoverflow, lemme know and I will happily move!

vasturiano commented 2 years ago

@ian-whitestone while those approaches would work, I think the simplest way is to set auto-rotate on the Three orbit controls, as in this example: https://github.com/vasturiano/globe.gl/blob/e7bfcc1408b97713d263838b6e8895d0514f64b5/example/countries-population/index.html#L23-L25

ian-whitestone commented 2 years ago

Thanks @vasturiano, apologies for not searching this repo more thoroughly.