Open kamami opened 3 months ago
@kamami for that I would focus on the hex bin layer.
@vasturiano I already experimented with it and sticked to this example: https://github.com/vasturiano/react-globe.gl/blob/master/example/world-population/index.html
Would you rather update the popData and increase/decrease the "pop" property of each object. Or would you update the hexAltitude to change the height of the pillars?
It depends. If you're visualizing actual data changes with your pillar height changes, then I would keep changing the data according to your time series, and feed it into the component frame by frame.
If on the other hand you just want to animate the pillars more for "visual effect", then I would simply adjust the accessor functions. You can play with either hexBinPointWeight
or hexAltitude
to get that effect.
Ok thanks, I think I am on a good way! Is it possible to transition the color of the hexBins based on the altitude? I am using this code, but when the hexBins are retracting, because the pop value is set to 0, they immediately get black. I want the color to transition smoothly just like in the world coin example.
useEffect(() => {
const intervalId = setInterval(() => {
setPopData(currentData =>
currentData.map(data => ({
...data,
pop: increasePop ? data.originalPop * 1.5 : 0, // Wechsle zwischen originalPop und originalPop * 1.5
}))
);
setIncreasePop(prevState => !prevState); // Wechsle den Zustand bei jedem Interval
}, 2000); // Wechsle alle 2 Sekunden
return () => clearInterval(intervalId);
}, [increasePop, popData]);
const weightColor = d3
.scaleSequentialSqrt(d3.interpolateRgb("black", "green"))
.domain([0, 1e6]);
@kamami if you're using hexTransitionDuration
, that only affects the altitude and radius of the poles.
@vasturiano So a transition of the hexSideColor is not possible, correct? Just trying to make sure so that I am not wasting any time on trying to find the solution.
@kamami correct, that's not available with the built-in animation. But you can always achieve the same result by tweening your own color changes and passing new values at every frame to the component, via hexSideColor
.
How can I achieve an animating globe like on the worldcoin page? https://worldcoin.org
I am in particular interested in the extruding dots. I already managed to get the dotted continents, but I am not able to make them animate and change the altitude... Any ideas?
This is my code so far: