I am trying to change the texture of a .gltf This is the code I’m trying to get it done
BABYLON.SceneLoader.ImportMeshAsync(null, "assets/model/", "sample-model.gltf",
scene).then(results => {
var root = results.meshes[1];
meshName = root.name;
});
function changeTexture(meshName){
var mesh = scene.getMeshByName(meshName);
var mat = new BABYLON.StandardMaterial("mat", scene);
var texture = new BABYLON.Texture("assets/img/img1.png", scene);
mat.diffuseTexture = texture;
console.log(mesh+" ||||||>>>>|||||| "+mat);
//output: Name: t+shirts, isInstance: YES, # of submeshes: 1, n vertices: 5107, parent: __root__ ||||||>>>>|||||| Name: mat
mesh.material = mat;
}
Also I loaded the same .gltf file in to babylon playground. I realized that with the above code I am able to replace this image
But my question is how can I replace the texture image (highlighted in the below screenshot)?