Triangle

A geometric triangle as defined by three Vector3s representing its three corners.

Constructor

Triangle(a : Vector3, b : Vector3, c : Vector3)

Creates a new Triangle.

Properties

.a : Vector3

The first corner of the triangle. Default is a Vector3 at (0, 0, 0).

.b : Vector3

The second corner of the triangle. Default is a Vector3 at (0, 0, 0).

.c : Vector3

The final corner of the triangle. Default is a Vector3 at (0, 0, 0).

Methods

.clone() → Triangle

Returns a new triangle with the same a, b and c properties as this one.

.closestPointToPoint(point : Vector3, target : Vector3) → Vector3

Returns the closest point on the triangle to point.

.containsPoint(point : Vector3) → Boolean

pointVector3 to check.

Returns true if the passed point, when projected onto the plane of the triangle, lies within the triangle.

.copy(triangle : Triangle) → this

Copies the values of the passed triangles's a, b and c properties to this triangle.

.equals(triangle : Triangle) → Boolean

Returns true if the two triangles have identical a, b and c properties.

.getArea() → Float

Return the area of the triangle.

.getBarycoord(point : Vector3, target : Vector3) → Vector3

Return the barycentric coordinates from the given vector.

.getMidpoint(target : Vector3) → Vector3

target — the result will be copied into this Vector3.

Calculate the midpoint of the triangle.

.getNormal(target : Vector3) → Vector3

target — the result will be copied into this Vector3.

Calculate the normal vector of the triangle.

.getPlane(target : Plane) → Plane

target — the result will be copied into this Plane.

Calculate a plane based on the triangle.

.getUV(point : Vector3, uv1 : Vector2, uv2 : Vector2, uv3 : Vector2, target : Vector2) → Vector2

Returns the UV coordinates for the given point on the triangle.

.intersectsBox(box : Box3) → Boolean

box — box to check for intersection against.

Determines whether or not this triangle intersects box.

.isFrontFacing(direction : Vector3) → Boolean

direction — the direction to test.

Whether the triangle is oriented towards the given direction or not.

.set(a : Vector3, b : Vector3, c : Vector3) → this this : Triangle

Sets the triangle's a, b and c properties to the passed vector3s. Please note that this method only copies the values from the given objects.

.setFromAttributeAndIndices(attribute : BufferAttribute, i0 : Integer, i1 : Integer, i2 : Integer) → this this : Triangle

Sets the triangle's vertices from the buffer attribute vertex data.

.setFromPointsAndIndices(points : Array, i0 : Integer, i1 : Integer, i2 : Integer) → this this : Triangle

Sets the triangle's vectors to the vectors in the array.

Source

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