Class Triangle

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

Hierarchy

  • Base
    • Triangle

Constructors

  • Creates a new Triangle.

    Parameters

    • Optional a: Vector3

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

    • Optional b: Vector3

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

    • Optional c: Vector3

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

    Returns Triangle

Properties

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

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

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

Accessors

  • get isBox2(): boolean
  • Returns boolean

  • get isBox3(): boolean
  • Returns boolean

  • get isColor(): boolean
  • Returns boolean

  • get isCylindrical(): boolean
  • Returns boolean

  • get isEuler(): boolean
  • Returns boolean

  • get isLine3(): boolean
  • Returns boolean

  • get isMatrix3(): boolean
  • Returns boolean

  • get isMatrix4(): boolean
  • Returns boolean

  • get isPlane(): boolean
  • Returns boolean

  • get isQuaternion(): boolean
  • Returns boolean

  • get isRay(): boolean
  • Returns boolean

  • get isSphere(): boolean
  • Returns boolean

  • get isSpherical(): boolean
  • Returns boolean

  • get isTriangle(): boolean
  • Read-only flag to check if a given object is of type Triangle.

    Returns boolean

  • get isVector2(): boolean
  • Returns boolean

  • get isVector3(): boolean
  • Returns boolean

  • get isVector4(): boolean
  • Returns boolean

Methods

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

    Returns

    A new Triangle instance equal to this triangle.

    Returns Triangle

  • Returns the closest point on the triangle to point.

    Algorithm thanks to Real-Time Collision Detection by Christer Ericson, published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc., under the accompanying license; see chapter 5.1.5 for detailed explanation. basically, we're distinguishing which of the voronoi regions of the triangle the point lies in with the minimum amount of redundant computation.

    Returns

    The closest point.

    Parameters

    • pt: Vector3

      Vector3 *

    • Optional target: Vector3

      — (Optional) The result will be copied into this Vector3. *

    Returns Vector3

  • Determine if a point, when projected onto the plane of the triangle, lies within the triangle.

    Returns

    True if the triangle contains the point.

    Parameters

    Returns boolean

  • Determing if the two triangles have identical a, b and c properties.

    Returns

    True if triangle has the same component values as this triangle.

    Parameters

    • triangle: Triangle

      The source triangle

    Returns boolean

  • Copmute the area of the triangle.

    Returns

    The area of the triangle.

    Returns number

  • Compute a barycentric coordinate from the given vector.

    Returns

    The barycentric coordinate.

    Parameters

    • point: Vector3

      Vector3

    • Optional target: Vector3

      (Optional) The result will be copied into this Vector3.

    Returns Vector3

  • Calculate the midpoint of the triangle.

    Returns

    The midpoint.

    Parameters

    • Optional target: Vector3

      (Optional) The result will be copied into this Vector3.

    Returns Vector3

  • Calculate the normal vector of the triangle.

    Returns

    The normal vector.

    Parameters

    • Optional target: Vector3

      (Optional) The result will be copied into this Vector3.

    Returns Vector3

  • Calculate a plane based on the triangle. .

    Returns

    The plane.

    Parameters

    • Optional target: Plane

      (Optional) The result will be copied into this Plane.

    Returns Plane

  • Compute the uv coordinates for the given point on the triangle.

    Returns

    The UV coordinate

    Parameters

    • point: Vector3

      The point on the triangle.

    • uv1: Vector2

      The uv coordinate of the triangle's first vertex.

    • uv2: Vector2

      The uv coordinate of the triangle's second vertex.

    • uv3: Vector2

      The uv coordinate of the triangle's third vertex.

    • Optional target: Vector2

      — (optional) The result will be copied into this Vector2

    Returns Vector2

  • Determines whether or not this triangle intersects box.

    Returns

    True if the box intersects this triangle.

    Parameters

    • box: Box3

      Box to check for intersection against.

    Returns boolean

  • Determine if the triangle is oriented towards the given direction or not.

    Returns

    True if the triangle is oriented towards the direction parameter.

    Parameters

    • direction: Vector3

      The direction to test.

    Returns boolean

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

    Returns

    This instance

    Parameters

    • points: Vector3[]

      Array of Vector3s

    • i0: number

      index into points array

    • i1: number

      index into points array

    • i2: number

      index into points array

    Returns Triangle