Why people passes array of materials to mesh?

do people use this to blend multiple textures?

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.

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

From the collection :

MorphBoxSphere


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 } ),

];

Here’s a material array example on jsfiddle. Note in particular how commenting out the geometry groups breaks it.

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.

1 Like

the example is so nice, thanks!