How to add particular texture to particular faces of BoxGeometry using ShaderMaterial in THREE.JS?

230 Views Asked by At

I am trying to add texture for each face of BoxGeometry.

I have tried passing an array of ShaderMaterial object into the mesh but its not working.

 createMaterials(texture){
return new ShaderMaterial({
  uniforms:{
    texture:{
      value:texture
    }
  }
})
}

  var mat0 =  this.createMaterials(brownImageTexture);
  var mat1  = this.createMaterials(texture1);
  var mat2  = this.createMaterials(texture2);
  var mat3  = this.createMaterials(texture3);
  var mat4  = this.createMaterials(texture4);
  var mat5  = this.createMaterials(texture5);

  var cube = new THREE.Mesh(geometry, [mat0 ,mat1, mat2, mat3, mat4, mat5] );

Not able to add texture for each face of Box Geometry.

Note : I want to use Shader Materials because I was able to add a texture to the cube over another texture.

Any guidance, reference or help would be really appreciated !! Thanks

0

There are 0 best solutions below