vasturiano / react-globe.gl

React component for Globe Data Visualization using ThreeJS/WebGL
https://vasturiano.github.io/react-globe.gl/example/world-population/
MIT License
818 stars 150 forks source link

the property point.__threeObj of onHexClick function is pointing to all bars of the same weight #148

Open lwdias opened 9 months ago

lwdias commented 9 months ago

Using the parameter onHexClick iIcall the function handleHexClick.

In this function I have this code to change the bar color to red:

const handleHexClick = (point: any, event: any, coords: any) => { point.__threeObj.material[1].color.b = 0; point.__threeObj.material[1].color.r = 1; point.__threeObj.material[1].color.g = 0; }

The problem is that when I click in an hexBin, all the same hexBins that has the same size (weight) is also changing to red. It appears to me as a bug. How can i change the color only of the hexbin I clicked?

vasturiano commented 9 months ago

@lwdias the first problem is that you shouldn't be directly manipulating attributes of the internal Threejs object. Please use the hexTopColor and hexSideColor props and let the module handle that for you.