Blender glb export secondaryUV

I’m writing code to load a GLB model from Blender into Three.js. When the number of objects exported from Blender is small, they load fine in Three.js. However, when there are many objects exported from Blender, I encounter the following errors:

ERROR: 0:398: ‘uv2’ : undeclared identifier ERROR: 0:398: ‘constructor’ : not enough data provided for construction

Looking at the object properties, uv2 does exist in geometry, so I’m not clear on the cause of the problem.

It might be an issue on Blender’s side, but I’m not sure. If you have any knowledge about this, I would appreciate your help. I’m also including my code for reference. Thank you for your cooperation

gltfLoader.load(
    '/models/wall_bake_test.glb',
    (gltf) =>
    {
        gltf.scene.traverse((child) => {
            if (child.name==="Cube022") {
                const mesh = child;
                const material = mesh.material
                const lightMapTexture = new THREE.TextureLoader().load('./textures/Cube.022_Bake1_PBR_Lightmap.png',function(){
                    material.needsUpdate = true; 
                });
                lightMapTexture.channel = 2
                lightMapTexture.flipY = false
                material.lightMap = lightMapTexture;
                console.log(lightMapTexture);
                material.needsUpdate = true; // 
                gui.add(child.material, 'lightMapIntensity').min(0).max(30).step(0.001).name('lightMapIntensity')
            }
 });

        scene.add(gltf.scene)

        updateAllMaterials()
    }
)

Try loading the model into https://gltf.report/ and checking the validation and metadata tabs. Do all affected meshes have 3+ UV sets? Does the model pass validation? If the model fails validation or doesn’t display properly in external viewers, then it’d be best to report an issue to the Blender exporter. If the model passes validation but fails to display in three.js-based viewers like https://gltf-viewer.donmccurdy.com/ then it could be an issue in three.js. If the model is OK in all of those but breaks only in your own application, then it’s something about your application’s code, and more reproducible steps would be required for others to debug that I think.

1 Like