Gltfpack material update issue


I’m loading a GLB model optimized with gltfpack.

I load the model; geometry, animations, etc. everything is fine. But when I try to change the material the mesh appears grey.

This is the way I’m changing it

gltf.scene.traverse( (m) => {
   if (m.type == 'Mesh' || m.type == 'SkinnedMesh') {
      switch (true) {
         case == 'Sofia':
            m.material = SofiaMaterial

This way works with models withouth gltfpack optimization.

Any help?

You probably have configured AlanMaterial in a way which breaks the visual appearance. E.g. when you miss setting vertexColors to true, vertex colors won’t work anymore.

Sorry the issue is with Sofia, not Alan.

No because I use the same material for every model. Just change the map.

const uMaterial = new THREE.MeshStandardMaterial({
    metalness: 0.4,
    roughness: 0.8,
    envMapIntensity: 2.5,
    skinning: true,
const AlanMaterial = uMaterial.clone() = imagesLoader('alan_base.jpg', 'sRGB')
const SofiaMaterial = uMaterial.clone() = imagesLoader('sofia_base.jpg', 'sRGB')

Alan works, Sofia dont.
Alan glb was directly from blender.
Sofia glb was passed through gltfpack optimization.

By replacing a material, you are discarding a lot of information that was in the original material. I think you will probably need to look at the settings on the original material and see what’s different compared to the material you’re adding.

1 Like