How to colour a mesh geometry by faces and not vertecies

I’m pretty much trynna do this: How to disable color interpolation when using vertexColors? but since the original question has no answer I’m asking again as it seems like a problem that should have an easily accessible solution that begginers should be able to understand.

One more thing i would like to ask the three.js community is why is the data accessible from a meshGeometry been limited so much when bufferedGeometries where removed? I keep getting redirected to this post talking about the performance benefits: THREE.Geometry will be removed from core with r125 but it just feels wierd not having any face information of a mesh.

Is this demo relevant?

https://codepen.io/boytchev/full/GRwMdPj

image

Note: left image – interpolated vertex colors; right image – clear face colors (actually, not, these are again vertex colors, but each face is colored individually)

1 Like

yhea that looks good any idea on how to get the same effect with react-three/fiber?

Sorry, I don’t do R3F. I hope that some of the R3F gurus will answer, but there are rumors, that any pure Three.js can be used within R3F.

1 Like

thanks anyways that was exactly what I was looking for

just for future reference found how to do the same in r3f

export const Component = () => {
    const meshRef = useRef();

    useEffect(() => {
        meshRef.current.geometry = meshRef.current.geometry.toNonIndexed( );
    }, [meshRef])

    return (
        <mesh ref={meshRef} >
            ...
        </mesh>
    );

}

ps: this is very much a hack but hopefully someone can build on it as it’s good enough for my usecase

2 Likes