t3d. Triangle

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

Constructor

new Triangle(a=opt, b=opt, c=opt)

Parameters:
NameTypeAttributesDescription
a=t3d.Vector3<optional>
the first corner of the triangle. Default is a Vector3 at (0, 0, 0).
b=t3d.Vector3<optional>
the second corner of the triangle. Default is a Vector3 at (0, 0, 0).
c=t3d.Vector3<optional>
the final corner of the triangle. Default is a Vector3 at (0, 0, 0).

Methods

set(a, b, c) → {t3d.Triangle}

Sets the triangle's a, b and c properties to the passed vector3s.
Parameters:
NameTypeDescription
at3d.Vector3
bt3d.Vector3
ct3d.Vector3
Returns:
Type: 
t3d.Triangle

(static) barycoordFromPoint(point, a, b, c, targetopt) → {t3d.Vector3}

static/instance method to calculate barycentric coordinates. based on: http://www.blackpawn.com/texts/pointinpoly/default.html
Parameters:
NameTypeAttributesDescription
pointt3d.Vector3Vector3
at3d.Vector3
bt3d.Vector3
ct3d.Vector3
targett3d.Vector3<optional>
the result will be copied into this Vector3.
Returns:
Type: 
t3d.Vector3

(static) containsPoint(point, a, b, c) → {t3d.Vector3}

Returns true if the passed point, when projected onto the plane of the triangle, lies within the triangle.
Parameters:
NameTypeDescription
pointt3d.Vector3
at3d.Vector3
bt3d.Vector3
ct3d.Vector3
Returns:
Type: 
t3d.Vector3

(static) normal(a, b, c, optionalTargetopt) → {t3d.Vector3}

Calculate the normal vector of the triangle.
Parameters:
NameTypeAttributesDescription
at3d.Vector3
bt3d.Vector3
ct3d.Vector3
optionalTargett3d.Vector3<optional>
Returns:
Type: 
t3d.Vector3