A triangle.
new Tri(
v0?: Vec3,
v1?: Vec3,
v2?: Vec3): Tri
Creates a new Tri object.
Vec3 = Vec3.ZERO
The first 3-dimensional vector.
Vec3 = Vec3.ZERO
The second 3-dimensional vector.
Vec3 = Vec3.ZERO
The third 3-dimensional vector.
const v0 = new Vec3(1, 0, 0)
const v1 = new Vec3(0, 1, 0)
const v2 = new Vec3(2, 2, 1)
const t = new Tri(v0, v1, v2)
readonly v0: Vec3;
The first 3-dimensional vector of the triangle.
readonly v1: Vec3;
The second 3-dimensional vector of the triangle.
readonly v2: Vec3;
The third 3-dimensional vector of the triangle.
intersectsRay(ray: Ray, point?: Vec3): boolean
Test if a ray intersects with the triangle.
Ray to test against (direction must be normalized).
If there is an intersection, the intersection point will be copied into here.
boolean
True if there is an intersection.
set(
v0: Vec3,
v1: Vec3,
v2: Vec3): Tri
Sets the specified triangle to the supplied 3-dimensional vectors.
The value set on the first 3-dimensional vector of the triangle.
The value set on the second 3-dimensional vector of the triangle.
The value set on the third 3-dimensional vector of the triangle.
Self for chaining
const t = new Tri(Vec3.UP, Vec3.RIGHT, Vec3.BACK)
const v0 = new Vec3(1, 0, 0)
const v1 = new Vec3(0, 1, 0)
const v2 = new Vec3(2, 2, 1)
t.set(v0, v1, v2)
// Outputs [[1, 0, 0], [0, 1, 0], [2, 2, 1]]
console.log('The result of the triangle set is: ' + t.toString())
toString(): string
Converts the specified triangle to string form.
string
The triangle in string form.
const t = new Tri(Vec3.UP, Vec3.RIGHT, Vec3.BACK)
// Outputs [[0, 1, 0], [1, 0, 0], [0, 0, 1]]
console.log(t.toString())