# Fetch texture using getMeshByName

**URL:** <https://forum.babylonjs.com/t/fetch-texture-using-getmeshbyname/3116>\
**Category:** Questions\
**Created:** [May 9, 2019, 8:05pm UTC](https://forum.babylonjs.com/t/fetch-texture-using-getmeshbyname/3116 "2019-05-09T20:05:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JulesClair](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@JulesClair](https://forum.babylonjs.com/u/JulesClair)\
**Post date:** [May 9, 2019, 8:05pm UTC](https://forum.babylonjs.com/t/fetch-texture-using-getmeshbyname/3116/1 "2019-05-09T20:05:31Z")

</div>

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](https://sandbox.babylonjs.com/). I realized that with the above code I am able to replace this image  
 ![screenshot-1](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/d/da3fe1a2c794a64e002fb5a8e9d2f1004e258507.jpeg)

But my question is how can I replace the texture image (highlighted in the below screenshot)?  
 ![screenshot-2](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/5/5d889dcecee67ddc4e5a65432f60666d2f6d93ee.jpeg)

---

<div class="post-metadata">

**Author:** ![syntheticmagus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/syntheticmagus/32/395_2.png) [@syntheticmagus](https://forum.babylonjs.com/u/syntheticmagus)\
**Post date:** [May 10, 2019, 4:31pm UTC](https://forum.babylonjs.com/t/fetch-texture-using-getmeshbyname/3116/2 "2019-05-10T16:31:07Z")

</div>

Hi JulesClair,

If it’s not too hard to port, can you reproduce your issue in a [Babylon Playground](https://playground.babylonjs.com/) and share the link here? That’ll make it much easier to discuss specifics. Thanks!
