Babylon Import the model and add external textures to the model

Hello, I introduced a model from outside and added a network linked texture to it. When I did not declare a material, the model can be displayed. However, after I gave the model a material, it will not be displayed. I need your help

The code is as follows:

  BABYLON.SceneLoader.ImportMesh('', "https://hyhh-fs.oss-cn-beijing.aliyuncs.com/model/", "ea4f4e7f0a2d48e18b22b1b0cff68b66.glb", scene, (meshes) => {
        meshes.forEach((mesh) => {
            var stdMaterial = new BABYLON.StandardMaterial("stdMaterial", scene);
            stdMaterial.diffuseTexture = new BABYLON.Texture("https://hyhh-fs.oss-cn-beijing.aliyuncs.com/model/67841f1c783b4826bc23313689412b77.png", scene, false, false)
            stdMaterial.diffuseColor = new BABYLON.Color3(1, 1, 1);
            mesh.material = stdMaterial
        });
        engine.runRenderLoop(() => {
            scene.render();
        });
    }, undefined, (error) => {
    });

Is this an issue with importing the model or is there an issue with my code

Welcome aboard!

Here’s a PG with your code:

It does not work because your model does not have texture coordinates:

image

Even if you don’t set the diffuse texture, it still does not work because vertex colors are enabled for your mesh, but the colors are fully transparent:

You can disable using vertex colors like this:

1 Like

Thank you very much, but why is the imported model semi transparent? How should I solve it

That’s how it has been authored. Maybe it’s a problem during export?

If you want to fix it, you will have to edit it in a DCC tool (like Blender) and remove/fix the vertex colors + add texture coordinates.

3 Likes

Thank you very much

Thank you, according to your method, it can really be displayed. Thank you again, my brother