[name]
Triangular face used in [page:Geometry]. These are created automatically for all
standard geometry types, however if you are building a custom geometry you will have to
create them manually.
Examples
[example:misc_ubiquity_test ubiquity / test]
[example:svg_sandbox svg / sandbox]
[example:misc_exporter_obj exporter / obj]
[example:webgl_shaders_vector WebGL / shaders / vector]
var material = new v3d.MeshStandardMaterial({ color : 0x00cc00 });
//create a triangular geometry
var geometry = new v3d.Geometry();
geometry.vertices.push(new v3d.Vector3(-50, -50, 0));
geometry.vertices.push(new v3d.Vector3( 50, -50, 0));
geometry.vertices.push(new v3d.Vector3( 50, 50, 0));
//create a new face using vertices 0, 1, 2
var normal = new v3d.Vector3(0, 1, 0); //optional
var color = new v3d.Color(0xffaa00); //optional
var materialIndex = 0; //optional
var face = new v3d.Face3(0, 1, 2, normal, color, materialIndex);
//add the face to the geometry's faces array
geometry.faces.push(face);
//the face normals and vertex normals can be calculated automatically if not supplied above
geometry.computeFaceNormals();
geometry.computeVertexNormals();
scene.add(new v3d.Mesh(geometry, material));
Constructor
[name]([page:Integer a], [page:Integer b], [page:Integer c], [page:Vector3 normal], [page:Color color], [page:Integer materialIndex])
a — Vertex A index.
b — Vertex B index.
c — Vertex C index.
normal — (optional) Face normal ([page:Vector3 Vector3]) or array of vertex normals.
If a single vector is passed in, this sets [page:.normal], otherwise if an array of three
vectors is passed in this sets [page:.vertexNormals]
color — (optional) Face [page:Color color] or array of vertex [page:Color colors].
If a single vector is passed in, this sets [page:.color], otherwise if an array of three
vectors is passed in this sets [page:.vertexColors]
materialIndex — (optional) which index of an array of materials to associate
with the face.
Properties
[property:Integer a]
Vertex A index.
[property:Integer b]
Vertex B index.
[property:Integer c]
Vertex C index.
[property:Vector3 normal]
Face normal - vector showing the direction of the Face3. If calculated automatically
(using [page:Geometry.computeFaceNormals]), this is the normalized cross product of two edges of the
triangle. Default is *(0, 0, 0)*.
[property:Color color]
Face color - for this to be used a material's [page:Material.vertexColors vertexColors] property
must be set to [page:Materials v3d.FaceColors].
[property:Array vertexNormals]
Array of 3 [page:Vector3 vertex normals].
[property:Array vertexColors]
Array of 3 vertex colors - for these to be used a material's [page:Material.vertexColors vertexColors] property
must be set to [page:Materials v3d.VertexColors].
[property:Integer materialIndex]
Material index (points to an index in the associated array of materials). Default is *0*.
Methods
[method:Face3 clone]()
Creates a new clone of the Face3 object.
[method:Face3 copy]([page:Face3 face3])
Copy the paramaters of another Face3 into this.
[sourceHint]