Is it possible to change an embedded texture in a 3D model (e.g. glb file) with an external texture file via Babylon js code?

I have a .glb model in my scene which has an embedded texture in it. I want to replace this model’s embedded texture with an external texture file in the onSuccess callback. Is it possible to change an embedded texture from Babylon js code and if it’s possible, is it a good practice or a bad practice?

I was trying this code, but it didn’t work:

    	meshTask = assetsManager.addMeshTask("", "", "scenes/", "lowpolyCar.glb");

            meshTask.onSuccess = function (task) {
        
            let material = new BABYLON.StandardMaterial('mat', scene);
            material.diffuseTexture = new BABYLON.Texture("scenes/Car Texture 1.png", scene);
            material.diffuseTexture.uScale = 1;
            material.diffuseTexture.vScale = 1; 
            task.loadedMeshes[1].material = material;

Update: I was able to apply a new texture but I am unable to set the tiling settings accurately. Moreover, the same tiling settings worked when I used .obj format of the same model.

1 Like

Hello can you provide a repro in the playground? Your code seems fine at first sight