dot big bang

Developer API
Menu

Class Triangle

All
  • Public
  • Public/Protected
  • All

Hierarchy

  • Triangle

Index

Constructors

constructor

  • Creates a new Triangle.

    Parameters

    • Optional a: Vector3

      The first point of the triangle. Default is (0, 0, 0).

    • Optional b: Vector3

      The second point of the triangle. Default is (0, 0, 0).

    • Optional c: Vector3

      The third point of the triangle. Default is (0, 0, 0).

    Returns Triangle

Properties

a

The first point of the triangle.

b

The second point of the triangle.

c

The third point of the triangle.

Methods

area

  • area(): number
  • Returns the area of the triangle.

    Returns number

barycoordFromPoint

  • Return the barycentric coordinates of the given point, relative to this triangle.

    Parameters

    • point: Vector3

      The point for which to calculate the barycentric coordinates.

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

clone

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

    Returns Triangle

closestPointToPoint

  • Returns the closest point on the triangle to point.

    Parameters

    • point: Vector3

      The point to which to calculate the closest point on the triangle

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

containsPoint

  • containsPoint(point: Vector3): boolean
  • Returns true if the provided point, when projected onto the plane of this triangle, lies within the triangle.

    Parameters

    • point: Vector3

      The point to check.

    Returns boolean

copy

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

    Parameters

    Returns Triangle

equals

  • Returns true if this triangle and the provided one v have identical a, b and c properties.

    Parameters

    Returns boolean

midpoint

  • Returns the calculated midpoint of the triangle. This is the average of the positions of the three points making up this triangle.

    Parameters

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

normal

  • Returns the calculated normal vector of this triangle.

    Parameters

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

plane

  • Returns a plane based on this triangle.

    Parameters

    • Optional optionalTarget: Plane

      The result will be copied into this Plane.

    Returns Plane

set

  • Sets the triangle's a, b and c points from the provided points (their values is copied into this triangle's).

    Parameters

    • a: Vector3

      The first point of the triangle.

    • b: Vector3

      The second point of the triangle.

    • c: Vector3

      The third point of the triangle.

    Returns Triangle

setFromPointsAndIndices

  • setFromPointsAndIndices(points: Vector3[], i0: number, i1: number, i2: number): Triangle
  • Sets the triangle's points a, b and c from the values contained in an array of Vector3, respectively at indices i0, i1 and i2.

    Parameters

    • points: Vector3[]

      The array of Vector3 where the points used to set this triangle are stored.

    • i0: number

      The index in points where to get the value point a of this triangle.

    • i1: number

      The index in points where to get the value point b of this triangle.

    • i2: number

      The index in points where to get the value point c of this triangle.

    Returns Triangle

Static barycoordFromPoint

  • Return the barycentric coordinates of the given point, relative to the triangle defined by the points a, b and c.

    Parameters

    • point: Vector3

      The point for which to calculate the barycentric coordinates.

    • a: Vector3

      The first point of the triangle.

    • b: Vector3

      The second point of the triangle.

    • c: Vector3

      The third point of the triangle.

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

Static containsPoint

  • Returns true if the provided point, when projected onto the plane of the triangle defined by the three points a, b and c, lies within the triangle.

    Parameters

    • point: Vector3

      The point to check.

    • a: Vector3

      The first point of the triangle.

    • b: Vector3

      The second point of the triangle.

    • c: Vector3

      The third point of the triangle.

    Returns boolean

Static normal

  • Returns the calculated normal vector of the triangle defined by the three points a, b and c.

    Parameters

    • a: Vector3

      The first point of the triangle.

    • b: Vector3

      The second point of the triangle.

    • c: Vector3

      The third point of the triangle.

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3