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

How to animate color change? #59

Open bingomanatee opened 2 years ago

bingomanatee commented 2 years ago

I want to be able to animate color change over time. My use case is polyhexes, but in general - how can you change the color/props of the graph without (the force method) running new data through your model? the new data approach seems to re-create the geometry - and for the record it is also flawed; for instance I filtered countries to European continents, then changed the data to Asian ones, and the only way I could get that to work was to re-create the entire globe.

you have a great visualizer, but its a shame that rendering data over time is not a native predicted feature of this component.

vasturiano commented 2 years ago

@bingomanatee you can just invoke the method hexPolygonColor every time you want to change the color logic associated with the hexes. That should be a light-weight enough change and doesn't trigger a geometry re-computation.

Additionally, if you want to animate it, you just need to invoke it repeatedly inside your own tween function.

Make sure to use the latest version of the module as I've just pushed a patch that further optimizes color changes in this layer.