# Texture on imported glb from github

**URL:** <https://forum.babylonjs.com/t/texture-on-imported-glb-from-github/34209>\
**Category:** Questions\
**Tags:** glb\
**Created:** [September 24, 2022, 12:03pm UTC](https://forum.babylonjs.com/t/texture-on-imported-glb-from-github/34209 "2022-09-24T12:03:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pavanpk](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pavanpk/32/27529_2.png) [@Pavanpk](https://forum.babylonjs.com/u/Pavanpk)\
**Post date:** [September 24, 2022, 12:03pm UTC](https://forum.babylonjs.com/t/texture-on-imported-glb-from-github/34209/1 "2022-09-24T12:03:23Z")

</div>

Hi everyone.  
I have a question like How to have a texture on imported mesh using url from github.

Here is how i imported glb file from github.

addModels = () =\> {

BABYLON.SceneLoader.ImportMesh(“”, “[https://raw.githubusercontent.com/pavankulkarni11/3D\_Meshes/main/Pillow.glb](https://raw.githubusercontent.com/pavankulkarni11/3D_Meshes/main/Pillow.glb)”, this.scene);

}

This is how im trying to add texture on it but its not working for me

addModels = () =\> {  
var myMaterial = BABYLON.SceneLoader.ImportMesh(“”, “[https://raw.githubusercontent.com/pavankulkarni11/3D\_Meshes/main/Pillow.glb](https://raw.githubusercontent.com/pavankulkarni11/3D_Meshes/main/Pillow.glb)”, this.scene);  
myMaterial.diffuseTexture = new BABYLON.Texture(“[https://www.babylonjs-playground.com/textures/floor.png](https://www.babylonjs-playground.com/textures/floor.png)”, this.scene);

};

---

<div class="post-metadata">

**Author:** ![Takemura](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/takemura/32/25836_2.png) [@Takemura](https://forum.babylonjs.com/u/Takemura)\
**Post date:** [September 24, 2022, 2:26pm UTC](https://forum.babylonjs.com/t/texture-on-imported-glb-from-github/34209/2 "2022-09-24T14:26:26Z")

</div>

Mine works, when I set it by:

`new BABYLON.Texture(“/textures/filename.png", scene)`

Here are Docs:

> **[The Texture Library | Babylon.js Documentation](https://doc.babylonjs.com/toolsAndResources/assetLibraries/availableTextures)**
>
> Learn about the free available textures in the Babylon.js texture library.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [September 24, 2022, 2:33pm UTC](https://forum.babylonjs.com/t/texture-on-imported-glb-from-github/34209/3 "2022-09-24T14:33:13Z")

</div>

Let’s put more logic.

First, you import GLB

```auto
    BABYLON.SceneLoader.ImportMesh("",
        "https://raw.githubusercontent.com/pavankulkarni11/3D_Meshes/main/",
        "Pillow.glb", scene, function (newMeshes) {
        })

```

and it goes fine like here - [Babylon.js Playground](https://playground.babylonjs.com/#MXJETW)  
If you would open the Inspector it shows that your model has 2 meshes:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/1/0120e36c0d2a37b874bea84f70409427851c532b.png)

Now you need to create a new Texture which you will apply to the material of the desired mesh.

```auto
const newTexture = new BABYLON.Texture("https://www.babylonjs-playground.com/textures/floor.png")

```

You use GLB, so all materials there will be PBR materials. They have no diffuse texture, they have albedo texture  
So you need to find the desired mesh material and change `albedoTexture`:

```auto
scene.getMeshByName("pollow_poly").material.albedoTexture = newTexture

```

And, finally, because you are using GLB, you better set up the environment lighting:

```auto
scene.createDefaultEnvironment({createGround:false, createSkybox:false})

```

Example - [https://playground.babylonjs.com/#NYUG5R#3](https://playground.babylonjs.com/#NYUG5R#3)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/4/a4e21ff68dd091a6f49f9157c9c72a193376cbfd.png)

More information about environment lighting and PBR materials here - [Introduction to Physically Based Rendering | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/materials/using/introToPBR)

---

<div class="post-metadata">

**Author:** ![Pavanpk](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pavanpk/32/27529_2.png) [@Pavanpk](https://forum.babylonjs.com/u/Pavanpk)\
**Post date:** [September 26, 2022, 5:21am UTC](https://forum.babylonjs.com/t/texture-on-imported-glb-from-github/34209/4 "2022-09-26T05:21:43Z")

</div>

Thanks labris, Its working for me.
