vasturiano / three-globe

WebGL Globe Data Visualization as a ThreeJS reusable 3D object
https://vasturiano.github.io/three-globe/example/links/
MIT License
1.22k stars 147 forks source link

Bug: component destructor leaves animationFrame running #72

Closed Andrewknackstedt closed 1 year ago

Andrewknackstedt commented 1 year ago

Hi, I'm using Globe.gl for an experimental project, and I need to create/destroy instances of globe.gl on the fly.

I was debugging an issue where instances don't fully deconstruct, and this event hook is not getting cleared when the rest of three-globe or globe-gl deconstructs.

https://github.com/vasturiano/three-globe/blob/75fb07404926b207d136628ca2b0c16723423eb5/src/globe-kapsule.js#L363

Should be a simple fix of adding an interrupt to the onFrame method that aborts if the destructor has been called.

vasturiano commented 1 year ago

@Andrewknackstedt thanks for reaching out.

I've added a destructor on this component, which is now invoked from globe.gl on destruction. So if you update globe.gl to latest you shouldn't experience this issue anymore.

Andrewknackstedt commented 1 year ago

Awesome