GLB showing black vertex colors as default value

This one seems a little tricky.

When I export a GLB file from 3DS Max, enable vertex colors on my materials in three.js and display it, meshes with no colors ever having been set display black. Meshes I do explicitely set colors for display those custom set colors. Before I blame it on the BabylonJS exporters, I throw it into donmccurdy’s gltf viewer and alas, all colors come out as expected - custom colors are displayed, and meshes with no colors set previously are not affected by the mul because they default to white.

I am using a mesh.traverse() after GLTFLoader:

mesh.traverse(node => {
        if (node instanceof THREE.Mesh) {
            let material = node.material;
            node.castShadow = true;
            node.receiveShadow = true;
            material.vertexColors = true;
...

            node.material = material;
}

results in:

Using donmccurdy’s viewer:

So it must be something else, seeing as his app seems to be interpreting the same GLB file fine?
The materials in-scene are a mix of MeshStandardMaterial and (unlit) MeshLambertMaterial, but that doesn’t make a difference. Any pointers maybe? We are on r117.

If you’re manually setting material.vertexColors = true on every material, are you 100% sure that you’ve added vertex colors to the geometry of every mesh using those materials? If they had vertex colors already in the GLB, GLTFLoader would have enabled the option for you.

Enabling this option on materials that don’t have vertex colors will not give good results.

2 Likes

I feel kinda stupid now. Works as intended. This I didn’t know:

If they had vertex colors already in the GLB, GLTFLoader would have enabled the option for you.

Thanks @donmccurdy! (and thanks for providing the viewer as a service)