vasturiano / globe.gl

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

Globe autorotates very quickly if the page is in background for a while #180

Closed mighty-phoenix closed 9 months ago

mighty-phoenix commented 9 months ago

Hey @vasturiano If I switch to some other tab for a while after opening the globe, and switch back to it, the globe autorotates very quickly for a while. Kindly see screen recording for reference.

https://github.com/vasturiano/globe.gl/assets/32777813/ad1ccbd0-4b57-48ab-b0a5-32c56e2992c1

How can I disable this behaviour and allow the globe to keep autorotating at the same speed as before? Quick help would be highly appreciated. Thanks!

slavanga commented 7 months ago

@mighty-phoenix I'm facing this issue too. did you find a solution? @vasturiano any advice how to prevent this?

vasturiano commented 7 months ago

@slavanga you can pause rotation of the globe when you detect a loss of focus from the browser tab, using the visibilityChange event.

I presume you are already controlling the rotation of the globe in your app via controls().autoRotate = true, so this is an extension of that control.

slavanga commented 7 months ago

@vasturiano thank you for quick reply. setting autoRotate via the visibilityChange event does not work for me.

here's a reduced example showing the issue: StackBlitz