Unique Face Color after Update to three.js125

I have upgraded my project to three.jsr125 and therefore had to replace Geometry with BufferGeometry. I need to assign unique colors to each individual face in my custom 3D geometry, which doesn’t seem to be possible with Buffergeometry because I can only set colors per vertex. As this causes a face to be colored by a gradient of the different vertex colors rather than a single color.
Does anyone know if there is a solution for this? Thanks in advance.

This is done by not sharing vertices across triangles. As a result, one vertex will have several “copies” in the buffer, one copy for each triangle that uses the vertex. Then, set the color of all three vertices of a triangle with a single color. WebGL will make a gradient again, but a gradient between three same colors will look like a solid color.

Demo with indexed and non-indexed geometries: https://codepen.io/boytchev/full/GRwMdPj

Also, see this

Never end your email with “Thanks in advance” | Academic workflows on a Mac

1 Like