vasturiano / globe.gl

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

[Feature suggestion] add filter in xxxData() to improve performance #24

Open lslzl3000 opened 3 years ago

lslzl3000 commented 3 years ago

As issue #17 , when we do .customLayerData(data) , it will loop all objs and trigger customThreeObjectUpdate for every objs. There will be performance issue with big data, but we can set a custom property/state to filter the process.

The customlayer works well with custom filter, but for all other layers, we still need a filter to improve performance with big data. e.g. airline demo

if we want to change something of a arc on click, e.g. color, after recall .arcsData(data), it will take 1-2s to process all arcs, meanwhile everything freezing. For all other .xxxData() apis, they all share the same problem with big data.

So we need an easy way or second param in xxxData() to add custom filter, like customLayerData() as #17, only update objs on demand, not loop all of them.

lslzl3000 commented 3 years ago

By the way, the pathsData() won't stop animation, the animation steps continue playing. But the arcsData() refresh all animation, anything to avoid that?

vasturiano commented 3 years ago

@lslzl3000 if you need to change just the arc color, you don't need to re-invoke .arcsData(data). You simply need to invoke .arcColor(<your new logic>). This is true for all the styling methods of the various layers.

In general data changes is what imposes the biggest performance penalty, because new objects may need to be recreated and/or removed. So, one way to alleviate the load is to manipulate only the styling props and not the data itself, which operation should be much more lightweight.

I'm not quite sure what you mean by stopping the animation with pathsData() (invoked in that way is just a getter by the way, it has no effect). Could you ellaborate?

lslzl3000 commented 3 years ago

@vasturiano thanks for your reply, even though set new colors with .arcColor(<logic>), in your airline demo, it still take 1-2s to loop the process, no big differences with re-invoking .arcsData(<new data>).

A simple demo on codepan, change color on click (line 10), but it takes around 1s to loop all lines, which is unnecessary

.arcColor() may be faster then re-invoking .arcsData(<new data>), but no big improvements in big data. Further, if we want to add or delete lines, or set multiple styling methods, we have to re-invoke .arcsData(<new data>), so the performance issue is still there, need to optimize with filter - just update those we needed, not loop them all

Sorry about the animation reset question, the airline demo uses .arcDashInitialGap(()=> Math.random()), so update dash position randomly~~ ignore this