Skip to content

Assigning Material to Specific Faces of Geometry #744

@vance

Description

@vance

Hallo,
Since the materials array is deprecated, how might one assign a different material to each face? Let's do a simple cube example.

var materialA= new THREE.MeshLambertMaterial({color: 0x00ffaa });
cursorBox = new THREE.CubeGeometry(1, 1, 1);
cubeMesh = new THREE.Mesh(cursorBox, materialA);

// how I might have assigned materialB to face 1 prior to the change? Not sure.

var materialB = new THREE.MeshLambertMaterial({color: 0xff0000 });
mesh.materials.push( materialB);
cubeMesh.goemetry.faces[0].materialIndex = 1;

// my theory on how to do it now. It causes no error but fails to change anything. 
// Waited for one render cycle to pass in case the material/geometry needs to bind

cubeMesh.geometry.faces[0].material = materialB ;              

Any ideas? I may just be missing something fundamentally simple. I'm using a dev build 036caa6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions