Game Development Reference
In-Depth Information
Constructor
Explanation
MeshFaceMaterial
It is essentially an array of materials used to map different
materials to different surfaces. This material is unique in that
instantiating it is different than all the others, as you can see in
the following code:
var mat1 = new THREE.MeshPhongMaterial({ color:
0x0000ff });
var mat2 = new THREE.MeshPhongMaterial({ color:
0xff0000 });
var mat3 = new THREE.MeshPhongMaterial({ color:
0xffffff });
var materials = [mat1, mat2, mat3];
material = new THREE.
MeshFaceMaterial(materials);
for (var i = 0, l = geometry.faces.length; i <
l; i++) {
geometry.faces[i].materialIndex = i % l;
}
Here, we create three new materials we want to use, pass
them in an array to MeshFaceMaterial , and then set each
face on our geometry to an index of the materials array that
corresponds to the material we want for that face.
ShaderMaterial
It displays a GLSL ( open Graphics Library Shading
Language ) texture. GLSL is a programming language based on
C that is used by WebGL and OpenGL to provide developers
with a high-level, platform-agnostic way to control graphics.
It is quite powerful and will be addressed more in Chapter 4 ,
Adding Detail .
Search WWH ::




Custom Search