How to update faces color

Hi, how to update faces.color in three js ? my code is :

mesh.geometry.faces.forEach((face, index) => {
  face.color = `rgb(${index}, ${index}, ${index})`;
});
mesh.geometry.elementsNeedUpdate = true;
mesh.geometry.colorsNeedUpdate = true;
mesh.geometry.groupsNeedUpdate = true;

but color is not changing…

Um, you normally do this like so:

var faces = geometry.faces;

for ( var face of faces ) {

	face.color.set( Math.random() * 0xffffff );

}

geometry.colorsNeedUpdate = true;

Demo: https://jsfiddle.net/e5sp31nf/

1 Like

Nvm, colors were changing but they all were white so i didnt see changes…