Game Development Reference
In-Depth Information
All of these material constructors except
MeshFaceMaterial
take a map of options as
their only parameter. We've already encountered three options from our icosahedron
example:
color
,
wireframe
, and
wireframeLinewidth
. Additionally, setting the
transparency
option to
true
allows use of the
opacity
option, a value between
zero and one indicating how see-through the material should be (zero is invisible,
one is opaque). For materials that don't use images, the other option that may be
relevant is
shading
, which has a value of either
THREE.SmoothShading
or
THREE.
FlatShading
indicating whether to blend colors of each face together, as shown in
the next screenshot:
Left, THREE.MeshNormalMaterial({shading: THREE.FlatShading}); Right, THREE.
MeshNormalMaterial({shading: THREE.SmoothShading});
There are several other properties, the most important of which is also the most
useful:
map
. This defines the texture used to wrap over the geometry. Usually, using
this property looks like the following code snippet:
var image = THREE.ImageUtils.loadTexture('image.jpg');
new THREE.MeshBasicMaterial({map: image});