# How to map different textures to a glb model

**URL:** https://discourse.threejs.org/t/how-to-map-different-textures-to-a-glb-model/50687
**Category:** Questions
**Tags:** materials, gltf-loader
**Created:** [April 21, 2023, 12:21pm UTC](https://discourse.threejs.org/t/how-to-map-different-textures-to-a-glb-model/50687 "2023-04-21T12:21:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![double\_J](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@double\_J](https://discourse.threejs.org/u/double_J)
#### Post date: [April 21, 2023, 12:21pm UTC](https://discourse.threejs.org/t/how-to-map-different-textures-to-a-glb-model/50687/1 "2023-04-21T12:21:45Z")

</div>

I’m new to three.js, I want to load different textures on different sides on my GLB model, is that possible?  
I tried it like this with a normal cube:

```javascript
var geometry_cube = new THREE.BoxGeometry(2,2,2);
var materials = [
  new THREE.MeshBasicMaterial({ color: 0xff0000}),
  new THREE.MeshBasicMaterial({ color: 0x0000ff }),
  new THREE.MeshBasicMaterial({ color: 0x00ff00 }),
  new THREE.MeshBasicMaterial({ color: 0xffff00 }),
  new THREE.MeshBasicMaterial({ map: texture_1 }),
  new THREE.MeshBasicMaterial({ map: texture_2 })
];

var cube = new THREE.Mesh(geometry_cube, materials);
scene.add(cube);

```

and then I wanted to do it like this with the glb model:  
Note: the glb model has also 6 sides.

```javascript
gltfLoader.load('glb_model.glb', (gltf) => {
  const model = gltf.scene;

  model.traverse((child) => {
    if (child.isMesh) {
      child.material = materials;
    }
  }),
});

```

The model does not load, but there is no error message.  
Then I tried `child.material.map = texture_1` and it works, but it renders on all sides.  
Hope you can help me, thanks in advance.

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [April 22, 2023, 9:40am UTC](https://discourse.threejs.org/t/how-to-map-different-textures-to-a-glb-model/50687/2 "2023-04-22T09:40:56Z")

</div>

You can’t use multi-materials with glTF assets since `GLTFLoader` does not support `BufferGeometry.groups`, a prerequisite for using multi-materials.

When a mesh is authored with multiple materials in a tool like Blender and exported to glTF, `GLTFLoader` will split up the mesh into multiple ones (each for one material). So if you authored your model correctly, you should end up with six meshes with six independent materials.

---

<div class="post-metadata">

### Author: ![double\_J](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@double\_J](https://discourse.threejs.org/u/double_J)
#### Post date: [April 22, 2023, 2:37pm UTC](https://discourse.threejs.org/t/how-to-map-different-textures-to-a-glb-model/50687/3 "2023-04-22T14:37:01Z")

</div>

Thanks @Mugen87 for your answer, it helped me and gave me food for thought.  
I made my model with different materials and changed the texture/color with `model.getObjectByName('cube').material.map = texture;`. It was easier than I thought.
