Graphics Reference
In-Depth Information
All you need is some small change to how you assign the materialIndex proper-
ties like this:
var plane = new THREE.PlaneGeometry(10, 10, 9,
9);
var materials = [];
var material_1 = new THREE.MeshBasicMaterial(
{color:Math.random()*0xff0000, side:
THREE.DoubleSide});
var material_2 = new THREE.MeshBasicMaterial(
{color:Math.random()*0xff0000, side:
THREE.DoubleSide});
materials.push(material_1);
materials.push(material_2);
var index = 0;
for (var i = 0 ; i < plane.faces.length-1 ;
i+=2) {
var face = plane.faces[i];
var nextFace = plane.faces[i+1];
face.materialIndex = index;
nextFace.materialIndex = index;
if (index === 0) {
index = 1;
} else {
index = 0;
}
}
See also
• If you don't want to style specific faces but apply multiple materials to a com-
plete geometry, you can look at the Creating a mesh with multiple materials
recipe, where we explain how to do just that
Search WWH ::




Custom Search