Graphics Reference
In-Depth Information
One thing to take into account is that the object we create here isn't THREE.Mesh
but THREE.Object3D . Why a different object is created is explained in the next sec-
tion.
How it works...
What happens when you call the createMultiMaterialObject function is that
Three.js simply creates multiple meshes and groups them together. If you open the
Three.js file and look up this function, you'll see the following code:
function createMultiMaterialObject( geometry,
materials ) {
var group = new THREE.Object3D();
for ( var i = 0, l = materials.length; i < l; i
++ ) {
group.add( new THREE.Mesh( geometry, materials[
i ] ) );
}
return group;
}
In this function, Three.js iterates over the materials that are provided, and for each
material, a new THREE.Mesh object is created. Because all the created meshes are
added to group, the result looks like a single mesh that's created with multiple ma-
terials.
See also
• When you use the approach from this recipe to create a material that uses
multiple materials, the materials are applied to the complete geometry. In the
Using separate materials for faces recipe, we show you how to use a differ-
ent material for each specific face of a geometry.
Search WWH ::




Custom Search