# Face3

Triangular face used in 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.

## Code Example

``` const material = new v3d.MeshStandardMaterial({ color : 0x00cc00 }); //create a triangular geometry const 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 const normal = new v3d.Vector3(0, 0, 1); //optional const color = new v3d.Color(0xffaa00); //optional const materialIndex = 0; //optional const 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

### Face3(a : Integer, b : Integer, c : Integer, normal : Vector3, color : Color, materialIndex : Integer)

a — Vertex A index.
b — Vertex B index.
c — Vertex C index.

normal — (optional) Face normal (Vector3) or array of vertex normals. If a single vector is passed in, this sets .normal, otherwise if an array of three vectors is passed in this sets .vertexNormals

color — (optional) Face color or array of vertex colors. If a single vector is passed in, this sets .color, otherwise if an array of three vectors is passed in this sets .vertexColors

materialIndex — (optional) which index of an array of materials to associate with the face.

## Properties

Vertex A index.

Vertex B index.

Vertex C index.

### # .normal : Vector3

Face normal - vector showing the direction of the Face3. If calculated automatically (using Geometry.computeFaceNormals), this is the normalized cross product of two edges of the triangle. Default is (0, 0, 0).

### # .color : Color

Face color - for this to be used a material's vertexColors property must be set to true.

### # .vertexNormals : Array

Array of 3 vertex normals.

### # .vertexColors : Array

Array of 3 vertex colors - for these to be used a material's vertexColors property must be set to true.

### # .materialIndex : Integer

Material index (points to an index in the associated array of materials). Default is 0.

## Methods

### # .clone () : Face3

Creates a new clone of the Face3 object.

### # .copy (face3 : Face3) : Face3

Copy the parameters of another Face3 into this.

## Source

For more info on how to obtain the source code of this module see this page.