I am building a digital earth that is made up of hexagons. I want to change the color of the individual hexagonal cells according to a time slider, to e.g. show cloud coverage, or rainfall, etc over time.
Each cell is a BufferGeometry
with one BufferAttribute
for color
(the vertex-color) and an id
so I can use the raycaster and identify the cell. I merge all cells with BufferGeometryUtils.mergeBufferGeometries(geoms)
I made a stripped down fiddle version with only 4 cells and a slider.
You can see that I define the colors per cell id in
let cells = [
[1, '#ff0000', '#ff0000', '#ff0000','#ffffff'],
[2, '#00ff00', '#ff00ff', '#ff0000','#ffffff'],
[3, '#0000ff', '#ffff00', '#ff00ff','#ffffff'],
[4, '#ffffff', '#ffff00', '#00ff00','#ffffff']
];
I added more BufferAttribute
s like color1
, color2
, color3
and color4
and thought of using copy to get them to color
with
mesh.geometry.attributes.color.copy(mesh.geometry.attributes.color1);
each time slider.oninput
happens.
I found this very helpful, but could not find a working way to apply this to my problem. I guess I am missing the needsUpdate
for the color?
BUT Maybe there is a way better approach to changing the vertex colors than multiple BufferAttribute
s and copy
???