Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 18x 21x 21x 21x 1x 1x 1x 1x 1x 1x 1x 1x | import type { Matrix4 } from "../math"; import { Vector3 } from "../math"; const v1 = new Vector3(); //plane specified by three points export class Triangle { a: Vector3; b: Vector3; c: Vector3; constructor(a = new Vector3(), b = new Vector3(), c = new Vector3()) { this.a = a; this.b = b; this.c = c; } copy(triangle: Triangle): Triangle { this.a.copy(triangle.a); this.b.copy(triangle.b); this.c.copy(triangle.c); return this; } applyMatrix4(matrix: Matrix4): Triangle { this.a.applyMatrix4(matrix); this.b.applyMatrix4(matrix); this.c.applyMatrix4(matrix); return this; } getNormal(): Vector3 { var norm = this.a.clone(); norm.sub(this.b); v1.subVectors(this.c, this.b); norm.cross(v1); norm.normalize(); return norm; } } |