I am using react-three-fiber and I cannot get updated mesh and vertex colors to display. The color of my mesh stays the same even after I do all the steps below:
I have the following code which creates a mesh:
const material = new THREE.MeshBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.5,
wireframe: false,
side: THREE.DoubleSide,
vertexColors: true,
});
const mesh = new THREE.Mesh(curvedGeometry, material);
I then render that mesh using a primitive component
<primitive object={mesh} />
Later, I change the face and vertex colors in that mesh. So that all the vertices and faces have the color values in the picture below:
Finally, I set the colorsNeedUpdate value on the geometry to true like this
polygonMesh.geometry.colorsNeedUpdate = true;
Code sandbox link here: https://codesandbox.io/s/change-vertex-colors-old-rz82v?runonclick=1&file=/src/index.tsx:665-673
