# Why people passes array of materials to mesh?

**URL:** <https://discourse.threejs.org/t/why-people-passes-array-of-materials-to-mesh/41272>\
**Category:** Questions\
**Tags:** materials\
**Created:** [August 10, 2022, 9:49am UTC](https://discourse.threejs.org/t/why-people-passes-array-of-materials-to-mesh/41272 "2022-08-10T09:49:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sohail\_Ansari](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/sohail_ansari/32/26312_2.png) [@Sohail\_Ansari](https://discourse.threejs.org/u/Sohail_Ansari)\
**Post date:** [August 10, 2022, 9:49am UTC](https://discourse.threejs.org/t/why-people-passes-array-of-materials-to-mesh/41272/1 "2022-08-10T09:49:18Z")

</div>

do people use this to blend multiple textures?

---

<div class="post-metadata">

**Author:** ![drcmda](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@drcmda](https://discourse.threejs.org/u/drcmda)\
**Post date:** [August 10, 2022, 10:06am UTC](https://discourse.threejs.org/t/why-people-passes-array-of-materials-to-mesh/41272/2 "2022-08-10T10:06:37Z")

</div>

your geometry can have material groups defined where you can specifically create indices and ranges. each material in the array corresponds to an index and will only affect its range of vertices. the default geometries already have material groups defined, so you can pass materials as an array. in short: the geometry can have multiple materials applied to various regions or faces.

---

<div class="post-metadata">

**Author:** ![hofk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hofk/32/44944_2.png) [@hofk](https://discourse.threejs.org/u/hofk)\
**Post date:** [August 10, 2022, 10:34am UTC](https://discourse.threejs.org/t/why-people-passes-array-of-materials-to-mesh/41272/3 "2022-08-10T10:34:09Z")

</div>

In this example, I use six materials for the cube.

From the [collection](https://discourse.threejs.org/t/collection-of-examples-from-discourse-threejs-org/4315) :

[MorphBoxSphere](https://hofk.de/main/discourse.threejs/2021/MorphBoxSphere/MorphBoxSphere.html)

```javascript

const texturLoader = new THREE.TextureLoader( );
 
const diceMaterial = [
    
	new THREE.MeshBasicMaterial( { map: texturLoader.load( 'dice/6.png' ), wireframe: false } ),
    new THREE.MeshBasicMaterial( { map: texturLoader.load( 'dice/1.png' ), wireframe: false } ),
    new THREE.MeshBasicMaterial( { map: texturLoader.load( 'dice/5.png' ), wireframe: false } ),
    new THREE.MeshBasicMaterial( { map: texturLoader.load( 'dice/2.png' ), wireframe: false } ),
    new THREE.MeshBasicMaterial( { map: texturLoader.load( 'dice/4.png' ), wireframe: false } ),
    new THREE.MeshBasicMaterial( { map: texturLoader.load( 'dice/3.png' ), wireframe: false } ),

];

```

---

<div class="post-metadata">

**Author:** ![trusktr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/trusktr/32/13726_2.png) [@trusktr](https://discourse.threejs.org/u/trusktr)\
**Post date:** [December 5, 2023, 9:50am UTC](https://discourse.threejs.org/t/why-people-passes-array-of-materials-to-mesh/41272/4 "2023-12-05T09:50:46Z")

</div>

Here’s a [material array example on jsfiddle](https://jsfiddle.net/v87f1j65/2/). Note in particular how [commenting out the geometry groups breaks it](https://jsfiddle.net/v87f1j65/3/).

Maybe it would be intuitive for that example to work the same without having to call `addGroup` to add every material to every face. I mean, that it seems intuitive for every material to be on every face out-of-the-box.

---

<div class="post-metadata">

**Author:** ![Sohail\_Ansari](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/sohail_ansari/32/26312_2.png) [@Sohail\_Ansari](https://discourse.threejs.org/u/Sohail_Ansari)\
**Post date:** [February 23, 2024, 5:00pm UTC](https://discourse.threejs.org/t/why-people-passes-array-of-materials-to-mesh/41272/5 "2024-02-23T17:00:40Z")

</div>

the example is so nice, thanks!
