Capítulo 368 de 859

Chapter 368: Triangle

Core Idea

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

Key Concepts

  • a : Vector3: The first corner of the triangle.
  • b : Vector3: The second corner of the triangle.
  • c : Vector3: The third corner of the triangle.

Reference Tables

Constructor

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

Properties

PropertyDescription
.a : Vector3The first corner of the triangle.
.b : Vector3The second corner of the triangle.
.c : Vector3The third corner of the triangle.

Methods

MethodDescription
.clone() : TriangleReturns a new triangle with copied values from this instance.
.closestPointToPoint( p : Vector3, target : Vector3 ) : Vector3Returns the closest point on the triangle to the given point.
.containsPoint( point : Vector3 ) : booleanReturns true if the given point, when projected onto the plane of the triangle, lies within the triangle.
.copy( triangle : Triangle ) : TriangleCopies the values of the given triangle to this instance.
.equals( triangle : Triangle ) : booleanReturns true if this triangle is equal with the given one.
.getArea() : numberComputes the area of the triangle.
.getBarycoord( point : Vector3, target : Vector3 ) : Vector3Computes a barycentric coordinates from the given vector. Returns null if the triangle is degenerate.
.getInterpolation( point : Vector3, v1 : Vector3, v2 : Vector3, v3 : Vector3, target : Vector3 ) : Vector3Computes the value barycentrically interpolated for the given point on the triangle. Returns null if the triangle is degenerate.
.getMidpoint( target : Vector3 ) : Vector3Computes the midpoint of the triangle.
.getNormal( target : Vector3 ) : Vector3Computes the normal of the triangle.
.getPlane( target : Plane ) : PlaneComputes a plane the triangle lies within.
.intersectsBox( box : Box3 ) : booleanReturns true if this triangle intersects with the given box.
.isFrontFacing( direction : Vector3 ) : booleanReturns true if the triangle is oriented towards the given direction.
.set( a : Vector3, b : Vector3, c : Vector3 ) : TriangleSets the triangle's vertices by copying the given values.
.setFromAttributeAndIndices( attribute : BufferAttribute, i0 : number, i1 : number, i2 : number ) : TriangleSets the triangle's vertices by copying the given attribute values.
.setFromPointsAndIndices( points : Array.<Vector3>, i0 : number, i1 : number, i2 : number ) : TriangleSets the triangle's vertices by copying the given array values.

Key Takeaways

  1. Most relevant properties: a, b, c.
  2. Key methods: clone, closestPointToPoint, containsPoint, copy.

Connects To