vasturiano / globe.gl

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

Is it possible to remove a single point without re-rendering entire array? #140

Open Godevmod opened 1 year ago

Godevmod commented 1 year ago

Hello, First of all the library is fantastic! Spent a few weeks doing something similar and reached about 45% of your success. Eventually using your product.

Now the question is how I can remove a single point from the scene. Tried something like this but, with no success:

const object = mesh.__threeObj object.geometry.dispose(); (object.material).dispose(); object!.parent!.remove(object); this.globe.scene().remove(object!.parent); this.globe.renderer().renderLists.dispose();

Am I missing some parts?

Thanks

vasturiano commented 1 year ago

@Godevmod thanks for reaching out. I'm glad the module is useful.

So, if you want to remove a data point all you have to do is pass a data array that excludes the point you wish to remove (f.e. via .pointsData(...)).

As for the existing points, if you pass the exact same objects (not cloned/copy), the module recognises them as existing ones and you don't need to take the performance penalty of removing/ recreating new Three objects. It only applies changes to the diff of the previous data set and the new one.