diff --git a/dist/2.x/mat3-impl.d.ts b/dist/2.x/mat3-impl.d.ts new file mode 100644 index 0000000..23f3ebe --- /dev/null +++ b/dist/2.x/mat3-impl.d.ts @@ -0,0 +1,271 @@ +import { Quat } from './quat'; +import { Mat3 } from './mat3'; +import { Mat4 } from './mat4'; +import Vec2 from './vec2-impl'; +export default Mat3; +export type Mat3LikeCtor = new (n: number) => Mat3; +/** + * Sets the type this library creates for a Mat3 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Mat3 + */ +export declare function setDefaultType(ctor: new (n: number) => Mat3): Mat3LikeCtor; +/** + * Create a Mat3 from values + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Mat3's specified type + * it would be faster to use + * + * ``` + * const m = mat3.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Mat3Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `mat3.create` is usually used + * to create a Mat3 to be filled out as in + * + * ``` + * const m = mat3.create(); + * mat3.perspective(fov, aspect, near, far, m); + * ``` + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @returns matrix created from values. + */ +export declare function create(v0?: number, v1?: number, v2?: number, v3?: number, v4?: number, v5?: number, v6?: number, v7?: number, v8?: number): Mat3; +/** + * Sets the values of a Mat3 + * Also see {@link mat3.create} and {@link mat3.copy} + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 set from values. + */ +export declare function set(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, dst?: Mat3): Mat3; +/** + * Creates a Mat3 from the upper left 3x3 part of a Mat4 + * @param m4 - source matrix + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 made from m4 + */ +export declare function fromMat4(m4: Mat4, dst?: Mat3): Mat3; +/** + * Creates a Mat3 rotation matrix from a quaternion + * @param q - quaternion to create matrix from + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 made from q + */ +export declare function fromQuat(q: Quat, dst?: Mat3): Mat3; +/** + * Negates a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns -m. + */ +export declare function negate(m: Mat3, dst?: Mat3): Mat3; +/** + * Copies a matrix. (same as {@link mat3.clone}) + * Also see {@link mat3.create} and {@link mat3.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +export declare function copy(m: Mat3, dst?: Mat3): Mat3; +/** + * Copies a matrix (same as {@link mat3.copy}) + * Also see {@link mat3.create} and {@link mat3.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +export declare const clone: typeof copy; +/** + * Check if 2 matrices are approximately equal + * @param a Operand matrix. + * @param b Operand matrix. + * @returns true if matrices are approximately equal + */ +export declare function equalsApproximately(a: Mat3, b: Mat3): boolean; +/** + * Check if 2 matrices are exactly equal + * @param a Operand matrix. + * @param b Operand matrix. + * @returns true if matrices are exactly equal + */ +export declare function equals(a: Mat3, b: Mat3): boolean; +/** + * Creates a 3-by-3 identity matrix. + * + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A 3-by-3 identity matrix. + */ +export declare function identity(dst?: Mat3): Mat3; +/** + * Takes the transpose of a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The transpose of m. + */ +export declare function transpose(m: Mat3, dst?: Mat3): Mat3; +/** + * Computes the inverse of a 3-by-3 matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +export declare function inverse(m: Mat3, dst?: Mat3): Mat3; +/** + * Compute the determinant of a matrix + * @param m - the matrix + * @returns the determinant + */ +export declare function determinant(m: Mat3): number; +/** + * Computes the inverse of a 3-by-3 matrix. (same as inverse) + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +export declare const invert: typeof inverse; +/** + * Multiplies two 3-by-3 matrices with a on the left and b on the right + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +export declare function multiply(a: Mat3, b: Mat3, dst?: Mat3): Mat3; +/** + * Multiplies two 3-by-3 matrices with a on the left and b on the right (same as multiply) + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +export declare const mul: typeof multiply; +/** + * Sets the translation component of a 3-by-3 matrix to the given + * vector. + * @param a - The matrix. + * @param v - The vector. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix with translation set. + */ +export declare function setTranslation(a: Mat3, v: Vec2, dst?: Mat3): Mat3; +/** + * Returns the translation component of a 3-by-3 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ +export declare function getTranslation(m: Mat3, dst?: Vec2): Vec2; +/** + * Returns an axis of a 3x3 matrix as a vector with 2 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, + * @returns The axis component of m. + */ +export declare function getAxis(m: Mat3, axis: number, dst?: Vec2): Vec2; +/** + * Sets an axis of a 3x3 matrix as a vector with 2 entries + * @param m - The matrix. + * @param v - the axis vector + * @param axis - The axis 0 = x, 1 = y; + * @param dst - The matrix to set. If not passed a new one is created. + * @returns The matrix with axis set. + */ +export declare function setAxis(m: Mat3, v: Vec2, axis: number, dst?: Mat3): Mat3; +/** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ +export declare function getScaling(m: Mat3, dst?: Vec2): Vec2; +/** + * Creates a 3-by-3 matrix which translates by the given vector v. + * @param v - The vector by which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translation matrix. + */ +export declare function translation(v: Vec2, dst?: Mat3): Mat3; +/** + * Translates the given 3-by-3 matrix by the given vector v. + * @param m - The matrix. + * @param v - The vector by which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translated matrix. + */ +export declare function translate(m: Mat3, v: Vec2, dst?: Mat3): Mat3; +/** + * Creates a 3-by-3 matrix which rotates by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +export declare function rotation(angleInRadians: number, dst?: Mat3): Mat3; +/** + * Rotates the given 3-by-3 matrix by the given angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export declare function rotate(m: Mat3, angleInRadians: number, dst?: Mat3): Mat3; +/** + * Creates a 3-by-3 matrix which scales in each dimension by an amount given by + * the corresponding entry in the given vector; assumes the vector has three + * entries. + * @param v - A vector of + * 2 entries specifying the factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +export declare function scaling(v: Vec2, dst?: Mat3): Mat3; +/** + * Scales the given 3-by-3 matrix in each dimension by an amount + * given by the corresponding entry in the given vector; assumes the vector has + * three entries. + * @param m - The matrix to be modified. + * @param v - A vector of 2 entries specifying the + * factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +export declare function scale(m: Mat3, v: Vec2, dst?: Mat3): Mat3; +/** + * Creates a 3-by-3 matrix which scales uniformly in each dimension + * @param s - Amount to scale + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +export declare function uniformScaling(s: number, dst?: Mat3): Mat3; +/** + * Scales the given 3-by-3 matrix in each dimension by an amount + * given. + * @param m - The matrix to be modified. + * @param s - Amount to scale. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +export declare function uniformScale(m: Mat3, s: number, dst?: Mat3): Mat3; diff --git a/dist/2.x/mat3-impl.js b/dist/2.x/mat3-impl.js new file mode 100644 index 0000000..1601930 --- /dev/null +++ b/dist/2.x/mat3-impl.js @@ -0,0 +1,751 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +import * as utils from './utils.js'; +import * as vec2 from './vec2-impl'; +/** + * 3x3 Matrix math math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new matrix. In other words you can do this + * + * const mat = mat3.translation([1, 2, 3]); // Creates a new translation matrix + * + * or + * + * const mat = mat3.create(); + * mat3.translation([1, 2, 3], mat); // Puts translation matrix in mat. + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always save to pass any matrix as the destination. So for example + * + * const mat = mat3.identity(); + * const trans = mat3.translation([1, 2, 3]); + * mat3.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat. + * + */ +let MatType = Float32Array; +// This mess is because with Mat3 we have 3 unused elements. +// For Float32Array and Float64Array that's not an issue +// but for Array it's troublesome +const ctorMap = new Map([ + [Float32Array, () => new Float32Array(12)], + [Float64Array, () => new Float64Array(12)], + [Array, () => new Array(12).fill(0)], +]); +let newMat3 = ctorMap.get(Float32Array); +/** + * Sets the type this library creates for a Mat3 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Mat3 + */ +export function setDefaultType(ctor) { + const oldType = MatType; + MatType = ctor; + newMat3 = ctorMap.get(ctor); + return oldType; +} +/** + * Create a Mat3 from values + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Mat3's specified type + * it would be faster to use + * + * ``` + * const m = mat3.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Mat3Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `mat3.create` is usually used + * to create a Mat3 to be filled out as in + * + * ``` + * const m = mat3.create(); + * mat3.perspective(fov, aspect, near, far, m); + * ``` + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @returns matrix created from values. + */ +export function create(v0, v1, v2, v3, v4, v5, v6, v7, v8) { + const dst = newMat3(); + // to make the array homogenous + dst[3] = 0; + dst[7] = 0; + dst[11] = 0; + if (v0 !== undefined) { + dst[0] = v0; + if (v1 !== undefined) { + dst[1] = v1; + if (v2 !== undefined) { + dst[2] = v2; + if (v3 !== undefined) { + dst[4] = v3; + if (v4 !== undefined) { + dst[5] = v4; + if (v5 !== undefined) { + dst[6] = v5; + if (v6 !== undefined) { + dst[8] = v6; + if (v7 !== undefined) { + dst[9] = v7; + if (v8 !== undefined) { + dst[10] = v8; + } + } + } + } + } + } + } + } + } + return dst; +} +/** + * Sets the values of a Mat3 + * Also see {@link mat3.create} and {@link mat3.copy} + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 set from values. + */ +export function set(v0, v1, v2, v3, v4, v5, v6, v7, v8, dst) { + dst = dst || newMat3(); + dst[0] = v0; + dst[1] = v1; + dst[2] = v2; + dst[3] = 0; + dst[4] = v3; + dst[5] = v4; + dst[6] = v5; + dst[7] = 0; + dst[8] = v6; + dst[9] = v7; + dst[10] = v8; + dst[11] = 0; + return dst; +} +/** + * Creates a Mat3 from the upper left 3x3 part of a Mat4 + * @param m4 - source matrix + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 made from m4 + */ +export function fromMat4(m4, dst) { + dst = dst || newMat3(); + dst[0] = m4[0]; + dst[1] = m4[1]; + dst[2] = m4[2]; + dst[3] = 0; + dst[4] = m4[4]; + dst[5] = m4[5]; + dst[6] = m4[6]; + dst[7] = 0; + dst[8] = m4[8]; + dst[9] = m4[9]; + dst[10] = m4[10]; + dst[11] = 0; + return dst; +} +/** + * Creates a Mat3 rotation matrix from a quaternion + * @param q - quaternion to create matrix from + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 made from q + */ +export function fromQuat(q, dst) { + dst = dst || newMat3(); + const x = q[0]; + const y = q[1]; + const z = q[2]; + const w = q[3]; + const x2 = x + x; + const y2 = y + y; + const z2 = z + z; + const xx = x * x2; + const yx = y * x2; + const yy = y * y2; + const zx = z * x2; + const zy = z * y2; + const zz = z * z2; + const wx = w * x2; + const wy = w * y2; + const wz = w * z2; + dst[0] = 1 - yy - zz; + dst[1] = yx + wz; + dst[2] = zx - wy; + dst[3] = 0; + dst[4] = yx - wz; + dst[5] = 1 - xx - zz; + dst[6] = zy + wx; + dst[7] = 0; + dst[8] = zx + wy; + dst[9] = zy - wx; + dst[10] = 1 - xx - yy; + dst[11] = 0; + return dst; +} +/** + * Negates a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns -m. + */ +export function negate(m, dst) { + dst = dst || newMat3(); + dst[0] = -m[0]; + dst[1] = -m[1]; + dst[2] = -m[2]; + dst[4] = -m[4]; + dst[5] = -m[5]; + dst[6] = -m[6]; + dst[8] = -m[8]; + dst[9] = -m[9]; + dst[10] = -m[10]; + return dst; +} +/** + * Copies a matrix. (same as {@link mat3.clone}) + * Also see {@link mat3.create} and {@link mat3.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +export function copy(m, dst) { + dst = dst || newMat3(); + dst[0] = m[0]; + dst[1] = m[1]; + dst[2] = m[2]; + dst[4] = m[4]; + dst[5] = m[5]; + dst[6] = m[6]; + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + return dst; +} +/** + * Copies a matrix (same as {@link mat3.copy}) + * Also see {@link mat3.create} and {@link mat3.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +export const clone = copy; +/** + * Check if 2 matrices are approximately equal + * @param a Operand matrix. + * @param b Operand matrix. + * @returns true if matrices are approximately equal + */ +export function equalsApproximately(a, b) { + return Math.abs(a[0] - b[0]) < utils.EPSILON && + Math.abs(a[1] - b[1]) < utils.EPSILON && + Math.abs(a[2] - b[2]) < utils.EPSILON && + Math.abs(a[4] - b[4]) < utils.EPSILON && + Math.abs(a[5] - b[5]) < utils.EPSILON && + Math.abs(a[6] - b[6]) < utils.EPSILON && + Math.abs(a[8] - b[8]) < utils.EPSILON && + Math.abs(a[9] - b[9]) < utils.EPSILON && + Math.abs(a[10] - b[10]) < utils.EPSILON; +} +/** + * Check if 2 matrices are exactly equal + * @param a Operand matrix. + * @param b Operand matrix. + * @returns true if matrices are exactly equal + */ +export function equals(a, b) { + return a[0] === b[0] && + a[1] === b[1] && + a[2] === b[2] && + a[4] === b[4] && + a[5] === b[5] && + a[6] === b[6] && + a[8] === b[8] && + a[9] === b[9] && + a[10] === b[10]; +} +/** + * Creates a 3-by-3 identity matrix. + * + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A 3-by-3 identity matrix. + */ +export function identity(dst) { + dst = dst || newMat3(); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; +} +/** + * Takes the transpose of a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The transpose of m. + */ +export function transpose(m, dst) { + dst = dst || newMat3(); + if (dst === m) { + let t; + // 0 1 2 + // 4 5 6 + // 8 9 10 + t = m[1]; + m[1] = m[4]; + m[4] = t; + t = m[2]; + m[2] = m[8]; + m[8] = t; + t = m[6]; + m[6] = m[9]; + m[9] = t; + return dst; + } + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + dst[0] = m00; + dst[1] = m10; + dst[2] = m20; + dst[4] = m01; + dst[5] = m11; + dst[6] = m21; + dst[8] = m02; + dst[9] = m12; + dst[10] = m22; + return dst; +} +/** + * Computes the inverse of a 3-by-3 matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +export function inverse(m, dst) { + dst = dst || newMat3(); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const b01 = m22 * m11 - m12 * m21; + const b11 = -m22 * m10 + m12 * m20; + const b21 = m21 * m10 - m11 * m20; + const invDet = 1 / (m00 * b01 + m01 * b11 + m02 * b21); + dst[0] = b01 * invDet; + dst[1] = (-m22 * m01 + m02 * m21) * invDet; + dst[2] = (m12 * m01 - m02 * m11) * invDet; + dst[4] = b11 * invDet; + dst[5] = (m22 * m00 - m02 * m20) * invDet; + dst[6] = (-m12 * m00 + m02 * m10) * invDet; + dst[8] = b21 * invDet; + dst[9] = (-m21 * m00 + m01 * m20) * invDet; + dst[10] = (m11 * m00 - m01 * m10) * invDet; + return dst; +} +/** + * Compute the determinant of a matrix + * @param m - the matrix + * @returns the determinant + */ +export function determinant(m) { + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + return m00 * (m11 * m22 - m21 * m12) - + m10 * (m01 * m22 - m21 * m02) + + m20 * (m01 * m12 - m11 * m02); +} +/** + * Computes the inverse of a 3-by-3 matrix. (same as inverse) + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +export const invert = inverse; +/** + * Multiplies two 3-by-3 matrices with a on the left and b on the right + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +export function multiply(a, b, dst) { + dst = dst || newMat3(); + const a00 = a[0]; + const a01 = a[1]; + const a02 = a[2]; + const a10 = a[4 + 0]; + const a11 = a[4 + 1]; + const a12 = a[4 + 2]; + const a20 = a[8 + 0]; + const a21 = a[8 + 1]; + const a22 = a[8 + 2]; + const b00 = b[0]; + const b01 = b[1]; + const b02 = b[2]; + const b10 = b[4 + 0]; + const b11 = b[4 + 1]; + const b12 = b[4 + 2]; + const b20 = b[8 + 0]; + const b21 = b[8 + 1]; + const b22 = b[8 + 2]; + dst[0] = a00 * b00 + a10 * b01 + a20 * b02; + dst[1] = a01 * b00 + a11 * b01 + a21 * b02; + dst[2] = a02 * b00 + a12 * b01 + a22 * b02; + dst[4] = a00 * b10 + a10 * b11 + a20 * b12; + dst[5] = a01 * b10 + a11 * b11 + a21 * b12; + dst[6] = a02 * b10 + a12 * b11 + a22 * b12; + dst[8] = a00 * b20 + a10 * b21 + a20 * b22; + dst[9] = a01 * b20 + a11 * b21 + a21 * b22; + dst[10] = a02 * b20 + a12 * b21 + a22 * b22; + return dst; +} +/** + * Multiplies two 3-by-3 matrices with a on the left and b on the right (same as multiply) + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +export const mul = multiply; +/** + * Sets the translation component of a 3-by-3 matrix to the given + * vector. + * @param a - The matrix. + * @param v - The vector. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix with translation set. + */ +export function setTranslation(a, v, dst) { + dst = dst || identity(); + if (a !== dst) { + dst[0] = a[0]; + dst[1] = a[1]; + dst[2] = a[2]; + dst[4] = a[4]; + dst[5] = a[5]; + dst[6] = a[6]; + } + dst[8] = v[0]; + dst[9] = v[1]; + dst[10] = 1; + return dst; +} +/** + * Returns the translation component of a 3-by-3 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ +export function getTranslation(m, dst) { + dst = dst || vec2.create(); + dst[0] = m[8]; + dst[1] = m[9]; + return dst; +} +/** + * Returns an axis of a 3x3 matrix as a vector with 2 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, + * @returns The axis component of m. + */ +export function getAxis(m, axis, dst) { + dst = dst || vec2.create(); + const off = axis * 4; + dst[0] = m[off + 0]; + dst[1] = m[off + 1]; + return dst; +} +/** + * Sets an axis of a 3x3 matrix as a vector with 2 entries + * @param m - The matrix. + * @param v - the axis vector + * @param axis - The axis 0 = x, 1 = y; + * @param dst - The matrix to set. If not passed a new one is created. + * @returns The matrix with axis set. + */ +export function setAxis(m, v, axis, dst) { + if (dst !== m) { + dst = copy(m, dst); + } + const off = axis * 4; + dst[off + 0] = v[0]; + dst[off + 1] = v[1]; + return dst; +} +/** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ +export function getScaling(m, dst) { + dst = dst || vec2.create(); + const xx = m[0]; + const xy = m[1]; + const yx = m[4]; + const yy = m[5]; + dst[0] = Math.sqrt(xx * xx + xy * xy); + dst[1] = Math.sqrt(yx * yx + yy * yy); + return dst; +} +/** + * Creates a 3-by-3 matrix which translates by the given vector v. + * @param v - The vector by which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translation matrix. + */ +export function translation(v, dst) { + dst = dst || newMat3(); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[8] = v[0]; + dst[9] = v[1]; + dst[10] = 1; + return dst; +} +/** + * Translates the given 3-by-3 matrix by the given vector v. + * @param m - The matrix. + * @param v - The vector by which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translated matrix. + */ +export function translate(m, v, dst) { + dst = dst || newMat3(); + const v0 = v[0]; + const v1 = v[1]; + const m00 = m[0]; + const m01 = m[1]; + const m02 = m[2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + if (m !== dst) { + dst[0] = m00; + dst[1] = m01; + dst[2] = m02; + dst[4] = m10; + dst[5] = m11; + dst[6] = m12; + } + dst[8] = m00 * v0 + m10 * v1 + m20; + dst[9] = m01 * v0 + m11 * v1 + m21; + dst[10] = m02 * v0 + m12 * v1 + m22; + return dst; +} +/** + * Creates a 3-by-3 matrix which rotates by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +export function rotation(angleInRadians, dst) { + dst = dst || newMat3(); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c; + dst[1] = s; + dst[2] = 0; + dst[4] = -s; + dst[5] = c; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; +} +/** + * Rotates the given 3-by-3 matrix by the given angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export function rotate(m, angleInRadians, dst) { + dst = dst || newMat3(); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c * m00 + s * m10; + dst[1] = c * m01 + s * m11; + dst[2] = c * m02 + s * m12; + dst[4] = c * m10 - s * m00; + dst[5] = c * m11 - s * m01; + dst[6] = c * m12 - s * m02; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + } + return dst; +} +/** + * Creates a 3-by-3 matrix which scales in each dimension by an amount given by + * the corresponding entry in the given vector; assumes the vector has three + * entries. + * @param v - A vector of + * 2 entries specifying the factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +export function scaling(v, dst) { + dst = dst || newMat3(); + dst[0] = v[0]; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = v[1]; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; +} +/** + * Scales the given 3-by-3 matrix in each dimension by an amount + * given by the corresponding entry in the given vector; assumes the vector has + * three entries. + * @param m - The matrix to be modified. + * @param v - A vector of 2 entries specifying the + * factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +export function scale(m, v, dst) { + dst = dst || newMat3(); + const v0 = v[0]; + const v1 = v[1]; + dst[0] = v0 * m[0 * 4 + 0]; + dst[1] = v0 * m[0 * 4 + 1]; + dst[2] = v0 * m[0 * 4 + 2]; + dst[4] = v1 * m[1 * 4 + 0]; + dst[5] = v1 * m[1 * 4 + 1]; + dst[6] = v1 * m[1 * 4 + 2]; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + } + return dst; +} +/** + * Creates a 3-by-3 matrix which scales uniformly in each dimension + * @param s - Amount to scale + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +export function uniformScaling(s, dst) { + dst = dst || newMat3(); + dst[0] = s; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = s; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; +} +/** + * Scales the given 3-by-3 matrix in each dimension by an amount + * given. + * @param m - The matrix to be modified. + * @param s - Amount to scale. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +export function uniformScale(m, s, dst) { + dst = dst || newMat3(); + dst[0] = s * m[0 * 4 + 0]; + dst[1] = s * m[0 * 4 + 1]; + dst[2] = s * m[0 * 4 + 2]; + dst[4] = s * m[1 * 4 + 0]; + dst[5] = s * m[1 * 4 + 1]; + dst[6] = s * m[1 * 4 + 2]; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + } + return dst; +} diff --git a/dist/2.x/mat3.d.ts b/dist/2.x/mat3.d.ts new file mode 100644 index 0000000..691ff27 --- /dev/null +++ b/dist/2.x/mat3.d.ts @@ -0,0 +1,6 @@ +/** + * A JavaScript array with 12 values, a Float32Array with 12 values, or a Float64Array with 12 values. + * When created by the library will create the default type which is `Float32Array` + * but can be set by calling {@link mat3.setDefaultType}. + */ +export type Mat3 = number[] | Float32Array | Float64Array; diff --git a/dist/2.x/mat3.js b/dist/2.x/mat3.js new file mode 100644 index 0000000..baf2d4b --- /dev/null +++ b/dist/2.x/mat3.js @@ -0,0 +1,22 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +export {}; diff --git a/dist/2.x/mat4-impl.d.ts b/dist/2.x/mat4-impl.d.ts new file mode 100644 index 0000000..63d25fb --- /dev/null +++ b/dist/2.x/mat4-impl.d.ts @@ -0,0 +1,507 @@ +import { Mat3 } from './mat3'; +import { Mat4 } from './mat4'; +import { Quat } from './quat'; +import Vec3 from './vec3-impl'; +export default Mat4; +export type Mat4LikeCtor = new (n: number) => Mat4; +/** + * Sets the type this library creates for a Mat4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Mat4 + */ +export declare function setDefaultType(ctor: new (n: number) => Mat4): Mat4LikeCtor; +/** + * Create a Mat4 from values + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Mat4's specified type + * it would be faster to use + * + * ``` + * const m = mat4.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Mat4Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `mat4.create` is usually used + * to create a Mat4 to be filled out as in + * + * ``` + * const m = mat4.create(); + * mat4.perspective(fov, aspect, near, far, m); + * ``` + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param v9 - value for element 9 + * @param v10 - value for element 10 + * @param v11 - value for element 11 + * @param v12 - value for element 12 + * @param v13 - value for element 13 + * @param v14 - value for element 14 + * @param v15 - value for element 15 + * @returns created from values. + */ +export declare function create(v0?: number, v1?: number, v2?: number, v3?: number, v4?: number, v5?: number, v6?: number, v7?: number, v8?: number, v9?: number, v10?: number, v11?: number, v12?: number, v13?: number, v14?: number, v15?: number): Mat4; +/** + * Sets the values of a Mat4 + * Also see {@link mat4.create} and {@link mat4.copy} + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param v9 - value for element 9 + * @param v10 - value for element 10 + * @param v11 - value for element 11 + * @param v12 - value for element 12 + * @param v13 - value for element 13 + * @param v14 - value for element 14 + * @param v15 - value for element 15 + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 created from values. + */ +export declare function set(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, dst?: Mat4): Mat4; +/** + * Creates a Mat4 from a Mat3 + * @param m3 - source matrix + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 made from m3 + */ +export declare function fromMat3(m3: Mat3, dst?: Mat4): Mat4; +/** + * Creates a Mat4 rotation matrix from a quaternion + * @param q - quaternion to create matrix from + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 made from q + */ +export declare function fromQuat(q: Quat, dst?: Mat4): Mat4; +/** + * Negates a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns -m. + */ +export declare function negate(m: Mat4, dst?: Mat4): Mat4; +/** + * Copies a matrix. (same as {@link mat4.clone}) + * Also see {@link mat4.create} and {@link mat4.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +export declare function copy(m: Mat4, dst?: Mat4): Mat4; +/** + * Copies a matrix (same as {@link mat4.copy}) + * Also see {@link mat4.create} and {@link mat4.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +export declare const clone: typeof copy; +/** + * Check if 2 matrices are approximately equal + * @param a - Operand matrix. + * @param b - Operand matrix. + * @returns true if matrices are approximately equal + */ +export declare function equalsApproximately(a: Mat4, b: Mat4): boolean; +/** + * Check if 2 matrices are exactly equal + * @param a - Operand matrix. + * @param b - Operand matrix. + * @returns true if matrices are exactly equal + */ +export declare function equals(a: Mat4, b: Mat4): boolean; +/** + * Creates a 4-by-4 identity matrix. + * + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A 4-by-4 identity matrix. + */ +export declare function identity(dst?: Mat4): Mat4; +/** + * Takes the transpose of a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The transpose of m. + */ +export declare function transpose(m: Mat4, dst?: Mat4): Mat4; +/** + * Computes the inverse of a 4-by-4 matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +export declare function inverse(m: Mat4, dst?: Mat4): Mat4; +/** + * Compute the determinant of a matrix + * @param m - the matrix + * @returns the determinant + */ +export declare function determinant(m: Mat4): number; +/** + * Computes the inverse of a 4-by-4 matrix. (same as inverse) + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +export declare const invert: typeof inverse; +/** + * Multiplies two 4-by-4 matrices with a on the left and b on the right + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +export declare function multiply(a: Mat4, b: Mat4, dst?: Mat4): Mat4; +/** + * Multiplies two 4-by-4 matrices with a on the left and b on the right (same as multiply) + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +export declare const mul: typeof multiply; +/** + * Sets the translation component of a 4-by-4 matrix to the given + * vector. + * @param a - The matrix. + * @param v - The vector. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix with translation set. + */ +export declare function setTranslation(a: Mat4, v: Vec3, dst?: Mat4): Mat4; +/** + * Returns the translation component of a 4-by-4 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ +export declare function getTranslation(m: Mat4, dst?: Vec3): Vec3; +/** + * Returns an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @returns The axis component of m. + */ +export declare function getAxis(m: Mat4, axis: number, dst?: Vec3): Vec3; +/** + * Sets an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param v - the axis vector + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @param dst - The matrix to set. If not passed a new one is created. + * @returns The matrix with axis set. + */ +export declare function setAxis(m: Mat4, v: Vec3, axis: number, dst: Mat4): Mat4; +/** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ +export declare function getScaling(m: Mat4, dst?: Vec3): Vec3; +/** + * Computes a 4-by-4 perspective transformation matrix given the angular height + * of the frustum, the aspect ratio, and the near and far clipping planes. The + * arguments define a frustum extending in the negative z direction. The given + * angle is the vertical angle of the frustum, and the horizontal angle is + * determined to produce the given aspect ratio. The arguments near and far are + * the distances to the near and far clipping planes. Note that near and far + * are not z coordinates, but rather they are distances along the negative + * z-axis. The matrix generated sends the viewing frustum to the unit box. + * We assume a unit box extending from -1 to 1 in the x and y dimensions and + * from 0 to 1 in the z dimension. + * + * Note: If you pass `Infinity` for zFar then it will produce a projection matrix + * returns -Infinity for Z when transforming coordinates with Z <= 0 and +Infinity for Z + * otherwise. + * + * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians). + * @param aspect - The aspect ratio width / height. + * @param zNear - The depth (negative z coordinate) + * of the near clipping plane. + * @param zFar - The depth (negative z coordinate) + * of the far clipping plane. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The perspective matrix. + */ +export declare function perspective(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar: number, dst?: Mat4): Mat4; +/** + * Computes a 4-by-4 reverse-z perspective transformation matrix given the angular height + * of the frustum, the aspect ratio, and the near and far clipping planes. The + * arguments define a frustum extending in the negative z direction. The given + * angle is the vertical angle of the frustum, and the horizontal angle is + * determined to produce the given aspect ratio. The arguments near and far are + * the distances to the near and far clipping planes. Note that near and far + * are not z coordinates, but rather they are distances along the negative + * z-axis. The matrix generated sends the viewing frustum to the unit box. + * We assume a unit box extending from -1 to 1 in the x and y dimensions and + * from 1 (at -zNear) to 0 (at -zFar) in the z dimension. + * + * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians). + * @param aspect - The aspect ratio width / height. + * @param zNear - The depth (negative z coordinate) + * of the near clipping plane. + * @param zFar - The depth (negative z coordinate) + * of the far clipping plane. (default = Infinity) + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The perspective matrix. + */ export declare function perspectiveReverseZ(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar?: number, dst?: Mat4): Mat4; +/** + * Computes a 4-by-4 orthogonal transformation matrix that transforms from + * the given the left, right, bottom, and top dimensions to -1 +1 in x, and y + * and 0 to +1 in z. + * @param left - Left side of the near clipping plane viewport. + * @param right - Right side of the near clipping plane viewport. + * @param bottom - Bottom of the near clipping plane viewport. + * @param top - Top of the near clipping plane viewport. + * @param near - The depth (negative z coordinate) + * of the near clipping plane. + * @param far - The depth (negative z coordinate) + * of the far clipping plane. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The orthographic projection matrix. + */ +export declare function ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4; +/** + * Computes a 4-by-4 perspective transformation matrix given the left, right, + * top, bottom, near and far clipping planes. The arguments define a frustum + * extending in the negative z direction. The arguments near and far are the + * distances to the near and far clipping planes. Note that near and far are not + * z coordinates, but rather they are distances along the negative z-axis. The + * matrix generated sends the viewing frustum to the unit box. We assume a unit + * box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z + * dimension. + * @param left - The x coordinate of the left plane of the box. + * @param right - The x coordinate of the right plane of the box. + * @param bottom - The y coordinate of the bottom plane of the box. + * @param top - The y coordinate of the right plane of the box. + * @param near - The negative z coordinate of the near plane of the box. + * @param far - The negative z coordinate of the far plane of the box. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The perspective projection matrix. + */ +export declare function frustum(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4; +/** + * Computes a 4-by-4 reverse-z perspective transformation matrix given the left, right, + * top, bottom, near and far clipping planes. The arguments define a frustum + * extending in the negative z direction. The arguments near and far are the + * distances to the near and far clipping planes. Note that near and far are not + * z coordinates, but rather they are distances along the negative z-axis. The + * matrix generated sends the viewing frustum to the unit box. We assume a unit + * box extending from -1 to 1 in the x and y dimensions and from 1 (-near) to 0 (-far) in the z + * dimension. + * @param left - The x coordinate of the left plane of the box. + * @param right - The x coordinate of the right plane of the box. + * @param bottom - The y coordinate of the bottom plane of the box. + * @param top - The y coordinate of the right plane of the box. + * @param near - The negative z coordinate of the near plane of the box. + * @param far - The negative z coordinate of the far plane of the box. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The perspective projection matrix. + */ +export declare function frustumReverseZ(left: number, right: number, bottom: number, top: number, near: number, far?: number, dst?: Mat4): Mat4; +/** + * Computes a 4-by-4 aim transformation. + * + * This is a matrix which positions an object aiming down positive Z. + * toward the target. + * + * Note: this is **NOT** the inverse of lookAt as lookAt looks at negative Z. + * + * @param position - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The aim matrix. + */ +export declare function aim(position: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4; +/** + * Computes a 4-by-4 camera aim transformation. + * + * This is a matrix which positions an object aiming down negative Z. + * toward the target. + * + * Note: this is the inverse of `lookAt` + * + * @param eye - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The aim matrix. + */ +export declare function cameraAim(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4; +/** + * Computes a 4-by-4 view transformation. + * + * This is a view matrix which transforms all other objects + * to be in the space of the view defined by the parameters. + * + * @param eye - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The look-at matrix. + */ +export declare function lookAt(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4; +/** + * Creates a 4-by-4 matrix which translates by the given vector v. + * @param v - The vector by + * which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translation matrix. + */ +export declare function translation(v: Vec3, dst?: Mat4): Mat4; +/** + * Translates the given 4-by-4 matrix by the given vector v. + * @param m - The matrix. + * @param v - The vector by + * which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translated matrix. + */ +export declare function translate(m: Mat4, v: Vec3, dst?: Mat4): Mat4; +/** + * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +export declare function rotationX(angleInRadians: number, dst?: Mat4): Mat4; +/** + * Rotates the given 4-by-4 matrix around the x-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export declare function rotateX(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4; +/** + * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +export declare function rotationY(angleInRadians: number, dst?: Mat4): Mat4; +/** + * Rotates the given 4-by-4 matrix around the y-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export declare function rotateY(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4; +/** + * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +export declare function rotationZ(angleInRadians: number, dst?: Mat4): Mat4; +/** + * Rotates the given 4-by-4 matrix around the z-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export declare function rotateZ(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4; +/** + * Creates a 4-by-4 matrix which rotates around the given axis by the given + * angle. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A matrix which rotates angle radians + * around the axis. + */ +export declare function axisRotation(axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4; +/** + * Creates a 4-by-4 matrix which rotates around the given axis by the given + * angle. (same as axisRotation) + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A matrix which rotates angle radians + * around the axis. + */ +export declare const rotation: typeof axisRotation; +/** + * Rotates the given 4-by-4 matrix around the given axis by the + * given angle. + * @param m - The matrix. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export declare function axisRotate(m: Mat4, axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4; +/** + * Rotates the given 4-by-4 matrix around the given axis by the + * given angle. (same as rotate) + * @param m - The matrix. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export declare const rotate: typeof axisRotate; +/** + * Creates a 4-by-4 matrix which scales in each dimension by an amount given by + * the corresponding entry in the given vector; assumes the vector has three + * entries. + * @param v - A vector of + * three entries specifying the factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +export declare function scaling(v: Vec3, dst?: Mat4): Mat4; +/** + * Scales the given 4-by-4 matrix in each dimension by an amount + * given by the corresponding entry in the given vector; assumes the vector has + * three entries. + * @param m - The matrix to be modified. + * @param v - A vector of three entries specifying the + * factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +export declare function scale(m: Mat4, v: Vec3, dst?: Mat4): Mat4; +/** + * Creates a 4-by-4 matrix which scales a uniform amount in each dimension. + * @param s - the amount to scale + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +export declare function uniformScaling(s: number, dst?: Mat4): Mat4; +/** + * Scales the given 4-by-4 matrix in each dimension by a uniform scale. + * @param m - The matrix to be modified. + * @param s - The amount to scale. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +export declare function uniformScale(m: Mat4, s: number, dst?: Mat4): Mat4; diff --git a/dist/2.x/mat4-impl.js b/dist/2.x/mat4-impl.js new file mode 100644 index 0000000..09df924 --- /dev/null +++ b/dist/2.x/mat4-impl.js @@ -0,0 +1,1521 @@ +import * as vec3 from './vec3-impl'; +import * as utils from './utils'; +/** + * 4x4 Matrix math math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new matrix. In other words you can do this + * + * const mat = mat4.translation([1, 2, 3]); // Creates a new translation matrix + * + * or + * + * const mat = mat4.create(); + * mat4.translation([1, 2, 3], mat); // Puts translation matrix in mat. + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always save to pass any matrix as the destination. So for example + * + * const mat = mat4.identity(); + * const trans = mat4.translation([1, 2, 3]); + * mat4.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat. + * + */ +let MatType = Float32Array; +/** + * Sets the type this library creates for a Mat4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Mat4 + */ +export function setDefaultType(ctor) { + const oldType = MatType; + MatType = ctor; + return oldType; +} +/** + * Create a Mat4 from values + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Mat4's specified type + * it would be faster to use + * + * ``` + * const m = mat4.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Mat4Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `mat4.create` is usually used + * to create a Mat4 to be filled out as in + * + * ``` + * const m = mat4.create(); + * mat4.perspective(fov, aspect, near, far, m); + * ``` + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param v9 - value for element 9 + * @param v10 - value for element 10 + * @param v11 - value for element 11 + * @param v12 - value for element 12 + * @param v13 - value for element 13 + * @param v14 - value for element 14 + * @param v15 - value for element 15 + * @returns created from values. + */ +export function create(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) { + const dst = new MatType(16); + if (v0 !== undefined) { + dst[0] = v0; + if (v1 !== undefined) { + dst[1] = v1; + if (v2 !== undefined) { + dst[2] = v2; + if (v3 !== undefined) { + dst[3] = v3; + if (v4 !== undefined) { + dst[4] = v4; + if (v5 !== undefined) { + dst[5] = v5; + if (v6 !== undefined) { + dst[6] = v6; + if (v7 !== undefined) { + dst[7] = v7; + if (v8 !== undefined) { + dst[8] = v8; + if (v9 !== undefined) { + dst[9] = v9; + if (v10 !== undefined) { + dst[10] = v10; + if (v11 !== undefined) { + dst[11] = v11; + if (v12 !== undefined) { + dst[12] = v12; + if (v13 !== undefined) { + dst[13] = v13; + if (v14 !== undefined) { + dst[14] = v14; + if (v15 !== undefined) { + dst[15] = v15; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return dst; +} +/** + * Sets the values of a Mat4 + * Also see {@link mat4.create} and {@link mat4.copy} + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param v9 - value for element 9 + * @param v10 - value for element 10 + * @param v11 - value for element 11 + * @param v12 - value for element 12 + * @param v13 - value for element 13 + * @param v14 - value for element 14 + * @param v15 - value for element 15 + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 created from values. + */ +export function set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, dst) { + dst = dst || new MatType(16); + dst[0] = v0; + dst[1] = v1; + dst[2] = v2; + dst[3] = v3; + dst[4] = v4; + dst[5] = v5; + dst[6] = v6; + dst[7] = v7; + dst[8] = v8; + dst[9] = v9; + dst[10] = v10; + dst[11] = v11; + dst[12] = v12; + dst[13] = v13; + dst[14] = v14; + dst[15] = v15; + return dst; +} +/** + * Creates a Mat4 from a Mat3 + * @param m3 - source matrix + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 made from m3 + */ +export function fromMat3(m3, dst) { + dst = dst || new MatType(16); + dst[0] = m3[0]; + dst[1] = m3[1]; + dst[2] = m3[2]; + dst[3] = 0; + dst[4] = m3[4]; + dst[5] = m3[5]; + dst[6] = m3[6]; + dst[7] = 0; + dst[8] = m3[8]; + dst[9] = m3[9]; + dst[10] = m3[10]; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Creates a Mat4 rotation matrix from a quaternion + * @param q - quaternion to create matrix from + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 made from q + */ +export function fromQuat(q, dst) { + dst = dst || new MatType(16); + const x = q[0]; + const y = q[1]; + const z = q[2]; + const w = q[3]; + const x2 = x + x; + const y2 = y + y; + const z2 = z + z; + const xx = x * x2; + const yx = y * x2; + const yy = y * y2; + const zx = z * x2; + const zy = z * y2; + const zz = z * z2; + const wx = w * x2; + const wy = w * y2; + const wz = w * z2; + dst[0] = 1 - yy - zz; + dst[1] = yx + wz; + dst[2] = zx - wy; + dst[3] = 0; + dst[4] = yx - wz; + dst[5] = 1 - xx - zz; + dst[6] = zy + wx; + dst[7] = 0; + dst[8] = zx + wy; + dst[9] = zy - wx; + dst[10] = 1 - xx - yy; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Negates a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns -m. + */ +export function negate(m, dst) { + dst = dst || new MatType(16); + dst[0] = -m[0]; + dst[1] = -m[1]; + dst[2] = -m[2]; + dst[3] = -m[3]; + dst[4] = -m[4]; + dst[5] = -m[5]; + dst[6] = -m[6]; + dst[7] = -m[7]; + dst[8] = -m[8]; + dst[9] = -m[9]; + dst[10] = -m[10]; + dst[11] = -m[11]; + dst[12] = -m[12]; + dst[13] = -m[13]; + dst[14] = -m[14]; + dst[15] = -m[15]; + return dst; +} +/** + * Copies a matrix. (same as {@link mat4.clone}) + * Also see {@link mat4.create} and {@link mat4.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +export function copy(m, dst) { + dst = dst || new MatType(16); + dst[0] = m[0]; + dst[1] = m[1]; + dst[2] = m[2]; + dst[3] = m[3]; + dst[4] = m[4]; + dst[5] = m[5]; + dst[6] = m[6]; + dst[7] = m[7]; + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + dst[11] = m[11]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + return dst; +} +/** + * Copies a matrix (same as {@link mat4.copy}) + * Also see {@link mat4.create} and {@link mat4.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +export const clone = copy; +/** + * Check if 2 matrices are approximately equal + * @param a - Operand matrix. + * @param b - Operand matrix. + * @returns true if matrices are approximately equal + */ +export function equalsApproximately(a, b) { + return Math.abs(a[0] - b[0]) < utils.EPSILON && + Math.abs(a[1] - b[1]) < utils.EPSILON && + Math.abs(a[2] - b[2]) < utils.EPSILON && + Math.abs(a[3] - b[3]) < utils.EPSILON && + Math.abs(a[4] - b[4]) < utils.EPSILON && + Math.abs(a[5] - b[5]) < utils.EPSILON && + Math.abs(a[6] - b[6]) < utils.EPSILON && + Math.abs(a[7] - b[7]) < utils.EPSILON && + Math.abs(a[8] - b[8]) < utils.EPSILON && + Math.abs(a[9] - b[9]) < utils.EPSILON && + Math.abs(a[10] - b[10]) < utils.EPSILON && + Math.abs(a[11] - b[11]) < utils.EPSILON && + Math.abs(a[12] - b[12]) < utils.EPSILON && + Math.abs(a[13] - b[13]) < utils.EPSILON && + Math.abs(a[14] - b[14]) < utils.EPSILON && + Math.abs(a[15] - b[15]) < utils.EPSILON; +} +/** + * Check if 2 matrices are exactly equal + * @param a - Operand matrix. + * @param b - Operand matrix. + * @returns true if matrices are exactly equal + */ +export function equals(a, b) { + return a[0] === b[0] && + a[1] === b[1] && + a[2] === b[2] && + a[3] === b[3] && + a[4] === b[4] && + a[5] === b[5] && + a[6] === b[6] && + a[7] === b[7] && + a[8] === b[8] && + a[9] === b[9] && + a[10] === b[10] && + a[11] === b[11] && + a[12] === b[12] && + a[13] === b[13] && + a[14] === b[14] && + a[15] === b[15]; +} +/** + * Creates a 4-by-4 identity matrix. + * + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A 4-by-4 identity matrix. + */ +export function identity(dst) { + dst = dst || new MatType(16); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Takes the transpose of a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The transpose of m. + */ +export function transpose(m, dst) { + dst = dst || new MatType(16); + if (dst === m) { + let t; + t = m[1]; + m[1] = m[4]; + m[4] = t; + t = m[2]; + m[2] = m[8]; + m[8] = t; + t = m[3]; + m[3] = m[12]; + m[12] = t; + t = m[6]; + m[6] = m[9]; + m[9] = t; + t = m[7]; + m[7] = m[13]; + m[13] = t; + t = m[11]; + m[11] = m[14]; + m[14] = t; + return dst; + } + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + dst[0] = m00; + dst[1] = m10; + dst[2] = m20; + dst[3] = m30; + dst[4] = m01; + dst[5] = m11; + dst[6] = m21; + dst[7] = m31; + dst[8] = m02; + dst[9] = m12; + dst[10] = m22; + dst[11] = m32; + dst[12] = m03; + dst[13] = m13; + dst[14] = m23; + dst[15] = m33; + return dst; +} +/** + * Computes the inverse of a 4-by-4 matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +export function inverse(m, dst) { + dst = dst || new MatType(16); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + const tmp0 = m22 * m33; + const tmp1 = m32 * m23; + const tmp2 = m12 * m33; + const tmp3 = m32 * m13; + const tmp4 = m12 * m23; + const tmp5 = m22 * m13; + const tmp6 = m02 * m33; + const tmp7 = m32 * m03; + const tmp8 = m02 * m23; + const tmp9 = m22 * m03; + const tmp10 = m02 * m13; + const tmp11 = m12 * m03; + const tmp12 = m20 * m31; + const tmp13 = m30 * m21; + const tmp14 = m10 * m31; + const tmp15 = m30 * m11; + const tmp16 = m10 * m21; + const tmp17 = m20 * m11; + const tmp18 = m00 * m31; + const tmp19 = m30 * m01; + const tmp20 = m00 * m21; + const tmp21 = m20 * m01; + const tmp22 = m00 * m11; + const tmp23 = m10 * m01; + const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) - + (tmp1 * m11 + tmp2 * m21 + tmp5 * m31); + const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) - + (tmp0 * m01 + tmp7 * m21 + tmp8 * m31); + const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) - + (tmp3 * m01 + tmp6 * m11 + tmp11 * m31); + const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) - + (tmp4 * m01 + tmp9 * m11 + tmp10 * m21); + const d = 1 / (m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3); + dst[0] = d * t0; + dst[1] = d * t1; + dst[2] = d * t2; + dst[3] = d * t3; + dst[4] = d * ((tmp1 * m10 + tmp2 * m20 + tmp5 * m30) - + (tmp0 * m10 + tmp3 * m20 + tmp4 * m30)); + dst[5] = d * ((tmp0 * m00 + tmp7 * m20 + tmp8 * m30) - + (tmp1 * m00 + tmp6 * m20 + tmp9 * m30)); + dst[6] = d * ((tmp3 * m00 + tmp6 * m10 + tmp11 * m30) - + (tmp2 * m00 + tmp7 * m10 + tmp10 * m30)); + dst[7] = d * ((tmp4 * m00 + tmp9 * m10 + tmp10 * m20) - + (tmp5 * m00 + tmp8 * m10 + tmp11 * m20)); + dst[8] = d * ((tmp12 * m13 + tmp15 * m23 + tmp16 * m33) - + (tmp13 * m13 + tmp14 * m23 + tmp17 * m33)); + dst[9] = d * ((tmp13 * m03 + tmp18 * m23 + tmp21 * m33) - + (tmp12 * m03 + tmp19 * m23 + tmp20 * m33)); + dst[10] = d * ((tmp14 * m03 + tmp19 * m13 + tmp22 * m33) - + (tmp15 * m03 + tmp18 * m13 + tmp23 * m33)); + dst[11] = d * ((tmp17 * m03 + tmp20 * m13 + tmp23 * m23) - + (tmp16 * m03 + tmp21 * m13 + tmp22 * m23)); + dst[12] = d * ((tmp14 * m22 + tmp17 * m32 + tmp13 * m12) - + (tmp16 * m32 + tmp12 * m12 + tmp15 * m22)); + dst[13] = d * ((tmp20 * m32 + tmp12 * m02 + tmp19 * m22) - + (tmp18 * m22 + tmp21 * m32 + tmp13 * m02)); + dst[14] = d * ((tmp18 * m12 + tmp23 * m32 + tmp15 * m02) - + (tmp22 * m32 + tmp14 * m02 + tmp19 * m12)); + dst[15] = d * ((tmp22 * m22 + tmp16 * m02 + tmp21 * m12) - + (tmp20 * m12 + tmp23 * m22 + tmp17 * m02)); + return dst; +} +/** + * Compute the determinant of a matrix + * @param m - the matrix + * @returns the determinant + */ +export function determinant(m) { + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + const tmp0 = m22 * m33; + const tmp1 = m32 * m23; + const tmp2 = m12 * m33; + const tmp3 = m32 * m13; + const tmp4 = m12 * m23; + const tmp5 = m22 * m13; + const tmp6 = m02 * m33; + const tmp7 = m32 * m03; + const tmp8 = m02 * m23; + const tmp9 = m22 * m03; + const tmp10 = m02 * m13; + const tmp11 = m12 * m03; + const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) - + (tmp1 * m11 + tmp2 * m21 + tmp5 * m31); + const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) - + (tmp0 * m01 + tmp7 * m21 + tmp8 * m31); + const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) - + (tmp3 * m01 + tmp6 * m11 + tmp11 * m31); + const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) - + (tmp4 * m01 + tmp9 * m11 + tmp10 * m21); + return m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3; +} +/** + * Computes the inverse of a 4-by-4 matrix. (same as inverse) + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +export const invert = inverse; +/** + * Multiplies two 4-by-4 matrices with a on the left and b on the right + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +export function multiply(a, b, dst) { + dst = dst || new MatType(16); + const a00 = a[0]; + const a01 = a[1]; + const a02 = a[2]; + const a03 = a[3]; + const a10 = a[4 + 0]; + const a11 = a[4 + 1]; + const a12 = a[4 + 2]; + const a13 = a[4 + 3]; + const a20 = a[8 + 0]; + const a21 = a[8 + 1]; + const a22 = a[8 + 2]; + const a23 = a[8 + 3]; + const a30 = a[12 + 0]; + const a31 = a[12 + 1]; + const a32 = a[12 + 2]; + const a33 = a[12 + 3]; + const b00 = b[0]; + const b01 = b[1]; + const b02 = b[2]; + const b03 = b[3]; + const b10 = b[4 + 0]; + const b11 = b[4 + 1]; + const b12 = b[4 + 2]; + const b13 = b[4 + 3]; + const b20 = b[8 + 0]; + const b21 = b[8 + 1]; + const b22 = b[8 + 2]; + const b23 = b[8 + 3]; + const b30 = b[12 + 0]; + const b31 = b[12 + 1]; + const b32 = b[12 + 2]; + const b33 = b[12 + 3]; + dst[0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03; + dst[1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03; + dst[2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03; + dst[3] = a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03; + dst[4] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13; + dst[5] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13; + dst[6] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13; + dst[7] = a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13; + dst[8] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23; + dst[9] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23; + dst[10] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23; + dst[11] = a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23; + dst[12] = a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33; + dst[13] = a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33; + dst[14] = a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33; + dst[15] = a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33; + return dst; +} +/** + * Multiplies two 4-by-4 matrices with a on the left and b on the right (same as multiply) + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +export const mul = multiply; +/** + * Sets the translation component of a 4-by-4 matrix to the given + * vector. + * @param a - The matrix. + * @param v - The vector. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix with translation set. + */ +export function setTranslation(a, v, dst) { + dst = dst || identity(); + if (a !== dst) { + dst[0] = a[0]; + dst[1] = a[1]; + dst[2] = a[2]; + dst[3] = a[3]; + dst[4] = a[4]; + dst[5] = a[5]; + dst[6] = a[6]; + dst[7] = a[7]; + dst[8] = a[8]; + dst[9] = a[9]; + dst[10] = a[10]; + dst[11] = a[11]; + } + dst[12] = v[0]; + dst[13] = v[1]; + dst[14] = v[2]; + dst[15] = 1; + return dst; +} +/** + * Returns the translation component of a 4-by-4 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ +export function getTranslation(m, dst) { + dst = dst || vec3.create(); + dst[0] = m[12]; + dst[1] = m[13]; + dst[2] = m[14]; + return dst; +} +/** + * Returns an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @returns The axis component of m. + */ +export function getAxis(m, axis, dst) { + dst = dst || vec3.create(); + const off = axis * 4; + dst[0] = m[off + 0]; + dst[1] = m[off + 1]; + dst[2] = m[off + 2]; + return dst; +} +/** + * Sets an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param v - the axis vector + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @param dst - The matrix to set. If not passed a new one is created. + * @returns The matrix with axis set. + */ +export function setAxis(m, v, axis, dst) { + if (dst !== m) { + dst = copy(m, dst); + } + const off = axis * 4; + dst[off + 0] = v[0]; + dst[off + 1] = v[1]; + dst[off + 2] = v[2]; + return dst; +} +/** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ +export function getScaling(m, dst) { + dst = dst || vec3.create(); + const xx = m[0]; + const xy = m[1]; + const xz = m[2]; + const yx = m[4]; + const yy = m[5]; + const yz = m[6]; + const zx = m[8]; + const zy = m[9]; + const zz = m[10]; + dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz); + dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz); + dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz); + return dst; +} +/** + * Computes a 4-by-4 perspective transformation matrix given the angular height + * of the frustum, the aspect ratio, and the near and far clipping planes. The + * arguments define a frustum extending in the negative z direction. The given + * angle is the vertical angle of the frustum, and the horizontal angle is + * determined to produce the given aspect ratio. The arguments near and far are + * the distances to the near and far clipping planes. Note that near and far + * are not z coordinates, but rather they are distances along the negative + * z-axis. The matrix generated sends the viewing frustum to the unit box. + * We assume a unit box extending from -1 to 1 in the x and y dimensions and + * from 0 to 1 in the z dimension. + * + * Note: If you pass `Infinity` for zFar then it will produce a projection matrix + * returns -Infinity for Z when transforming coordinates with Z <= 0 and +Infinity for Z + * otherwise. + * + * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians). + * @param aspect - The aspect ratio width / height. + * @param zNear - The depth (negative z coordinate) + * of the near clipping plane. + * @param zFar - The depth (negative z coordinate) + * of the far clipping plane. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The perspective matrix. + */ +export function perspective(fieldOfViewYInRadians, aspect, zNear, zFar, dst) { + dst = dst || new MatType(16); + const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians); + dst[0] = f / aspect; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = f; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[15] = 0; + if (zFar === Infinity) { + dst[10] = -1; + dst[14] = -zNear; + } + else { + const rangeInv = 1 / (zNear - zFar); + dst[10] = zFar * rangeInv; + dst[14] = zFar * zNear * rangeInv; + } + return dst; +} +/** + * Computes a 4-by-4 orthogonal transformation matrix that transforms from + * the given the left, right, bottom, and top dimensions to -1 +1 in x, and y + * and 0 to +1 in z. + * @param left - Left side of the near clipping plane viewport. + * @param right - Right side of the near clipping plane viewport. + * @param bottom - Bottom of the near clipping plane viewport. + * @param top - Top of the near clipping plane viewport. + * @param near - The depth (negative z coordinate) + * of the near clipping plane. + * @param far - The depth (negative z coordinate) + * of the far clipping plane. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The orthographic projection matrix. + */ +export function ortho(left, right, bottom, top, near, far, dst) { + dst = dst || new MatType(16); + dst[0] = 2 / (right - left); + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 2 / (top - bottom); + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1 / (near - far); + dst[11] = 0; + dst[12] = (right + left) / (left - right); + dst[13] = (top + bottom) / (bottom - top); + dst[14] = near / (near - far); + dst[15] = 1; + return dst; +} +/** + * Computes a 4-by-4 perspective transformation matrix given the left, right, + * top, bottom, near and far clipping planes. The arguments define a frustum + * extending in the negative z direction. The arguments near and far are the + * distances to the near and far clipping planes. Note that near and far are not + * z coordinates, but rather they are distances along the negative z-axis. The + * matrix generated sends the viewing frustum to the unit box. We assume a unit + * box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z + * dimension. + * @param left - The x coordinate of the left plane of the box. + * @param right - The x coordinate of the right plane of the box. + * @param bottom - The y coordinate of the bottom plane of the box. + * @param top - The y coordinate of the right plane of the box. + * @param near - The negative z coordinate of the near plane of the box. + * @param far - The negative z coordinate of the far plane of the box. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The perspective projection matrix. + */ +export function frustum(left, right, bottom, top, near, far, dst) { + dst = dst || new MatType(16); + const dx = (right - left); + const dy = (top - bottom); + const dz = (near - far); + dst[0] = 2 * near / dx; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 2 * near / dy; + dst[6] = 0; + dst[7] = 0; + dst[8] = (left + right) / dx; + dst[9] = (top + bottom) / dy; + dst[10] = far / dz; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[14] = near * far / dz; + dst[15] = 0; + return dst; +} +let xAxis; +let yAxis; +let zAxis; +/** + * Computes a 4-by-4 aim transformation. + * + * This is a matrix which positions an object aiming down positive Z. + * toward the target. + * + * Note: this is **NOT** the inverse of lookAt as lookAt looks at negative Z. + * + * @param position - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The aim matrix. + */ +export function aim(position, target, up, dst) { + dst = dst || new MatType(16); + xAxis = xAxis || vec3.create(); + yAxis = yAxis || vec3.create(); + zAxis = zAxis || vec3.create(); + vec3.normalize(vec3.subtract(target, position, zAxis), zAxis); + vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis); + vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis); + dst[0] = xAxis[0]; + dst[1] = xAxis[1]; + dst[2] = xAxis[2]; + dst[3] = 0; + dst[4] = yAxis[0]; + dst[5] = yAxis[1]; + dst[6] = yAxis[2]; + dst[7] = 0; + dst[8] = zAxis[0]; + dst[9] = zAxis[1]; + dst[10] = zAxis[2]; + dst[11] = 0; + dst[12] = position[0]; + dst[13] = position[1]; + dst[14] = position[2]; + dst[15] = 1; + return dst; +} +/** + * Computes a 4-by-4 camera aim transformation. + * + * This is a matrix which positions an object aiming down negative Z. + * toward the target. + * + * Note: this is the inverse of `lookAt` + * + * @param eye - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The aim matrix. + */ +export function cameraAim(eye, target, up, dst) { + dst = dst || new MatType(16); + xAxis = xAxis || vec3.create(); + yAxis = yAxis || vec3.create(); + zAxis = zAxis || vec3.create(); + vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis); + vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis); + vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis); + dst[0] = xAxis[0]; + dst[1] = xAxis[1]; + dst[2] = xAxis[2]; + dst[3] = 0; + dst[4] = yAxis[0]; + dst[5] = yAxis[1]; + dst[6] = yAxis[2]; + dst[7] = 0; + dst[8] = zAxis[0]; + dst[9] = zAxis[1]; + dst[10] = zAxis[2]; + dst[11] = 0; + dst[12] = eye[0]; + dst[13] = eye[1]; + dst[14] = eye[2]; + dst[15] = 1; + return dst; +} +/** + * Computes a 4-by-4 view transformation. + * + * This is a view matrix which transforms all other objects + * to be in the space of the view defined by the parameters. + * + * @param eye - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The look-at matrix. + */ +export function lookAt(eye, target, up, dst) { + dst = dst || new MatType(16); + xAxis = xAxis || vec3.create(); + yAxis = yAxis || vec3.create(); + zAxis = zAxis || vec3.create(); + vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis); + vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis); + vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis); + dst[0] = xAxis[0]; + dst[1] = yAxis[0]; + dst[2] = zAxis[0]; + dst[3] = 0; + dst[4] = xAxis[1]; + dst[5] = yAxis[1]; + dst[6] = zAxis[1]; + dst[7] = 0; + dst[8] = xAxis[2]; + dst[9] = yAxis[2]; + dst[10] = zAxis[2]; + dst[11] = 0; + dst[12] = -(xAxis[0] * eye[0] + xAxis[1] * eye[1] + xAxis[2] * eye[2]); + dst[13] = -(yAxis[0] * eye[0] + yAxis[1] * eye[1] + yAxis[2] * eye[2]); + dst[14] = -(zAxis[0] * eye[0] + zAxis[1] * eye[1] + zAxis[2] * eye[2]); + dst[15] = 1; + return dst; +} +/** + * Creates a 4-by-4 matrix which translates by the given vector v. + * @param v - The vector by + * which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translation matrix. + */ +export function translation(v, dst) { + dst = dst || new MatType(16); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + dst[11] = 0; + dst[12] = v[0]; + dst[13] = v[1]; + dst[14] = v[2]; + dst[15] = 1; + return dst; +} +/** + * Translates the given 4-by-4 matrix by the given vector v. + * @param m - The matrix. + * @param v - The vector by + * which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translated matrix. + */ +export function translate(m, v, dst) { + dst = dst || new MatType(16); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const m00 = m[0]; + const m01 = m[1]; + const m02 = m[2]; + const m03 = m[3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + if (m !== dst) { + dst[0] = m00; + dst[1] = m01; + dst[2] = m02; + dst[3] = m03; + dst[4] = m10; + dst[5] = m11; + dst[6] = m12; + dst[7] = m13; + dst[8] = m20; + dst[9] = m21; + dst[10] = m22; + dst[11] = m23; + } + dst[12] = m00 * v0 + m10 * v1 + m20 * v2 + m30; + dst[13] = m01 * v0 + m11 * v1 + m21 * v2 + m31; + dst[14] = m02 * v0 + m12 * v1 + m22 * v2 + m32; + dst[15] = m03 * v0 + m13 * v1 + m23 * v2 + m33; + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +export function rotationX(angleInRadians, dst) { + dst = dst || new MatType(16); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = c; + dst[6] = s; + dst[7] = 0; + dst[8] = 0; + dst[9] = -s; + dst[10] = c; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Rotates the given 4-by-4 matrix around the x-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export function rotateX(m, angleInRadians, dst) { + dst = dst || new MatType(16); + const m10 = m[4]; + const m11 = m[5]; + const m12 = m[6]; + const m13 = m[7]; + const m20 = m[8]; + const m21 = m[9]; + const m22 = m[10]; + const m23 = m[11]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[4] = c * m10 + s * m20; + dst[5] = c * m11 + s * m21; + dst[6] = c * m12 + s * m22; + dst[7] = c * m13 + s * m23; + dst[8] = c * m20 - s * m10; + dst[9] = c * m21 - s * m11; + dst[10] = c * m22 - s * m12; + dst[11] = c * m23 - s * m13; + if (m !== dst) { + dst[0] = m[0]; + dst[1] = m[1]; + dst[2] = m[2]; + dst[3] = m[3]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +export function rotationY(angleInRadians, dst) { + dst = dst || new MatType(16); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c; + dst[1] = 0; + dst[2] = -s; + dst[3] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[7] = 0; + dst[8] = s; + dst[9] = 0; + dst[10] = c; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Rotates the given 4-by-4 matrix around the y-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export function rotateY(m, angleInRadians, dst) { + dst = dst || new MatType(16); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c * m00 - s * m20; + dst[1] = c * m01 - s * m21; + dst[2] = c * m02 - s * m22; + dst[3] = c * m03 - s * m23; + dst[8] = c * m20 + s * m00; + dst[9] = c * m21 + s * m01; + dst[10] = c * m22 + s * m02; + dst[11] = c * m23 + s * m03; + if (m !== dst) { + dst[4] = m[4]; + dst[5] = m[5]; + dst[6] = m[6]; + dst[7] = m[7]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +export function rotationZ(angleInRadians, dst) { + dst = dst || new MatType(16); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c; + dst[1] = s; + dst[2] = 0; + dst[3] = 0; + dst[4] = -s; + dst[5] = c; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Rotates the given 4-by-4 matrix around the z-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export function rotateZ(m, angleInRadians, dst) { + dst = dst || new MatType(16); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c * m00 + s * m10; + dst[1] = c * m01 + s * m11; + dst[2] = c * m02 + s * m12; + dst[3] = c * m03 + s * m13; + dst[4] = c * m10 - s * m00; + dst[5] = c * m11 - s * m01; + dst[6] = c * m12 - s * m02; + dst[7] = c * m13 - s * m03; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + dst[11] = m[11]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the given axis by the given + * angle. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A matrix which rotates angle radians + * around the axis. + */ +export function axisRotation(axis, angleInRadians, dst) { + dst = dst || new MatType(16); + let x = axis[0]; + let y = axis[1]; + let z = axis[2]; + const n = Math.sqrt(x * x + y * y + z * z); + x /= n; + y /= n; + z /= n; + const xx = x * x; + const yy = y * y; + const zz = z * z; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + const oneMinusCosine = 1 - c; + dst[0] = xx + (1 - xx) * c; + dst[1] = x * y * oneMinusCosine + z * s; + dst[2] = x * z * oneMinusCosine - y * s; + dst[3] = 0; + dst[4] = x * y * oneMinusCosine - z * s; + dst[5] = yy + (1 - yy) * c; + dst[6] = y * z * oneMinusCosine + x * s; + dst[7] = 0; + dst[8] = x * z * oneMinusCosine + y * s; + dst[9] = y * z * oneMinusCosine - x * s; + dst[10] = zz + (1 - zz) * c; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the given axis by the given + * angle. (same as axisRotation) + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A matrix which rotates angle radians + * around the axis. + */ +export const rotation = axisRotation; +/** + * Rotates the given 4-by-4 matrix around the given axis by the + * given angle. + * @param m - The matrix. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export function axisRotate(m, axis, angleInRadians, dst) { + dst = dst || new MatType(16); + let x = axis[0]; + let y = axis[1]; + let z = axis[2]; + const n = Math.sqrt(x * x + y * y + z * z); + x /= n; + y /= n; + z /= n; + const xx = x * x; + const yy = y * y; + const zz = z * z; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + const oneMinusCosine = 1 - c; + const r00 = xx + (1 - xx) * c; + const r01 = x * y * oneMinusCosine + z * s; + const r02 = x * z * oneMinusCosine - y * s; + const r10 = x * y * oneMinusCosine - z * s; + const r11 = yy + (1 - yy) * c; + const r12 = y * z * oneMinusCosine + x * s; + const r20 = x * z * oneMinusCosine + y * s; + const r21 = y * z * oneMinusCosine - x * s; + const r22 = zz + (1 - zz) * c; + const m00 = m[0]; + const m01 = m[1]; + const m02 = m[2]; + const m03 = m[3]; + const m10 = m[4]; + const m11 = m[5]; + const m12 = m[6]; + const m13 = m[7]; + const m20 = m[8]; + const m21 = m[9]; + const m22 = m[10]; + const m23 = m[11]; + dst[0] = r00 * m00 + r01 * m10 + r02 * m20; + dst[1] = r00 * m01 + r01 * m11 + r02 * m21; + dst[2] = r00 * m02 + r01 * m12 + r02 * m22; + dst[3] = r00 * m03 + r01 * m13 + r02 * m23; + dst[4] = r10 * m00 + r11 * m10 + r12 * m20; + dst[5] = r10 * m01 + r11 * m11 + r12 * m21; + dst[6] = r10 * m02 + r11 * m12 + r12 * m22; + dst[7] = r10 * m03 + r11 * m13 + r12 * m23; + dst[8] = r20 * m00 + r21 * m10 + r22 * m20; + dst[9] = r20 * m01 + r21 * m11 + r22 * m21; + dst[10] = r20 * m02 + r21 * m12 + r22 * m22; + dst[11] = r20 * m03 + r21 * m13 + r22 * m23; + if (m !== dst) { + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Rotates the given 4-by-4 matrix around the given axis by the + * given angle. (same as rotate) + * @param m - The matrix. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +export const rotate = axisRotate; +/** + * Creates a 4-by-4 matrix which scales in each dimension by an amount given by + * the corresponding entry in the given vector; assumes the vector has three + * entries. + * @param v - A vector of + * three entries specifying the factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +export function scaling(v, dst) { + dst = dst || new MatType(16); + dst[0] = v[0]; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = v[1]; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = v[2]; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Scales the given 4-by-4 matrix in each dimension by an amount + * given by the corresponding entry in the given vector; assumes the vector has + * three entries. + * @param m - The matrix to be modified. + * @param v - A vector of three entries specifying the + * factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +export function scale(m, v, dst) { + dst = dst || new MatType(16); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + dst[0] = v0 * m[0 * 4 + 0]; + dst[1] = v0 * m[0 * 4 + 1]; + dst[2] = v0 * m[0 * 4 + 2]; + dst[3] = v0 * m[0 * 4 + 3]; + dst[4] = v1 * m[1 * 4 + 0]; + dst[5] = v1 * m[1 * 4 + 1]; + dst[6] = v1 * m[1 * 4 + 2]; + dst[7] = v1 * m[1 * 4 + 3]; + dst[8] = v2 * m[2 * 4 + 0]; + dst[9] = v2 * m[2 * 4 + 1]; + dst[10] = v2 * m[2 * 4 + 2]; + dst[11] = v2 * m[2 * 4 + 3]; + if (m !== dst) { + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Creates a 4-by-4 matrix which scales a uniform amount in each dimension. + * @param s - the amount to scale + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +export function uniformScaling(s, dst) { + dst = dst || new MatType(16); + dst[0] = s; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = s; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = s; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Scales the given 4-by-4 matrix in each dimension by a uniform scale. + * @param m - The matrix to be modified. + * @param s - The amount to scale. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +export function uniformScale(m, s, dst) { + dst = dst || new MatType(16); + dst[0] = s * m[0 * 4 + 0]; + dst[1] = s * m[0 * 4 + 1]; + dst[2] = s * m[0 * 4 + 2]; + dst[3] = s * m[0 * 4 + 3]; + dst[4] = s * m[1 * 4 + 0]; + dst[5] = s * m[1 * 4 + 1]; + dst[6] = s * m[1 * 4 + 2]; + dst[7] = s * m[1 * 4 + 3]; + dst[8] = s * m[2 * 4 + 0]; + dst[9] = s * m[2 * 4 + 1]; + dst[10] = s * m[2 * 4 + 2]; + dst[11] = s * m[2 * 4 + 3]; + if (m !== dst) { + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} diff --git a/dist/2.x/mat4.d.ts b/dist/2.x/mat4.d.ts new file mode 100644 index 0000000..90b1708 --- /dev/null +++ b/dist/2.x/mat4.d.ts @@ -0,0 +1,6 @@ +/** + * A JavaScript array with 16 values, a Float32Array with 16 values, or a Float64Array with 16 values. + * When created by the library will create the default type which is `Float32Array` + * but can be set by calling {@link mat4.setDefaultType}. + */ +export type Mat4 = number[] | Float32Array | Float64Array; diff --git a/dist/2.x/mat4.js b/dist/2.x/mat4.js new file mode 100644 index 0000000..baf2d4b --- /dev/null +++ b/dist/2.x/mat4.js @@ -0,0 +1,22 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +export {}; diff --git a/dist/2.x/quat-impl.d.ts b/dist/2.x/quat-impl.d.ts new file mode 100644 index 0000000..7153b02 --- /dev/null +++ b/dist/2.x/quat-impl.d.ts @@ -0,0 +1,298 @@ +import { Quat, create, setDefaultType } from './quat'; +import { Mat3 } from './mat3.js'; +import { Mat4 } from './mat4.js'; +import { Vec3 } from './vec3.js'; +export type RotationOrder = 'xyz' | 'xzy' | 'yxz' | 'yzx' | 'zxy' | 'zyx'; +export default Quat; +export { create, setDefaultType }; +/** + * Creates a Quat; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param z - Initial w value. + * @returns the created vector + */ +export declare const fromValues: typeof create; +/** + * Sets the values of a Quat + * Also see {@link quat.create} and {@link quat.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param w fourth value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +export declare function set(x: number, y: number, z: number, w: number, dst?: Quat): Quat; +/** + * Sets a quaternion from the given angle and axis, + * then returns it. + * + * @param axis - the axis to rotate around + * @param angleInRadians - the angle + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The quaternion that represents the given axis and angle + **/ +export declare function fromAxisAngle(axis: Vec3, angleInRadians: number, dst?: Quat): Quat; +/** + * Gets the rotation axis and angle + * @param q - quaternion to compute from + * @param dst - Vec3 to hold result. If not passed in a new one is created. + * @return angle and axis + */ +export declare function toAxisAngle(q: Quat, dst?: Vec3): { + angle: number; + axis: Vec3; +}; +/** + * Returns the angle in degrees between two rotations a and b. + * @param a - quaternion a + * @param b - quaternion b + * @return angle in radians between the two quaternions + */ +export declare function angle(a: Quat, b: Quat): number; +/** + * Multiplies two quaternions + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export declare function multiply(a: Quat, b: Quat, dst?: Quat): Quat; +/** + * Multiplies two quaternions + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export declare const mul: typeof multiply; +/** + * Rotates the given quaternion around the X axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export declare function rotateX(q: Quat, angleInRadians: number, dst?: Quat): Quat; +/** + * Rotates the given quaternion around the Y axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export declare function rotateY(q: Quat, angleInRadians: number, dst?: Quat): Quat; +/** + * Rotates the given quaternion around the Z axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export declare function rotateZ(q: Quat, angleInRadians: number, dst?: Quat): Quat; +/** + * Spherically linear interpolate between two quaternions + * + * @param a - starting value + * @param b - ending value + * @param t - value where 0 = a and 1 = b + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export declare function slerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat; +/** + * Compute the inverse of a quaternion + * + * @param q - quaternion to compute the inverse of + * @returns A quaternion that is the result of a * b + */ +export declare function inverse(q: Quat, dst?: Quat): Quat; +/** + * Compute the conjugate of a quaternion + * For quaternions with a magnitude of 1 (a unit quaternion) + * this returns the same as the inverse but is faster to calculate. + * + * @param q - quaternion to compute the conjugate of. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The conjugate of q + */ +export declare function conjugate(q: Quat, dst?: Quat): Quat; +/** + * Creates a quaternion from the given rotation matrix. + * + * The created quaternion is not normalized. + * + * @param m - rotation matrix + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns the result + */ +export declare function fromMat(m: Mat3 | Mat4, dst?: Quat): Quat; +/** + * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion. + * + * @param xAngleInRadians - angle to rotate around X axis in radians. + * @param yAngleInRadians - angle to rotate around Y axis in radians. + * @param zAngleInRadians - angle to rotate around Z axis in radians. + * @param order - order to apply euler angles + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion representing the same rotation as the euler angles applied in the given order + */ +export declare function fromEuler(xAngleInRadians: number, yAngleInRadians: number, zAngleInRadians: number, order: RotationOrder, dst?: Quat): Quat; +/** + * Copies a quaternion. (same as {@link quat.clone}) + * Also see {@link quat.create} and {@link quat.set} + * @param q - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is a copy of q + */ +export declare function copy(q: Quat, dst?: Quat): Quat; +/** + * Clones a quaternion. (same as {@link quat.copy}) + * Also see {@link quat.create} and {@link quat.set} + * @param q - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A copy of q. + */ +export declare const clone: typeof copy; +/** + * Adds two quaternions; assumes a and b have the same dimension. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the sum of a and b. + */ +export declare function add(a: Quat, b: Quat, dst?: Quat): Quat; +/** + * Subtracts two quaternions. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the difference of a and b. + */ +export declare function subtract(a: Quat, b: Quat, dst?: Quat): Quat; +/** + * Subtracts two quaternions. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the difference of a and b. + */ +export declare const sub: typeof subtract; +/** + * Multiplies a quaternion by a scalar. + * @param v - The quaternion. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ +export declare function mulScalar(v: Quat, k: number, dst?: Quat): Quat; +/** + * Multiplies a quaternion by a scalar. (same as mulScalar) + * @param v - The quaternion. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ +export declare const scale: typeof mulScalar; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ +export declare function divScalar(v: Quat, k: number, dst?: Quat): Quat; +/** + * Computes the dot product of two quaternions + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns dot product + */ +export declare function dot(a: Quat, b: Quat): number; +/** + * Performs linear interpolation on two quaternions. + * Given quaternions a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param t - Interpolation coefficient. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +export declare function lerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat; +/** + * Computes the length of quaternion + * @param v - quaternion. + * @returns length of quaternion. + */ +export declare function length(v: Quat): number; +/** + * Computes the length of quaternion (same as length) + * @param v - quaternion. + * @returns length of quaternion. + */ +export declare const len: typeof length; +/** + * Computes the square of the length of quaternion + * @param v - quaternion. + * @returns square of the length of quaternion. + */ +export declare function lengthSq(v: Quat): number; +/** + * Computes the square of the length of quaternion (same as lengthSq) + * @param v - quaternion. + * @returns square of the length of quaternion. + */ +export declare const lenSq: typeof lengthSq; +/** + * Divides a quaternion by its Euclidean length and returns the quotient. + * @param v - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The normalized quaternion. + */ +export declare function normalize(v: Quat, dst?: Quat): Quat; +/** + * Check if 2 quaternions are approximately equal + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns true if quaternions are approximately equal + */ +export declare function equalsApproximately(a: Quat, b: Quat): boolean; +/** + * Check if 2 quaternions are exactly equal + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns true if quaternions are exactly equal + */ +export declare function equals(a: Quat, b: Quat): boolean; +/** + * Creates an identity quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns an identity quaternion + */ +export declare function identity(dst?: Quat): Quat; +/** + * Computes a quaternion to represent the shortest rotation from one vector to another. + * + * @param aUnit - the start vector + * @param bUnit - the end vector + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns the result + */ +export declare function rotationTo(aUnit: Vec3, bUnit: Vec3, dst?: Quat): Quat; +/** + * Performs a spherical linear interpolation with two control points + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param c - the third quaternion + * @param d - the fourth quaternion + * @param t - Interpolation coefficient 0 to 1 + * @returns result + */ +export declare function sqlerp(a: Quat, b: Quat, c: Quat, d: Quat, t: number, dst?: Quat): Quat; diff --git a/dist/2.x/quat-impl.js b/dist/2.x/quat-impl.js new file mode 100644 index 0000000..382c6f1 --- /dev/null +++ b/dist/2.x/quat-impl.js @@ -0,0 +1,686 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +import * as utils from './utils.js'; +import { create, setDefaultType, QuatType } from './quat'; +import * as vec3 from './vec3-impl.js'; +export { create, setDefaultType }; +/** + * Creates a Quat; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param z - Initial w value. + * @returns the created vector + */ +export const fromValues = create; +/** + * Sets the values of a Quat + * Also see {@link quat.create} and {@link quat.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param w fourth value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +export function set(x, y, z, w, dst) { + dst = dst || new QuatType(4); + dst[0] = x; + dst[1] = y; + dst[2] = z; + dst[3] = w; + return dst; +} +/** + * Sets a quaternion from the given angle and axis, + * then returns it. + * + * @param axis - the axis to rotate around + * @param angleInRadians - the angle + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The quaternion that represents the given axis and angle + **/ +export function fromAxisAngle(axis, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const s = Math.sin(halfAngle); + dst[0] = s * axis[0]; + dst[1] = s * axis[1]; + dst[2] = s * axis[2]; + dst[3] = Math.cos(halfAngle); + return dst; +} +/** + * Gets the rotation axis and angle + * @param q - quaternion to compute from + * @param dst - Vec3 to hold result. If not passed in a new one is created. + * @return angle and axis + */ +export function toAxisAngle(q, dst) { + dst = dst || vec3.create(4); + const angle = Math.acos(q[3]) * 2; + const s = Math.sin(angle * 0.5); + if (s > utils.EPSILON) { + dst[0] = q[0] / s; + dst[1] = q[1] / s; + dst[2] = q[2] / s; + } + else { + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + } + return { angle, axis: dst }; +} +/** + * Returns the angle in degrees between two rotations a and b. + * @param a - quaternion a + * @param b - quaternion b + * @return angle in radians between the two quaternions + */ +export function angle(a, b) { + const d = dot(a, b); + return Math.acos(2 * d * d - 1); +} +/** + * Multiplies two quaternions + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export function multiply(a, b, dst) { + dst = dst || new QuatType(4); + const ax = a[0]; + const ay = a[1]; + const az = a[2]; + const aw = a[3]; + const bx = b[0]; + const by = b[1]; + const bz = b[2]; + const bw = b[3]; + dst[0] = ax * bw + aw * bx + ay * bz - az * by; + dst[1] = ay * bw + aw * by + az * bx - ax * bz; + dst[2] = az * bw + aw * bz + ax * by - ay * bx; + dst[3] = aw * bw - ax * bx - ay * by - az * bz; + return dst; +} +/** + * Multiplies two quaternions + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export const mul = multiply; +/** + * Rotates the given quaternion around the X axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export function rotateX(q, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const qw = q[3]; + const bx = Math.sin(halfAngle); + const bw = Math.cos(halfAngle); + dst[0] = qx * bw + qw * bx; + dst[1] = qy * bw + qz * bx; + dst[2] = qz * bw - qy * bx; + dst[3] = qw * bw - qx * bx; + return dst; +} +/** + * Rotates the given quaternion around the Y axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export function rotateY(q, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const qw = q[3]; + const by = Math.sin(halfAngle); + const bw = Math.cos(halfAngle); + dst[0] = qx * bw - qz * by; + dst[1] = qy * bw + qw * by; + dst[2] = qz * bw + qx * by; + dst[3] = qw * bw - qy * by; + return dst; +} +/** + * Rotates the given quaternion around the Z axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export function rotateZ(q, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const qw = q[3]; + const bz = Math.sin(halfAngle); + const bw = Math.cos(halfAngle); + dst[0] = qx * bw + qy * bz; + dst[1] = qy * bw - qx * bz; + dst[2] = qz * bw + qw * bz; + dst[3] = qw * bw - qz * bz; + return dst; +} +/** + * Spherically linear interpolate between two quaternions + * + * @param a - starting value + * @param b - ending value + * @param t - value where 0 = a and 1 = b + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +export function slerp(a, b, t, dst) { + dst = dst || new QuatType(4); + const ax = a[0]; + const ay = a[1]; + const az = a[2]; + const aw = a[3]; + let bx = b[0]; + let by = b[1]; + let bz = b[2]; + let bw = b[3]; + let cosOmega = ax * bx + ay * by + az * bz + aw * bw; + if (cosOmega < 0) { + cosOmega = -cosOmega; + bx = -bx; + by = -by; + bz = -bz; + bw = -bw; + } + let scale0; + let scale1; + if (1.0 - cosOmega > utils.EPSILON) { + const omega = Math.acos(cosOmega); + const sinOmega = Math.sin(omega); + scale0 = Math.sin((1 - t) * omega) / sinOmega; + scale1 = Math.sin(t * omega) / sinOmega; + } + else { + scale0 = 1.0 - t; + scale1 = t; + } + dst[0] = scale0 * ax + scale1 * bx; + dst[1] = scale0 * ay + scale1 * by; + dst[2] = scale0 * az + scale1 * bz; + dst[3] = scale0 * aw + scale1 * bw; + return dst; +} +/** + * Compute the inverse of a quaternion + * + * @param q - quaternion to compute the inverse of + * @returns A quaternion that is the result of a * b + */ +export function inverse(q, dst) { + dst = dst || new QuatType(4); + const a0 = q[0]; + const a1 = q[1]; + const a2 = q[2]; + const a3 = q[3]; + const dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + const invDot = dot ? 1 / dot : 0; + dst[0] = -a0 * invDot; + dst[1] = -a1 * invDot; + dst[2] = -a2 * invDot; + dst[3] = a3 * invDot; + return dst; +} +/** + * Compute the conjugate of a quaternion + * For quaternions with a magnitude of 1 (a unit quaternion) + * this returns the same as the inverse but is faster to calculate. + * + * @param q - quaternion to compute the conjugate of. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The conjugate of q + */ +export function conjugate(q, dst) { + dst = dst || new QuatType(4); + dst[0] = -q[0]; + dst[1] = -q[1]; + dst[2] = -q[2]; + dst[3] = q[3]; + return dst; +} +/** + * Creates a quaternion from the given rotation matrix. + * + * The created quaternion is not normalized. + * + * @param m - rotation matrix + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns the result + */ +export function fromMat(m, dst) { + dst = dst || new QuatType(4); + /* + 0 1 2 + 3 4 5 + 6 7 8 + + 0 1 2 + 4 5 6 + 8 9 10 + */ + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + const trace = m[0] + m[5] + m[10]; + if (trace > 0.0) { + // |w| > 1/2, may as well choose w > 1/2 + const root = Math.sqrt(trace + 1); // 2w + dst[3] = 0.5 * root; + const invRoot = 0.5 / root; // 1/(4w) + dst[0] = (m[6] - m[9]) * invRoot; + dst[1] = (m[8] - m[2]) * invRoot; + dst[2] = (m[1] - m[4]) * invRoot; + } + else { + // |w| <= 1/2 + let i = 0; + if (m[5] > m[0]) { + i = 1; + } + if (m[10] > m[i * 4 + i]) { + i = 2; + } + const j = (i + 1) % 3; + const k = (i + 2) % 3; + const root = Math.sqrt(m[i * 4 + i] - m[j * 4 + j] - m[k * 4 + k] + 1.0); + dst[i] = 0.5 * root; + const invRoot = 0.5 / root; + dst[3] = (m[j * 4 + k] - m[k * 4 + j]) * invRoot; + dst[j] = (m[j * 4 + i] + m[i * 4 + j]) * invRoot; + dst[k] = (m[k * 4 + i] + m[i * 4 + k]) * invRoot; + } + return dst; +} +/** + * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion. + * + * @param xAngleInRadians - angle to rotate around X axis in radians. + * @param yAngleInRadians - angle to rotate around Y axis in radians. + * @param zAngleInRadians - angle to rotate around Z axis in radians. + * @param order - order to apply euler angles + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion representing the same rotation as the euler angles applied in the given order + */ +export function fromEuler(xAngleInRadians, yAngleInRadians, zAngleInRadians, order, dst) { + dst = dst || new QuatType(4); + const xHalfAngle = xAngleInRadians * 0.5; + const yHalfAngle = yAngleInRadians * 0.5; + const zHalfAngle = zAngleInRadians * 0.5; + const sx = Math.sin(xHalfAngle); + const cx = Math.cos(xHalfAngle); + const sy = Math.sin(yHalfAngle); + const cy = Math.cos(yHalfAngle); + const sz = Math.sin(zHalfAngle); + const cz = Math.cos(zHalfAngle); + switch (order) { + case 'xyz': + dst[0] = sx * cy * cz + cx * sy * sz; + dst[1] = cx * sy * cz - sx * cy * sz; + dst[2] = cx * cy * sz + sx * sy * cz; + dst[3] = cx * cy * cz - sx * sy * sz; + break; + case 'xzy': + dst[0] = sx * cy * cz - cx * sy * sz; + dst[1] = cx * sy * cz - sx * cy * sz; + dst[2] = cx * cy * sz + sx * sy * cz; + dst[3] = cx * cy * cz + sx * sy * sz; + break; + case 'yxz': + dst[0] = sx * cy * cz + cx * sy * sz; + dst[1] = cx * sy * cz - sx * cy * sz; + dst[2] = cx * cy * sz - sx * sy * cz; + dst[3] = cx * cy * cz + sx * sy * sz; + break; + case 'yzx': + dst[0] = sx * cy * cz + cx * sy * sz; + dst[1] = cx * sy * cz + sx * cy * sz; + dst[2] = cx * cy * sz - sx * sy * cz; + dst[3] = cx * cy * cz - sx * sy * sz; + break; + case 'zxy': + dst[0] = sx * cy * cz - cx * sy * sz; + dst[1] = cx * sy * cz + sx * cy * sz; + dst[2] = cx * cy * sz + sx * sy * cz; + dst[3] = cx * cy * cz - sx * sy * sz; + break; + case 'zyx': + dst[0] = sx * cy * cz - cx * sy * sz; + dst[1] = cx * sy * cz + sx * cy * sz; + dst[2] = cx * cy * sz - sx * sy * cz; + dst[3] = cx * cy * cz + sx * sy * sz; + break; + default: + throw new Error(`Unknown rotation order: ${order}`); + } + return dst; +} +/** + * Copies a quaternion. (same as {@link quat.clone}) + * Also see {@link quat.create} and {@link quat.set} + * @param q - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is a copy of q + */ +export function copy(q, dst) { + dst = dst || new QuatType(4); + dst[0] = q[0]; + dst[1] = q[1]; + dst[2] = q[2]; + dst[3] = q[3]; + return dst; +} +/** + * Clones a quaternion. (same as {@link quat.copy}) + * Also see {@link quat.create} and {@link quat.set} + * @param q - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A copy of q. + */ +export const clone = copy; +/** + * Adds two quaternions; assumes a and b have the same dimension. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the sum of a and b. + */ +export function add(a, b, dst) { + dst = dst || new QuatType(4); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + dst[2] = a[2] + b[2]; + dst[3] = a[3] + b[3]; + return dst; +} +/** + * Subtracts two quaternions. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the difference of a and b. + */ +export function subtract(a, b, dst) { + dst = dst || new QuatType(4); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + dst[2] = a[2] - b[2]; + dst[3] = a[3] - b[3]; + return dst; +} +/** + * Subtracts two quaternions. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the difference of a and b. + */ +export const sub = subtract; +/** + * Multiplies a quaternion by a scalar. + * @param v - The quaternion. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ +export function mulScalar(v, k, dst) { + dst = dst || new QuatType(4); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + dst[2] = v[2] * k; + dst[3] = v[3] * k; + return dst; +} +/** + * Multiplies a quaternion by a scalar. (same as mulScalar) + * @param v - The quaternion. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ +export const scale = mulScalar; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ +export function divScalar(v, k, dst) { + dst = dst || new QuatType(4); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + dst[2] = v[2] / k; + dst[3] = v[3] / k; + return dst; +} +/** + * Computes the dot product of two quaternions + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns dot product + */ +export function dot(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]); +} +/** + * Performs linear interpolation on two quaternions. + * Given quaternions a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param t - Interpolation coefficient. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +export function lerp(a, b, t, dst) { + dst = dst || new QuatType(4); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + dst[2] = a[2] + t * (b[2] - a[2]); + dst[3] = a[3] + t * (b[3] - a[3]); + return dst; +} +/** + * Computes the length of quaternion + * @param v - quaternion. + * @returns length of quaternion. + */ +export function length(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); +} +/** + * Computes the length of quaternion (same as length) + * @param v - quaternion. + * @returns length of quaternion. + */ +export const len = length; +/** + * Computes the square of the length of quaternion + * @param v - quaternion. + * @returns square of the length of quaternion. + */ +export function lengthSq(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3; +} +/** + * Computes the square of the length of quaternion (same as lengthSq) + * @param v - quaternion. + * @returns square of the length of quaternion. + */ +export const lenSq = lengthSq; +/** + * Divides a quaternion by its Euclidean length and returns the quotient. + * @param v - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The normalized quaternion. + */ +export function normalize(v, dst) { + dst = dst || new QuatType(4); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + dst[2] = v2 / len; + dst[3] = v3 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + } + return dst; +} +/** + * Check if 2 quaternions are approximately equal + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns true if quaternions are approximately equal + */ +export function equalsApproximately(a, b) { + return Math.abs(a[0] - b[0]) < utils.EPSILON && + Math.abs(a[1] - b[1]) < utils.EPSILON && + Math.abs(a[2] - b[2]) < utils.EPSILON && + Math.abs(a[3] - b[3]) < utils.EPSILON; +} +/** + * Check if 2 quaternions are exactly equal + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns true if quaternions are exactly equal + */ +export function equals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} +/** + * Creates an identity quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns an identity quaternion + */ +export function identity(dst) { + dst = dst || new QuatType(4); + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 1; + return dst; +} +let tempVec3; +let xUnitVec3; +let yUnitVec3; +/** + * Computes a quaternion to represent the shortest rotation from one vector to another. + * + * @param aUnit - the start vector + * @param bUnit - the end vector + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns the result + */ +export function rotationTo(aUnit, bUnit, dst) { + dst = dst || new QuatType(4); + tempVec3 = tempVec3 || vec3.create(); + xUnitVec3 = xUnitVec3 || vec3.create(1, 0, 0); + yUnitVec3 = yUnitVec3 || vec3.create(0, 1, 0); + const dot = vec3.dot(aUnit, bUnit); + if (dot < -0.999999) { + vec3.cross(xUnitVec3, aUnit, tempVec3); + if (vec3.len(tempVec3) < 0.000001) { + vec3.cross(yUnitVec3, aUnit, tempVec3); + } + vec3.normalize(tempVec3, tempVec3); + fromAxisAngle(tempVec3, Math.PI, dst); + return dst; + } + else if (dot > 0.999999) { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 1; + return dst; + } + else { + vec3.cross(aUnit, bUnit, tempVec3); + dst[0] = tempVec3[0]; + dst[1] = tempVec3[1]; + dst[2] = tempVec3[2]; + dst[3] = 1 + dot; + return normalize(dst, dst); + } +} +let tempQuat1; +let tempQuat2; +/** + * Performs a spherical linear interpolation with two control points + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param c - the third quaternion + * @param d - the fourth quaternion + * @param t - Interpolation coefficient 0 to 1 + * @returns result + */ +export function sqlerp(a, b, c, d, t, dst) { + dst = dst || new QuatType(4); + tempQuat1 = tempQuat1 || new QuatType(4); + tempQuat2 = tempQuat2 || new QuatType(4); + slerp(a, d, t, tempQuat1); + slerp(b, c, t, tempQuat2); + slerp(tempQuat1, tempQuat2, 2 * t * (1 - t), dst); + return dst; +} diff --git a/dist/2.x/quat.d.ts b/dist/2.x/quat.d.ts new file mode 100644 index 0000000..7a35408 --- /dev/null +++ b/dist/2.x/quat.d.ts @@ -0,0 +1,44 @@ +/** + * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values. + * When created by the library will create the default type which is `Float32Array` + * but can be set by calling {@link quat.setDefaultType}. + */ +export type Quat = number[] | Float32Array | Float64Array; +/** + * + * Quat4 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Quat4`. In other words you can do this + * + * const v = quat4.cross(v1, v2); // Creates a new Quat4 with the cross product of v1 x v2. + * + * or + * + * const v = quat4.create(); + * quat4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * quat4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +export declare let QuatType: new (n: number) => Quat; +/** + * Sets the type this library creates for a Quat4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Quat4 + */ +export declare function setDefaultType(ctor: new (n: number) => Quat): new (n: number) => Quat; +/** + * Creates a quat4; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param w - Initial w value. + * @returns the created vector + */ +export declare function create(x?: number, y?: number, z?: number, w?: number): Quat; diff --git a/dist/2.x/quat.js b/dist/2.x/quat.js new file mode 100644 index 0000000..fb30647 --- /dev/null +++ b/dist/2.x/quat.js @@ -0,0 +1,78 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * + * Quat4 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Quat4`. In other words you can do this + * + * const v = quat4.cross(v1, v2); // Creates a new Quat4 with the cross product of v1 x v2. + * + * or + * + * const v = quat4.create(); + * quat4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * quat4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +export let QuatType = Float32Array; +/** + * Sets the type this library creates for a Quat4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Quat4 + */ +export function setDefaultType(ctor) { + const oldType = QuatType; + QuatType = ctor; + return oldType; +} +/** + * Creates a quat4; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param w - Initial w value. + * @returns the created vector + */ +export function create(x, y, z, w) { + const dst = new QuatType(4); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + if (z !== undefined) { + dst[2] = z; + if (w !== undefined) { + dst[3] = w; + } + } + } + } + return dst; +} diff --git a/dist/2.x/types.d.ts b/dist/2.x/types.d.ts new file mode 100644 index 0000000..06e5762 --- /dev/null +++ b/dist/2.x/types.d.ts @@ -0,0 +1,19 @@ +/** + * The types you can pass to most functions that take an + * array of numbers. + */ +export type BaseArgType = Float32Array | Float64Array | number[]; +export declare const ZeroArray: { + (arrayLength: number): number[]; + (...items: number[]): number[]; + new (arrayLength: number): number[]; + new (...items: number[]): number[]; + isArray(arg: any): arg is any[]; + readonly prototype: any[]; + from(arrayLike: ArrayLike): T[]; + from(arrayLike: ArrayLike, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[]; + from(iterable: Iterable | ArrayLike): T_2[]; + from(iterable: Iterable | ArrayLike, mapfn: (v: T_3, k: number) => U_1, thisArg?: any): U_1[]; + of(...items: T_4[]): T_4[]; + readonly [Symbol.species]: ArrayConstructor; +}; diff --git a/dist/2.x/utils.d.ts b/dist/2.x/utils.d.ts new file mode 100644 index 0000000..d231f94 --- /dev/null +++ b/dist/2.x/utils.d.ts @@ -0,0 +1,53 @@ +export declare let EPSILON: number; +/** + * Set the value for EPSILON for various checks + * @param v - Value to use for EPSILON. + * @returns previous value of EPSILON; + */ +export declare function setEpsilon(v: number): number; +/** + * Convert degrees to radians + * @param degrees - Angle in degrees + * @returns angle converted to radians + */ +export declare function degToRad(degrees: number): number; +/** + * Convert radians to degrees + * @param radians - Angle in radians + * @returns angle converted to degrees + */ +export declare function radToDeg(radians: number): number; +/** + * Lerps between a and b via t + * @param a - starting value + * @param b - ending value + * @param t - value where 0 = a and 1 = b + * @returns a + (b - a) * t + */ +export declare function lerp(a: number, b: number, t: number): number; +/** + * Compute the opposite of lerp. Given a and b and a value between + * a and b returns a value between 0 and 1. 0 if a, 1 if b. + * Note: no clamping is done. + * @param a - start value + * @param b - end value + * @param v - value between a and b + * @returns (v - a) / (b - a) + */ +export declare function inverseLerp(a: number, b: number, v: number): number; +/** + * Compute the euclidean modulo + * + * ``` + * // table for n / 3 + * -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 <- n + * ------------------------------------ + * -2 -1 -0 -2 -1 0, 1, 2, 0, 1, 2 <- n % 3 + * 1 2 0 1 2 0, 1, 2, 0, 1, 2 <- euclideanModule(n, 3) + * ``` + * + * @param n - dividend + * @param m - divisor + * @returns the euclidean modulo of n / m + */ +export declare function euclideanModulo(n: number, m: number): number; diff --git a/dist/2.x/utils.js b/dist/2.x/utils.js new file mode 100644 index 0000000..02504a4 --- /dev/null +++ b/dist/2.x/utils.js @@ -0,0 +1,91 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +export let EPSILON = 0.000001; +/** + * Set the value for EPSILON for various checks + * @param v - Value to use for EPSILON. + * @returns previous value of EPSILON; + */ +export function setEpsilon(v) { + const old = EPSILON; + EPSILON = v; + return old; +} +/** + * Convert degrees to radians + * @param degrees - Angle in degrees + * @returns angle converted to radians + */ +export function degToRad(degrees) { + return degrees * Math.PI / 180; +} +/** + * Convert radians to degrees + * @param radians - Angle in radians + * @returns angle converted to degrees + */ +export function radToDeg(radians) { + return radians * 180 / Math.PI; +} +/** + * Lerps between a and b via t + * @param a - starting value + * @param b - ending value + * @param t - value where 0 = a and 1 = b + * @returns a + (b - a) * t + */ +export function lerp(a, b, t) { + return a + (b - a) * t; +} +/** + * Compute the opposite of lerp. Given a and b and a value between + * a and b returns a value between 0 and 1. 0 if a, 1 if b. + * Note: no clamping is done. + * @param a - start value + * @param b - end value + * @param v - value between a and b + * @returns (v - a) / (b - a) + */ +export function inverseLerp(a, b, v) { + const d = b - a; + return (Math.abs(b - a) < EPSILON) + ? a + : (v - a) / d; +} +/** + * Compute the euclidean modulo + * + * ``` + * // table for n / 3 + * -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 <- n + * ------------------------------------ + * -2 -1 -0 -2 -1 0, 1, 2, 0, 1, 2 <- n % 3 + * 1 2 0 1 2 0, 1, 2, 0, 1, 2 <- euclideanModule(n, 3) + * ``` + * + * @param n - dividend + * @param m - divisor + * @returns the euclidean modulo of n / m + */ +export function euclideanModulo(n, m) { + return ((n % m) + m) % m; +} diff --git a/dist/2.x/vec2-impl.d.ts b/dist/2.x/vec2-impl.d.ts new file mode 100644 index 0000000..ce1871f --- /dev/null +++ b/dist/2.x/vec2-impl.d.ts @@ -0,0 +1,385 @@ +import { Mat3 } from './mat3'; +import { Mat4 } from './mat4'; +import { Vec2, create, setDefaultType } from './vec2'; +import { Vec3 } from './vec3'; +export default Vec2; +export { create, setDefaultType }; +/** + * Creates a Vec2; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @returns the created vector + */ +export declare const fromValues: typeof create; +/** + * Sets the values of a Vec2 + * Also see {@link vec2.create} and {@link vec2.copy} + * + * @param x first value + * @param y second value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +export declare function set(x: number, y: number, dst?: Vec2): Vec2; +/** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ +export declare function ceil(v: Vec2, dst?: Vec2): Vec2; +/** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ +export declare function floor(v: Vec2, dst?: Vec2): Vec2; +/** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ +export declare function round(v: Vec2, dst?: Vec2): Vec2; +/** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ +export declare function clamp(v: Vec2, min?: number, max?: number, dst?: Vec2): Vec2; +/** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ +export declare function add(a: Vec2, b: Vec2, dst?: Vec2): Vec2; +/** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ +export declare function addScaled(a: Vec2, b: Vec2, scale: number, dst?: Vec2): Vec2; +/** + * Returns the angle in radians between two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns The angle in radians between the 2 vectors. + */ +export declare function angle(a: Vec2, b: Vec2): number; +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export declare function subtract(a: Vec2, b: Vec2, dst?: Vec2): Vec2; +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export declare const sub: typeof subtract; +/** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ +export declare function equalsApproximately(a: Vec2, b: Vec2): boolean; +/** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ +export declare function equals(a: Vec2, b: Vec2): boolean; +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +export declare function lerp(a: Vec2, b: Vec2, t: number, dst?: Vec2): Vec2; +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ +export declare function lerpV(a: Vec2, b: Vec2, t: Vec2, dst?: Vec2): Vec2; +/** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ +export declare function max(a: Vec2, b: Vec2, dst?: Vec2): Vec2; +/** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ +export declare function min(a: Vec2, b: Vec2, dst?: Vec2): Vec2; +/** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export declare function mulScalar(v: Vec2, k: number, dst?: Vec2): Vec2; +/** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export declare const scale: typeof mulScalar; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export declare function divScalar(v: Vec2, k: number, dst?: Vec2): Vec2; +/** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export declare function inverse(v: Vec2, dst?: Vec2): Vec2; +/** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export declare const invert: typeof inverse; +/** + * Computes the cross product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of a cross b. + */ +export declare function cross(a: Vec2, b: Vec2, dst?: Vec3): Vec3; +/** + * Computes the dot product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ +export declare function dot(a: Vec2, b: Vec2): number; +/** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ +export declare function length(v: Vec2): number; +/** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ +export declare const len: typeof length; +/** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ +export declare function lengthSq(v: Vec2): number; +/** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ +export declare const lenSq: typeof lengthSq; +/** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export declare function distance(a: Vec2, b: Vec2): number; +/** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export declare const dist: typeof distance; +/** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export declare function distanceSq(a: Vec2, b: Vec2): number; +/** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export declare const distSq: typeof distanceSq; +/** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ +export declare function normalize(v: Vec2, dst?: Vec2): Vec2; +/** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ +export declare function negate(v: Vec2, dst?: Vec2): Vec2; +/** + * Copies a vector. (same as {@link vec2.clone}) + * Also see {@link vec2.create} and {@link vec2.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export declare function copy(v: Vec2, dst?: Vec2): Vec2; +/** + * Clones a vector. (same as {@link vec2.copy}) + * Also see {@link vec2.create} and {@link vec2.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export declare const clone: typeof copy; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export declare function multiply(a: Vec2, b: Vec2, dst?: Vec2): Vec2; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export declare const mul: typeof multiply; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export declare function divide(a: Vec2, b: Vec2, dst?: Vec2): Vec2; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export declare const div: typeof divide; +/** + * Creates a random unit vector * scale + * @param scale - Default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The random vector. + */ +export declare function random(scale?: number, dst?: Vec2): Vec2; +/** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ +export declare function zero(dst?: Vec2): Vec2; +/** + * transform Vec2 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional Vec2 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export declare function transformMat4(v: Vec2, m: Mat4, dst?: Vec2): Vec2; +/** + * Transforms vec4 by 3x3 matrix + * + * @param v - the vector + * @param m - The matrix. + * @param dst - optional Vec2 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export declare function transformMat3(v: Vec2, m: Mat3, dst?: Vec2): Vec2; +/** + * Rotate a 2D vector + * + * @param a The vec2 point to rotate + * @param b The origin of the rotation + * @param rad The angle of rotation in radians + * @returns the rotated vector + */ +export declare function rotate(a: Vec2, b: Vec2, rad: number, dst?: Vec2): Vec2; +/** + * Treat a 2D vector as a direction and set it's length + * + * @param a The vec2 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ +export declare function setLength(a: Vec2, len: number, dst?: Vec2): Vec2; +/** + * Ensure a vector is not longer than a max length + * + * @param a The vec2 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ +export declare function truncate(a: Vec2, maxLen: number, dst?: Vec2): Vec2; +/** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ +export declare function midpoint(a: Vec2, b: Vec2, dst?: Vec2): Vec2; diff --git a/dist/2.x/vec2-impl.js b/dist/2.x/vec2-impl.js new file mode 100644 index 0000000..cd7a7d6 --- /dev/null +++ b/dist/2.x/vec2-impl.js @@ -0,0 +1,602 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +import * as utils from './utils.js'; +import { create, setDefaultType, VecType } from './vec2'; +import { VecType as Vec3Type } from './vec3'; +export { create, setDefaultType }; +/** + * Creates a Vec2; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @returns the created vector + */ +export const fromValues = create; +/** + * Sets the values of a Vec2 + * Also see {@link vec2.create} and {@link vec2.copy} + * + * @param x first value + * @param y second value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +export function set(x, y, dst) { + dst = dst || new VecType(2); + dst[0] = x; + dst[1] = y; + return dst; +} +/** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ +export function ceil(v, dst) { + dst = dst || new VecType(2); + dst[0] = Math.ceil(v[0]); + dst[1] = Math.ceil(v[1]); + return dst; +} +/** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ +export function floor(v, dst) { + dst = dst || new VecType(2); + dst[0] = Math.floor(v[0]); + dst[1] = Math.floor(v[1]); + return dst; +} +/** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ +export function round(v, dst) { + dst = dst || new VecType(2); + dst[0] = Math.round(v[0]); + dst[1] = Math.round(v[1]); + return dst; +} +/** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ +export function clamp(v, min = 0, max = 1, dst) { + dst = dst || new VecType(2); + dst[0] = Math.min(max, Math.max(min, v[0])); + dst[1] = Math.min(max, Math.max(min, v[1])); + return dst; +} +/** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ +export function add(a, b, dst) { + dst = dst || new VecType(2); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + return dst; +} +/** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ +export function addScaled(a, b, scale, dst) { + dst = dst || new VecType(2); + dst[0] = a[0] + b[0] * scale; + dst[1] = a[1] + b[1] * scale; + return dst; +} +/** + * Returns the angle in radians between two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns The angle in radians between the 2 vectors. + */ +export function angle(a, b) { + const ax = a[0]; + const ay = a[1]; + const bx = b[0]; + const by = b[1]; + const mag1 = Math.sqrt(ax * ax + ay * ay); + const mag2 = Math.sqrt(bx * bx + by * by); + const mag = mag1 * mag2; + const cosine = mag && dot(a, b) / mag; + return Math.acos(cosine); +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export function subtract(a, b, dst) { + dst = dst || new VecType(2); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + return dst; +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export const sub = subtract; +/** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ +export function equalsApproximately(a, b) { + return Math.abs(a[0] - b[0]) < utils.EPSILON && + Math.abs(a[1] - b[1]) < utils.EPSILON; +} +/** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ +export function equals(a, b) { + return a[0] === b[0] && a[1] === b[1]; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +export function lerp(a, b, t, dst) { + dst = dst || new VecType(2); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + return dst; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ +export function lerpV(a, b, t, dst) { + dst = dst || new VecType(2); + dst[0] = a[0] + t[0] * (b[0] - a[0]); + dst[1] = a[1] + t[1] * (b[1] - a[1]); + return dst; +} +/** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ +export function max(a, b, dst) { + dst = dst || new VecType(2); + dst[0] = Math.max(a[0], b[0]); + dst[1] = Math.max(a[1], b[1]); + return dst; +} +/** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ +export function min(a, b, dst) { + dst = dst || new VecType(2); + dst[0] = Math.min(a[0], b[0]); + dst[1] = Math.min(a[1], b[1]); + return dst; +} +/** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export function mulScalar(v, k, dst) { + dst = dst || new VecType(2); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + return dst; +} +/** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export const scale = mulScalar; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export function divScalar(v, k, dst) { + dst = dst || new VecType(2); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + return dst; +} +/** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export function inverse(v, dst) { + dst = dst || new VecType(2); + dst[0] = 1 / v[0]; + dst[1] = 1 / v[1]; + return dst; +} +/** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export const invert = inverse; +/** + * Computes the cross product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of a cross b. + */ +export function cross(a, b, dst) { + dst = dst || new Vec3Type(3); + const z = a[0] * b[1] - a[1] * b[0]; + dst[0] = 0; + dst[1] = 0; + dst[2] = z; + return dst; +} +/** + * Computes the dot product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ +export function dot(a, b) { + return a[0] * b[0] + a[1] * b[1]; +} +/** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ +export function length(v) { + const v0 = v[0]; + const v1 = v[1]; + return Math.sqrt(v0 * v0 + v1 * v1); +} +/** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ +export const len = length; +/** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ +export function lengthSq(v) { + const v0 = v[0]; + const v1 = v[1]; + return v0 * v0 + v1 * v1; +} +/** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ +export const lenSq = lengthSq; +/** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export function distance(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + return Math.sqrt(dx * dx + dy * dy); +} +/** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export const dist = distance; +/** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export function distanceSq(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + return dx * dx + dy * dy; +} +/** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export const distSq = distanceSq; +/** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ +export function normalize(v, dst) { + dst = dst || new VecType(2); + const v0 = v[0]; + const v1 = v[1]; + const len = Math.sqrt(v0 * v0 + v1 * v1); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + } + return dst; +} +/** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ +export function negate(v, dst) { + dst = dst || new VecType(2); + dst[0] = -v[0]; + dst[1] = -v[1]; + return dst; +} +/** + * Copies a vector. (same as {@link vec2.clone}) + * Also see {@link vec2.create} and {@link vec2.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export function copy(v, dst) { + dst = dst || new VecType(2); + dst[0] = v[0]; + dst[1] = v[1]; + return dst; +} +/** + * Clones a vector. (same as {@link vec2.copy}) + * Also see {@link vec2.create} and {@link vec2.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export const clone = copy; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export function multiply(a, b, dst) { + dst = dst || new VecType(2); + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + return dst; +} +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export const mul = multiply; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export function divide(a, b, dst) { + dst = dst || new VecType(2); + dst[0] = a[0] / b[0]; + dst[1] = a[1] / b[1]; + return dst; +} +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export const div = divide; +/** + * Creates a random unit vector * scale + * @param scale - Default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The random vector. + */ +export function random(scale = 1, dst) { + dst = dst || new VecType(2); + const angle = Math.random() * 2 * Math.PI; + dst[0] = Math.cos(angle) * scale; + dst[1] = Math.sin(angle) * scale; + return dst; +} +/** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ +export function zero(dst) { + dst = dst || new VecType(2); + dst[0] = 0; + dst[1] = 0; + return dst; +} +/** + * transform Vec2 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional Vec2 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export function transformMat4(v, m, dst) { + dst = dst || new VecType(2); + const x = v[0]; + const y = v[1]; + dst[0] = x * m[0] + y * m[4] + m[12]; + dst[1] = x * m[1] + y * m[5] + m[13]; + return dst; +} +/** + * Transforms vec4 by 3x3 matrix + * + * @param v - the vector + * @param m - The matrix. + * @param dst - optional Vec2 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export function transformMat3(v, m, dst) { + dst = dst || new VecType(2); + const x = v[0]; + const y = v[1]; + dst[0] = m[0] * x + m[4] * y + m[8]; + dst[1] = m[1] * x + m[5] * y + m[9]; + return dst; +} +/** + * Rotate a 2D vector + * + * @param a The vec2 point to rotate + * @param b The origin of the rotation + * @param rad The angle of rotation in radians + * @returns the rotated vector + */ +export function rotate(a, b, rad, dst) { + dst = dst || new VecType(2); + // Translate point to the origin + const p0 = a[0] - b[0]; + const p1 = a[1] - b[1]; + const sinC = Math.sin(rad); + const cosC = Math.cos(rad); + //perform rotation and translate to correct position + dst[0] = p0 * cosC - p1 * sinC + b[0]; + dst[1] = p0 * sinC + p1 * cosC + b[1]; + return dst; +} +/** + * Treat a 2D vector as a direction and set it's length + * + * @param a The vec2 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ +export function setLength(a, len, dst) { + dst = dst || new VecType(2); + normalize(a, dst); + return mulScalar(dst, len, dst); +} +/** + * Ensure a vector is not longer than a max length + * + * @param a The vec2 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ +export function truncate(a, maxLen, dst) { + dst = dst || new VecType(2); + if (length(a) > maxLen) { + return setLength(a, maxLen, dst); + } + return copy(a, dst); +} +/** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ +export function midpoint(a, b, dst) { + dst = dst || new VecType(2); + return lerp(a, b, 0.5, dst); +} diff --git a/dist/2.x/vec2.d.ts b/dist/2.x/vec2.d.ts new file mode 100644 index 0000000..ab730b6 --- /dev/null +++ b/dist/2.x/vec2.d.ts @@ -0,0 +1,63 @@ +/** + * A JavaScript array with 2 values, Float32Array with 2 values, or a Float64Array with 2 values. + * When created by the library will create the default type which is `Float32Array` + * but can be set by calling {@link vec2.setDefaultType}. + */ +export type Vec2 = number[] | Float32Array | Float64Array; +/** + * + * Vec2 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new Vec2. In other words you can do this + * + * const v = vec2.cross(v1, v2); // Creates a new Vec2 with the cross product of v1 x v2. + * + * or + * + * const v = vec2.create(); + * vec2.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec2.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +export declare let VecType: new (n: number) => Vec2; +/** + * Sets the type this library creates for a Vec2 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec2 + */ +export declare function setDefaultType(ctor: new (n: number) => Vec2): new (n: number) => Vec2; +/** + * Creates a Vec2; may be called with x, y, z to set initial values. + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Vec2's specified type + * it would be faster to use + * + * ``` + * const v = vec2.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Vec2Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `vec2.create` is usually used + * to create a Vec2 to be filled out as in + * + * ``` + * const sum = vec2.create(); + * vec2.add(v1, v2, sum); + * ``` + * + * @param x - Initial x value. + * @param y - Initial y value. + * @returns the created vector + */ +export declare function create(x?: number, y?: number): Vec2; diff --git a/dist/2.x/vec2.js b/dist/2.x/vec2.js new file mode 100644 index 0000000..9d2bcae --- /dev/null +++ b/dist/2.x/vec2.js @@ -0,0 +1,91 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * + * Vec2 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new Vec2. In other words you can do this + * + * const v = vec2.cross(v1, v2); // Creates a new Vec2 with the cross product of v1 x v2. + * + * or + * + * const v = vec2.create(); + * vec2.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec2.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +export let VecType = Float32Array; +/** + * Sets the type this library creates for a Vec2 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec2 + */ +export function setDefaultType(ctor) { + const oldType = VecType; + VecType = ctor; + return oldType; +} +/** + * Creates a Vec2; may be called with x, y, z to set initial values. + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Vec2's specified type + * it would be faster to use + * + * ``` + * const v = vec2.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Vec2Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `vec2.create` is usually used + * to create a Vec2 to be filled out as in + * + * ``` + * const sum = vec2.create(); + * vec2.add(v1, v2, sum); + * ``` + * + * @param x - Initial x value. + * @param y - Initial y value. + * @returns the created vector + */ +export function create(x = 0, y = 0) { + const dst = new VecType(2); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + } + } + return dst; +} diff --git a/dist/2.x/vec3-impl.d.ts b/dist/2.x/vec3-impl.d.ts new file mode 100644 index 0000000..8455fd9 --- /dev/null +++ b/dist/2.x/vec3-impl.d.ts @@ -0,0 +1,445 @@ +import { Vec3, create, setDefaultType } from './vec3'; +import { Mat3 } from './mat3'; +import { Mat4 } from './mat4'; +import { Quat } from './quat'; +export default Vec3; +export { create, setDefaultType }; +/** + * Creates a vec3; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @returns the created vector + */ +export declare const fromValues: typeof create; +/** + * Sets the values of a Vec3 + * Also see {@link vec3.create} and {@link vec3.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +export declare function set(x: number, y: number, z: number, dst?: Vec3): Vec3; +/** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ +export declare function ceil(v: Vec3, dst?: Vec3): Vec3; +/** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ +export declare function floor(v: Vec3, dst?: Vec3): Vec3; +/** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ +export declare function round(v: Vec3, dst?: Vec3): Vec3; +/** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ +export declare function clamp(v: Vec3, min?: number, max?: number, dst?: Vec3): Vec3; +/** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ +export declare function add(a: Vec3, b: Vec3, dst?: Vec3): Vec3; +/** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ +export declare function addScaled(a: Vec3, b: Vec3, scale: number, dst?: Vec3): Vec3; +/** + * Returns the angle in radians between two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns The angle in radians between the 2 vectors. + */ +export declare function angle(a: Vec3, b: Vec3): number; +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export declare function subtract(a: Vec3, b: Vec3, dst?: Vec3): Vec3; +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export declare const sub: typeof subtract; +/** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ +export declare function equalsApproximately(a: Vec3, b: Vec3): boolean; +/** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ +export declare function equals(a: Vec3, b: Vec3): boolean; +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +export declare function lerp(a: Vec3, b: Vec3, t: number, dst?: Vec3): Vec3; +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ +export declare function lerpV(a: Vec3, b: Vec3, t: Vec3, dst?: Vec3): Vec3; +/** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ +export declare function max(a: Vec3, b: Vec3, dst?: Vec3): Vec3; +/** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ +export declare function min(a: Vec3, b: Vec3, dst?: Vec3): Vec3; +/** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export declare function mulScalar(v: Vec3, k: number, dst?: Vec3): Vec3; +/** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export declare const scale: typeof mulScalar; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export declare function divScalar(v: Vec3, k: number, dst?: Vec3): Vec3; +/** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export declare function inverse(v: Vec3, dst?: Vec3): Vec3; +/** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export declare const invert: typeof inverse; +/** + * Computes the cross product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of a cross b. + */ +export declare function cross(a: Vec3, b: Vec3, dst?: Vec3): Vec3; +/** + * Computes the dot product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ +export declare function dot(a: Vec3, b: Vec3): number; +/** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ +export declare function length(v: Vec3): number; +/** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ +export declare const len: typeof length; +/** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ +export declare function lengthSq(v: Vec3): number; +/** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ +export declare const lenSq: typeof lengthSq; +/** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export declare function distance(a: Vec3, b: Vec3): number; +/** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export declare const dist: typeof distance; +/** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export declare function distanceSq(a: Vec3, b: Vec3): number; +/** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export declare const distSq: typeof distanceSq; +/** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ +export declare function normalize(v: Vec3, dst?: Vec3): Vec3; +/** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ +export declare function negate(v: Vec3, dst?: Vec3): Vec3; +/** + * Copies a vector. (same as {@link vec3.clone}) + * Also see {@link vec3.create} and {@link vec3.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export declare function copy(v: Vec3, dst?: Vec3): Vec3; +/** + * Clones a vector. (same as {@link vec3.copy}) + * Also see {@link vec3.create} and {@link vec3.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export declare const clone: typeof copy; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export declare function multiply(a: Vec3, b: Vec3, dst?: Vec3): Vec3; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export declare const mul: typeof multiply; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export declare function divide(a: Vec3, b: Vec3, dst?: Vec3): Vec3; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export declare const div: typeof divide; +/** + * Creates a random vector + * @param scale - Default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The random vector. + */ +export declare function random(scale?: number, dst?: Vec3): Vec3; +/** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ +export declare function zero(dst?: Vec3): Vec3; +/** + * transform vec3 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export declare function transformMat4(v: Vec3, m: Mat4, dst?: Vec3): Vec3; +/** + * Transform vec4 by upper 3x3 matrix inside 4x4 matrix. + * @param v - The direction. + * @param m - The matrix. + * @param dst - optional Vec3 to store result. If not passed a new one is created. + * @returns The transformed vector. + */ +export declare function transformMat4Upper3x3(v: Vec3, m: Mat4, dst?: Vec3): Vec3; +/** + * Transforms vec3 by 3x3 matrix + * + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export declare function transformMat3(v: Vec3, m: Mat3, dst?: Vec3): Vec3; +/** + * Transforms vec3 by Quaternion + * @param v - the vector to transform + * @param q - the quaternion to transform by + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed + */ +export declare function transformQuat(v: Vec3, q: Quat, dst?: Vec3): Vec3; +/** + * Returns the translation component of a 4-by-4 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ +export declare function getTranslation(m: Mat3, dst?: Vec3): Vec3; +/** + * Returns an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @returns The axis component of m. + */ +export declare function getAxis(m: Mat4, axis: number, dst?: Vec3): Vec3; +/** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ +export declare function getScaling(m: Mat4, dst: Vec3): Vec3; +/** + * Rotate a 3D vector around the x-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns the rotated vector + */ +export declare function rotateX(a: Vec3, b: Vec3, rad: number, dst?: Vec3): Vec3; +/** + * Rotate a 3D vector around the y-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns the rotated vector + */ +export declare function rotateY(a: Vec3, b: Vec3, rad: number, dst?: Vec3): Vec3; +/** + * Rotate a 3D vector around the z-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns {vec3} out + */ +export declare function rotateZ(a: Vec3, b: Vec3, rad: number, dst?: Vec3): Vec3; +/** + * Treat a 3D vector as a direction and set it's length + * + * @param a The vec3 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ +export declare function setLength(a: Vec3, len: number, dst?: Vec3): Vec3; +/** + * Ensure a vector is not longer than a max length + * + * @param a The vec3 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ +export declare function truncate(a: Vec3, maxLen: number, dst?: Vec3): Vec3; +/** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ +export declare function midpoint(a: Vec3, b: Vec3, dst?: Vec3): Vec3; diff --git a/dist/2.x/vec3-impl.js b/dist/2.x/vec3-impl.js new file mode 100644 index 0000000..a312df4 --- /dev/null +++ b/dist/2.x/vec3-impl.js @@ -0,0 +1,793 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +import * as utils from './utils.js'; +import { create, setDefaultType, VecType } from './vec3'; +export { create, setDefaultType }; +/** + * Creates a vec3; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @returns the created vector + */ +export const fromValues = create; +/** + * Sets the values of a Vec3 + * Also see {@link vec3.create} and {@link vec3.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +export function set(x, y, z, dst) { + dst = dst || new VecType(3); + dst[0] = x; + dst[1] = y; + dst[2] = z; + return dst; +} +/** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ +export function ceil(v, dst) { + dst = dst || new VecType(3); + dst[0] = Math.ceil(v[0]); + dst[1] = Math.ceil(v[1]); + dst[2] = Math.ceil(v[2]); + return dst; +} +/** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ +export function floor(v, dst) { + dst = dst || new VecType(3); + dst[0] = Math.floor(v[0]); + dst[1] = Math.floor(v[1]); + dst[2] = Math.floor(v[2]); + return dst; +} +/** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ +export function round(v, dst) { + dst = dst || new VecType(3); + dst[0] = Math.round(v[0]); + dst[1] = Math.round(v[1]); + dst[2] = Math.round(v[2]); + return dst; +} +/** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ +export function clamp(v, min = 0, max = 1, dst) { + dst = dst || new VecType(3); + dst[0] = Math.min(max, Math.max(min, v[0])); + dst[1] = Math.min(max, Math.max(min, v[1])); + dst[2] = Math.min(max, Math.max(min, v[2])); + return dst; +} +/** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ +export function add(a, b, dst) { + dst = dst || new VecType(3); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + dst[2] = a[2] + b[2]; + return dst; +} +/** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ +export function addScaled(a, b, scale, dst) { + dst = dst || new VecType(3); + dst[0] = a[0] + b[0] * scale; + dst[1] = a[1] + b[1] * scale; + dst[2] = a[2] + b[2] * scale; + return dst; +} +/** + * Returns the angle in radians between two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns The angle in radians between the 2 vectors. + */ +export function angle(a, b) { + const ax = a[0]; + const ay = a[1]; + const az = a[2]; + const bx = b[0]; + const by = b[1]; + const bz = b[2]; + const mag1 = Math.sqrt(ax * ax + ay * ay + az * az); + const mag2 = Math.sqrt(bx * bx + by * by + bz * bz); + const mag = mag1 * mag2; + const cosine = mag && dot(a, b) / mag; + return Math.acos(cosine); +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export function subtract(a, b, dst) { + dst = dst || new VecType(3); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + dst[2] = a[2] - b[2]; + return dst; +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export const sub = subtract; +/** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ +export function equalsApproximately(a, b) { + return Math.abs(a[0] - b[0]) < utils.EPSILON && + Math.abs(a[1] - b[1]) < utils.EPSILON && + Math.abs(a[2] - b[2]) < utils.EPSILON; +} +/** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ +export function equals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +export function lerp(a, b, t, dst) { + dst = dst || new VecType(3); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + dst[2] = a[2] + t * (b[2] - a[2]); + return dst; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ +export function lerpV(a, b, t, dst) { + dst = dst || new VecType(3); + dst[0] = a[0] + t[0] * (b[0] - a[0]); + dst[1] = a[1] + t[1] * (b[1] - a[1]); + dst[2] = a[2] + t[2] * (b[2] - a[2]); + return dst; +} +/** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ +export function max(a, b, dst) { + dst = dst || new VecType(3); + dst[0] = Math.max(a[0], b[0]); + dst[1] = Math.max(a[1], b[1]); + dst[2] = Math.max(a[2], b[2]); + return dst; +} +/** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ +export function min(a, b, dst) { + dst = dst || new VecType(3); + dst[0] = Math.min(a[0], b[0]); + dst[1] = Math.min(a[1], b[1]); + dst[2] = Math.min(a[2], b[2]); + return dst; +} +/** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export function mulScalar(v, k, dst) { + dst = dst || new VecType(3); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + dst[2] = v[2] * k; + return dst; +} +/** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export const scale = mulScalar; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export function divScalar(v, k, dst) { + dst = dst || new VecType(3); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + dst[2] = v[2] / k; + return dst; +} +/** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export function inverse(v, dst) { + dst = dst || new VecType(3); + dst[0] = 1 / v[0]; + dst[1] = 1 / v[1]; + dst[2] = 1 / v[2]; + return dst; +} +/** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export const invert = inverse; +/** + * Computes the cross product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of a cross b. + */ +export function cross(a, b, dst) { + dst = dst || new VecType(3); + const t1 = a[2] * b[0] - a[0] * b[2]; + const t2 = a[0] * b[1] - a[1] * b[0]; + dst[0] = a[1] * b[2] - a[2] * b[1]; + dst[1] = t1; + dst[2] = t2; + return dst; +} +/** + * Computes the dot product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ +export function dot(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]); +} +/** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ +export function length(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2); +} +/** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ +export const len = length; +/** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ +export function lengthSq(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + return v0 * v0 + v1 * v1 + v2 * v2; +} +/** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ +export const lenSq = lengthSq; +/** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export function distance(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + return Math.sqrt(dx * dx + dy * dy + dz * dz); +} +/** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export const dist = distance; +/** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export function distanceSq(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + return dx * dx + dy * dy + dz * dz; +} +/** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export const distSq = distanceSq; +/** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ +export function normalize(v, dst) { + dst = dst || new VecType(3); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + dst[2] = v2 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + } + return dst; +} +/** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ +export function negate(v, dst) { + dst = dst || new VecType(3); + dst[0] = -v[0]; + dst[1] = -v[1]; + dst[2] = -v[2]; + return dst; +} +/** + * Copies a vector. (same as {@link vec3.clone}) + * Also see {@link vec3.create} and {@link vec3.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export function copy(v, dst) { + dst = dst || new VecType(3); + dst[0] = v[0]; + dst[1] = v[1]; + dst[2] = v[2]; + return dst; +} +/** + * Clones a vector. (same as {@link vec3.copy}) + * Also see {@link vec3.create} and {@link vec3.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export const clone = copy; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export function multiply(a, b, dst) { + dst = dst || new VecType(3); + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + dst[2] = a[2] * b[2]; + return dst; +} +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export const mul = multiply; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export function divide(a, b, dst) { + dst = dst || new VecType(3); + dst[0] = a[0] / b[0]; + dst[1] = a[1] / b[1]; + dst[2] = a[2] / b[2]; + return dst; +} +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export const div = divide; +/** + * Creates a random vector + * @param scale - Default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The random vector. + */ +export function random(scale = 1, dst) { + dst = dst || new VecType(3); + const angle = Math.random() * 2 * Math.PI; + const z = Math.random() * 2 - 1; + const zScale = Math.sqrt(1 - z * z) * scale; + dst[0] = Math.cos(angle) * zScale; + dst[1] = Math.sin(angle) * zScale; + dst[2] = z * scale; + return dst; +} +/** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ +export function zero(dst) { + dst = dst || new VecType(3); + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + return dst; +} +/** + * transform vec3 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export function transformMat4(v, m, dst) { + dst = dst || new VecType(3); + const x = v[0]; + const y = v[1]; + const z = v[2]; + const w = (m[3] * x + m[7] * y + m[11] * z + m[15]) || 1; + dst[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; + dst[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; + dst[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; + return dst; +} +/** + * Transform vec4 by upper 3x3 matrix inside 4x4 matrix. + * @param v - The direction. + * @param m - The matrix. + * @param dst - optional Vec3 to store result. If not passed a new one is created. + * @returns The transformed vector. + */ +export function transformMat4Upper3x3(v, m, dst) { + dst = dst || new VecType(3); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0]; + dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1]; + dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v2 * m[2 * 4 + 2]; + return dst; +} +/** + * Transforms vec3 by 3x3 matrix + * + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export function transformMat3(v, m, dst) { + dst = dst || new VecType(3); + const x = v[0]; + const y = v[1]; + const z = v[2]; + dst[0] = x * m[0] + y * m[4] + z * m[8]; + dst[1] = x * m[1] + y * m[5] + z * m[9]; + dst[2] = x * m[2] + y * m[6] + z * m[10]; + return dst; +} +/** + * Transforms vec3 by Quaternion + * @param v - the vector to transform + * @param q - the quaternion to transform by + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed + */ +export function transformQuat(v, q, dst) { + dst = dst || new VecType(3); + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const w2 = q[3] * 2; + const x = v[0]; + const y = v[1]; + const z = v[2]; + const uvX = qy * z - qz * y; + const uvY = qz * x - qx * z; + const uvZ = qx * y - qy * x; + dst[0] = x + uvX * w2 + (qy * uvZ - qz * uvY) * 2; + dst[1] = y + uvY * w2 + (qz * uvX - qx * uvZ) * 2; + dst[2] = z + uvZ * w2 + (qx * uvY - qy * uvX) * 2; + return dst; +} +/** + * Returns the translation component of a 4-by-4 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ +export function getTranslation(m, dst) { + dst = dst || new VecType(3); + dst[0] = m[12]; + dst[1] = m[13]; + dst[2] = m[14]; + return dst; +} +/** + * Returns an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @returns The axis component of m. + */ +export function getAxis(m, axis, dst) { + dst = dst || new VecType(3); + const off = axis * 4; + dst[0] = m[off + 0]; + dst[1] = m[off + 1]; + dst[2] = m[off + 2]; + return dst; +} +/** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ +export function getScaling(m, dst) { + dst = dst || new VecType(3); + const xx = m[0]; + const xy = m[1]; + const xz = m[2]; + const yx = m[4]; + const yy = m[5]; + const yz = m[6]; + const zx = m[8]; + const zy = m[9]; + const zz = m[10]; + dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz); + dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz); + dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz); + return dst; +} +/** + * Rotate a 3D vector around the x-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns the rotated vector + */ +export function rotateX(a, b, rad, dst) { + dst = dst || new VecType(3); + const p = []; + const r = []; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + //perform rotation + r[0] = p[0]; + r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad); + r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); + //translate to correct position + dst[0] = r[0] + b[0]; + dst[1] = r[1] + b[1]; + dst[2] = r[2] + b[2]; + return dst; +} +/** + * Rotate a 3D vector around the y-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns the rotated vector + */ +export function rotateY(a, b, rad, dst) { + dst = dst || new VecType(3); + const p = []; + const r = []; + // translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + // perform rotation + r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad); + r[1] = p[1]; + r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); + // translate to correct position + dst[0] = r[0] + b[0]; + dst[1] = r[1] + b[1]; + dst[2] = r[2] + b[2]; + return dst; +} +/** + * Rotate a 3D vector around the z-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns {vec3} out + */ +export function rotateZ(a, b, rad, dst) { + dst = dst || new VecType(3); + const p = []; + const r = []; + // translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + // perform rotation + r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad); + r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad); + r[2] = p[2]; + // translate to correct position + dst[0] = r[0] + b[0]; + dst[1] = r[1] + b[1]; + dst[2] = r[2] + b[2]; + return dst; +} +/** + * Treat a 3D vector as a direction and set it's length + * + * @param a The vec3 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ +export function setLength(a, len, dst) { + dst = dst || new VecType(3); + normalize(a, dst); + return mulScalar(dst, len, dst); +} +/** + * Ensure a vector is not longer than a max length + * + * @param a The vec3 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ +export function truncate(a, maxLen, dst) { + dst = dst || new VecType(3); + if (length(a) > maxLen) { + return setLength(a, maxLen, dst); + } + return copy(a, dst); +} +/** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ +export function midpoint(a, b, dst) { + dst = dst || new VecType(3); + return lerp(a, b, 0.5, dst); +} diff --git a/dist/2.x/vec3.d.ts b/dist/2.x/vec3.d.ts new file mode 100644 index 0000000..7d21ca3 --- /dev/null +++ b/dist/2.x/vec3.d.ts @@ -0,0 +1,43 @@ +/** + * A JavaScript array with 3 values, Float32Array with 3 values, or a Float64Array with 3 values. + * When created by the library will create the default type which is `Float32Array` + * but can be set by calling {@link vec3.setDefaultType}. + */ +export type Vec3 = number[] | Float32Array | Float64Array; +/** + * + * Vec3 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Vec3`. In other words you can do this + * + * const v = vec3.cross(v1, v2); // Creates a new Vec3 with the cross product of v1 x v2. + * + * or + * + * const v = vec3.create(); + * vec3.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec3.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +export declare let VecType: new (n: number) => Vec3; +/** + * Sets the type this library creates for a Vec3 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec3 + */ +export declare function setDefaultType(ctor: new (n: number) => Vec3): new (n: number) => Vec3; +/** + * Creates a vec3; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @returns the created vector + */ +export declare function create(x?: number, y?: number, z?: number): Vec3; diff --git a/dist/2.x/vec3.js b/dist/2.x/vec3.js new file mode 100644 index 0000000..e1d988e --- /dev/null +++ b/dist/2.x/vec3.js @@ -0,0 +1,74 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * + * Vec3 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Vec3`. In other words you can do this + * + * const v = vec3.cross(v1, v2); // Creates a new Vec3 with the cross product of v1 x v2. + * + * or + * + * const v = vec3.create(); + * vec3.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec3.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +export let VecType = Float32Array; +/** + * Sets the type this library creates for a Vec3 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec3 + */ +export function setDefaultType(ctor) { + const oldType = VecType; + VecType = ctor; + return oldType; +} +/** + * Creates a vec3; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @returns the created vector + */ +export function create(x, y, z) { + const dst = new VecType(3); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + if (z !== undefined) { + dst[2] = z; + } + } + } + return dst; +} diff --git a/dist/2.x/vec4-impl.d.ts b/dist/2.x/vec4-impl.d.ts new file mode 100644 index 0000000..e6df561 --- /dev/null +++ b/dist/2.x/vec4-impl.d.ts @@ -0,0 +1,345 @@ +import { Vec4, create, setDefaultType } from './vec4'; +import { Mat4 } from './mat4'; +export default Vec4; +export { create, setDefaultType }; +/** + * Creates a vec4; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param z - Initial w value. + * @returns the created vector + */ +export declare const fromValues: typeof create; +/** + * Sets the values of a Vec4 + * Also see {@link vec4.create} and {@link vec4.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param w fourth value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +export declare function set(x: number, y: number, z: number, w: number, dst?: Vec4): Vec4; +/** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ +export declare function ceil(v: Vec4, dst?: Vec4): Vec4; +/** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ +export declare function floor(v: Vec4, dst?: Vec4): Vec4; +/** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ +export declare function round(v: Vec4, dst?: Vec4): Vec4; +/** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ +export declare function clamp(v: Vec4, min?: number, max?: number, dst?: Vec4): Vec4; +/** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ +export declare function add(a: Vec4, b: Vec4, dst?: Vec4): Vec4; +/** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ +export declare function addScaled(a: Vec4, b: Vec4, scale: number, dst?: Vec4): Vec4; +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export declare function subtract(a: Vec4, b: Vec4, dst?: Vec4): Vec4; +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export declare const sub: typeof subtract; +/** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ +export declare function equalsApproximately(a: Vec4, b: Vec4): boolean; +/** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ +export declare function equals(a: Vec4, b: Vec4): boolean; +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +export declare function lerp(a: Vec4, b: Vec4, t: number, dst?: Vec4): Vec4; +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ +export declare function lerpV(a: Vec4, b: Vec4, t: Vec4, dst?: Vec4): Vec4; +/** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ +export declare function max(a: Vec4, b: Vec4, dst?: Vec4): Vec4; +/** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ +export declare function min(a: Vec4, b: Vec4, dst?: Vec4): Vec4; +/** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export declare function mulScalar(v: Vec4, k: number, dst?: Vec4): Vec4; +/** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export declare const scale: typeof mulScalar; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export declare function divScalar(v: Vec4, k: number, dst?: Vec4): Vec4; +/** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export declare function inverse(v: Vec4, dst?: Vec4): Vec4; +/** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export declare const invert: typeof inverse; +/** + * Computes the dot product of two vectors + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ +export declare function dot(a: Vec4, b: Vec4): number; +/** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ +export declare function length(v: Vec4): number; +/** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ +export declare const len: typeof length; +/** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ +export declare function lengthSq(v: Vec4): number; +/** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ +export declare const lenSq: typeof lengthSq; +/** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export declare function distance(a: Vec4, b: Vec4): number; +/** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export declare const dist: typeof distance; +/** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export declare function distanceSq(a: Vec4, b: Vec4): number; +/** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export declare const distSq: typeof distanceSq; +/** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ +export declare function normalize(v: Vec4, dst?: Vec4): Vec4; +/** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ +export declare function negate(v: Vec4, dst?: Vec4): Vec4; +/** + * Copies a vector. (same as {@link vec4.clone}) + * Also see {@link vec4.create} and {@link vec4.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export declare function copy(v: Vec4, dst?: Vec4): Vec4; +/** + * Clones a vector. (same as {@link vec4.copy}) + * Also see {@link vec4.create} and {@link vec4.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export declare const clone: typeof copy; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export declare function multiply(a: Vec4, b: Vec4, dst?: Vec4): Vec4; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export declare const mul: typeof multiply; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export declare function divide(a: Vec4, b: Vec4, dst?: Vec4): Vec4; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export declare const div: typeof divide; +/** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ +export declare function zero(dst?: Vec4): Vec4; +/** + * transform vec4 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec4 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export declare function transformMat4(v: Vec4, m: Mat4, dst?: Vec4): Vec4; +/** + * Treat a 4D vector as a direction and set it's length + * + * @param a The vec4 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ +export declare function setLength(a: Vec4, len: number, dst?: Vec4): Vec4; +/** + * Ensure a vector is not longer than a max length + * + * @param a The vec4 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ +export declare function truncate(a: Vec4, maxLen: number, dst?: Vec4): Vec4; +/** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ +export declare function midpoint(a: Vec4, b: Vec4, dst?: Vec4): Vec4; diff --git a/dist/2.x/vec4-impl.js b/dist/2.x/vec4-impl.js new file mode 100644 index 0000000..23b1481 --- /dev/null +++ b/dist/2.x/vec4-impl.js @@ -0,0 +1,582 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +import * as utils from './utils.js'; +import { create, setDefaultType, VecType } from './vec4'; +export { create, setDefaultType }; +/** + * Creates a vec4; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param z - Initial w value. + * @returns the created vector + */ +export const fromValues = create; +/** + * Sets the values of a Vec4 + * Also see {@link vec4.create} and {@link vec4.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param w fourth value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +export function set(x, y, z, w, dst) { + dst = dst || new VecType(4); + dst[0] = x; + dst[1] = y; + dst[2] = z; + dst[3] = w; + return dst; +} +/** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ +export function ceil(v, dst) { + dst = dst || new VecType(4); + dst[0] = Math.ceil(v[0]); + dst[1] = Math.ceil(v[1]); + dst[2] = Math.ceil(v[2]); + dst[3] = Math.ceil(v[3]); + return dst; +} +/** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ +export function floor(v, dst) { + dst = dst || new VecType(4); + dst[0] = Math.floor(v[0]); + dst[1] = Math.floor(v[1]); + dst[2] = Math.floor(v[2]); + dst[3] = Math.floor(v[3]); + return dst; +} +/** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ +export function round(v, dst) { + dst = dst || new VecType(4); + dst[0] = Math.round(v[0]); + dst[1] = Math.round(v[1]); + dst[2] = Math.round(v[2]); + dst[3] = Math.round(v[3]); + return dst; +} +/** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ +export function clamp(v, min = 0, max = 1, dst) { + dst = dst || new VecType(4); + dst[0] = Math.min(max, Math.max(min, v[0])); + dst[1] = Math.min(max, Math.max(min, v[1])); + dst[2] = Math.min(max, Math.max(min, v[2])); + dst[3] = Math.min(max, Math.max(min, v[3])); + return dst; +} +/** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ +export function add(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + dst[2] = a[2] + b[2]; + dst[3] = a[3] + b[3]; + return dst; +} +/** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ +export function addScaled(a, b, scale, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + b[0] * scale; + dst[1] = a[1] + b[1] * scale; + dst[2] = a[2] + b[2] * scale; + dst[3] = a[3] + b[3] * scale; + return dst; +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export function subtract(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + dst[2] = a[2] - b[2]; + dst[3] = a[3] - b[3]; + return dst; +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +export const sub = subtract; +/** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ +export function equalsApproximately(a, b) { + return Math.abs(a[0] - b[0]) < utils.EPSILON && + Math.abs(a[1] - b[1]) < utils.EPSILON && + Math.abs(a[2] - b[2]) < utils.EPSILON && + Math.abs(a[3] - b[3]) < utils.EPSILON; +} +/** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ +export function equals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +export function lerp(a, b, t, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + dst[2] = a[2] + t * (b[2] - a[2]); + dst[3] = a[3] + t * (b[3] - a[3]); + return dst; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ +export function lerpV(a, b, t, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + t[0] * (b[0] - a[0]); + dst[1] = a[1] + t[1] * (b[1] - a[1]); + dst[2] = a[2] + t[2] * (b[2] - a[2]); + dst[3] = a[3] + t[3] * (b[3] - a[3]); + return dst; +} +/** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ +export function max(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = Math.max(a[0], b[0]); + dst[1] = Math.max(a[1], b[1]); + dst[2] = Math.max(a[2], b[2]); + dst[3] = Math.max(a[3], b[3]); + return dst; +} +/** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ +export function min(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = Math.min(a[0], b[0]); + dst[1] = Math.min(a[1], b[1]); + dst[2] = Math.min(a[2], b[2]); + dst[3] = Math.min(a[3], b[3]); + return dst; +} +/** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export function mulScalar(v, k, dst) { + dst = dst || new VecType(4); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + dst[2] = v[2] * k; + dst[3] = v[3] * k; + return dst; +} +/** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export const scale = mulScalar; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +export function divScalar(v, k, dst) { + dst = dst || new VecType(4); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + dst[2] = v[2] / k; + dst[3] = v[3] / k; + return dst; +} +/** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export function inverse(v, dst) { + dst = dst || new VecType(4); + dst[0] = 1 / v[0]; + dst[1] = 1 / v[1]; + dst[2] = 1 / v[2]; + dst[3] = 1 / v[3]; + return dst; +} +/** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +export const invert = inverse; +/** + * Computes the dot product of two vectors + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ +export function dot(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]); +} +/** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ +export function length(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); +} +/** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ +export const len = length; +/** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ +export function lengthSq(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3; +} +/** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ +export const lenSq = lengthSq; +/** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export function distance(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + const dw = a[3] - b[3]; + return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); +} +/** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +export const dist = distance; +/** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export function distanceSq(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + const dw = a[3] - b[3]; + return dx * dx + dy * dy + dz * dz + dw * dw; +} +/** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +export const distSq = distanceSq; +/** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ +export function normalize(v, dst) { + dst = dst || new VecType(4); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + dst[2] = v2 / len; + dst[3] = v3 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + } + return dst; +} +/** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ +export function negate(v, dst) { + dst = dst || new VecType(4); + dst[0] = -v[0]; + dst[1] = -v[1]; + dst[2] = -v[2]; + dst[3] = -v[3]; + return dst; +} +/** + * Copies a vector. (same as {@link vec4.clone}) + * Also see {@link vec4.create} and {@link vec4.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export function copy(v, dst) { + dst = dst || new VecType(4); + dst[0] = v[0]; + dst[1] = v[1]; + dst[2] = v[2]; + dst[3] = v[3]; + return dst; +} +/** + * Clones a vector. (same as {@link vec4.copy}) + * Also see {@link vec4.create} and {@link vec4.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +export const clone = copy; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export function multiply(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + dst[2] = a[2] * b[2]; + dst[3] = a[3] * b[3]; + return dst; +} +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +export const mul = multiply; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export function divide(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] / b[0]; + dst[1] = a[1] / b[1]; + dst[2] = a[2] / b[2]; + dst[3] = a[3] / b[3]; + return dst; +} +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +export const div = divide; +/** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ +export function zero(dst) { + dst = dst || new VecType(4); + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + return dst; +} +/** + * transform vec4 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec4 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +export function transformMat4(v, m, dst) { + dst = dst || new VecType(4); + const x = v[0]; + const y = v[1]; + const z = v[2]; + const w = v[3]; + dst[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + dst[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + dst[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + dst[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + return dst; +} +/** + * Treat a 4D vector as a direction and set it's length + * + * @param a The vec4 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ +export function setLength(a, len, dst) { + dst = dst || new VecType(4); + normalize(a, dst); + return mulScalar(dst, len, dst); +} +/** + * Ensure a vector is not longer than a max length + * + * @param a The vec4 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ +export function truncate(a, maxLen, dst) { + dst = dst || new VecType(4); + if (length(a) > maxLen) { + return setLength(a, maxLen, dst); + } + return copy(a, dst); +} +/** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ +export function midpoint(a, b, dst) { + dst = dst || new VecType(4); + return lerp(a, b, 0.5, dst); +} diff --git a/dist/2.x/vec4.d.ts b/dist/2.x/vec4.d.ts new file mode 100644 index 0000000..09a3f29 --- /dev/null +++ b/dist/2.x/vec4.d.ts @@ -0,0 +1,44 @@ +/** + * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values. + * When created by the library will create the default type which is `Float32Array` + * but can be set by calling {@link vec4.setDefaultType}. + */ +export type Vec4 = number[] | Float32Array | Float64Array; +/** + * + * Vec4 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Vec4`. In other words you can do this + * + * const v = vec4.cross(v1, v2); // Creates a new Vec4 with the cross product of v1 x v2. + * + * or + * + * const v = vec4.create(); + * vec4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +export declare let VecType: new (n: number) => Vec4; +/** + * Sets the type this library creates for a Vec4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec4 + */ +export declare function setDefaultType(ctor: new (n: number) => Vec4): new (n: number) => Vec4; +/** + * Creates a vec4; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param w - Initial w value. + * @returns the created vector + */ +export declare function create(x?: number, y?: number, z?: number, w?: number): Vec4; diff --git a/dist/2.x/vec4.js b/dist/2.x/vec4.js new file mode 100644 index 0000000..24e4839 --- /dev/null +++ b/dist/2.x/vec4.js @@ -0,0 +1,78 @@ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * + * Vec4 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Vec4`. In other words you can do this + * + * const v = vec4.cross(v1, v2); // Creates a new Vec4 with the cross product of v1 x v2. + * + * or + * + * const v = vec4.create(); + * vec4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +export let VecType = Float32Array; +/** + * Sets the type this library creates for a Vec4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec4 + */ +export function setDefaultType(ctor) { + const oldType = VecType; + VecType = ctor; + return oldType; +} +/** + * Creates a vec4; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param w - Initial w value. + * @returns the created vector + */ +export function create(x, y, z, w) { + const dst = new VecType(4); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + if (z !== undefined) { + dst[2] = z; + if (w !== undefined) { + dst[3] = w; + } + } + } + } + return dst; +} diff --git a/dist/2.x/wgpu-matrix.d.ts b/dist/2.x/wgpu-matrix.d.ts new file mode 100644 index 0000000..1eea4c0 --- /dev/null +++ b/dist/2.x/wgpu-matrix.d.ts @@ -0,0 +1,20 @@ +import Mat3, * as mat3 from './mat3-impl'; +import Mat4, * as mat4 from './mat4-impl'; +import Quat, * as quat from './quat-impl'; +import Vec2, * as vec2 from './vec2-impl'; +import Vec3, * as vec3 from './vec3-impl'; +import Vec4, * as vec4 from './vec4-impl'; +import * as utils from './utils'; +/** + * Sets the type this library creates for all types + * + * example: + * + * ``` + * setDefaultType(Float64Array); + * ``` + * + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + */ +export declare function setDefaultType(ctor: new (n: number) => Float32Array | Float64Array | number[]): void; +export { Mat3, mat3, Mat4, mat4, Quat, quat, utils, Vec2, vec2, Vec3, vec3, Vec4, vec4, }; diff --git a/dist/2.x/wgpu-matrix.js b/dist/2.x/wgpu-matrix.js new file mode 100644 index 0000000..54a0628 --- /dev/null +++ b/dist/2.x/wgpu-matrix.js @@ -0,0 +1,5773 @@ +/* wgpu-matrix@2.9.1, license MIT */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.wgpuMatrix = {})); +})(this, (function (exports) { 'use strict'; + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + let EPSILON = 0.000001; + /** + * Set the value for EPSILON for various checks + * @param v - Value to use for EPSILON. + * @returns previous value of EPSILON; + */ + function setEpsilon(v) { + const old = EPSILON; + EPSILON = v; + return old; + } + /** + * Convert degrees to radians + * @param degrees - Angle in degrees + * @returns angle converted to radians + */ + function degToRad(degrees) { + return degrees * Math.PI / 180; + } + /** + * Convert radians to degrees + * @param radians - Angle in radians + * @returns angle converted to degrees + */ + function radToDeg(radians) { + return radians * 180 / Math.PI; + } + /** + * Lerps between a and b via t + * @param a - starting value + * @param b - ending value + * @param t - value where 0 = a and 1 = b + * @returns a + (b - a) * t + */ + function lerp$4(a, b, t) { + return a + (b - a) * t; + } + /** + * Compute the opposite of lerp. Given a and b and a value between + * a and b returns a value between 0 and 1. 0 if a, 1 if b. + * Note: no clamping is done. + * @param a - start value + * @param b - end value + * @param v - value between a and b + * @returns (v - a) / (b - a) + */ + function inverseLerp(a, b, v) { + const d = b - a; + return (Math.abs(b - a) < EPSILON) + ? a + : (v - a) / d; + } + /** + * Compute the euclidean modulo + * + * ``` + * // table for n / 3 + * -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 <- n + * ------------------------------------ + * -2 -1 -0 -2 -1 0, 1, 2, 0, 1, 2 <- n % 3 + * 1 2 0 1 2 0, 1, 2, 0, 1, 2 <- euclideanModule(n, 3) + * ``` + * + * @param n - dividend + * @param m - divisor + * @returns the euclidean modulo of n / m + */ + function euclideanModulo(n, m) { + return ((n % m) + m) % m; + } + + var utils = { + __proto__: null, + get EPSILON () { return EPSILON; }, + degToRad: degToRad, + euclideanModulo: euclideanModulo, + inverseLerp: inverseLerp, + lerp: lerp$4, + radToDeg: radToDeg, + setEpsilon: setEpsilon + }; + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + /** + * + * Vec2 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new Vec2. In other words you can do this + * + * const v = vec2.cross(v1, v2); // Creates a new Vec2 with the cross product of v1 x v2. + * + * or + * + * const v = vec2.create(); + * vec2.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec2.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ + let VecType$2 = Float32Array; + /** + * Sets the type this library creates for a Vec2 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec2 + */ + function setDefaultType$6(ctor) { + const oldType = VecType$2; + VecType$2 = ctor; + return oldType; + } + /** + * Creates a Vec2; may be called with x, y, z to set initial values. + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Vec2's specified type + * it would be faster to use + * + * ``` + * const v = vec2.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Vec2Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `vec2.create` is usually used + * to create a Vec2 to be filled out as in + * + * ``` + * const sum = vec2.create(); + * vec2.add(v1, v2, sum); + * ``` + * + * @param x - Initial x value. + * @param y - Initial y value. + * @returns the created vector + */ + function create$5(x = 0, y = 0) { + const dst = new VecType$2(2); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + } + } + return dst; + } + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + /** + * + * Vec3 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Vec3`. In other words you can do this + * + * const v = vec3.cross(v1, v2); // Creates a new Vec3 with the cross product of v1 x v2. + * + * or + * + * const v = vec3.create(); + * vec3.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec3.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ + let VecType$1 = Float32Array; + /** + * Sets the type this library creates for a Vec3 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec3 + */ + function setDefaultType$5(ctor) { + const oldType = VecType$1; + VecType$1 = ctor; + return oldType; + } + /** + * Creates a vec3; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @returns the created vector + */ + function create$4(x, y, z) { + const dst = new VecType$1(3); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + if (z !== undefined) { + dst[2] = z; + } + } + } + return dst; + } + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + /** + * Creates a Vec2; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @returns the created vector + */ + const fromValues$3 = create$5; + /** + * Sets the values of a Vec2 + * Also see {@link vec2.create} and {@link vec2.copy} + * + * @param x first value + * @param y second value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ + function set$5(x, y, dst) { + dst = dst || new VecType$2(2); + dst[0] = x; + dst[1] = y; + return dst; + } + /** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ + function ceil$2(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.ceil(v[0]); + dst[1] = Math.ceil(v[1]); + return dst; + } + /** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ + function floor$2(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.floor(v[0]); + dst[1] = Math.floor(v[1]); + return dst; + } + /** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ + function round$2(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.round(v[0]); + dst[1] = Math.round(v[1]); + return dst; + } + /** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ + function clamp$2(v, min = 0, max = 1, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.min(max, Math.max(min, v[0])); + dst[1] = Math.min(max, Math.max(min, v[1])); + return dst; + } + /** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ + function add$3(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + return dst; + } + /** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ + function addScaled$2(a, b, scale, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] + b[0] * scale; + dst[1] = a[1] + b[1] * scale; + return dst; + } + /** + * Returns the angle in radians between two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns The angle in radians between the 2 vectors. + */ + function angle$2(a, b) { + const ax = a[0]; + const ay = a[1]; + const bx = b[0]; + const by = b[1]; + const mag1 = Math.sqrt(ax * ax + ay * ay); + const mag2 = Math.sqrt(bx * bx + by * by); + const mag = mag1 * mag2; + const cosine = mag && dot$3(a, b) / mag; + return Math.acos(cosine); + } + /** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ + function subtract$3(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + return dst; + } + /** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ + const sub$3 = subtract$3; + /** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ + function equalsApproximately$5(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON; + } + /** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ + function equals$5(a, b) { + return a[0] === b[0] && a[1] === b[1]; + } + /** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ + function lerp$3(a, b, t, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + return dst; + } + /** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ + function lerpV$2(a, b, t, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] + t[0] * (b[0] - a[0]); + dst[1] = a[1] + t[1] * (b[1] - a[1]); + return dst; + } + /** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ + function max$2(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.max(a[0], b[0]); + dst[1] = Math.max(a[1], b[1]); + return dst; + } + /** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ + function min$2(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.min(a[0], b[0]); + dst[1] = Math.min(a[1], b[1]); + return dst; + } + /** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ + function mulScalar$3(v, k, dst) { + dst = dst || new VecType$2(2); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + return dst; + } + /** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ + const scale$5 = mulScalar$3; + /** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ + function divScalar$3(v, k, dst) { + dst = dst || new VecType$2(2); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + return dst; + } + /** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ + function inverse$5(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = 1 / v[0]; + dst[1] = 1 / v[1]; + return dst; + } + /** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ + const invert$4 = inverse$5; + /** + * Computes the cross product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of a cross b. + */ + function cross$1(a, b, dst) { + dst = dst || new VecType$1(3); + const z = a[0] * b[1] - a[1] * b[0]; + dst[0] = 0; + dst[1] = 0; + dst[2] = z; + return dst; + } + /** + * Computes the dot product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ + function dot$3(a, b) { + return a[0] * b[0] + a[1] * b[1]; + } + /** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ + function length$3(v) { + const v0 = v[0]; + const v1 = v[1]; + return Math.sqrt(v0 * v0 + v1 * v1); + } + /** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ + const len$3 = length$3; + /** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ + function lengthSq$3(v) { + const v0 = v[0]; + const v1 = v[1]; + return v0 * v0 + v1 * v1; + } + /** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ + const lenSq$3 = lengthSq$3; + /** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ + function distance$2(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + return Math.sqrt(dx * dx + dy * dy); + } + /** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ + const dist$2 = distance$2; + /** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ + function distanceSq$2(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + return dx * dx + dy * dy; + } + /** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ + const distSq$2 = distanceSq$2; + /** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ + function normalize$3(v, dst) { + dst = dst || new VecType$2(2); + const v0 = v[0]; + const v1 = v[1]; + const len = Math.sqrt(v0 * v0 + v1 * v1); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + } + return dst; + } + /** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ + function negate$4(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = -v[0]; + dst[1] = -v[1]; + return dst; + } + /** + * Copies a vector. (same as {@link vec2.clone}) + * Also see {@link vec2.create} and {@link vec2.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ + function copy$5(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = v[0]; + dst[1] = v[1]; + return dst; + } + /** + * Clones a vector. (same as {@link vec2.copy}) + * Also see {@link vec2.create} and {@link vec2.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ + const clone$5 = copy$5; + /** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ + function multiply$5(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + return dst; + } + /** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ + const mul$5 = multiply$5; + /** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ + function divide$2(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] / b[0]; + dst[1] = a[1] / b[1]; + return dst; + } + /** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ + const div$2 = divide$2; + /** + * Creates a random unit vector * scale + * @param scale - Default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The random vector. + */ + function random$1(scale = 1, dst) { + dst = dst || new VecType$2(2); + const angle = Math.random() * 2 * Math.PI; + dst[0] = Math.cos(angle) * scale; + dst[1] = Math.sin(angle) * scale; + return dst; + } + /** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ + function zero$2(dst) { + dst = dst || new VecType$2(2); + dst[0] = 0; + dst[1] = 0; + return dst; + } + /** + * transform Vec2 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional Vec2 to store result. If not passed a new one is created. + * @returns the transformed vector + */ + function transformMat4$2(v, m, dst) { + dst = dst || new VecType$2(2); + const x = v[0]; + const y = v[1]; + dst[0] = x * m[0] + y * m[4] + m[12]; + dst[1] = x * m[1] + y * m[5] + m[13]; + return dst; + } + /** + * Transforms vec4 by 3x3 matrix + * + * @param v - the vector + * @param m - The matrix. + * @param dst - optional Vec2 to store result. If not passed a new one is created. + * @returns the transformed vector + */ + function transformMat3$1(v, m, dst) { + dst = dst || new VecType$2(2); + const x = v[0]; + const y = v[1]; + dst[0] = m[0] * x + m[4] * y + m[8]; + dst[1] = m[1] * x + m[5] * y + m[9]; + return dst; + } + /** + * Rotate a 2D vector + * + * @param a The vec2 point to rotate + * @param b The origin of the rotation + * @param rad The angle of rotation in radians + * @returns the rotated vector + */ + function rotate$2(a, b, rad, dst) { + dst = dst || new VecType$2(2); + // Translate point to the origin + const p0 = a[0] - b[0]; + const p1 = a[1] - b[1]; + const sinC = Math.sin(rad); + const cosC = Math.cos(rad); + //perform rotation and translate to correct position + dst[0] = p0 * cosC - p1 * sinC + b[0]; + dst[1] = p0 * sinC + p1 * cosC + b[1]; + return dst; + } + /** + * Treat a 2D vector as a direction and set it's length + * + * @param a The vec2 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ + function setLength$2(a, len, dst) { + dst = dst || new VecType$2(2); + normalize$3(a, dst); + return mulScalar$3(dst, len, dst); + } + /** + * Ensure a vector is not longer than a max length + * + * @param a The vec2 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ + function truncate$2(a, maxLen, dst) { + dst = dst || new VecType$2(2); + if (length$3(a) > maxLen) { + return setLength$2(a, maxLen, dst); + } + return copy$5(a, dst); + } + /** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ + function midpoint$2(a, b, dst) { + dst = dst || new VecType$2(2); + return lerp$3(a, b, 0.5, dst); + } + + var vec2Impl = { + __proto__: null, + add: add$3, + addScaled: addScaled$2, + angle: angle$2, + ceil: ceil$2, + clamp: clamp$2, + clone: clone$5, + copy: copy$5, + create: create$5, + cross: cross$1, + dist: dist$2, + distSq: distSq$2, + distance: distance$2, + distanceSq: distanceSq$2, + div: div$2, + divScalar: divScalar$3, + divide: divide$2, + dot: dot$3, + equals: equals$5, + equalsApproximately: equalsApproximately$5, + floor: floor$2, + fromValues: fromValues$3, + inverse: inverse$5, + invert: invert$4, + len: len$3, + lenSq: lenSq$3, + length: length$3, + lengthSq: lengthSq$3, + lerp: lerp$3, + lerpV: lerpV$2, + max: max$2, + midpoint: midpoint$2, + min: min$2, + mul: mul$5, + mulScalar: mulScalar$3, + multiply: multiply$5, + negate: negate$4, + normalize: normalize$3, + random: random$1, + rotate: rotate$2, + round: round$2, + scale: scale$5, + set: set$5, + setDefaultType: setDefaultType$6, + setLength: setLength$2, + sub: sub$3, + subtract: subtract$3, + transformMat3: transformMat3$1, + transformMat4: transformMat4$2, + truncate: truncate$2, + zero: zero$2 + }; + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + /** + * 3x3 Matrix math math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new matrix. In other words you can do this + * + * const mat = mat3.translation([1, 2, 3]); // Creates a new translation matrix + * + * or + * + * const mat = mat3.create(); + * mat3.translation([1, 2, 3], mat); // Puts translation matrix in mat. + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always save to pass any matrix as the destination. So for example + * + * const mat = mat3.identity(); + * const trans = mat3.translation([1, 2, 3]); + * mat3.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat. + * + */ + let MatType$1 = Float32Array; + // This mess is because with Mat3 we have 3 unused elements. + // For Float32Array and Float64Array that's not an issue + // but for Array it's troublesome + const ctorMap = new Map([ + [Float32Array, () => new Float32Array(12)], + [Float64Array, () => new Float64Array(12)], + [Array, () => new Array(12).fill(0)], + ]); + let newMat3 = ctorMap.get(Float32Array); + /** + * Sets the type this library creates for a Mat3 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Mat3 + */ + function setDefaultType$4(ctor) { + const oldType = MatType$1; + MatType$1 = ctor; + newMat3 = ctorMap.get(ctor); + return oldType; + } + /** + * Create a Mat3 from values + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Mat3's specified type + * it would be faster to use + * + * ``` + * const m = mat3.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Mat3Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `mat3.create` is usually used + * to create a Mat3 to be filled out as in + * + * ``` + * const m = mat3.create(); + * mat3.perspective(fov, aspect, near, far, m); + * ``` + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @returns matrix created from values. + */ + function create$3(v0, v1, v2, v3, v4, v5, v6, v7, v8) { + const dst = newMat3(); + // to make the array homogenous + dst[3] = 0; + dst[7] = 0; + dst[11] = 0; + if (v0 !== undefined) { + dst[0] = v0; + if (v1 !== undefined) { + dst[1] = v1; + if (v2 !== undefined) { + dst[2] = v2; + if (v3 !== undefined) { + dst[4] = v3; + if (v4 !== undefined) { + dst[5] = v4; + if (v5 !== undefined) { + dst[6] = v5; + if (v6 !== undefined) { + dst[8] = v6; + if (v7 !== undefined) { + dst[9] = v7; + if (v8 !== undefined) { + dst[10] = v8; + } + } + } + } + } + } + } + } + } + return dst; + } + /** + * Sets the values of a Mat3 + * Also see {@link mat3.create} and {@link mat3.copy} + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 set from values. + */ + function set$4(v0, v1, v2, v3, v4, v5, v6, v7, v8, dst) { + dst = dst || newMat3(); + dst[0] = v0; + dst[1] = v1; + dst[2] = v2; + dst[3] = 0; + dst[4] = v3; + dst[5] = v4; + dst[6] = v5; + dst[7] = 0; + dst[8] = v6; + dst[9] = v7; + dst[10] = v8; + dst[11] = 0; + return dst; + } + /** + * Creates a Mat3 from the upper left 3x3 part of a Mat4 + * @param m4 - source matrix + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 made from m4 + */ + function fromMat4(m4, dst) { + dst = dst || newMat3(); + dst[0] = m4[0]; + dst[1] = m4[1]; + dst[2] = m4[2]; + dst[3] = 0; + dst[4] = m4[4]; + dst[5] = m4[5]; + dst[6] = m4[6]; + dst[7] = 0; + dst[8] = m4[8]; + dst[9] = m4[9]; + dst[10] = m4[10]; + dst[11] = 0; + return dst; + } + /** + * Creates a Mat3 rotation matrix from a quaternion + * @param q - quaternion to create matrix from + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 made from q + */ + function fromQuat$1(q, dst) { + dst = dst || newMat3(); + const x = q[0]; + const y = q[1]; + const z = q[2]; + const w = q[3]; + const x2 = x + x; + const y2 = y + y; + const z2 = z + z; + const xx = x * x2; + const yx = y * x2; + const yy = y * y2; + const zx = z * x2; + const zy = z * y2; + const zz = z * z2; + const wx = w * x2; + const wy = w * y2; + const wz = w * z2; + dst[0] = 1 - yy - zz; + dst[1] = yx + wz; + dst[2] = zx - wy; + dst[3] = 0; + dst[4] = yx - wz; + dst[5] = 1 - xx - zz; + dst[6] = zy + wx; + dst[7] = 0; + dst[8] = zx + wy; + dst[9] = zy - wx; + dst[10] = 1 - xx - yy; + dst[11] = 0; + return dst; + } + /** + * Negates a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns -m. + */ + function negate$3(m, dst) { + dst = dst || newMat3(); + dst[0] = -m[0]; + dst[1] = -m[1]; + dst[2] = -m[2]; + dst[4] = -m[4]; + dst[5] = -m[5]; + dst[6] = -m[6]; + dst[8] = -m[8]; + dst[9] = -m[9]; + dst[10] = -m[10]; + return dst; + } + /** + * Copies a matrix. (same as {@link mat3.clone}) + * Also see {@link mat3.create} and {@link mat3.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ + function copy$4(m, dst) { + dst = dst || newMat3(); + dst[0] = m[0]; + dst[1] = m[1]; + dst[2] = m[2]; + dst[4] = m[4]; + dst[5] = m[5]; + dst[6] = m[6]; + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + return dst; + } + /** + * Copies a matrix (same as {@link mat3.copy}) + * Also see {@link mat3.create} and {@link mat3.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ + const clone$4 = copy$4; + /** + * Check if 2 matrices are approximately equal + * @param a Operand matrix. + * @param b Operand matrix. + * @returns true if matrices are approximately equal + */ + function equalsApproximately$4(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON && + Math.abs(a[4] - b[4]) < EPSILON && + Math.abs(a[5] - b[5]) < EPSILON && + Math.abs(a[6] - b[6]) < EPSILON && + Math.abs(a[8] - b[8]) < EPSILON && + Math.abs(a[9] - b[9]) < EPSILON && + Math.abs(a[10] - b[10]) < EPSILON; + } + /** + * Check if 2 matrices are exactly equal + * @param a Operand matrix. + * @param b Operand matrix. + * @returns true if matrices are exactly equal + */ + function equals$4(a, b) { + return a[0] === b[0] && + a[1] === b[1] && + a[2] === b[2] && + a[4] === b[4] && + a[5] === b[5] && + a[6] === b[6] && + a[8] === b[8] && + a[9] === b[9] && + a[10] === b[10]; + } + /** + * Creates a 3-by-3 identity matrix. + * + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A 3-by-3 identity matrix. + */ + function identity$2(dst) { + dst = dst || newMat3(); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; + } + /** + * Takes the transpose of a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The transpose of m. + */ + function transpose$1(m, dst) { + dst = dst || newMat3(); + if (dst === m) { + let t; + // 0 1 2 + // 4 5 6 + // 8 9 10 + t = m[1]; + m[1] = m[4]; + m[4] = t; + t = m[2]; + m[2] = m[8]; + m[8] = t; + t = m[6]; + m[6] = m[9]; + m[9] = t; + return dst; + } + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + dst[0] = m00; + dst[1] = m10; + dst[2] = m20; + dst[4] = m01; + dst[5] = m11; + dst[6] = m21; + dst[8] = m02; + dst[9] = m12; + dst[10] = m22; + return dst; + } + /** + * Computes the inverse of a 3-by-3 matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ + function inverse$4(m, dst) { + dst = dst || newMat3(); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const b01 = m22 * m11 - m12 * m21; + const b11 = -m22 * m10 + m12 * m20; + const b21 = m21 * m10 - m11 * m20; + const invDet = 1 / (m00 * b01 + m01 * b11 + m02 * b21); + dst[0] = b01 * invDet; + dst[1] = (-m22 * m01 + m02 * m21) * invDet; + dst[2] = (m12 * m01 - m02 * m11) * invDet; + dst[4] = b11 * invDet; + dst[5] = (m22 * m00 - m02 * m20) * invDet; + dst[6] = (-m12 * m00 + m02 * m10) * invDet; + dst[8] = b21 * invDet; + dst[9] = (-m21 * m00 + m01 * m20) * invDet; + dst[10] = (m11 * m00 - m01 * m10) * invDet; + return dst; + } + /** + * Compute the determinant of a matrix + * @param m - the matrix + * @returns the determinant + */ + function determinant$1(m) { + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + return m00 * (m11 * m22 - m21 * m12) - + m10 * (m01 * m22 - m21 * m02) + + m20 * (m01 * m12 - m11 * m02); + } + /** + * Computes the inverse of a 3-by-3 matrix. (same as inverse) + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ + const invert$3 = inverse$4; + /** + * Multiplies two 3-by-3 matrices with a on the left and b on the right + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ + function multiply$4(a, b, dst) { + dst = dst || newMat3(); + const a00 = a[0]; + const a01 = a[1]; + const a02 = a[2]; + const a10 = a[4 + 0]; + const a11 = a[4 + 1]; + const a12 = a[4 + 2]; + const a20 = a[8 + 0]; + const a21 = a[8 + 1]; + const a22 = a[8 + 2]; + const b00 = b[0]; + const b01 = b[1]; + const b02 = b[2]; + const b10 = b[4 + 0]; + const b11 = b[4 + 1]; + const b12 = b[4 + 2]; + const b20 = b[8 + 0]; + const b21 = b[8 + 1]; + const b22 = b[8 + 2]; + dst[0] = a00 * b00 + a10 * b01 + a20 * b02; + dst[1] = a01 * b00 + a11 * b01 + a21 * b02; + dst[2] = a02 * b00 + a12 * b01 + a22 * b02; + dst[4] = a00 * b10 + a10 * b11 + a20 * b12; + dst[5] = a01 * b10 + a11 * b11 + a21 * b12; + dst[6] = a02 * b10 + a12 * b11 + a22 * b12; + dst[8] = a00 * b20 + a10 * b21 + a20 * b22; + dst[9] = a01 * b20 + a11 * b21 + a21 * b22; + dst[10] = a02 * b20 + a12 * b21 + a22 * b22; + return dst; + } + /** + * Multiplies two 3-by-3 matrices with a on the left and b on the right (same as multiply) + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ + const mul$4 = multiply$4; + /** + * Sets the translation component of a 3-by-3 matrix to the given + * vector. + * @param a - The matrix. + * @param v - The vector. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix with translation set. + */ + function setTranslation$1(a, v, dst) { + dst = dst || identity$2(); + if (a !== dst) { + dst[0] = a[0]; + dst[1] = a[1]; + dst[2] = a[2]; + dst[4] = a[4]; + dst[5] = a[5]; + dst[6] = a[6]; + } + dst[8] = v[0]; + dst[9] = v[1]; + dst[10] = 1; + return dst; + } + /** + * Returns the translation component of a 3-by-3 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ + function getTranslation$2(m, dst) { + dst = dst || create$5(); + dst[0] = m[8]; + dst[1] = m[9]; + return dst; + } + /** + * Returns an axis of a 3x3 matrix as a vector with 2 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, + * @returns The axis component of m. + */ + function getAxis$2(m, axis, dst) { + dst = dst || create$5(); + const off = axis * 4; + dst[0] = m[off + 0]; + dst[1] = m[off + 1]; + return dst; + } + /** + * Sets an axis of a 3x3 matrix as a vector with 2 entries + * @param m - The matrix. + * @param v - the axis vector + * @param axis - The axis 0 = x, 1 = y; + * @param dst - The matrix to set. If not passed a new one is created. + * @returns The matrix with axis set. + */ + function setAxis$1(m, v, axis, dst) { + if (dst !== m) { + dst = copy$4(m, dst); + } + const off = axis * 4; + dst[off + 0] = v[0]; + dst[off + 1] = v[1]; + return dst; + } + /** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ + function getScaling$2(m, dst) { + dst = dst || create$5(); + const xx = m[0]; + const xy = m[1]; + const yx = m[4]; + const yy = m[5]; + dst[0] = Math.sqrt(xx * xx + xy * xy); + dst[1] = Math.sqrt(yx * yx + yy * yy); + return dst; + } + /** + * Creates a 3-by-3 matrix which translates by the given vector v. + * @param v - The vector by which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translation matrix. + */ + function translation$1(v, dst) { + dst = dst || newMat3(); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[8] = v[0]; + dst[9] = v[1]; + dst[10] = 1; + return dst; + } + /** + * Translates the given 3-by-3 matrix by the given vector v. + * @param m - The matrix. + * @param v - The vector by which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translated matrix. + */ + function translate$1(m, v, dst) { + dst = dst || newMat3(); + const v0 = v[0]; + const v1 = v[1]; + const m00 = m[0]; + const m01 = m[1]; + const m02 = m[2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + if (m !== dst) { + dst[0] = m00; + dst[1] = m01; + dst[2] = m02; + dst[4] = m10; + dst[5] = m11; + dst[6] = m12; + } + dst[8] = m00 * v0 + m10 * v1 + m20; + dst[9] = m01 * v0 + m11 * v1 + m21; + dst[10] = m02 * v0 + m12 * v1 + m22; + return dst; + } + /** + * Creates a 3-by-3 matrix which rotates by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ + function rotation$1(angleInRadians, dst) { + dst = dst || newMat3(); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c; + dst[1] = s; + dst[2] = 0; + dst[4] = -s; + dst[5] = c; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; + } + /** + * Rotates the given 3-by-3 matrix by the given angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ + function rotate$1(m, angleInRadians, dst) { + dst = dst || newMat3(); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c * m00 + s * m10; + dst[1] = c * m01 + s * m11; + dst[2] = c * m02 + s * m12; + dst[4] = c * m10 - s * m00; + dst[5] = c * m11 - s * m01; + dst[6] = c * m12 - s * m02; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + } + return dst; + } + /** + * Creates a 3-by-3 matrix which scales in each dimension by an amount given by + * the corresponding entry in the given vector; assumes the vector has three + * entries. + * @param v - A vector of + * 2 entries specifying the factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ + function scaling$1(v, dst) { + dst = dst || newMat3(); + dst[0] = v[0]; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = v[1]; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; + } + /** + * Scales the given 3-by-3 matrix in each dimension by an amount + * given by the corresponding entry in the given vector; assumes the vector has + * three entries. + * @param m - The matrix to be modified. + * @param v - A vector of 2 entries specifying the + * factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ + function scale$4(m, v, dst) { + dst = dst || newMat3(); + const v0 = v[0]; + const v1 = v[1]; + dst[0] = v0 * m[0 * 4 + 0]; + dst[1] = v0 * m[0 * 4 + 1]; + dst[2] = v0 * m[0 * 4 + 2]; + dst[4] = v1 * m[1 * 4 + 0]; + dst[5] = v1 * m[1 * 4 + 1]; + dst[6] = v1 * m[1 * 4 + 2]; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + } + return dst; + } + /** + * Creates a 3-by-3 matrix which scales uniformly in each dimension + * @param s - Amount to scale + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ + function uniformScaling$1(s, dst) { + dst = dst || newMat3(); + dst[0] = s; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = s; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; + } + /** + * Scales the given 3-by-3 matrix in each dimension by an amount + * given. + * @param m - The matrix to be modified. + * @param s - Amount to scale. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ + function uniformScale$1(m, s, dst) { + dst = dst || newMat3(); + dst[0] = s * m[0 * 4 + 0]; + dst[1] = s * m[0 * 4 + 1]; + dst[2] = s * m[0 * 4 + 2]; + dst[4] = s * m[1 * 4 + 0]; + dst[5] = s * m[1 * 4 + 1]; + dst[6] = s * m[1 * 4 + 2]; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + } + return dst; + } + + var mat3Impl = { + __proto__: null, + clone: clone$4, + copy: copy$4, + create: create$3, + determinant: determinant$1, + equals: equals$4, + equalsApproximately: equalsApproximately$4, + fromMat4: fromMat4, + fromQuat: fromQuat$1, + getAxis: getAxis$2, + getScaling: getScaling$2, + getTranslation: getTranslation$2, + identity: identity$2, + inverse: inverse$4, + invert: invert$3, + mul: mul$4, + multiply: multiply$4, + negate: negate$3, + rotate: rotate$1, + rotation: rotation$1, + scale: scale$4, + scaling: scaling$1, + set: set$4, + setAxis: setAxis$1, + setDefaultType: setDefaultType$4, + setTranslation: setTranslation$1, + translate: translate$1, + translation: translation$1, + transpose: transpose$1, + uniformScale: uniformScale$1, + uniformScaling: uniformScaling$1 + }; + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + /** + * Creates a vec3; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @returns the created vector + */ + const fromValues$2 = create$4; + /** + * Sets the values of a Vec3 + * Also see {@link vec3.create} and {@link vec3.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ + function set$3(x, y, z, dst) { + dst = dst || new VecType$1(3); + dst[0] = x; + dst[1] = y; + dst[2] = z; + return dst; + } + /** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ + function ceil$1(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.ceil(v[0]); + dst[1] = Math.ceil(v[1]); + dst[2] = Math.ceil(v[2]); + return dst; + } + /** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ + function floor$1(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.floor(v[0]); + dst[1] = Math.floor(v[1]); + dst[2] = Math.floor(v[2]); + return dst; + } + /** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ + function round$1(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.round(v[0]); + dst[1] = Math.round(v[1]); + dst[2] = Math.round(v[2]); + return dst; + } + /** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ + function clamp$1(v, min = 0, max = 1, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.min(max, Math.max(min, v[0])); + dst[1] = Math.min(max, Math.max(min, v[1])); + dst[2] = Math.min(max, Math.max(min, v[2])); + return dst; + } + /** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ + function add$2(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + dst[2] = a[2] + b[2]; + return dst; + } + /** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ + function addScaled$1(a, b, scale, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] + b[0] * scale; + dst[1] = a[1] + b[1] * scale; + dst[2] = a[2] + b[2] * scale; + return dst; + } + /** + * Returns the angle in radians between two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns The angle in radians between the 2 vectors. + */ + function angle$1(a, b) { + const ax = a[0]; + const ay = a[1]; + const az = a[2]; + const bx = b[0]; + const by = b[1]; + const bz = b[2]; + const mag1 = Math.sqrt(ax * ax + ay * ay + az * az); + const mag2 = Math.sqrt(bx * bx + by * by + bz * bz); + const mag = mag1 * mag2; + const cosine = mag && dot$2(a, b) / mag; + return Math.acos(cosine); + } + /** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ + function subtract$2(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + dst[2] = a[2] - b[2]; + return dst; + } + /** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ + const sub$2 = subtract$2; + /** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ + function equalsApproximately$3(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON; + } + /** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ + function equals$3(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; + } + /** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ + function lerp$2(a, b, t, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + dst[2] = a[2] + t * (b[2] - a[2]); + return dst; + } + /** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ + function lerpV$1(a, b, t, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] + t[0] * (b[0] - a[0]); + dst[1] = a[1] + t[1] * (b[1] - a[1]); + dst[2] = a[2] + t[2] * (b[2] - a[2]); + return dst; + } + /** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ + function max$1(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.max(a[0], b[0]); + dst[1] = Math.max(a[1], b[1]); + dst[2] = Math.max(a[2], b[2]); + return dst; + } + /** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ + function min$1(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.min(a[0], b[0]); + dst[1] = Math.min(a[1], b[1]); + dst[2] = Math.min(a[2], b[2]); + return dst; + } + /** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ + function mulScalar$2(v, k, dst) { + dst = dst || new VecType$1(3); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + dst[2] = v[2] * k; + return dst; + } + /** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ + const scale$3 = mulScalar$2; + /** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ + function divScalar$2(v, k, dst) { + dst = dst || new VecType$1(3); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + dst[2] = v[2] / k; + return dst; + } + /** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ + function inverse$3(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = 1 / v[0]; + dst[1] = 1 / v[1]; + dst[2] = 1 / v[2]; + return dst; + } + /** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ + const invert$2 = inverse$3; + /** + * Computes the cross product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of a cross b. + */ + function cross(a, b, dst) { + dst = dst || new VecType$1(3); + const t1 = a[2] * b[0] - a[0] * b[2]; + const t2 = a[0] * b[1] - a[1] * b[0]; + dst[0] = a[1] * b[2] - a[2] * b[1]; + dst[1] = t1; + dst[2] = t2; + return dst; + } + /** + * Computes the dot product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ + function dot$2(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]); + } + /** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ + function length$2(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2); + } + /** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ + const len$2 = length$2; + /** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ + function lengthSq$2(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + return v0 * v0 + v1 * v1 + v2 * v2; + } + /** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ + const lenSq$2 = lengthSq$2; + /** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ + function distance$1(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + return Math.sqrt(dx * dx + dy * dy + dz * dz); + } + /** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ + const dist$1 = distance$1; + /** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ + function distanceSq$1(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + return dx * dx + dy * dy + dz * dz; + } + /** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ + const distSq$1 = distanceSq$1; + /** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ + function normalize$2(v, dst) { + dst = dst || new VecType$1(3); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + dst[2] = v2 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + } + return dst; + } + /** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ + function negate$2(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = -v[0]; + dst[1] = -v[1]; + dst[2] = -v[2]; + return dst; + } + /** + * Copies a vector. (same as {@link vec3.clone}) + * Also see {@link vec3.create} and {@link vec3.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ + function copy$3(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = v[0]; + dst[1] = v[1]; + dst[2] = v[2]; + return dst; + } + /** + * Clones a vector. (same as {@link vec3.copy}) + * Also see {@link vec3.create} and {@link vec3.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ + const clone$3 = copy$3; + /** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ + function multiply$3(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + dst[2] = a[2] * b[2]; + return dst; + } + /** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ + const mul$3 = multiply$3; + /** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ + function divide$1(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] / b[0]; + dst[1] = a[1] / b[1]; + dst[2] = a[2] / b[2]; + return dst; + } + /** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ + const div$1 = divide$1; + /** + * Creates a random vector + * @param scale - Default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The random vector. + */ + function random(scale = 1, dst) { + dst = dst || new VecType$1(3); + const angle = Math.random() * 2 * Math.PI; + const z = Math.random() * 2 - 1; + const zScale = Math.sqrt(1 - z * z) * scale; + dst[0] = Math.cos(angle) * zScale; + dst[1] = Math.sin(angle) * zScale; + dst[2] = z * scale; + return dst; + } + /** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ + function zero$1(dst) { + dst = dst || new VecType$1(3); + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + return dst; + } + /** + * transform vec3 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed vector + */ + function transformMat4$1(v, m, dst) { + dst = dst || new VecType$1(3); + const x = v[0]; + const y = v[1]; + const z = v[2]; + const w = (m[3] * x + m[7] * y + m[11] * z + m[15]) || 1; + dst[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; + dst[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; + dst[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; + return dst; + } + /** + * Transform vec4 by upper 3x3 matrix inside 4x4 matrix. + * @param v - The direction. + * @param m - The matrix. + * @param dst - optional Vec3 to store result. If not passed a new one is created. + * @returns The transformed vector. + */ + function transformMat4Upper3x3(v, m, dst) { + dst = dst || new VecType$1(3); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0]; + dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1]; + dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v2 * m[2 * 4 + 2]; + return dst; + } + /** + * Transforms vec3 by 3x3 matrix + * + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed vector + */ + function transformMat3(v, m, dst) { + dst = dst || new VecType$1(3); + const x = v[0]; + const y = v[1]; + const z = v[2]; + dst[0] = x * m[0] + y * m[4] + z * m[8]; + dst[1] = x * m[1] + y * m[5] + z * m[9]; + dst[2] = x * m[2] + y * m[6] + z * m[10]; + return dst; + } + /** + * Transforms vec3 by Quaternion + * @param v - the vector to transform + * @param q - the quaternion to transform by + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed + */ + function transformQuat(v, q, dst) { + dst = dst || new VecType$1(3); + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const w2 = q[3] * 2; + const x = v[0]; + const y = v[1]; + const z = v[2]; + const uvX = qy * z - qz * y; + const uvY = qz * x - qx * z; + const uvZ = qx * y - qy * x; + dst[0] = x + uvX * w2 + (qy * uvZ - qz * uvY) * 2; + dst[1] = y + uvY * w2 + (qz * uvX - qx * uvZ) * 2; + dst[2] = z + uvZ * w2 + (qx * uvY - qy * uvX) * 2; + return dst; + } + /** + * Returns the translation component of a 4-by-4 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ + function getTranslation$1(m, dst) { + dst = dst || new VecType$1(3); + dst[0] = m[12]; + dst[1] = m[13]; + dst[2] = m[14]; + return dst; + } + /** + * Returns an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @returns The axis component of m. + */ + function getAxis$1(m, axis, dst) { + dst = dst || new VecType$1(3); + const off = axis * 4; + dst[0] = m[off + 0]; + dst[1] = m[off + 1]; + dst[2] = m[off + 2]; + return dst; + } + /** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ + function getScaling$1(m, dst) { + dst = dst || new VecType$1(3); + const xx = m[0]; + const xy = m[1]; + const xz = m[2]; + const yx = m[4]; + const yy = m[5]; + const yz = m[6]; + const zx = m[8]; + const zy = m[9]; + const zz = m[10]; + dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz); + dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz); + dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz); + return dst; + } + /** + * Rotate a 3D vector around the x-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns the rotated vector + */ + function rotateX$2(a, b, rad, dst) { + dst = dst || new VecType$1(3); + const p = []; + const r = []; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + //perform rotation + r[0] = p[0]; + r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad); + r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); + //translate to correct position + dst[0] = r[0] + b[0]; + dst[1] = r[1] + b[1]; + dst[2] = r[2] + b[2]; + return dst; + } + /** + * Rotate a 3D vector around the y-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns the rotated vector + */ + function rotateY$2(a, b, rad, dst) { + dst = dst || new VecType$1(3); + const p = []; + const r = []; + // translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + // perform rotation + r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad); + r[1] = p[1]; + r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); + // translate to correct position + dst[0] = r[0] + b[0]; + dst[1] = r[1] + b[1]; + dst[2] = r[2] + b[2]; + return dst; + } + /** + * Rotate a 3D vector around the z-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns {vec3} out + */ + function rotateZ$2(a, b, rad, dst) { + dst = dst || new VecType$1(3); + const p = []; + const r = []; + // translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + // perform rotation + r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad); + r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad); + r[2] = p[2]; + // translate to correct position + dst[0] = r[0] + b[0]; + dst[1] = r[1] + b[1]; + dst[2] = r[2] + b[2]; + return dst; + } + /** + * Treat a 3D vector as a direction and set it's length + * + * @param a The vec3 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ + function setLength$1(a, len, dst) { + dst = dst || new VecType$1(3); + normalize$2(a, dst); + return mulScalar$2(dst, len, dst); + } + /** + * Ensure a vector is not longer than a max length + * + * @param a The vec3 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ + function truncate$1(a, maxLen, dst) { + dst = dst || new VecType$1(3); + if (length$2(a) > maxLen) { + return setLength$1(a, maxLen, dst); + } + return copy$3(a, dst); + } + /** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ + function midpoint$1(a, b, dst) { + dst = dst || new VecType$1(3); + return lerp$2(a, b, 0.5, dst); + } + + var vec3Impl = { + __proto__: null, + add: add$2, + addScaled: addScaled$1, + angle: angle$1, + ceil: ceil$1, + clamp: clamp$1, + clone: clone$3, + copy: copy$3, + create: create$4, + cross: cross, + dist: dist$1, + distSq: distSq$1, + distance: distance$1, + distanceSq: distanceSq$1, + div: div$1, + divScalar: divScalar$2, + divide: divide$1, + dot: dot$2, + equals: equals$3, + equalsApproximately: equalsApproximately$3, + floor: floor$1, + fromValues: fromValues$2, + getAxis: getAxis$1, + getScaling: getScaling$1, + getTranslation: getTranslation$1, + inverse: inverse$3, + invert: invert$2, + len: len$2, + lenSq: lenSq$2, + length: length$2, + lengthSq: lengthSq$2, + lerp: lerp$2, + lerpV: lerpV$1, + max: max$1, + midpoint: midpoint$1, + min: min$1, + mul: mul$3, + mulScalar: mulScalar$2, + multiply: multiply$3, + negate: negate$2, + normalize: normalize$2, + random: random, + rotateX: rotateX$2, + rotateY: rotateY$2, + rotateZ: rotateZ$2, + round: round$1, + scale: scale$3, + set: set$3, + setDefaultType: setDefaultType$5, + setLength: setLength$1, + sub: sub$2, + subtract: subtract$2, + transformMat3: transformMat3, + transformMat4: transformMat4$1, + transformMat4Upper3x3: transformMat4Upper3x3, + transformQuat: transformQuat, + truncate: truncate$1, + zero: zero$1 + }; + + /** + * 4x4 Matrix math math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new matrix. In other words you can do this + * + * const mat = mat4.translation([1, 2, 3]); // Creates a new translation matrix + * + * or + * + * const mat = mat4.create(); + * mat4.translation([1, 2, 3], mat); // Puts translation matrix in mat. + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always save to pass any matrix as the destination. So for example + * + * const mat = mat4.identity(); + * const trans = mat4.translation([1, 2, 3]); + * mat4.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat. + * + */ + let MatType = Float32Array; + /** + * Sets the type this library creates for a Mat4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Mat4 + */ + function setDefaultType$3(ctor) { + const oldType = MatType; + MatType = ctor; + return oldType; + } + /** + * Create a Mat4 from values + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Mat4's specified type + * it would be faster to use + * + * ``` + * const m = mat4.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Mat4Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `mat4.create` is usually used + * to create a Mat4 to be filled out as in + * + * ``` + * const m = mat4.create(); + * mat4.perspective(fov, aspect, near, far, m); + * ``` + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param v9 - value for element 9 + * @param v10 - value for element 10 + * @param v11 - value for element 11 + * @param v12 - value for element 12 + * @param v13 - value for element 13 + * @param v14 - value for element 14 + * @param v15 - value for element 15 + * @returns created from values. + */ + function create$2(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) { + const dst = new MatType(16); + if (v0 !== undefined) { + dst[0] = v0; + if (v1 !== undefined) { + dst[1] = v1; + if (v2 !== undefined) { + dst[2] = v2; + if (v3 !== undefined) { + dst[3] = v3; + if (v4 !== undefined) { + dst[4] = v4; + if (v5 !== undefined) { + dst[5] = v5; + if (v6 !== undefined) { + dst[6] = v6; + if (v7 !== undefined) { + dst[7] = v7; + if (v8 !== undefined) { + dst[8] = v8; + if (v9 !== undefined) { + dst[9] = v9; + if (v10 !== undefined) { + dst[10] = v10; + if (v11 !== undefined) { + dst[11] = v11; + if (v12 !== undefined) { + dst[12] = v12; + if (v13 !== undefined) { + dst[13] = v13; + if (v14 !== undefined) { + dst[14] = v14; + if (v15 !== undefined) { + dst[15] = v15; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return dst; + } + /** + * Sets the values of a Mat4 + * Also see {@link mat4.create} and {@link mat4.copy} + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param v9 - value for element 9 + * @param v10 - value for element 10 + * @param v11 - value for element 11 + * @param v12 - value for element 12 + * @param v13 - value for element 13 + * @param v14 - value for element 14 + * @param v15 - value for element 15 + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 created from values. + */ + function set$2(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, dst) { + dst = dst || new MatType(16); + dst[0] = v0; + dst[1] = v1; + dst[2] = v2; + dst[3] = v3; + dst[4] = v4; + dst[5] = v5; + dst[6] = v6; + dst[7] = v7; + dst[8] = v8; + dst[9] = v9; + dst[10] = v10; + dst[11] = v11; + dst[12] = v12; + dst[13] = v13; + dst[14] = v14; + dst[15] = v15; + return dst; + } + /** + * Creates a Mat4 from a Mat3 + * @param m3 - source matrix + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 made from m3 + */ + function fromMat3(m3, dst) { + dst = dst || new MatType(16); + dst[0] = m3[0]; + dst[1] = m3[1]; + dst[2] = m3[2]; + dst[3] = 0; + dst[4] = m3[4]; + dst[5] = m3[5]; + dst[6] = m3[6]; + dst[7] = 0; + dst[8] = m3[8]; + dst[9] = m3[9]; + dst[10] = m3[10]; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; + } + /** + * Creates a Mat4 rotation matrix from a quaternion + * @param q - quaternion to create matrix from + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 made from q + */ + function fromQuat(q, dst) { + dst = dst || new MatType(16); + const x = q[0]; + const y = q[1]; + const z = q[2]; + const w = q[3]; + const x2 = x + x; + const y2 = y + y; + const z2 = z + z; + const xx = x * x2; + const yx = y * x2; + const yy = y * y2; + const zx = z * x2; + const zy = z * y2; + const zz = z * z2; + const wx = w * x2; + const wy = w * y2; + const wz = w * z2; + dst[0] = 1 - yy - zz; + dst[1] = yx + wz; + dst[2] = zx - wy; + dst[3] = 0; + dst[4] = yx - wz; + dst[5] = 1 - xx - zz; + dst[6] = zy + wx; + dst[7] = 0; + dst[8] = zx + wy; + dst[9] = zy - wx; + dst[10] = 1 - xx - yy; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; + } + /** + * Negates a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns -m. + */ + function negate$1(m, dst) { + dst = dst || new MatType(16); + dst[0] = -m[0]; + dst[1] = -m[1]; + dst[2] = -m[2]; + dst[3] = -m[3]; + dst[4] = -m[4]; + dst[5] = -m[5]; + dst[6] = -m[6]; + dst[7] = -m[7]; + dst[8] = -m[8]; + dst[9] = -m[9]; + dst[10] = -m[10]; + dst[11] = -m[11]; + dst[12] = -m[12]; + dst[13] = -m[13]; + dst[14] = -m[14]; + dst[15] = -m[15]; + return dst; + } + /** + * Copies a matrix. (same as {@link mat4.clone}) + * Also see {@link mat4.create} and {@link mat4.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ + function copy$2(m, dst) { + dst = dst || new MatType(16); + dst[0] = m[0]; + dst[1] = m[1]; + dst[2] = m[2]; + dst[3] = m[3]; + dst[4] = m[4]; + dst[5] = m[5]; + dst[6] = m[6]; + dst[7] = m[7]; + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + dst[11] = m[11]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + return dst; + } + /** + * Copies a matrix (same as {@link mat4.copy}) + * Also see {@link mat4.create} and {@link mat4.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ + const clone$2 = copy$2; + /** + * Check if 2 matrices are approximately equal + * @param a - Operand matrix. + * @param b - Operand matrix. + * @returns true if matrices are approximately equal + */ + function equalsApproximately$2(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON && + Math.abs(a[3] - b[3]) < EPSILON && + Math.abs(a[4] - b[4]) < EPSILON && + Math.abs(a[5] - b[5]) < EPSILON && + Math.abs(a[6] - b[6]) < EPSILON && + Math.abs(a[7] - b[7]) < EPSILON && + Math.abs(a[8] - b[8]) < EPSILON && + Math.abs(a[9] - b[9]) < EPSILON && + Math.abs(a[10] - b[10]) < EPSILON && + Math.abs(a[11] - b[11]) < EPSILON && + Math.abs(a[12] - b[12]) < EPSILON && + Math.abs(a[13] - b[13]) < EPSILON && + Math.abs(a[14] - b[14]) < EPSILON && + Math.abs(a[15] - b[15]) < EPSILON; + } + /** + * Check if 2 matrices are exactly equal + * @param a - Operand matrix. + * @param b - Operand matrix. + * @returns true if matrices are exactly equal + */ + function equals$2(a, b) { + return a[0] === b[0] && + a[1] === b[1] && + a[2] === b[2] && + a[3] === b[3] && + a[4] === b[4] && + a[5] === b[5] && + a[6] === b[6] && + a[7] === b[7] && + a[8] === b[8] && + a[9] === b[9] && + a[10] === b[10] && + a[11] === b[11] && + a[12] === b[12] && + a[13] === b[13] && + a[14] === b[14] && + a[15] === b[15]; + } + /** + * Creates a 4-by-4 identity matrix. + * + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A 4-by-4 identity matrix. + */ + function identity$1(dst) { + dst = dst || new MatType(16); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; + } + /** + * Takes the transpose of a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The transpose of m. + */ + function transpose(m, dst) { + dst = dst || new MatType(16); + if (dst === m) { + let t; + t = m[1]; + m[1] = m[4]; + m[4] = t; + t = m[2]; + m[2] = m[8]; + m[8] = t; + t = m[3]; + m[3] = m[12]; + m[12] = t; + t = m[6]; + m[6] = m[9]; + m[9] = t; + t = m[7]; + m[7] = m[13]; + m[13] = t; + t = m[11]; + m[11] = m[14]; + m[14] = t; + return dst; + } + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + dst[0] = m00; + dst[1] = m10; + dst[2] = m20; + dst[3] = m30; + dst[4] = m01; + dst[5] = m11; + dst[6] = m21; + dst[7] = m31; + dst[8] = m02; + dst[9] = m12; + dst[10] = m22; + dst[11] = m32; + dst[12] = m03; + dst[13] = m13; + dst[14] = m23; + dst[15] = m33; + return dst; + } + /** + * Computes the inverse of a 4-by-4 matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ + function inverse$2(m, dst) { + dst = dst || new MatType(16); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + const tmp0 = m22 * m33; + const tmp1 = m32 * m23; + const tmp2 = m12 * m33; + const tmp3 = m32 * m13; + const tmp4 = m12 * m23; + const tmp5 = m22 * m13; + const tmp6 = m02 * m33; + const tmp7 = m32 * m03; + const tmp8 = m02 * m23; + const tmp9 = m22 * m03; + const tmp10 = m02 * m13; + const tmp11 = m12 * m03; + const tmp12 = m20 * m31; + const tmp13 = m30 * m21; + const tmp14 = m10 * m31; + const tmp15 = m30 * m11; + const tmp16 = m10 * m21; + const tmp17 = m20 * m11; + const tmp18 = m00 * m31; + const tmp19 = m30 * m01; + const tmp20 = m00 * m21; + const tmp21 = m20 * m01; + const tmp22 = m00 * m11; + const tmp23 = m10 * m01; + const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) - + (tmp1 * m11 + tmp2 * m21 + tmp5 * m31); + const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) - + (tmp0 * m01 + tmp7 * m21 + tmp8 * m31); + const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) - + (tmp3 * m01 + tmp6 * m11 + tmp11 * m31); + const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) - + (tmp4 * m01 + tmp9 * m11 + tmp10 * m21); + const d = 1 / (m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3); + dst[0] = d * t0; + dst[1] = d * t1; + dst[2] = d * t2; + dst[3] = d * t3; + dst[4] = d * ((tmp1 * m10 + tmp2 * m20 + tmp5 * m30) - + (tmp0 * m10 + tmp3 * m20 + tmp4 * m30)); + dst[5] = d * ((tmp0 * m00 + tmp7 * m20 + tmp8 * m30) - + (tmp1 * m00 + tmp6 * m20 + tmp9 * m30)); + dst[6] = d * ((tmp3 * m00 + tmp6 * m10 + tmp11 * m30) - + (tmp2 * m00 + tmp7 * m10 + tmp10 * m30)); + dst[7] = d * ((tmp4 * m00 + tmp9 * m10 + tmp10 * m20) - + (tmp5 * m00 + tmp8 * m10 + tmp11 * m20)); + dst[8] = d * ((tmp12 * m13 + tmp15 * m23 + tmp16 * m33) - + (tmp13 * m13 + tmp14 * m23 + tmp17 * m33)); + dst[9] = d * ((tmp13 * m03 + tmp18 * m23 + tmp21 * m33) - + (tmp12 * m03 + tmp19 * m23 + tmp20 * m33)); + dst[10] = d * ((tmp14 * m03 + tmp19 * m13 + tmp22 * m33) - + (tmp15 * m03 + tmp18 * m13 + tmp23 * m33)); + dst[11] = d * ((tmp17 * m03 + tmp20 * m13 + tmp23 * m23) - + (tmp16 * m03 + tmp21 * m13 + tmp22 * m23)); + dst[12] = d * ((tmp14 * m22 + tmp17 * m32 + tmp13 * m12) - + (tmp16 * m32 + tmp12 * m12 + tmp15 * m22)); + dst[13] = d * ((tmp20 * m32 + tmp12 * m02 + tmp19 * m22) - + (tmp18 * m22 + tmp21 * m32 + tmp13 * m02)); + dst[14] = d * ((tmp18 * m12 + tmp23 * m32 + tmp15 * m02) - + (tmp22 * m32 + tmp14 * m02 + tmp19 * m12)); + dst[15] = d * ((tmp22 * m22 + tmp16 * m02 + tmp21 * m12) - + (tmp20 * m12 + tmp23 * m22 + tmp17 * m02)); + return dst; + } + /** + * Compute the determinant of a matrix + * @param m - the matrix + * @returns the determinant + */ + function determinant(m) { + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + const tmp0 = m22 * m33; + const tmp1 = m32 * m23; + const tmp2 = m12 * m33; + const tmp3 = m32 * m13; + const tmp4 = m12 * m23; + const tmp5 = m22 * m13; + const tmp6 = m02 * m33; + const tmp7 = m32 * m03; + const tmp8 = m02 * m23; + const tmp9 = m22 * m03; + const tmp10 = m02 * m13; + const tmp11 = m12 * m03; + const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) - + (tmp1 * m11 + tmp2 * m21 + tmp5 * m31); + const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) - + (tmp0 * m01 + tmp7 * m21 + tmp8 * m31); + const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) - + (tmp3 * m01 + tmp6 * m11 + tmp11 * m31); + const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) - + (tmp4 * m01 + tmp9 * m11 + tmp10 * m21); + return m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3; + } + /** + * Computes the inverse of a 4-by-4 matrix. (same as inverse) + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ + const invert$1 = inverse$2; + /** + * Multiplies two 4-by-4 matrices with a on the left and b on the right + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ + function multiply$2(a, b, dst) { + dst = dst || new MatType(16); + const a00 = a[0]; + const a01 = a[1]; + const a02 = a[2]; + const a03 = a[3]; + const a10 = a[4 + 0]; + const a11 = a[4 + 1]; + const a12 = a[4 + 2]; + const a13 = a[4 + 3]; + const a20 = a[8 + 0]; + const a21 = a[8 + 1]; + const a22 = a[8 + 2]; + const a23 = a[8 + 3]; + const a30 = a[12 + 0]; + const a31 = a[12 + 1]; + const a32 = a[12 + 2]; + const a33 = a[12 + 3]; + const b00 = b[0]; + const b01 = b[1]; + const b02 = b[2]; + const b03 = b[3]; + const b10 = b[4 + 0]; + const b11 = b[4 + 1]; + const b12 = b[4 + 2]; + const b13 = b[4 + 3]; + const b20 = b[8 + 0]; + const b21 = b[8 + 1]; + const b22 = b[8 + 2]; + const b23 = b[8 + 3]; + const b30 = b[12 + 0]; + const b31 = b[12 + 1]; + const b32 = b[12 + 2]; + const b33 = b[12 + 3]; + dst[0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03; + dst[1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03; + dst[2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03; + dst[3] = a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03; + dst[4] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13; + dst[5] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13; + dst[6] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13; + dst[7] = a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13; + dst[8] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23; + dst[9] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23; + dst[10] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23; + dst[11] = a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23; + dst[12] = a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33; + dst[13] = a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33; + dst[14] = a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33; + dst[15] = a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33; + return dst; + } + /** + * Multiplies two 4-by-4 matrices with a on the left and b on the right (same as multiply) + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ + const mul$2 = multiply$2; + /** + * Sets the translation component of a 4-by-4 matrix to the given + * vector. + * @param a - The matrix. + * @param v - The vector. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix with translation set. + */ + function setTranslation(a, v, dst) { + dst = dst || identity$1(); + if (a !== dst) { + dst[0] = a[0]; + dst[1] = a[1]; + dst[2] = a[2]; + dst[3] = a[3]; + dst[4] = a[4]; + dst[5] = a[5]; + dst[6] = a[6]; + dst[7] = a[7]; + dst[8] = a[8]; + dst[9] = a[9]; + dst[10] = a[10]; + dst[11] = a[11]; + } + dst[12] = v[0]; + dst[13] = v[1]; + dst[14] = v[2]; + dst[15] = 1; + return dst; + } + /** + * Returns the translation component of a 4-by-4 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ + function getTranslation(m, dst) { + dst = dst || create$4(); + dst[0] = m[12]; + dst[1] = m[13]; + dst[2] = m[14]; + return dst; + } + /** + * Returns an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @returns The axis component of m. + */ + function getAxis(m, axis, dst) { + dst = dst || create$4(); + const off = axis * 4; + dst[0] = m[off + 0]; + dst[1] = m[off + 1]; + dst[2] = m[off + 2]; + return dst; + } + /** + * Sets an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param v - the axis vector + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @param dst - The matrix to set. If not passed a new one is created. + * @returns The matrix with axis set. + */ + function setAxis(m, v, axis, dst) { + if (dst !== m) { + dst = copy$2(m, dst); + } + const off = axis * 4; + dst[off + 0] = v[0]; + dst[off + 1] = v[1]; + dst[off + 2] = v[2]; + return dst; + } + /** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ + function getScaling(m, dst) { + dst = dst || create$4(); + const xx = m[0]; + const xy = m[1]; + const xz = m[2]; + const yx = m[4]; + const yy = m[5]; + const yz = m[6]; + const zx = m[8]; + const zy = m[9]; + const zz = m[10]; + dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz); + dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz); + dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz); + return dst; + } + /** + * Computes a 4-by-4 perspective transformation matrix given the angular height + * of the frustum, the aspect ratio, and the near and far clipping planes. The + * arguments define a frustum extending in the negative z direction. The given + * angle is the vertical angle of the frustum, and the horizontal angle is + * determined to produce the given aspect ratio. The arguments near and far are + * the distances to the near and far clipping planes. Note that near and far + * are not z coordinates, but rather they are distances along the negative + * z-axis. The matrix generated sends the viewing frustum to the unit box. + * We assume a unit box extending from -1 to 1 in the x and y dimensions and + * from 0 to 1 in the z dimension. + * + * Note: If you pass `Infinity` for zFar then it will produce a projection matrix + * returns -Infinity for Z when transforming coordinates with Z <= 0 and +Infinity for Z + * otherwise. + * + * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians). + * @param aspect - The aspect ratio width / height. + * @param zNear - The depth (negative z coordinate) + * of the near clipping plane. + * @param zFar - The depth (negative z coordinate) + * of the far clipping plane. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The perspective matrix. + */ + function perspective(fieldOfViewYInRadians, aspect, zNear, zFar, dst) { + dst = dst || new MatType(16); + const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians); + dst[0] = f / aspect; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = f; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[15] = 0; + if (Number.isFinite(zFar)) { + const rangeInv = 1 / (zNear - zFar); + dst[10] = zFar * rangeInv; + dst[14] = zFar * zNear * rangeInv; + } + else { + dst[10] = -1; + dst[14] = -zNear; + } + return dst; + } + /** + * Computes a 4-by-4 reverse-z perspective transformation matrix given the angular height + * of the frustum, the aspect ratio, and the near and far clipping planes. The + * arguments define a frustum extending in the negative z direction. The given + * angle is the vertical angle of the frustum, and the horizontal angle is + * determined to produce the given aspect ratio. The arguments near and far are + * the distances to the near and far clipping planes. Note that near and far + * are not z coordinates, but rather they are distances along the negative + * z-axis. The matrix generated sends the viewing frustum to the unit box. + * We assume a unit box extending from -1 to 1 in the x and y dimensions and + * from 1 (at -zNear) to 0 (at -zFar) in the z dimension. + * + * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians). + * @param aspect - The aspect ratio width / height. + * @param zNear - The depth (negative z coordinate) + * of the near clipping plane. + * @param zFar - The depth (negative z coordinate) + * of the far clipping plane. (default = Infinity) + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The perspective matrix. + */ function perspectiveReverseZ(fieldOfViewYInRadians, aspect, zNear, zFar = Infinity, dst) { + dst = dst || new MatType(16); + const f = 1 / Math.tan(fieldOfViewYInRadians * 0.5); + dst[0] = f / aspect; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = f; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[15] = 0; + if (zFar === Infinity) { + dst[10] = 0; + dst[14] = zNear; + } + else { + const rangeInv = 1 / (zFar - zNear); + dst[10] = zNear * rangeInv; + dst[14] = zFar * zNear * rangeInv; + } + return dst; + } + /** + * Computes a 4-by-4 orthogonal transformation matrix that transforms from + * the given the left, right, bottom, and top dimensions to -1 +1 in x, and y + * and 0 to +1 in z. + * @param left - Left side of the near clipping plane viewport. + * @param right - Right side of the near clipping plane viewport. + * @param bottom - Bottom of the near clipping plane viewport. + * @param top - Top of the near clipping plane viewport. + * @param near - The depth (negative z coordinate) + * of the near clipping plane. + * @param far - The depth (negative z coordinate) + * of the far clipping plane. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The orthographic projection matrix. + */ + function ortho(left, right, bottom, top, near, far, dst) { + dst = dst || new MatType(16); + dst[0] = 2 / (right - left); + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 2 / (top - bottom); + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1 / (near - far); + dst[11] = 0; + dst[12] = (right + left) / (left - right); + dst[13] = (top + bottom) / (bottom - top); + dst[14] = near / (near - far); + dst[15] = 1; + return dst; + } + /** + * Computes a 4-by-4 perspective transformation matrix given the left, right, + * top, bottom, near and far clipping planes. The arguments define a frustum + * extending in the negative z direction. The arguments near and far are the + * distances to the near and far clipping planes. Note that near and far are not + * z coordinates, but rather they are distances along the negative z-axis. The + * matrix generated sends the viewing frustum to the unit box. We assume a unit + * box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z + * dimension. + * @param left - The x coordinate of the left plane of the box. + * @param right - The x coordinate of the right plane of the box. + * @param bottom - The y coordinate of the bottom plane of the box. + * @param top - The y coordinate of the right plane of the box. + * @param near - The negative z coordinate of the near plane of the box. + * @param far - The negative z coordinate of the far plane of the box. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The perspective projection matrix. + */ + function frustum(left, right, bottom, top, near, far, dst) { + dst = dst || new MatType(16); + const dx = (right - left); + const dy = (top - bottom); + const dz = (near - far); + dst[0] = 2 * near / dx; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 2 * near / dy; + dst[6] = 0; + dst[7] = 0; + dst[8] = (left + right) / dx; + dst[9] = (top + bottom) / dy; + dst[10] = far / dz; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[14] = near * far / dz; + dst[15] = 0; + return dst; + } + /** + * Computes a 4-by-4 reverse-z perspective transformation matrix given the left, right, + * top, bottom, near and far clipping planes. The arguments define a frustum + * extending in the negative z direction. The arguments near and far are the + * distances to the near and far clipping planes. Note that near and far are not + * z coordinates, but rather they are distances along the negative z-axis. The + * matrix generated sends the viewing frustum to the unit box. We assume a unit + * box extending from -1 to 1 in the x and y dimensions and from 1 (-near) to 0 (-far) in the z + * dimension. + * @param left - The x coordinate of the left plane of the box. + * @param right - The x coordinate of the right plane of the box. + * @param bottom - The y coordinate of the bottom plane of the box. + * @param top - The y coordinate of the right plane of the box. + * @param near - The negative z coordinate of the near plane of the box. + * @param far - The negative z coordinate of the far plane of the box. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The perspective projection matrix. + */ + function frustumReverseZ(left, right, bottom, top, near, far = Infinity, dst) { + dst = dst || new MatType(16); + const dx = (right - left); + const dy = (top - bottom); + dst[0] = 2 * near / dx; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 2 * near / dy; + dst[6] = 0; + dst[7] = 0; + dst[8] = (left + right) / dx; + dst[9] = (top + bottom) / dy; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[15] = 0; + if (far === Infinity) { + dst[10] = 0; + dst[14] = near; + } + else { + const rangeInv = 1 / (far - near); + dst[10] = near * rangeInv; + dst[14] = far * near * rangeInv; + } + return dst; + } + let xAxis; + let yAxis; + let zAxis; + /** + * Computes a 4-by-4 aim transformation. + * + * This is a matrix which positions an object aiming down positive Z. + * toward the target. + * + * Note: this is **NOT** the inverse of lookAt as lookAt looks at negative Z. + * + * @param position - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The aim matrix. + */ + function aim(position, target, up, dst) { + dst = dst || new MatType(16); + xAxis = xAxis || create$4(); + yAxis = yAxis || create$4(); + zAxis = zAxis || create$4(); + normalize$2(subtract$2(target, position, zAxis), zAxis); + normalize$2(cross(up, zAxis, xAxis), xAxis); + normalize$2(cross(zAxis, xAxis, yAxis), yAxis); + dst[0] = xAxis[0]; + dst[1] = xAxis[1]; + dst[2] = xAxis[2]; + dst[3] = 0; + dst[4] = yAxis[0]; + dst[5] = yAxis[1]; + dst[6] = yAxis[2]; + dst[7] = 0; + dst[8] = zAxis[0]; + dst[9] = zAxis[1]; + dst[10] = zAxis[2]; + dst[11] = 0; + dst[12] = position[0]; + dst[13] = position[1]; + dst[14] = position[2]; + dst[15] = 1; + return dst; + } + /** + * Computes a 4-by-4 camera aim transformation. + * + * This is a matrix which positions an object aiming down negative Z. + * toward the target. + * + * Note: this is the inverse of `lookAt` + * + * @param eye - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The aim matrix. + */ + function cameraAim(eye, target, up, dst) { + dst = dst || new MatType(16); + xAxis = xAxis || create$4(); + yAxis = yAxis || create$4(); + zAxis = zAxis || create$4(); + normalize$2(subtract$2(eye, target, zAxis), zAxis); + normalize$2(cross(up, zAxis, xAxis), xAxis); + normalize$2(cross(zAxis, xAxis, yAxis), yAxis); + dst[0] = xAxis[0]; + dst[1] = xAxis[1]; + dst[2] = xAxis[2]; + dst[3] = 0; + dst[4] = yAxis[0]; + dst[5] = yAxis[1]; + dst[6] = yAxis[2]; + dst[7] = 0; + dst[8] = zAxis[0]; + dst[9] = zAxis[1]; + dst[10] = zAxis[2]; + dst[11] = 0; + dst[12] = eye[0]; + dst[13] = eye[1]; + dst[14] = eye[2]; + dst[15] = 1; + return dst; + } + /** + * Computes a 4-by-4 view transformation. + * + * This is a view matrix which transforms all other objects + * to be in the space of the view defined by the parameters. + * + * @param eye - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The look-at matrix. + */ + function lookAt(eye, target, up, dst) { + dst = dst || new MatType(16); + xAxis = xAxis || create$4(); + yAxis = yAxis || create$4(); + zAxis = zAxis || create$4(); + normalize$2(subtract$2(eye, target, zAxis), zAxis); + normalize$2(cross(up, zAxis, xAxis), xAxis); + normalize$2(cross(zAxis, xAxis, yAxis), yAxis); + dst[0] = xAxis[0]; + dst[1] = yAxis[0]; + dst[2] = zAxis[0]; + dst[3] = 0; + dst[4] = xAxis[1]; + dst[5] = yAxis[1]; + dst[6] = zAxis[1]; + dst[7] = 0; + dst[8] = xAxis[2]; + dst[9] = yAxis[2]; + dst[10] = zAxis[2]; + dst[11] = 0; + dst[12] = -(xAxis[0] * eye[0] + xAxis[1] * eye[1] + xAxis[2] * eye[2]); + dst[13] = -(yAxis[0] * eye[0] + yAxis[1] * eye[1] + yAxis[2] * eye[2]); + dst[14] = -(zAxis[0] * eye[0] + zAxis[1] * eye[1] + zAxis[2] * eye[2]); + dst[15] = 1; + return dst; + } + /** + * Creates a 4-by-4 matrix which translates by the given vector v. + * @param v - The vector by + * which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translation matrix. + */ + function translation(v, dst) { + dst = dst || new MatType(16); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + dst[11] = 0; + dst[12] = v[0]; + dst[13] = v[1]; + dst[14] = v[2]; + dst[15] = 1; + return dst; + } + /** + * Translates the given 4-by-4 matrix by the given vector v. + * @param m - The matrix. + * @param v - The vector by + * which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translated matrix. + */ + function translate(m, v, dst) { + dst = dst || new MatType(16); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const m00 = m[0]; + const m01 = m[1]; + const m02 = m[2]; + const m03 = m[3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + if (m !== dst) { + dst[0] = m00; + dst[1] = m01; + dst[2] = m02; + dst[3] = m03; + dst[4] = m10; + dst[5] = m11; + dst[6] = m12; + dst[7] = m13; + dst[8] = m20; + dst[9] = m21; + dst[10] = m22; + dst[11] = m23; + } + dst[12] = m00 * v0 + m10 * v1 + m20 * v2 + m30; + dst[13] = m01 * v0 + m11 * v1 + m21 * v2 + m31; + dst[14] = m02 * v0 + m12 * v1 + m22 * v2 + m32; + dst[15] = m03 * v0 + m13 * v1 + m23 * v2 + m33; + return dst; + } + /** + * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ + function rotationX(angleInRadians, dst) { + dst = dst || new MatType(16); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = c; + dst[6] = s; + dst[7] = 0; + dst[8] = 0; + dst[9] = -s; + dst[10] = c; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; + } + /** + * Rotates the given 4-by-4 matrix around the x-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ + function rotateX$1(m, angleInRadians, dst) { + dst = dst || new MatType(16); + const m10 = m[4]; + const m11 = m[5]; + const m12 = m[6]; + const m13 = m[7]; + const m20 = m[8]; + const m21 = m[9]; + const m22 = m[10]; + const m23 = m[11]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[4] = c * m10 + s * m20; + dst[5] = c * m11 + s * m21; + dst[6] = c * m12 + s * m22; + dst[7] = c * m13 + s * m23; + dst[8] = c * m20 - s * m10; + dst[9] = c * m21 - s * m11; + dst[10] = c * m22 - s * m12; + dst[11] = c * m23 - s * m13; + if (m !== dst) { + dst[0] = m[0]; + dst[1] = m[1]; + dst[2] = m[2]; + dst[3] = m[3]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; + } + /** + * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ + function rotationY(angleInRadians, dst) { + dst = dst || new MatType(16); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c; + dst[1] = 0; + dst[2] = -s; + dst[3] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[7] = 0; + dst[8] = s; + dst[9] = 0; + dst[10] = c; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; + } + /** + * Rotates the given 4-by-4 matrix around the y-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ + function rotateY$1(m, angleInRadians, dst) { + dst = dst || new MatType(16); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c * m00 - s * m20; + dst[1] = c * m01 - s * m21; + dst[2] = c * m02 - s * m22; + dst[3] = c * m03 - s * m23; + dst[8] = c * m20 + s * m00; + dst[9] = c * m21 + s * m01; + dst[10] = c * m22 + s * m02; + dst[11] = c * m23 + s * m03; + if (m !== dst) { + dst[4] = m[4]; + dst[5] = m[5]; + dst[6] = m[6]; + dst[7] = m[7]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; + } + /** + * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ + function rotationZ(angleInRadians, dst) { + dst = dst || new MatType(16); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c; + dst[1] = s; + dst[2] = 0; + dst[3] = 0; + dst[4] = -s; + dst[5] = c; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; + } + /** + * Rotates the given 4-by-4 matrix around the z-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ + function rotateZ$1(m, angleInRadians, dst) { + dst = dst || new MatType(16); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c * m00 + s * m10; + dst[1] = c * m01 + s * m11; + dst[2] = c * m02 + s * m12; + dst[3] = c * m03 + s * m13; + dst[4] = c * m10 - s * m00; + dst[5] = c * m11 - s * m01; + dst[6] = c * m12 - s * m02; + dst[7] = c * m13 - s * m03; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + dst[11] = m[11]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; + } + /** + * Creates a 4-by-4 matrix which rotates around the given axis by the given + * angle. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A matrix which rotates angle radians + * around the axis. + */ + function axisRotation(axis, angleInRadians, dst) { + dst = dst || new MatType(16); + let x = axis[0]; + let y = axis[1]; + let z = axis[2]; + const n = Math.sqrt(x * x + y * y + z * z); + x /= n; + y /= n; + z /= n; + const xx = x * x; + const yy = y * y; + const zz = z * z; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + const oneMinusCosine = 1 - c; + dst[0] = xx + (1 - xx) * c; + dst[1] = x * y * oneMinusCosine + z * s; + dst[2] = x * z * oneMinusCosine - y * s; + dst[3] = 0; + dst[4] = x * y * oneMinusCosine - z * s; + dst[5] = yy + (1 - yy) * c; + dst[6] = y * z * oneMinusCosine + x * s; + dst[7] = 0; + dst[8] = x * z * oneMinusCosine + y * s; + dst[9] = y * z * oneMinusCosine - x * s; + dst[10] = zz + (1 - zz) * c; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; + } + /** + * Creates a 4-by-4 matrix which rotates around the given axis by the given + * angle. (same as axisRotation) + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A matrix which rotates angle radians + * around the axis. + */ + const rotation = axisRotation; + /** + * Rotates the given 4-by-4 matrix around the given axis by the + * given angle. + * @param m - The matrix. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ + function axisRotate(m, axis, angleInRadians, dst) { + dst = dst || new MatType(16); + let x = axis[0]; + let y = axis[1]; + let z = axis[2]; + const n = Math.sqrt(x * x + y * y + z * z); + x /= n; + y /= n; + z /= n; + const xx = x * x; + const yy = y * y; + const zz = z * z; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + const oneMinusCosine = 1 - c; + const r00 = xx + (1 - xx) * c; + const r01 = x * y * oneMinusCosine + z * s; + const r02 = x * z * oneMinusCosine - y * s; + const r10 = x * y * oneMinusCosine - z * s; + const r11 = yy + (1 - yy) * c; + const r12 = y * z * oneMinusCosine + x * s; + const r20 = x * z * oneMinusCosine + y * s; + const r21 = y * z * oneMinusCosine - x * s; + const r22 = zz + (1 - zz) * c; + const m00 = m[0]; + const m01 = m[1]; + const m02 = m[2]; + const m03 = m[3]; + const m10 = m[4]; + const m11 = m[5]; + const m12 = m[6]; + const m13 = m[7]; + const m20 = m[8]; + const m21 = m[9]; + const m22 = m[10]; + const m23 = m[11]; + dst[0] = r00 * m00 + r01 * m10 + r02 * m20; + dst[1] = r00 * m01 + r01 * m11 + r02 * m21; + dst[2] = r00 * m02 + r01 * m12 + r02 * m22; + dst[3] = r00 * m03 + r01 * m13 + r02 * m23; + dst[4] = r10 * m00 + r11 * m10 + r12 * m20; + dst[5] = r10 * m01 + r11 * m11 + r12 * m21; + dst[6] = r10 * m02 + r11 * m12 + r12 * m22; + dst[7] = r10 * m03 + r11 * m13 + r12 * m23; + dst[8] = r20 * m00 + r21 * m10 + r22 * m20; + dst[9] = r20 * m01 + r21 * m11 + r22 * m21; + dst[10] = r20 * m02 + r21 * m12 + r22 * m22; + dst[11] = r20 * m03 + r21 * m13 + r22 * m23; + if (m !== dst) { + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; + } + /** + * Rotates the given 4-by-4 matrix around the given axis by the + * given angle. (same as rotate) + * @param m - The matrix. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ + const rotate = axisRotate; + /** + * Creates a 4-by-4 matrix which scales in each dimension by an amount given by + * the corresponding entry in the given vector; assumes the vector has three + * entries. + * @param v - A vector of + * three entries specifying the factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ + function scaling(v, dst) { + dst = dst || new MatType(16); + dst[0] = v[0]; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = v[1]; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = v[2]; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; + } + /** + * Scales the given 4-by-4 matrix in each dimension by an amount + * given by the corresponding entry in the given vector; assumes the vector has + * three entries. + * @param m - The matrix to be modified. + * @param v - A vector of three entries specifying the + * factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ + function scale$2(m, v, dst) { + dst = dst || new MatType(16); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + dst[0] = v0 * m[0 * 4 + 0]; + dst[1] = v0 * m[0 * 4 + 1]; + dst[2] = v0 * m[0 * 4 + 2]; + dst[3] = v0 * m[0 * 4 + 3]; + dst[4] = v1 * m[1 * 4 + 0]; + dst[5] = v1 * m[1 * 4 + 1]; + dst[6] = v1 * m[1 * 4 + 2]; + dst[7] = v1 * m[1 * 4 + 3]; + dst[8] = v2 * m[2 * 4 + 0]; + dst[9] = v2 * m[2 * 4 + 1]; + dst[10] = v2 * m[2 * 4 + 2]; + dst[11] = v2 * m[2 * 4 + 3]; + if (m !== dst) { + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; + } + /** + * Creates a 4-by-4 matrix which scales a uniform amount in each dimension. + * @param s - the amount to scale + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ + function uniformScaling(s, dst) { + dst = dst || new MatType(16); + dst[0] = s; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = s; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = s; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; + } + /** + * Scales the given 4-by-4 matrix in each dimension by a uniform scale. + * @param m - The matrix to be modified. + * @param s - The amount to scale. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ + function uniformScale(m, s, dst) { + dst = dst || new MatType(16); + dst[0] = s * m[0 * 4 + 0]; + dst[1] = s * m[0 * 4 + 1]; + dst[2] = s * m[0 * 4 + 2]; + dst[3] = s * m[0 * 4 + 3]; + dst[4] = s * m[1 * 4 + 0]; + dst[5] = s * m[1 * 4 + 1]; + dst[6] = s * m[1 * 4 + 2]; + dst[7] = s * m[1 * 4 + 3]; + dst[8] = s * m[2 * 4 + 0]; + dst[9] = s * m[2 * 4 + 1]; + dst[10] = s * m[2 * 4 + 2]; + dst[11] = s * m[2 * 4 + 3]; + if (m !== dst) { + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; + } + + var mat4Impl = { + __proto__: null, + aim: aim, + axisRotate: axisRotate, + axisRotation: axisRotation, + cameraAim: cameraAim, + clone: clone$2, + copy: copy$2, + create: create$2, + determinant: determinant, + equals: equals$2, + equalsApproximately: equalsApproximately$2, + fromMat3: fromMat3, + fromQuat: fromQuat, + frustum: frustum, + frustumReverseZ: frustumReverseZ, + getAxis: getAxis, + getScaling: getScaling, + getTranslation: getTranslation, + identity: identity$1, + inverse: inverse$2, + invert: invert$1, + lookAt: lookAt, + mul: mul$2, + multiply: multiply$2, + negate: negate$1, + ortho: ortho, + perspective: perspective, + perspectiveReverseZ: perspectiveReverseZ, + rotate: rotate, + rotateX: rotateX$1, + rotateY: rotateY$1, + rotateZ: rotateZ$1, + rotation: rotation, + rotationX: rotationX, + rotationY: rotationY, + rotationZ: rotationZ, + scale: scale$2, + scaling: scaling, + set: set$2, + setAxis: setAxis, + setDefaultType: setDefaultType$3, + setTranslation: setTranslation, + translate: translate, + translation: translation, + transpose: transpose, + uniformScale: uniformScale, + uniformScaling: uniformScaling + }; + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + /** + * + * Quat4 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Quat4`. In other words you can do this + * + * const v = quat4.cross(v1, v2); // Creates a new Quat4 with the cross product of v1 x v2. + * + * or + * + * const v = quat4.create(); + * quat4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * quat4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ + let QuatType = Float32Array; + /** + * Sets the type this library creates for a Quat4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Quat4 + */ + function setDefaultType$2(ctor) { + const oldType = QuatType; + QuatType = ctor; + return oldType; + } + /** + * Creates a quat4; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param w - Initial w value. + * @returns the created vector + */ + function create$1(x, y, z, w) { + const dst = new QuatType(4); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + if (z !== undefined) { + dst[2] = z; + if (w !== undefined) { + dst[3] = w; + } + } + } + } + return dst; + } + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + /** + * Creates a Quat; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param z - Initial w value. + * @returns the created vector + */ + const fromValues$1 = create$1; + /** + * Sets the values of a Quat + * Also see {@link quat.create} and {@link quat.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param w fourth value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ + function set$1(x, y, z, w, dst) { + dst = dst || new QuatType(4); + dst[0] = x; + dst[1] = y; + dst[2] = z; + dst[3] = w; + return dst; + } + /** + * Sets a quaternion from the given angle and axis, + * then returns it. + * + * @param axis - the axis to rotate around + * @param angleInRadians - the angle + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The quaternion that represents the given axis and angle + **/ + function fromAxisAngle(axis, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const s = Math.sin(halfAngle); + dst[0] = s * axis[0]; + dst[1] = s * axis[1]; + dst[2] = s * axis[2]; + dst[3] = Math.cos(halfAngle); + return dst; + } + /** + * Gets the rotation axis and angle + * @param q - quaternion to compute from + * @param dst - Vec3 to hold result. If not passed in a new one is created. + * @return angle and axis + */ + function toAxisAngle(q, dst) { + dst = dst || create$4(4); + const angle = Math.acos(q[3]) * 2; + const s = Math.sin(angle * 0.5); + if (s > EPSILON) { + dst[0] = q[0] / s; + dst[1] = q[1] / s; + dst[2] = q[2] / s; + } + else { + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + } + return { angle, axis: dst }; + } + /** + * Returns the angle in degrees between two rotations a and b. + * @param a - quaternion a + * @param b - quaternion b + * @return angle in radians between the two quaternions + */ + function angle(a, b) { + const d = dot$1(a, b); + return Math.acos(2 * d * d - 1); + } + /** + * Multiplies two quaternions + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ + function multiply$1(a, b, dst) { + dst = dst || new QuatType(4); + const ax = a[0]; + const ay = a[1]; + const az = a[2]; + const aw = a[3]; + const bx = b[0]; + const by = b[1]; + const bz = b[2]; + const bw = b[3]; + dst[0] = ax * bw + aw * bx + ay * bz - az * by; + dst[1] = ay * bw + aw * by + az * bx - ax * bz; + dst[2] = az * bw + aw * bz + ax * by - ay * bx; + dst[3] = aw * bw - ax * bx - ay * by - az * bz; + return dst; + } + /** + * Multiplies two quaternions + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ + const mul$1 = multiply$1; + /** + * Rotates the given quaternion around the X axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ + function rotateX(q, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const qw = q[3]; + const bx = Math.sin(halfAngle); + const bw = Math.cos(halfAngle); + dst[0] = qx * bw + qw * bx; + dst[1] = qy * bw + qz * bx; + dst[2] = qz * bw - qy * bx; + dst[3] = qw * bw - qx * bx; + return dst; + } + /** + * Rotates the given quaternion around the Y axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ + function rotateY(q, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const qw = q[3]; + const by = Math.sin(halfAngle); + const bw = Math.cos(halfAngle); + dst[0] = qx * bw - qz * by; + dst[1] = qy * bw + qw * by; + dst[2] = qz * bw + qx * by; + dst[3] = qw * bw - qy * by; + return dst; + } + /** + * Rotates the given quaternion around the Z axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ + function rotateZ(q, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const qw = q[3]; + const bz = Math.sin(halfAngle); + const bw = Math.cos(halfAngle); + dst[0] = qx * bw + qy * bz; + dst[1] = qy * bw - qx * bz; + dst[2] = qz * bw + qw * bz; + dst[3] = qw * bw - qz * bz; + return dst; + } + /** + * Spherically linear interpolate between two quaternions + * + * @param a - starting value + * @param b - ending value + * @param t - value where 0 = a and 1 = b + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ + function slerp(a, b, t, dst) { + dst = dst || new QuatType(4); + const ax = a[0]; + const ay = a[1]; + const az = a[2]; + const aw = a[3]; + let bx = b[0]; + let by = b[1]; + let bz = b[2]; + let bw = b[3]; + let cosOmega = ax * bx + ay * by + az * bz + aw * bw; + if (cosOmega < 0) { + cosOmega = -cosOmega; + bx = -bx; + by = -by; + bz = -bz; + bw = -bw; + } + let scale0; + let scale1; + if (1.0 - cosOmega > EPSILON) { + const omega = Math.acos(cosOmega); + const sinOmega = Math.sin(omega); + scale0 = Math.sin((1 - t) * omega) / sinOmega; + scale1 = Math.sin(t * omega) / sinOmega; + } + else { + scale0 = 1.0 - t; + scale1 = t; + } + dst[0] = scale0 * ax + scale1 * bx; + dst[1] = scale0 * ay + scale1 * by; + dst[2] = scale0 * az + scale1 * bz; + dst[3] = scale0 * aw + scale1 * bw; + return dst; + } + /** + * Compute the inverse of a quaternion + * + * @param q - quaternion to compute the inverse of + * @returns A quaternion that is the result of a * b + */ + function inverse$1(q, dst) { + dst = dst || new QuatType(4); + const a0 = q[0]; + const a1 = q[1]; + const a2 = q[2]; + const a3 = q[3]; + const dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + const invDot = dot ? 1 / dot : 0; + dst[0] = -a0 * invDot; + dst[1] = -a1 * invDot; + dst[2] = -a2 * invDot; + dst[3] = a3 * invDot; + return dst; + } + /** + * Compute the conjugate of a quaternion + * For quaternions with a magnitude of 1 (a unit quaternion) + * this returns the same as the inverse but is faster to calculate. + * + * @param q - quaternion to compute the conjugate of. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The conjugate of q + */ + function conjugate(q, dst) { + dst = dst || new QuatType(4); + dst[0] = -q[0]; + dst[1] = -q[1]; + dst[2] = -q[2]; + dst[3] = q[3]; + return dst; + } + /** + * Creates a quaternion from the given rotation matrix. + * + * The created quaternion is not normalized. + * + * @param m - rotation matrix + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns the result + */ + function fromMat(m, dst) { + dst = dst || new QuatType(4); + /* + 0 1 2 + 3 4 5 + 6 7 8 + + 0 1 2 + 4 5 6 + 8 9 10 + */ + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + const trace = m[0] + m[5] + m[10]; + if (trace > 0.0) { + // |w| > 1/2, may as well choose w > 1/2 + const root = Math.sqrt(trace + 1); // 2w + dst[3] = 0.5 * root; + const invRoot = 0.5 / root; // 1/(4w) + dst[0] = (m[6] - m[9]) * invRoot; + dst[1] = (m[8] - m[2]) * invRoot; + dst[2] = (m[1] - m[4]) * invRoot; + } + else { + // |w| <= 1/2 + let i = 0; + if (m[5] > m[0]) { + i = 1; + } + if (m[10] > m[i * 4 + i]) { + i = 2; + } + const j = (i + 1) % 3; + const k = (i + 2) % 3; + const root = Math.sqrt(m[i * 4 + i] - m[j * 4 + j] - m[k * 4 + k] + 1.0); + dst[i] = 0.5 * root; + const invRoot = 0.5 / root; + dst[3] = (m[j * 4 + k] - m[k * 4 + j]) * invRoot; + dst[j] = (m[j * 4 + i] + m[i * 4 + j]) * invRoot; + dst[k] = (m[k * 4 + i] + m[i * 4 + k]) * invRoot; + } + return dst; + } + /** + * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion. + * + * @param xAngleInRadians - angle to rotate around X axis in radians. + * @param yAngleInRadians - angle to rotate around Y axis in radians. + * @param zAngleInRadians - angle to rotate around Z axis in radians. + * @param order - order to apply euler angles + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion representing the same rotation as the euler angles applied in the given order + */ + function fromEuler(xAngleInRadians, yAngleInRadians, zAngleInRadians, order, dst) { + dst = dst || new QuatType(4); + const xHalfAngle = xAngleInRadians * 0.5; + const yHalfAngle = yAngleInRadians * 0.5; + const zHalfAngle = zAngleInRadians * 0.5; + const sx = Math.sin(xHalfAngle); + const cx = Math.cos(xHalfAngle); + const sy = Math.sin(yHalfAngle); + const cy = Math.cos(yHalfAngle); + const sz = Math.sin(zHalfAngle); + const cz = Math.cos(zHalfAngle); + switch (order) { + case 'xyz': + dst[0] = sx * cy * cz + cx * sy * sz; + dst[1] = cx * sy * cz - sx * cy * sz; + dst[2] = cx * cy * sz + sx * sy * cz; + dst[3] = cx * cy * cz - sx * sy * sz; + break; + case 'xzy': + dst[0] = sx * cy * cz - cx * sy * sz; + dst[1] = cx * sy * cz - sx * cy * sz; + dst[2] = cx * cy * sz + sx * sy * cz; + dst[3] = cx * cy * cz + sx * sy * sz; + break; + case 'yxz': + dst[0] = sx * cy * cz + cx * sy * sz; + dst[1] = cx * sy * cz - sx * cy * sz; + dst[2] = cx * cy * sz - sx * sy * cz; + dst[3] = cx * cy * cz + sx * sy * sz; + break; + case 'yzx': + dst[0] = sx * cy * cz + cx * sy * sz; + dst[1] = cx * sy * cz + sx * cy * sz; + dst[2] = cx * cy * sz - sx * sy * cz; + dst[3] = cx * cy * cz - sx * sy * sz; + break; + case 'zxy': + dst[0] = sx * cy * cz - cx * sy * sz; + dst[1] = cx * sy * cz + sx * cy * sz; + dst[2] = cx * cy * sz + sx * sy * cz; + dst[3] = cx * cy * cz - sx * sy * sz; + break; + case 'zyx': + dst[0] = sx * cy * cz - cx * sy * sz; + dst[1] = cx * sy * cz + sx * cy * sz; + dst[2] = cx * cy * sz - sx * sy * cz; + dst[3] = cx * cy * cz + sx * sy * sz; + break; + default: + throw new Error(`Unknown rotation order: ${order}`); + } + return dst; + } + /** + * Copies a quaternion. (same as {@link quat.clone}) + * Also see {@link quat.create} and {@link quat.set} + * @param q - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is a copy of q + */ + function copy$1(q, dst) { + dst = dst || new QuatType(4); + dst[0] = q[0]; + dst[1] = q[1]; + dst[2] = q[2]; + dst[3] = q[3]; + return dst; + } + /** + * Clones a quaternion. (same as {@link quat.copy}) + * Also see {@link quat.create} and {@link quat.set} + * @param q - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A copy of q. + */ + const clone$1 = copy$1; + /** + * Adds two quaternions; assumes a and b have the same dimension. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the sum of a and b. + */ + function add$1(a, b, dst) { + dst = dst || new QuatType(4); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + dst[2] = a[2] + b[2]; + dst[3] = a[3] + b[3]; + return dst; + } + /** + * Subtracts two quaternions. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the difference of a and b. + */ + function subtract$1(a, b, dst) { + dst = dst || new QuatType(4); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + dst[2] = a[2] - b[2]; + dst[3] = a[3] - b[3]; + return dst; + } + /** + * Subtracts two quaternions. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the difference of a and b. + */ + const sub$1 = subtract$1; + /** + * Multiplies a quaternion by a scalar. + * @param v - The quaternion. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ + function mulScalar$1(v, k, dst) { + dst = dst || new QuatType(4); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + dst[2] = v[2] * k; + dst[3] = v[3] * k; + return dst; + } + /** + * Multiplies a quaternion by a scalar. (same as mulScalar) + * @param v - The quaternion. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ + const scale$1 = mulScalar$1; + /** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ + function divScalar$1(v, k, dst) { + dst = dst || new QuatType(4); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + dst[2] = v[2] / k; + dst[3] = v[3] / k; + return dst; + } + /** + * Computes the dot product of two quaternions + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns dot product + */ + function dot$1(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]); + } + /** + * Performs linear interpolation on two quaternions. + * Given quaternions a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param t - Interpolation coefficient. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ + function lerp$1(a, b, t, dst) { + dst = dst || new QuatType(4); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + dst[2] = a[2] + t * (b[2] - a[2]); + dst[3] = a[3] + t * (b[3] - a[3]); + return dst; + } + /** + * Computes the length of quaternion + * @param v - quaternion. + * @returns length of quaternion. + */ + function length$1(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); + } + /** + * Computes the length of quaternion (same as length) + * @param v - quaternion. + * @returns length of quaternion. + */ + const len$1 = length$1; + /** + * Computes the square of the length of quaternion + * @param v - quaternion. + * @returns square of the length of quaternion. + */ + function lengthSq$1(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3; + } + /** + * Computes the square of the length of quaternion (same as lengthSq) + * @param v - quaternion. + * @returns square of the length of quaternion. + */ + const lenSq$1 = lengthSq$1; + /** + * Divides a quaternion by its Euclidean length and returns the quotient. + * @param v - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The normalized quaternion. + */ + function normalize$1(v, dst) { + dst = dst || new QuatType(4); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + dst[2] = v2 / len; + dst[3] = v3 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + } + return dst; + } + /** + * Check if 2 quaternions are approximately equal + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns true if quaternions are approximately equal + */ + function equalsApproximately$1(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON && + Math.abs(a[3] - b[3]) < EPSILON; + } + /** + * Check if 2 quaternions are exactly equal + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns true if quaternions are exactly equal + */ + function equals$1(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; + } + /** + * Creates an identity quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns an identity quaternion + */ + function identity(dst) { + dst = dst || new QuatType(4); + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 1; + return dst; + } + let tempVec3; + let xUnitVec3; + let yUnitVec3; + /** + * Computes a quaternion to represent the shortest rotation from one vector to another. + * + * @param aUnit - the start vector + * @param bUnit - the end vector + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns the result + */ + function rotationTo(aUnit, bUnit, dst) { + dst = dst || new QuatType(4); + tempVec3 = tempVec3 || create$4(); + xUnitVec3 = xUnitVec3 || create$4(1, 0, 0); + yUnitVec3 = yUnitVec3 || create$4(0, 1, 0); + const dot = dot$2(aUnit, bUnit); + if (dot < -0.999999) { + cross(xUnitVec3, aUnit, tempVec3); + if (len$2(tempVec3) < 0.000001) { + cross(yUnitVec3, aUnit, tempVec3); + } + normalize$2(tempVec3, tempVec3); + fromAxisAngle(tempVec3, Math.PI, dst); + return dst; + } + else if (dot > 0.999999) { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 1; + return dst; + } + else { + cross(aUnit, bUnit, tempVec3); + dst[0] = tempVec3[0]; + dst[1] = tempVec3[1]; + dst[2] = tempVec3[2]; + dst[3] = 1 + dot; + return normalize$1(dst, dst); + } + } + let tempQuat1; + let tempQuat2; + /** + * Performs a spherical linear interpolation with two control points + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param c - the third quaternion + * @param d - the fourth quaternion + * @param t - Interpolation coefficient 0 to 1 + * @returns result + */ + function sqlerp(a, b, c, d, t, dst) { + dst = dst || new QuatType(4); + tempQuat1 = tempQuat1 || new QuatType(4); + tempQuat2 = tempQuat2 || new QuatType(4); + slerp(a, d, t, tempQuat1); + slerp(b, c, t, tempQuat2); + slerp(tempQuat1, tempQuat2, 2 * t * (1 - t), dst); + return dst; + } + + var quatImpl = { + __proto__: null, + add: add$1, + angle: angle, + clone: clone$1, + conjugate: conjugate, + copy: copy$1, + create: create$1, + divScalar: divScalar$1, + dot: dot$1, + equals: equals$1, + equalsApproximately: equalsApproximately$1, + fromAxisAngle: fromAxisAngle, + fromEuler: fromEuler, + fromMat: fromMat, + fromValues: fromValues$1, + identity: identity, + inverse: inverse$1, + len: len$1, + lenSq: lenSq$1, + length: length$1, + lengthSq: lengthSq$1, + lerp: lerp$1, + mul: mul$1, + mulScalar: mulScalar$1, + multiply: multiply$1, + normalize: normalize$1, + rotateX: rotateX, + rotateY: rotateY, + rotateZ: rotateZ, + rotationTo: rotationTo, + scale: scale$1, + set: set$1, + setDefaultType: setDefaultType$2, + slerp: slerp, + sqlerp: sqlerp, + sub: sub$1, + subtract: subtract$1, + toAxisAngle: toAxisAngle + }; + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + /** + * + * Vec4 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Vec4`. In other words you can do this + * + * const v = vec4.cross(v1, v2); // Creates a new Vec4 with the cross product of v1 x v2. + * + * or + * + * const v = vec4.create(); + * vec4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ + let VecType = Float32Array; + /** + * Sets the type this library creates for a Vec4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec4 + */ + function setDefaultType$1(ctor) { + const oldType = VecType; + VecType = ctor; + return oldType; + } + /** + * Creates a vec4; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param w - Initial w value. + * @returns the created vector + */ + function create(x, y, z, w) { + const dst = new VecType(4); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + if (z !== undefined) { + dst[2] = z; + if (w !== undefined) { + dst[3] = w; + } + } + } + } + return dst; + } + + /* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + /** + * Creates a vec4; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param z - Initial w value. + * @returns the created vector + */ + const fromValues = create; + /** + * Sets the values of a Vec4 + * Also see {@link vec4.create} and {@link vec4.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param w fourth value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ + function set(x, y, z, w, dst) { + dst = dst || new VecType(4); + dst[0] = x; + dst[1] = y; + dst[2] = z; + dst[3] = w; + return dst; + } + /** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ + function ceil(v, dst) { + dst = dst || new VecType(4); + dst[0] = Math.ceil(v[0]); + dst[1] = Math.ceil(v[1]); + dst[2] = Math.ceil(v[2]); + dst[3] = Math.ceil(v[3]); + return dst; + } + /** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ + function floor(v, dst) { + dst = dst || new VecType(4); + dst[0] = Math.floor(v[0]); + dst[1] = Math.floor(v[1]); + dst[2] = Math.floor(v[2]); + dst[3] = Math.floor(v[3]); + return dst; + } + /** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ + function round(v, dst) { + dst = dst || new VecType(4); + dst[0] = Math.round(v[0]); + dst[1] = Math.round(v[1]); + dst[2] = Math.round(v[2]); + dst[3] = Math.round(v[3]); + return dst; + } + /** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ + function clamp(v, min = 0, max = 1, dst) { + dst = dst || new VecType(4); + dst[0] = Math.min(max, Math.max(min, v[0])); + dst[1] = Math.min(max, Math.max(min, v[1])); + dst[2] = Math.min(max, Math.max(min, v[2])); + dst[3] = Math.min(max, Math.max(min, v[3])); + return dst; + } + /** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ + function add(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + dst[2] = a[2] + b[2]; + dst[3] = a[3] + b[3]; + return dst; + } + /** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ + function addScaled(a, b, scale, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + b[0] * scale; + dst[1] = a[1] + b[1] * scale; + dst[2] = a[2] + b[2] * scale; + dst[3] = a[3] + b[3] * scale; + return dst; + } + /** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ + function subtract(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + dst[2] = a[2] - b[2]; + dst[3] = a[3] - b[3]; + return dst; + } + /** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ + const sub = subtract; + /** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ + function equalsApproximately(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON && + Math.abs(a[3] - b[3]) < EPSILON; + } + /** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ + function equals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; + } + /** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ + function lerp(a, b, t, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + dst[2] = a[2] + t * (b[2] - a[2]); + dst[3] = a[3] + t * (b[3] - a[3]); + return dst; + } + /** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ + function lerpV(a, b, t, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + t[0] * (b[0] - a[0]); + dst[1] = a[1] + t[1] * (b[1] - a[1]); + dst[2] = a[2] + t[2] * (b[2] - a[2]); + dst[3] = a[3] + t[3] * (b[3] - a[3]); + return dst; + } + /** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ + function max(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = Math.max(a[0], b[0]); + dst[1] = Math.max(a[1], b[1]); + dst[2] = Math.max(a[2], b[2]); + dst[3] = Math.max(a[3], b[3]); + return dst; + } + /** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ + function min(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = Math.min(a[0], b[0]); + dst[1] = Math.min(a[1], b[1]); + dst[2] = Math.min(a[2], b[2]); + dst[3] = Math.min(a[3], b[3]); + return dst; + } + /** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ + function mulScalar(v, k, dst) { + dst = dst || new VecType(4); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + dst[2] = v[2] * k; + dst[3] = v[3] * k; + return dst; + } + /** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ + const scale = mulScalar; + /** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ + function divScalar(v, k, dst) { + dst = dst || new VecType(4); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + dst[2] = v[2] / k; + dst[3] = v[3] / k; + return dst; + } + /** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ + function inverse(v, dst) { + dst = dst || new VecType(4); + dst[0] = 1 / v[0]; + dst[1] = 1 / v[1]; + dst[2] = 1 / v[2]; + dst[3] = 1 / v[3]; + return dst; + } + /** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ + const invert = inverse; + /** + * Computes the dot product of two vectors + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ + function dot(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]); + } + /** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ + function length(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); + } + /** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ + const len = length; + /** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ + function lengthSq(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3; + } + /** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ + const lenSq = lengthSq; + /** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ + function distance(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + const dw = a[3] - b[3]; + return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); + } + /** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ + const dist = distance; + /** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ + function distanceSq(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + const dw = a[3] - b[3]; + return dx * dx + dy * dy + dz * dz + dw * dw; + } + /** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ + const distSq = distanceSq; + /** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ + function normalize(v, dst) { + dst = dst || new VecType(4); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + dst[2] = v2 / len; + dst[3] = v3 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + } + return dst; + } + /** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ + function negate(v, dst) { + dst = dst || new VecType(4); + dst[0] = -v[0]; + dst[1] = -v[1]; + dst[2] = -v[2]; + dst[3] = -v[3]; + return dst; + } + /** + * Copies a vector. (same as {@link vec4.clone}) + * Also see {@link vec4.create} and {@link vec4.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ + function copy(v, dst) { + dst = dst || new VecType(4); + dst[0] = v[0]; + dst[1] = v[1]; + dst[2] = v[2]; + dst[3] = v[3]; + return dst; + } + /** + * Clones a vector. (same as {@link vec4.copy}) + * Also see {@link vec4.create} and {@link vec4.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ + const clone = copy; + /** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ + function multiply(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + dst[2] = a[2] * b[2]; + dst[3] = a[3] * b[3]; + return dst; + } + /** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ + const mul = multiply; + /** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ + function divide(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] / b[0]; + dst[1] = a[1] / b[1]; + dst[2] = a[2] / b[2]; + dst[3] = a[3] / b[3]; + return dst; + } + /** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ + const div = divide; + /** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ + function zero(dst) { + dst = dst || new VecType(4); + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + return dst; + } + /** + * transform vec4 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec4 to store result. If not passed a new one is created. + * @returns the transformed vector + */ + function transformMat4(v, m, dst) { + dst = dst || new VecType(4); + const x = v[0]; + const y = v[1]; + const z = v[2]; + const w = v[3]; + dst[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + dst[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + dst[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + dst[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + return dst; + } + /** + * Treat a 4D vector as a direction and set it's length + * + * @param a The vec4 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ + function setLength(a, len, dst) { + dst = dst || new VecType(4); + normalize(a, dst); + return mulScalar(dst, len, dst); + } + /** + * Ensure a vector is not longer than a max length + * + * @param a The vec4 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ + function truncate(a, maxLen, dst) { + dst = dst || new VecType(4); + if (length(a) > maxLen) { + return setLength(a, maxLen, dst); + } + return copy(a, dst); + } + /** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ + function midpoint(a, b, dst) { + dst = dst || new VecType(4); + return lerp(a, b, 0.5, dst); + } + + var vec4Impl = { + __proto__: null, + add: add, + addScaled: addScaled, + ceil: ceil, + clamp: clamp, + clone: clone, + copy: copy, + create: create, + dist: dist, + distSq: distSq, + distance: distance, + distanceSq: distanceSq, + div: div, + divScalar: divScalar, + divide: divide, + dot: dot, + equals: equals, + equalsApproximately: equalsApproximately, + floor: floor, + fromValues: fromValues, + inverse: inverse, + invert: invert, + len: len, + lenSq: lenSq, + length: length, + lengthSq: lengthSq, + lerp: lerp, + lerpV: lerpV, + max: max, + midpoint: midpoint, + min: min, + mul: mul, + mulScalar: mulScalar, + multiply: multiply, + negate: negate, + normalize: normalize, + round: round, + scale: scale, + set: set, + setDefaultType: setDefaultType$1, + setLength: setLength, + sub: sub, + subtract: subtract, + transformMat4: transformMat4, + truncate: truncate, + zero: zero + }; + + /** + * Sets the type this library creates for all types + * + * example: + * + * ``` + * setDefaultType(Float64Array); + * ``` + * + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + */ + function setDefaultType(ctor) { + setDefaultType$4(ctor); + setDefaultType$3(ctor); + setDefaultType$2(ctor); + setDefaultType$6(ctor); + setDefaultType$5(ctor); + setDefaultType$1(ctor); + } + + exports.mat3 = mat3Impl; + exports.mat4 = mat4Impl; + exports.quat = quatImpl; + exports.setDefaultType = setDefaultType; + exports.utils = utils; + exports.vec2 = vec2Impl; + exports.vec3 = vec3Impl; + exports.vec4 = vec4Impl; + +})); +//# sourceMappingURL=wgpu-matrix.js.map diff --git a/dist/2.x/wgpu-matrix.js.map b/dist/2.x/wgpu-matrix.js.map new file mode 100644 index 0000000..3c9a94e --- /dev/null +++ b/dist/2.x/wgpu-matrix.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wgpu-matrix.js","sources":["../../../src/utils.ts","../../../src/vec2.ts","../../../src/vec3.ts","../../../src/vec2-impl.ts","../../../src/mat3-impl.ts","../../../src/vec3-impl.ts","../../../src/mat4-impl.ts","../../../src/quat.ts","../../../src/quat-impl.ts","../../../src/vec4.ts","../../../src/vec4-impl.ts","../../../src/wgpu-matrix.ts"],"sourcesContent":["/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nexport let EPSILON = 0.000001;\n\n/**\n * Set the value for EPSILON for various checks\n * @param v - Value to use for EPSILON.\n * @returns previous value of EPSILON;\n */\nexport function setEpsilon(v: number): number {\n const old = EPSILON;\n EPSILON = v;\n return old;\n}\n\n/**\n * Convert degrees to radians\n * @param degrees - Angle in degrees\n * @returns angle converted to radians\n */\nexport function degToRad(degrees: number): number {\n return degrees * Math.PI / 180;\n}\n\n/**\n * Convert radians to degrees\n * @param radians - Angle in radians\n * @returns angle converted to degrees\n */\nexport function radToDeg(radians: number): number {\n return radians * 180 / Math.PI;\n}\n\n/**\n * Lerps between a and b via t\n * @param a - starting value\n * @param b - ending value\n * @param t - value where 0 = a and 1 = b\n * @returns a + (b - a) * t\n */\nexport function lerp(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\n/**\n * Compute the opposite of lerp. Given a and b and a value between\n * a and b returns a value between 0 and 1. 0 if a, 1 if b.\n * Note: no clamping is done.\n * @param a - start value\n * @param b - end value\n * @param v - value between a and b\n * @returns (v - a) / (b - a)\n */\nexport function inverseLerp(a: number, b: number, v: number): number {\n const d = b - a;\n return (Math.abs(b - a) < EPSILON)\n ? a\n : (v - a) / d;\n}\n\n/**\n * Compute the euclidean modulo\n *\n * ```\n * // table for n / 3\n * -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 <- n\n * ------------------------------------\n * -2 -1 -0 -2 -1 0, 1, 2, 0, 1, 2 <- n % 3\n * 1 2 0 1 2 0, 1, 2, 0, 1, 2 <- euclideanModule(n, 3)\n * ```\n *\n * @param n - dividend\n * @param m - divisor\n * @returns the euclidean modulo of n / m\n */\nexport function euclideanModulo(n: number, m: number) {\n return ((n % m) + m) % m;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 2 values, Float32Array with 2 values, or a Float64Array with 2 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec2.setDefaultType}.\n */\nexport type Vec2 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec2 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new Vec2. In other words you can do this\n *\n * const v = vec2.cross(v1, v2); // Creates a new Vec2 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec2.create();\n * vec2.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec2.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec2 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec2\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec2\n */\nexport function setDefaultType(ctor: new (n: number) => Vec2) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a Vec2; may be called with x, y, z to set initial values.\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Vec2's specified type\n * it would be faster to use\n *\n * ```\n * const v = vec2.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Vec2Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `vec2.create` is usually used\n * to create a Vec2 to be filled out as in\n *\n * ```\n * const sum = vec2.create();\n * vec2.add(v1, v2, sum);\n * ```\n *\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @returns the created vector\n */\nexport function create(x = 0, y = 0): Vec2 {\n const dst = new VecType(2);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n }\n }\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 3 values, Float32Array with 3 values, or a Float64Array with 3 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec3.setDefaultType}.\n */\nexport type Vec3 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec3 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Vec3`. In other words you can do this\n *\n * const v = vec3.cross(v1, v2); // Creates a new Vec3 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec3.create();\n * vec3.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec3.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec3 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec3\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec3\n */\nexport function setDefaultType(ctor: new (n: number) => Vec3) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a vec3; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number): Vec3 {\n const dst = new VecType(3);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Vec2, create, setDefaultType, VecType } from './vec2';\nimport { Vec3, VecType as Vec3Type } from './vec3';\n\nexport default Vec2;\nexport { create, setDefaultType };\n\n/**\n * Creates a Vec2; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec2\n * Also see {@link vec2.create} and {@link vec2.copy}\n *\n * @param x first value\n * @param y second value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = x;\n dst[1] = y;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec2, min = 0, max = 1, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec2, b: Vec2, scale: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n\n return dst;\n}\n\n/**\n * Returns the angle in radians between two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns The angle in radians between the 2 vectors.\n */\nexport function angle(a: Vec2, b: Vec2): number {\n const ax = a[0];\n const ay = a[1];\n const bx = b[0];\n const by = b[1];\n const mag1 = Math.sqrt(ax * ax + ay * ay);\n const mag2 = Math.sqrt(bx * bx + by * by);\n const mag = mag1 * mag2;\n const cosine = mag && dot(a, b) / mag;\n return Math.acos(cosine);\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec2, b: Vec2): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec2, b: Vec2): boolean {\n return a[0] === b[0] && a[1] === b[1];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec2, b: Vec2, t: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec2, b: Vec2, t: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec2, k: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec2, k: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the cross product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of a cross b.\n */\nexport function cross(a: Vec2, b: Vec2, dst?: Vec3): Vec3 {\n dst = dst || new Vec3Type(3);\n const z = a[0] * b[1] - a[1] * b[0];\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = z;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec2, b: Vec2): number {\n return a[0] * b[0] + a[1] * b[1];\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec2): number {\n const v0 = v[0];\n const v1 = v[1];\n return Math.sqrt(v0 * v0 + v1 * v1);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec2): number {\n const v0 = v[0];\n const v1 = v[1];\n return v0 * v0 + v1 * v1;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec2, b: Vec2): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n return Math.sqrt(dx * dx + dy * dy);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec2, b: Vec2): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n return dx * dx + dy * dy;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const v0 = v[0];\n const v1 = v[1];\n const len = Math.sqrt(v0 * v0 + v1 * v1);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n }\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec2.clone})\n * Also see {@link vec2.create} and {@link vec2.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0];\n dst[1] = v[1];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec2.copy})\n * Also see {@link vec2.create} and {@link vec2.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec2, b: Vec2, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Creates a random unit vector * scale\n * @param scale - Default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The random vector.\n */\nexport function random(scale = 1, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const angle = Math.random() * 2 * Math.PI;\n dst[0] = Math.cos(angle) * scale;\n dst[1] = Math.sin(angle) * scale;\n\n return dst;\n}\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = 0;\n dst[1] = 0;\n\n return dst;\n}\n\n\n/**\n * transform Vec2 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional Vec2 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec2, m: Mat4, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const x = v[0];\n const y = v[1];\n\n dst[0] = x * m[0] + y * m[4] + m[12];\n dst[1] = x * m[1] + y * m[5] + m[13];\n\n return dst;\n}\n\n/**\n * Transforms vec4 by 3x3 matrix\n *\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional Vec2 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat3(v: Vec2, m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const x = v[0];\n const y = v[1];\n\n dst[0] = m[0] * x + m[4] * y + m[8];\n dst[1] = m[1] * x + m[5] * y + m[9];\n\n return dst;\n}\n\n/**\n * Rotate a 2D vector\n *\n * @param a The vec2 point to rotate\n * @param b The origin of the rotation\n * @param rad The angle of rotation in radians\n * @returns the rotated vector\n */\nexport function rotate(a: Vec2, b: Vec2, rad: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n // Translate point to the origin\n const p0 = a[0] - b[0];\n const p1 = a[1] - b[1];\n const sinC = Math.sin(rad);\n const cosC = Math.cos(rad);\n\n //perform rotation and translate to correct position\n dst[0] = p0 * cosC - p1 * sinC + b[0];\n dst[1] = p0 * sinC + p1 * cosC + b[1];\n\n return dst;\n}\n\n/**\n * Treat a 2D vector as a direction and set it's length\n *\n * @param a The vec2 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec2, len: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec2 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec2, maxLen: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec2, b: Vec2, dst?: Vec2) {\n dst = dst || new VecType(2);\n return lerp(a, b, 0.5, dst);\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nimport * as utils from './utils.js';\nimport { Quat } from './quat';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport Vec2, * as vec2 from './vec2-impl';\n\nexport default Mat3;\n\nexport type Mat3LikeCtor = new (n: number) => Mat3;\n\n/**\n * 3x3 Matrix math math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new matrix. In other words you can do this\n *\n * const mat = mat3.translation([1, 2, 3]); // Creates a new translation matrix\n *\n * or\n *\n * const mat = mat3.create();\n * mat3.translation([1, 2, 3], mat); // Puts translation matrix in mat.\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always save to pass any matrix as the destination. So for example\n *\n * const mat = mat3.identity();\n * const trans = mat3.translation([1, 2, 3]);\n * mat3.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat.\n *\n */\nlet MatType: Mat3LikeCtor = Float32Array;\n\n// This mess is because with Mat3 we have 3 unused elements.\n// For Float32Array and Float64Array that's not an issue\n// but for Array it's troublesome\nconst ctorMap = new Map Mat3>([\n [Float32Array, () => new Float32Array(12)],\n [Float64Array, () => new Float64Array(12)],\n [Array, () => new Array(12).fill(0)],\n]);\nlet newMat3: () => Mat3 = ctorMap.get(Float32Array)!;\n\n/**\n * Sets the type this library creates for a Mat3\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Mat3\n */\nexport function setDefaultType(ctor: new (n: number) => Mat3) {\n const oldType = MatType;\n MatType = ctor;\n newMat3 = ctorMap.get(ctor)!;\n return oldType;\n}\n\n/**\n * Create a Mat3 from values\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Mat3's specified type\n * it would be faster to use\n *\n * ```\n * const m = mat3.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Mat3Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `mat3.create` is usually used\n * to create a Mat3 to be filled out as in\n *\n * ```\n * const m = mat3.create();\n * mat3.perspective(fov, aspect, near, far, m);\n * ```\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @returns matrix created from values.\n */\nexport function create(\n v0?: number, v1?: number, v2?: number,\n v3?: number, v4?: number, v5?: number,\n v6?: number, v7?: number, v8?: number): Mat3 {\n const dst = newMat3();\n // to make the array homogenous\n dst[3] = 0;\n dst[7] = 0;\n dst[11] = 0;\n\n if (v0 !== undefined) {\n dst[0] = v0;\n if (v1 !== undefined) {\n dst[1] = v1;\n if (v2 !== undefined) {\n dst[2] = v2;\n if (v3 !== undefined) {\n dst[4] = v3;\n if (v4 !== undefined) {\n dst[5] = v4;\n if (v5 !== undefined) {\n dst[6] = v5;\n if (v6 !== undefined) {\n dst[8] = v6;\n if (v7 !== undefined) {\n dst[9] = v7;\n if (v8 !== undefined) {\n dst[10] = v8;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n return dst;\n}\n\n/**\n * Sets the values of a Mat3\n * Also see {@link mat3.create} and {@link mat3.copy}\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 set from values.\n */\nexport function set(\n v0: number, v1: number, v2: number,\n v3: number, v4: number, v5: number,\n v6: number, v7: number, v8: number, dst?: Mat3) {\n dst = dst || newMat3();\n\n dst[0] = v0; dst[1] = v1; dst[ 2] = v2; dst[ 3] = 0;\n dst[4] = v3; dst[5] = v4; dst[ 6] = v5; dst[ 7] = 0;\n dst[8] = v6; dst[9] = v7; dst[10] = v8; dst[11] = 0;\n\n return dst;\n}\n\n/**\n * Creates a Mat3 from the upper left 3x3 part of a Mat4\n * @param m4 - source matrix\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 made from m4\n */\nexport function fromMat4(m4: Mat4, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n dst[0] = m4[0]; dst[1] = m4[1]; dst[ 2] = m4[ 2]; dst[ 3] = 0;\n dst[4] = m4[4]; dst[5] = m4[5]; dst[ 6] = m4[ 6]; dst[ 7] = 0;\n dst[8] = m4[8]; dst[9] = m4[9]; dst[10] = m4[10]; dst[11] = 0;\n return dst;\n}\n\n/**\n * Creates a Mat3 rotation matrix from a quaternion\n * @param q - quaternion to create matrix from\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 made from q\n */\nexport function fromQuat(q: Quat, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3];\n const x2 = x + x; const y2 = y + y; const z2 = z + z;\n\n const xx = x * x2;\n const yx = y * x2;\n const yy = y * y2;\n const zx = z * x2;\n const zy = z * y2;\n const zz = z * z2;\n const wx = w * x2;\n const wy = w * y2;\n const wz = w * z2;\n\n dst[ 0] = 1 - yy - zz; dst[ 1] = yx + wz; dst[ 2] = zx - wy; dst[ 3] = 0;\n dst[ 4] = yx - wz; dst[ 5] = 1 - xx - zz; dst[ 6] = zy + wx; dst[ 7] = 0;\n dst[ 8] = zx + wy; dst[ 9] = zy - wx; dst[10] = 1 - xx - yy; dst[11] = 0;\n\n return dst;\n}\n\n/**\n * Negates a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns -m.\n */\nexport function negate(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = -m[ 0]; dst[ 1] = -m[ 1]; dst[ 2] = -m[ 2];\n dst[ 4] = -m[ 4]; dst[ 5] = -m[ 5]; dst[ 6] = -m[ 6];\n dst[ 8] = -m[ 8]; dst[ 9] = -m[ 9]; dst[10] = -m[10];\n\n return dst;\n}\n\n/**\n * Copies a matrix. (same as {@link mat3.clone})\n * Also see {@link mat3.create} and {@link mat3.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport function copy(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = m[ 0]; dst[ 1] = m[ 1]; dst[ 2] = m[ 2];\n dst[ 4] = m[ 4]; dst[ 5] = m[ 5]; dst[ 6] = m[ 6];\n dst[ 8] = m[ 8]; dst[ 9] = m[ 9]; dst[10] = m[10];\n\n return dst;\n}\n\n/**\n * Copies a matrix (same as {@link mat3.copy})\n * Also see {@link mat3.create} and {@link mat3.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport const clone = copy;\n\n/**\n * Check if 2 matrices are approximately equal\n * @param a Operand matrix.\n * @param b Operand matrix.\n * @returns true if matrices are approximately equal\n */\nexport function equalsApproximately(a: Mat3, b: Mat3): boolean {\n return Math.abs(a[ 0] - b[ 0]) < utils.EPSILON &&\n Math.abs(a[ 1] - b[ 1]) < utils.EPSILON &&\n Math.abs(a[ 2] - b[ 2]) < utils.EPSILON &&\n Math.abs(a[ 4] - b[ 4]) < utils.EPSILON &&\n Math.abs(a[ 5] - b[ 5]) < utils.EPSILON &&\n Math.abs(a[ 6] - b[ 6]) < utils.EPSILON &&\n Math.abs(a[ 8] - b[ 8]) < utils.EPSILON &&\n Math.abs(a[ 9] - b[ 9]) < utils.EPSILON &&\n Math.abs(a[10] - b[10]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 matrices are exactly equal\n * @param a Operand matrix.\n * @param b Operand matrix.\n * @returns true if matrices are exactly equal\n */\nexport function equals(a: Mat3, b: Mat3): boolean {\n return a[ 0] === b[ 0] &&\n a[ 1] === b[ 1] &&\n a[ 2] === b[ 2] &&\n a[ 4] === b[ 4] &&\n a[ 5] === b[ 5] &&\n a[ 6] === b[ 6] &&\n a[ 8] === b[ 8] &&\n a[ 9] === b[ 9] &&\n a[10] === b[10];\n}\n\n/**\n * Creates a 3-by-3 identity matrix.\n *\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A 3-by-3 identity matrix.\n */\nexport function identity(dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Takes the transpose of a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The transpose of m.\n */\nexport function transpose(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n if (dst === m) {\n let t: number;\n\n // 0 1 2\n // 4 5 6\n // 8 9 10\n\n t = m[1];\n m[1] = m[4];\n m[4] = t;\n\n t = m[2];\n m[2] = m[8];\n m[8] = t;\n\n t = m[6];\n m[6] = m[9];\n m[9] = t;\n\n return dst;\n }\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n dst[ 0] = m00; dst[ 1] = m10; dst[ 2] = m20;\n dst[ 4] = m01; dst[ 5] = m11; dst[ 6] = m21;\n dst[ 8] = m02; dst[ 9] = m12; dst[10] = m22;\n\n return dst;\n}\n\n/**\n * Computes the inverse of a 3-by-3 matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport function inverse(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n const b01 = m22 * m11 - m12 * m21;\n const b11 = -m22 * m10 + m12 * m20;\n const b21 = m21 * m10 - m11 * m20;\n\n const invDet = 1 / (m00 * b01 + m01 * b11 + m02 * b21);\n\n dst[ 0] = b01 * invDet;\n dst[ 1] = (-m22 * m01 + m02 * m21) * invDet;\n dst[ 2] = ( m12 * m01 - m02 * m11) * invDet;\n dst[ 4] = b11 * invDet;\n dst[ 5] = ( m22 * m00 - m02 * m20) * invDet;\n dst[ 6] = (-m12 * m00 + m02 * m10) * invDet;\n dst[ 8] = b21 * invDet;\n dst[ 9] = (-m21 * m00 + m01 * m20) * invDet;\n dst[10] = ( m11 * m00 - m01 * m10) * invDet;\n\n return dst;\n}\n\n/**\n * Compute the determinant of a matrix\n * @param m - the matrix\n * @returns the determinant\n */\nexport function determinant(m: Mat3): number {\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n return m00 * (m11 * m22 - m21 * m12) -\n m10 * (m01 * m22 - m21 * m02) +\n m20 * (m01 * m12 - m11 * m02);\n}\n\n/**\n * Computes the inverse of a 3-by-3 matrix. (same as inverse)\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport const invert = inverse;\n\n/**\n * Multiplies two 3-by-3 matrices with a on the left and b on the right\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport function multiply(a: Mat3, b: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const a00 = a[0];\n const a01 = a[1];\n const a02 = a[2];\n const a10 = a[ 4 + 0];\n const a11 = a[ 4 + 1];\n const a12 = a[ 4 + 2];\n const a20 = a[ 8 + 0];\n const a21 = a[ 8 + 1];\n const a22 = a[ 8 + 2];\n const b00 = b[0];\n const b01 = b[1];\n const b02 = b[2];\n const b10 = b[ 4 + 0];\n const b11 = b[ 4 + 1];\n const b12 = b[ 4 + 2];\n const b20 = b[ 8 + 0];\n const b21 = b[ 8 + 1];\n const b22 = b[ 8 + 2];\n\n dst[ 0] = a00 * b00 + a10 * b01 + a20 * b02;\n dst[ 1] = a01 * b00 + a11 * b01 + a21 * b02;\n dst[ 2] = a02 * b00 + a12 * b01 + a22 * b02;\n dst[ 4] = a00 * b10 + a10 * b11 + a20 * b12;\n dst[ 5] = a01 * b10 + a11 * b11 + a21 * b12;\n dst[ 6] = a02 * b10 + a12 * b11 + a22 * b12;\n dst[ 8] = a00 * b20 + a10 * b21 + a20 * b22;\n dst[ 9] = a01 * b20 + a11 * b21 + a21 * b22;\n dst[10] = a02 * b20 + a12 * b21 + a22 * b22;\n\n return dst;\n}\n\n/**\n * Multiplies two 3-by-3 matrices with a on the left and b on the right (same as multiply)\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Sets the translation component of a 3-by-3 matrix to the given\n * vector.\n * @param a - The matrix.\n * @param v - The vector.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix with translation set.\n */\nexport function setTranslation(a: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || identity();\n if (a !== dst) {\n dst[ 0] = a[ 0];\n dst[ 1] = a[ 1];\n dst[ 2] = a[ 2];\n dst[ 4] = a[ 4];\n dst[ 5] = a[ 5];\n dst[ 6] = a[ 6];\n }\n dst[ 8] = v[0];\n dst[ 9] = v[1];\n dst[10] = 1;\n return dst;\n}\n\n/**\n * Returns the translation component of a 3-by-3 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n dst[0] = m[8];\n dst[1] = m[9];\n return dst;\n}\n\n/**\n * Returns an axis of a 3x3 matrix as a vector with 2 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y,\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat3, axis: number, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n return dst;\n}\n\n/**\n * Sets an axis of a 3x3 matrix as a vector with 2 entries\n * @param m - The matrix.\n * @param v - the axis vector\n * @param axis - The axis 0 = x, 1 = y;\n * @param dst - The matrix to set. If not passed a new one is created.\n * @returns The matrix with axis set.\n */\nexport function setAxis(m: Mat3, v: Vec2, axis: number, dst?: Mat3): Mat3 {\n if (dst !== m) {\n dst = copy(m, dst);\n }\n const off = axis * 4;\n dst[off + 0] = v[0];\n dst[off + 1] = v[1];\n return dst;\n}\n\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n\n const xx = m[0];\n const xy = m[1];\n const yx = m[4];\n const yy = m[5];\n\n dst[0] = Math.sqrt(xx * xx + xy * xy);\n dst[1] = Math.sqrt(yx * yx + yy * yy);\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which translates by the given vector v.\n * @param v - The vector by which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translation matrix.\n */\nexport function translation(v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0;\n dst[ 8] = v[0]; dst[ 9] = v[1]; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Translates the given 3-by-3 matrix by the given vector v.\n * @param m - The matrix.\n * @param v - The vector by which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translated matrix.\n */\nexport function translate(m: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const v0 = v[0];\n const v1 = v[1];\n\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n if (m !== dst) {\n dst[ 0] = m00;\n dst[ 1] = m01;\n dst[ 2] = m02;\n dst[ 4] = m10;\n dst[ 5] = m11;\n dst[ 6] = m12;\n }\n\n dst[ 8] = m00 * v0 + m10 * v1 + m20;\n dst[ 9] = m01 * v0 + m11 * v1 + m21;\n dst[10] = m02 * v0 + m12 * v1 + m22;\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which rotates by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotation(angleInRadians: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = s; dst[ 2] = 0;\n dst[ 4] = -s; dst[ 5] = c; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 3-by-3 matrix by the given angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotate(m: Mat3, angleInRadians: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 + s * m10;\n dst[ 1] = c * m01 + s * m11;\n dst[ 2] = c * m02 + s * m12;\n\n dst[ 4] = c * m10 - s * m00;\n dst[ 5] = c * m11 - s * m01;\n dst[ 6] = c * m12 - s * m02;\n\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which scales in each dimension by an amount given by\n * the corresponding entry in the given vector; assumes the vector has three\n * entries.\n * @param v - A vector of\n * 2 entries specifying the factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function scaling(v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = v[0]; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = v[1]; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 3-by-3 matrix in each dimension by an amount\n * given by the corresponding entry in the given vector; assumes the vector has\n * three entries.\n * @param m - The matrix to be modified.\n * @param v - A vector of 2 entries specifying the\n * factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function scale(m: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const v0 = v[0];\n const v1 = v[1];\n\n dst[ 0] = v0 * m[0 * 4 + 0];\n dst[ 1] = v0 * m[0 * 4 + 1];\n dst[ 2] = v0 * m[0 * 4 + 2];\n\n dst[ 4] = v1 * m[1 * 4 + 0];\n dst[ 5] = v1 * m[1 * 4 + 1];\n dst[ 6] = v1 * m[1 * 4 + 2];\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which scales uniformly in each dimension\n * @param s - Amount to scale\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function uniformScaling(s: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = s; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = s; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 3-by-3 matrix in each dimension by an amount\n * given.\n * @param m - The matrix to be modified.\n * @param s - Amount to scale.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function uniformScale(m: Mat3, s: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = s * m[0 * 4 + 0];\n dst[ 1] = s * m[0 * 4 + 1];\n dst[ 2] = s * m[0 * 4 + 2];\n\n dst[ 4] = s * m[1 * 4 + 0];\n dst[ 5] = s * m[1 * 4 + 1];\n dst[ 6] = s * m[1 * 4 + 2];\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Vec3, create, setDefaultType, VecType } from './vec3';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Quat } from './quat';\n\nexport default Vec3;\nexport { create, setDefaultType };\n\n/**\n * Creates a vec3; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec3\n * Also see {@link vec3.create} and {@link vec3.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n dst[2] = Math.ceil(v[2]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n dst[2] = Math.floor(v[2]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n dst[2] = Math.round(v[2]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec3, min = 0, max = 1, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n dst[2] = Math.min(max, Math.max(min, v[2]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec3, b: Vec3, scale: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n dst[2] = a[2] + b[2] * scale;\n\n return dst;\n}\n\n/**\n * Returns the angle in radians between two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns The angle in radians between the 2 vectors.\n */\nexport function angle(a: Vec3, b: Vec3): number {\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const bx = b[0];\n const by = b[1];\n const bz = b[2];\n const mag1 = Math.sqrt(ax * ax + ay * ay + az * az);\n const mag2 = Math.sqrt(bx * bx + by * by + bz * bz);\n const mag = mag1 * mag2;\n const cosine = mag && dot(a, b) / mag;\n return Math.acos(cosine);\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec3, b: Vec3): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec3, b: Vec3): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec3, b: Vec3, t: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec3, b: Vec3, t: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n dst[2] = a[2] + t[2] * (b[2] - a[2]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n dst[2] = Math.max(a[2], b[2]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n dst[2] = Math.min(a[2], b[2]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec3, k: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec3, k: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n dst[2] = 1 / v[2];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the cross product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of a cross b.\n */\nexport function cross(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const t1 = a[2] * b[0] - a[0] * b[2];\n const t2 = a[0] * b[1] - a[1] * b[0];\n dst[0] = a[1] * b[2] - a[2] * b[1];\n dst[1] = t1;\n dst[2] = t2;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec3, b: Vec3): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]);\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec3): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec3): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n return v0 * v0 + v1 * v1 + v2 * v2;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec3, b: Vec3): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n return Math.sqrt(dx * dx + dy * dy + dz * dz);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec3, b: Vec3): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n return dx * dx + dy * dy + dz * dz;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n }\n\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n dst[2] = -v[2];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec3.clone})\n * Also see {@link vec3.create} and {@link vec3.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0];\n dst[1] = v[1];\n dst[2] = v[2];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec3.copy})\n * Also see {@link vec3.create} and {@link vec3.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n dst[2] = a[2] * b[2];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n dst[2] = a[2] / b[2];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Creates a random vector\n * @param scale - Default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The random vector.\n */\nexport function random(scale = 1, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const angle = Math.random() * 2 * Math.PI;\n const z = Math.random() * 2 - 1;\n const zScale = Math.sqrt(1 - z * z) * scale;\n dst[0] = Math.cos(angle) * zScale;\n dst[1] = Math.sin(angle) * zScale;\n dst[2] = z * scale;\n\n return dst;\n}\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n\n return dst;\n}\n\n\n/**\n * transform vec3 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec3, m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n const w = (m[3] * x + m[7] * y + m[11] * z + m[15]) || 1;\n\n dst[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n dst[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n dst[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n\n return dst;\n}\n\n/**\n * Transform vec4 by upper 3x3 matrix inside 4x4 matrix.\n * @param v - The direction.\n * @param m - The matrix.\n * @param dst - optional Vec3 to store result. If not passed a new one is created.\n * @returns The transformed vector.\n */\nexport function transformMat4Upper3x3(v: Vec3, m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n\n dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0];\n dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1];\n dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v2 * m[2 * 4 + 2];\n\n return dst;\n}\n\n/**\n * Transforms vec3 by 3x3 matrix\n *\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat3(v: Vec3, m: Mat3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n\n dst[0] = x * m[0] + y * m[4] + z * m[8];\n dst[1] = x * m[1] + y * m[5] + z * m[9];\n dst[2] = x * m[2] + y * m[6] + z * m[10];\n\n return dst;\n}\n\n/**\n * Transforms vec3 by Quaternion\n * @param v - the vector to transform\n * @param q - the quaternion to transform by\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed\n */\nexport function transformQuat(v: Vec3, q: Quat, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const w2 = q[3] * 2;\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n\n const uvX = qy * z - qz * y;\n const uvY = qz * x - qx * z;\n const uvZ = qx * y - qy * x;\n\n dst[0] = x + uvX * w2 + (qy * uvZ - qz * uvY) * 2;\n dst[1] = y + uvY * w2 + (qz * uvX - qx * uvZ) * 2;\n dst[2] = z + uvZ * w2 + (qx * uvY - qy * uvX) * 2;\n\n return dst;\n}\n\n/**\n * Returns the translation component of a 4-by-4 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat3, dst?: Vec3) {\n dst = dst || new VecType(3);\n dst[0] = m[12];\n dst[1] = m[13];\n dst[2] = m[14];\n return dst;\n}\n/**\n * Returns an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat4, axis: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n dst[2] = m[off + 2];\n return dst;\n}\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat4, dst: Vec3) {\n dst = dst || new VecType(3);\n const xx = m[0];\n const xy = m[1];\n const xz = m[2];\n const yx = m[4];\n const yy = m[5];\n const yz = m[6];\n const zx = m[8];\n const zy = m[9];\n const zz = m[10];\n dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz);\n dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz);\n dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz);\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the x-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns the rotated vector\n */\nexport function rotateX(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n //Translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n //perform rotation\n r[0] = p[0];\n r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);\n r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad);\n\n //translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the y-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns the rotated vector\n */\nexport function rotateY(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n // translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n // perform rotation\n r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);\n r[1] = p[1];\n r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad);\n\n // translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the z-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns {vec3} out\n */\nexport function rotateZ(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n // translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n // perform rotation\n r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);\n r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);\n r[2] = p[2];\n\n // translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Treat a 3D vector as a direction and set it's length\n *\n * @param a The vec3 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec3, len: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec3 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec3, maxLen: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n return lerp(a, b, 0.5, dst);\n}\n","\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Quat } from './quat';\nimport Vec3, * as vec3 from './vec3-impl';\nimport * as utils from './utils';\n\nexport default Mat4;\n\nexport type Mat4LikeCtor = new (n: number) => Mat4;\n\n/**\n * 4x4 Matrix math math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new matrix. In other words you can do this\n *\n * const mat = mat4.translation([1, 2, 3]); // Creates a new translation matrix\n *\n * or\n *\n * const mat = mat4.create();\n * mat4.translation([1, 2, 3], mat); // Puts translation matrix in mat.\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always save to pass any matrix as the destination. So for example\n *\n * const mat = mat4.identity();\n * const trans = mat4.translation([1, 2, 3]);\n * mat4.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat.\n *\n */\nlet MatType: Mat4LikeCtor = Float32Array;\n\n/**\n * Sets the type this library creates for a Mat4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Mat4\n */\nexport function setDefaultType(ctor: new (n: number) => Mat4) {\n const oldType = MatType;\n MatType = ctor;\n return oldType;\n}\n\n/**\n * Create a Mat4 from values\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Mat4's specified type\n * it would be faster to use\n *\n * ```\n * const m = mat4.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Mat4Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `mat4.create` is usually used\n * to create a Mat4 to be filled out as in\n *\n * ```\n * const m = mat4.create();\n * mat4.perspective(fov, aspect, near, far, m);\n * ```\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param v9 - value for element 9\n * @param v10 - value for element 10\n * @param v11 - value for element 11\n * @param v12 - value for element 12\n * @param v13 - value for element 13\n * @param v14 - value for element 14\n * @param v15 - value for element 15\n * @returns created from values.\n */\nexport function create(\n v0?: number, v1?: number, v2?: number, v3?: number,\n v4?: number, v5?: number, v6?: number, v7?: number,\n v8?: number, v9?: number, v10?: number, v11?: number,\n v12?: number, v13?: number, v14?: number, v15?: number): Mat4 {\n const dst = new MatType(16);\n if (v0 !== undefined) {\n dst[0] = v0;\n if (v1 !== undefined) {\n dst[1] = v1;\n if (v2 !== undefined) {\n dst[2] = v2;\n if (v3 !== undefined) {\n dst[3] = v3;\n if (v4 !== undefined) {\n dst[4] = v4;\n if (v5 !== undefined) {\n dst[5] = v5;\n if (v6 !== undefined) {\n dst[6] = v6;\n if (v7 !== undefined) {\n dst[7] = v7;\n if (v8 !== undefined) {\n dst[8] = v8;\n if (v9 !== undefined) {\n dst[9] = v9;\n if (v10 !== undefined) {\n dst[10] = v10;\n if (v11 !== undefined) {\n dst[11] = v11;\n if (v12 !== undefined) {\n dst[12] = v12;\n if (v13 !== undefined) {\n dst[13] = v13;\n if (v14 !== undefined) {\n dst[14] = v14;\n if (v15 !== undefined) {\n dst[15] = v15;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n return dst;\n}\n\n/**\n * Sets the values of a Mat4\n * Also see {@link mat4.create} and {@link mat4.copy}\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param v9 - value for element 9\n * @param v10 - value for element 10\n * @param v11 - value for element 11\n * @param v12 - value for element 12\n * @param v13 - value for element 13\n * @param v14 - value for element 14\n * @param v15 - value for element 15\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 created from values.\n */\nexport function set(\n v0: number, v1: number, v2: number, v3: number,\n v4: number, v5: number, v6: number, v7: number,\n v8: number, v9: number, v10: number, v11: number,\n v12: number, v13: number, v14: number, v15: number,\n dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = v0; dst[ 1] = v1; dst[ 2] = v2; dst[ 3] = v3;\n dst[ 4] = v4; dst[ 5] = v5; dst[ 6] = v6; dst[ 7] = v7;\n dst[ 8] = v8; dst[ 9] = v9; dst[10] = v10; dst[11] = v11;\n dst[12] = v12; dst[13] = v13; dst[14] = v14; dst[15] = v15;\n\n return dst;\n}\n\n/**\n * Creates a Mat4 from a Mat3\n * @param m3 - source matrix\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 made from m3\n */\nexport function fromMat3(m3: Mat3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = m3[0]; dst[ 1] = m3[1]; dst[ 2] = m3[ 2]; dst[ 3] = 0;\n dst[ 4] = m3[4]; dst[ 5] = m3[5]; dst[ 6] = m3[ 6]; dst[ 7] = 0;\n dst[ 8] = m3[8]; dst[ 9] = m3[9]; dst[10] = m3[10]; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a Mat4 rotation matrix from a quaternion\n * @param q - quaternion to create matrix from\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 made from q\n */\nexport function fromQuat(q: Quat, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3];\n const x2 = x + x; const y2 = y + y; const z2 = z + z;\n\n const xx = x * x2;\n const yx = y * x2;\n const yy = y * y2;\n const zx = z * x2;\n const zy = z * y2;\n const zz = z * z2;\n const wx = w * x2;\n const wy = w * y2;\n const wz = w * z2;\n\n dst[ 0] = 1 - yy - zz; dst[ 1] = yx + wz; dst[ 2] = zx - wy; dst[ 3] = 0;\n dst[ 4] = yx - wz; dst[ 5] = 1 - xx - zz; dst[ 6] = zy + wx; dst[ 7] = 0;\n dst[ 8] = zx + wy; dst[ 9] = zy - wx; dst[10] = 1 - xx - yy; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Negates a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns -m.\n */\nexport function negate(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = -m[ 0]; dst[ 1] = -m[ 1]; dst[ 2] = -m[ 2]; dst[ 3] = -m[ 3];\n dst[ 4] = -m[ 4]; dst[ 5] = -m[ 5]; dst[ 6] = -m[ 6]; dst[ 7] = -m[ 7];\n dst[ 8] = -m[ 8]; dst[ 9] = -m[ 9]; dst[10] = -m[10]; dst[11] = -m[11];\n dst[12] = -m[12]; dst[13] = -m[13]; dst[14] = -m[14]; dst[15] = -m[15];\n\n return dst;\n}\n\n/**\n * Copies a matrix. (same as {@link mat4.clone})\n * Also see {@link mat4.create} and {@link mat4.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport function copy(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = m[ 0]; dst[ 1] = m[ 1]; dst[ 2] = m[ 2]; dst[ 3] = m[ 3];\n dst[ 4] = m[ 4]; dst[ 5] = m[ 5]; dst[ 6] = m[ 6]; dst[ 7] = m[ 7];\n dst[ 8] = m[ 8]; dst[ 9] = m[ 9]; dst[10] = m[10]; dst[11] = m[11];\n dst[12] = m[12]; dst[13] = m[13]; dst[14] = m[14]; dst[15] = m[15];\n\n return dst;\n}\n\n/**\n * Copies a matrix (same as {@link mat4.copy})\n * Also see {@link mat4.create} and {@link mat4.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport const clone = copy;\n\n/**\n * Check if 2 matrices are approximately equal\n * @param a - Operand matrix.\n * @param b - Operand matrix.\n * @returns true if matrices are approximately equal\n */\nexport function equalsApproximately(a: Mat4, b: Mat4): boolean {\n return Math.abs(a[ 0] - b[ 0]) < utils.EPSILON &&\n Math.abs(a[ 1] - b[ 1]) < utils.EPSILON &&\n Math.abs(a[ 2] - b[ 2]) < utils.EPSILON &&\n Math.abs(a[ 3] - b[ 3]) < utils.EPSILON &&\n Math.abs(a[ 4] - b[ 4]) < utils.EPSILON &&\n Math.abs(a[ 5] - b[ 5]) < utils.EPSILON &&\n Math.abs(a[ 6] - b[ 6]) < utils.EPSILON &&\n Math.abs(a[ 7] - b[ 7]) < utils.EPSILON &&\n Math.abs(a[ 8] - b[ 8]) < utils.EPSILON &&\n Math.abs(a[ 9] - b[ 9]) < utils.EPSILON &&\n Math.abs(a[10] - b[10]) < utils.EPSILON &&\n Math.abs(a[11] - b[11]) < utils.EPSILON &&\n Math.abs(a[12] - b[12]) < utils.EPSILON &&\n Math.abs(a[13] - b[13]) < utils.EPSILON &&\n Math.abs(a[14] - b[14]) < utils.EPSILON &&\n Math.abs(a[15] - b[15]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 matrices are exactly equal\n * @param a - Operand matrix.\n * @param b - Operand matrix.\n * @returns true if matrices are exactly equal\n */\nexport function equals(a: Mat4, b: Mat4): boolean {\n return a[ 0] === b[ 0] &&\n a[ 1] === b[ 1] &&\n a[ 2] === b[ 2] &&\n a[ 3] === b[ 3] &&\n a[ 4] === b[ 4] &&\n a[ 5] === b[ 5] &&\n a[ 6] === b[ 6] &&\n a[ 7] === b[ 7] &&\n a[ 8] === b[ 8] &&\n a[ 9] === b[ 9] &&\n a[10] === b[10] &&\n a[11] === b[11] &&\n a[12] === b[12] &&\n a[13] === b[13] &&\n a[14] === b[14] &&\n a[15] === b[15];\n}\n\n/**\n * Creates a 4-by-4 identity matrix.\n *\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A 4-by-4 identity matrix.\n */\nexport function identity(dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Takes the transpose of a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The transpose of m.\n */\nexport function transpose(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n if (dst === m) {\n let t;\n\n t = m[1];\n m[1] = m[4];\n m[4] = t;\n\n t = m[2];\n m[2] = m[8];\n m[8] = t;\n\n t = m[3];\n m[3] = m[12];\n m[12] = t;\n\n t = m[6];\n m[6] = m[9];\n m[9] = t;\n\n t = m[7];\n m[7] = m[13];\n m[13] = t;\n\n t = m[11];\n m[11] = m[14];\n m[14] = t;\n return dst;\n }\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n dst[ 0] = m00; dst[ 1] = m10; dst[ 2] = m20; dst[ 3] = m30;\n dst[ 4] = m01; dst[ 5] = m11; dst[ 6] = m21; dst[ 7] = m31;\n dst[ 8] = m02; dst[ 9] = m12; dst[10] = m22; dst[11] = m32;\n dst[12] = m03; dst[13] = m13; dst[14] = m23; dst[15] = m33;\n\n return dst;\n}\n\n/**\n * Computes the inverse of a 4-by-4 matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport function inverse(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n const tmp0 = m22 * m33;\n const tmp1 = m32 * m23;\n const tmp2 = m12 * m33;\n const tmp3 = m32 * m13;\n const tmp4 = m12 * m23;\n const tmp5 = m22 * m13;\n const tmp6 = m02 * m33;\n const tmp7 = m32 * m03;\n const tmp8 = m02 * m23;\n const tmp9 = m22 * m03;\n const tmp10 = m02 * m13;\n const tmp11 = m12 * m03;\n const tmp12 = m20 * m31;\n const tmp13 = m30 * m21;\n const tmp14 = m10 * m31;\n const tmp15 = m30 * m11;\n const tmp16 = m10 * m21;\n const tmp17 = m20 * m11;\n const tmp18 = m00 * m31;\n const tmp19 = m30 * m01;\n const tmp20 = m00 * m21;\n const tmp21 = m20 * m01;\n const tmp22 = m00 * m11;\n const tmp23 = m10 * m01;\n\n const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) -\n (tmp1 * m11 + tmp2 * m21 + tmp5 * m31);\n const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) -\n (tmp0 * m01 + tmp7 * m21 + tmp8 * m31);\n const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) -\n (tmp3 * m01 + tmp6 * m11 + tmp11 * m31);\n const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) -\n (tmp4 * m01 + tmp9 * m11 + tmp10 * m21);\n\n const d = 1 / (m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3);\n\n dst[ 0] = d * t0;\n dst[ 1] = d * t1;\n dst[ 2] = d * t2;\n dst[ 3] = d * t3;\n dst[ 4] = d * ((tmp1 * m10 + tmp2 * m20 + tmp5 * m30) -\n (tmp0 * m10 + tmp3 * m20 + tmp4 * m30));\n dst[ 5] = d * ((tmp0 * m00 + tmp7 * m20 + tmp8 * m30) -\n (tmp1 * m00 + tmp6 * m20 + tmp9 * m30));\n dst[ 6] = d * ((tmp3 * m00 + tmp6 * m10 + tmp11 * m30) -\n (tmp2 * m00 + tmp7 * m10 + tmp10 * m30));\n dst[ 7] = d * ((tmp4 * m00 + tmp9 * m10 + tmp10 * m20) -\n (tmp5 * m00 + tmp8 * m10 + tmp11 * m20));\n dst[ 8] = d * ((tmp12 * m13 + tmp15 * m23 + tmp16 * m33) -\n (tmp13 * m13 + tmp14 * m23 + tmp17 * m33));\n dst[ 9] = d * ((tmp13 * m03 + tmp18 * m23 + tmp21 * m33) -\n (tmp12 * m03 + tmp19 * m23 + tmp20 * m33));\n dst[10] = d * ((tmp14 * m03 + tmp19 * m13 + tmp22 * m33) -\n (tmp15 * m03 + tmp18 * m13 + tmp23 * m33));\n dst[11] = d * ((tmp17 * m03 + tmp20 * m13 + tmp23 * m23) -\n (tmp16 * m03 + tmp21 * m13 + tmp22 * m23));\n dst[12] = d * ((tmp14 * m22 + tmp17 * m32 + tmp13 * m12) -\n (tmp16 * m32 + tmp12 * m12 + tmp15 * m22));\n dst[13] = d * ((tmp20 * m32 + tmp12 * m02 + tmp19 * m22) -\n (tmp18 * m22 + tmp21 * m32 + tmp13 * m02));\n dst[14] = d * ((tmp18 * m12 + tmp23 * m32 + tmp15 * m02) -\n (tmp22 * m32 + tmp14 * m02 + tmp19 * m12));\n dst[15] = d * ((tmp22 * m22 + tmp16 * m02 + tmp21 * m12) -\n (tmp20 * m12 + tmp23 * m22 + tmp17 * m02));\n\n return dst;\n}\n\n/**\n * Compute the determinant of a matrix\n * @param m - the matrix\n * @returns the determinant\n */\nexport function determinant(m: Mat4): number {\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n const tmp0 = m22 * m33;\n const tmp1 = m32 * m23;\n const tmp2 = m12 * m33;\n const tmp3 = m32 * m13;\n const tmp4 = m12 * m23;\n const tmp5 = m22 * m13;\n const tmp6 = m02 * m33;\n const tmp7 = m32 * m03;\n const tmp8 = m02 * m23;\n const tmp9 = m22 * m03;\n const tmp10 = m02 * m13;\n const tmp11 = m12 * m03;\n\n const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) -\n (tmp1 * m11 + tmp2 * m21 + tmp5 * m31);\n const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) -\n (tmp0 * m01 + tmp7 * m21 + tmp8 * m31);\n const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) -\n (tmp3 * m01 + tmp6 * m11 + tmp11 * m31);\n const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) -\n (tmp4 * m01 + tmp9 * m11 + tmp10 * m21);\n\n return m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3;\n}\n\n/**\n * Computes the inverse of a 4-by-4 matrix. (same as inverse)\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport const invert = inverse;\n\n/**\n * Multiplies two 4-by-4 matrices with a on the left and b on the right\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport function multiply(a: Mat4, b: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const a00 = a[0];\n const a01 = a[1];\n const a02 = a[2];\n const a03 = a[3];\n const a10 = a[ 4 + 0];\n const a11 = a[ 4 + 1];\n const a12 = a[ 4 + 2];\n const a13 = a[ 4 + 3];\n const a20 = a[ 8 + 0];\n const a21 = a[ 8 + 1];\n const a22 = a[ 8 + 2];\n const a23 = a[ 8 + 3];\n const a30 = a[12 + 0];\n const a31 = a[12 + 1];\n const a32 = a[12 + 2];\n const a33 = a[12 + 3];\n const b00 = b[0];\n const b01 = b[1];\n const b02 = b[2];\n const b03 = b[3];\n const b10 = b[ 4 + 0];\n const b11 = b[ 4 + 1];\n const b12 = b[ 4 + 2];\n const b13 = b[ 4 + 3];\n const b20 = b[ 8 + 0];\n const b21 = b[ 8 + 1];\n const b22 = b[ 8 + 2];\n const b23 = b[ 8 + 3];\n const b30 = b[12 + 0];\n const b31 = b[12 + 1];\n const b32 = b[12 + 2];\n const b33 = b[12 + 3];\n\n dst[ 0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03;\n dst[ 1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03;\n dst[ 2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03;\n dst[ 3] = a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03;\n dst[ 4] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13;\n dst[ 5] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13;\n dst[ 6] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13;\n dst[ 7] = a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13;\n dst[ 8] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23;\n dst[ 9] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23;\n dst[10] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23;\n dst[11] = a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23;\n dst[12] = a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33;\n dst[13] = a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33;\n dst[14] = a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33;\n dst[15] = a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33;\n\n return dst;\n}\n\n/**\n * Multiplies two 4-by-4 matrices with a on the left and b on the right (same as multiply)\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Sets the translation component of a 4-by-4 matrix to the given\n * vector.\n * @param a - The matrix.\n * @param v - The vector.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix with translation set.\n */\nexport function setTranslation(a: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || identity();\n if (a !== dst) {\n dst[ 0] = a[ 0];\n dst[ 1] = a[ 1];\n dst[ 2] = a[ 2];\n dst[ 3] = a[ 3];\n dst[ 4] = a[ 4];\n dst[ 5] = a[ 5];\n dst[ 6] = a[ 6];\n dst[ 7] = a[ 7];\n dst[ 8] = a[ 8];\n dst[ 9] = a[ 9];\n dst[10] = a[10];\n dst[11] = a[11];\n }\n dst[12] = v[0];\n dst[13] = v[1];\n dst[14] = v[2];\n dst[15] = 1;\n return dst;\n}\n\n/**\n * Returns the translation component of a 4-by-4 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n dst[0] = m[12];\n dst[1] = m[13];\n dst[2] = m[14];\n return dst;\n}\n\n/**\n * Returns an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat4, axis: number, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n dst[2] = m[off + 2];\n return dst;\n}\n\n/**\n * Sets an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param v - the axis vector\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @param dst - The matrix to set. If not passed a new one is created.\n * @returns The matrix with axis set.\n */\nexport function setAxis(m: Mat4, v: Vec3, axis: number, dst: Mat4): Mat4 {\n if (dst !== m) {\n dst = copy(m, dst);\n }\n const off = axis * 4;\n dst[off + 0] = v[0];\n dst[off + 1] = v[1];\n dst[off + 2] = v[2];\n return dst;\n}\n\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n\n const xx = m[0];\n const xy = m[1];\n const xz = m[2];\n const yx = m[4];\n const yy = m[5];\n const yz = m[6];\n const zx = m[8];\n const zy = m[9];\n const zz = m[10];\n\n dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz);\n dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz);\n dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz);\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 perspective transformation matrix given the angular height\n * of the frustum, the aspect ratio, and the near and far clipping planes. The\n * arguments define a frustum extending in the negative z direction. The given\n * angle is the vertical angle of the frustum, and the horizontal angle is\n * determined to produce the given aspect ratio. The arguments near and far are\n * the distances to the near and far clipping planes. Note that near and far\n * are not z coordinates, but rather they are distances along the negative\n * z-axis. The matrix generated sends the viewing frustum to the unit box.\n * We assume a unit box extending from -1 to 1 in the x and y dimensions and\n * from 0 to 1 in the z dimension.\n *\n * Note: If you pass `Infinity` for zFar then it will produce a projection matrix\n * returns -Infinity for Z when transforming coordinates with Z <= 0 and +Infinity for Z\n * otherwise.\n *\n * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians).\n * @param aspect - The aspect ratio width / height.\n * @param zNear - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param zFar - The depth (negative z coordinate)\n * of the far clipping plane.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The perspective matrix.\n */\nexport function perspective(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians);\n\n dst[0] = f / aspect;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n dst[4] = 0;\n dst[5] = f;\n dst[6] = 0;\n dst[7] = 0;\n\n dst[8] = 0;\n dst[9] = 0;\n dst[11] = -1;\n\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (Number.isFinite(zFar)) {\n const rangeInv = 1 / (zNear - zFar);\n dst[10] = zFar * rangeInv;\n dst[14] = zFar * zNear * rangeInv;\n } else {\n dst[10] = -1;\n dst[14] = -zNear;\n }\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 reverse-z perspective transformation matrix given the angular height\n * of the frustum, the aspect ratio, and the near and far clipping planes. The\n * arguments define a frustum extending in the negative z direction. The given\n * angle is the vertical angle of the frustum, and the horizontal angle is\n * determined to produce the given aspect ratio. The arguments near and far are\n * the distances to the near and far clipping planes. Note that near and far\n * are not z coordinates, but rather they are distances along the negative\n * z-axis. The matrix generated sends the viewing frustum to the unit box.\n * We assume a unit box extending from -1 to 1 in the x and y dimensions and\n * from 1 (at -zNear) to 0 (at -zFar) in the z dimension.\n *\n * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians).\n * @param aspect - The aspect ratio width / height.\n * @param zNear - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param zFar - The depth (negative z coordinate)\n * of the far clipping plane. (default = Infinity)\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The perspective matrix.\n */export function perspectiveReverseZ(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar = Infinity, dst?: Mat4) {\n dst = dst || new MatType(16);\n\n const f = 1 / Math.tan(fieldOfViewYInRadians * 0.5);\n\n dst[ 0] = f / aspect;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n\n dst[ 4] = 0;\n dst[ 5] = f;\n dst[ 6] = 0;\n dst[ 7] = 0;\n\n dst[ 8] = 0;\n dst[ 9] = 0;\n dst[11] = -1;\n\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (zFar === Infinity) {\n dst[10] = 0;\n dst[14] = zNear;\n } else {\n const rangeInv = 1 / (zFar - zNear);\n dst[10] = zNear * rangeInv;\n dst[14] = zFar * zNear * rangeInv;\n }\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 orthogonal transformation matrix that transforms from\n * the given the left, right, bottom, and top dimensions to -1 +1 in x, and y\n * and 0 to +1 in z.\n * @param left - Left side of the near clipping plane viewport.\n * @param right - Right side of the near clipping plane viewport.\n * @param bottom - Bottom of the near clipping plane viewport.\n * @param top - Top of the near clipping plane viewport.\n * @param near - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param far - The depth (negative z coordinate)\n * of the far clipping plane.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The orthographic projection matrix.\n */\nexport function ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[0] = 2 / (right - left);\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n dst[4] = 0;\n dst[5] = 2 / (top - bottom);\n dst[6] = 0;\n dst[7] = 0;\n\n dst[8] = 0;\n dst[9] = 0;\n dst[10] = 1 / (near - far);\n dst[11] = 0;\n\n dst[12] = (right + left) / (left - right);\n dst[13] = (top + bottom) / (bottom - top);\n dst[14] = near / (near - far);\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 perspective transformation matrix given the left, right,\n * top, bottom, near and far clipping planes. The arguments define a frustum\n * extending in the negative z direction. The arguments near and far are the\n * distances to the near and far clipping planes. Note that near and far are not\n * z coordinates, but rather they are distances along the negative z-axis. The\n * matrix generated sends the viewing frustum to the unit box. We assume a unit\n * box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z\n * dimension.\n * @param left - The x coordinate of the left plane of the box.\n * @param right - The x coordinate of the right plane of the box.\n * @param bottom - The y coordinate of the bottom plane of the box.\n * @param top - The y coordinate of the right plane of the box.\n * @param near - The negative z coordinate of the near plane of the box.\n * @param far - The negative z coordinate of the far plane of the box.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The perspective projection matrix.\n */\nexport function frustum(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const dx = (right - left);\n const dy = (top - bottom);\n const dz = (near - far);\n\n dst[ 0] = 2 * near / dx;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 2 * near / dy;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = (left + right) / dx;\n dst[ 9] = (top + bottom) / dy;\n dst[10] = far / dz;\n dst[11] = -1;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = near * far / dz;\n dst[15] = 0;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 reverse-z perspective transformation matrix given the left, right,\n * top, bottom, near and far clipping planes. The arguments define a frustum\n * extending in the negative z direction. The arguments near and far are the\n * distances to the near and far clipping planes. Note that near and far are not\n * z coordinates, but rather they are distances along the negative z-axis. The\n * matrix generated sends the viewing frustum to the unit box. We assume a unit\n * box extending from -1 to 1 in the x and y dimensions and from 1 (-near) to 0 (-far) in the z\n * dimension.\n * @param left - The x coordinate of the left plane of the box.\n * @param right - The x coordinate of the right plane of the box.\n * @param bottom - The y coordinate of the bottom plane of the box.\n * @param top - The y coordinate of the right plane of the box.\n * @param near - The negative z coordinate of the near plane of the box.\n * @param far - The negative z coordinate of the far plane of the box.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The perspective projection matrix.\n */\nexport function frustumReverseZ(left: number, right: number, bottom: number, top: number, near: number, far = Infinity, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const dx = (right - left);\n const dy = (top - bottom);\n\n dst[ 0] = 2 * near / dx;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 2 * near / dy;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = (left + right) / dx;\n dst[ 9] = (top + bottom) / dy;\n dst[11] = -1;\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (far === Infinity) {\n dst[10] = 0;\n dst[14] = near;\n } else {\n const rangeInv = 1 / (far - near);\n dst[10] = near * rangeInv;\n dst[14] = far * near * rangeInv;\n }\n\n return dst;\n}\n\nlet xAxis: Vec3;\nlet yAxis: Vec3;\nlet zAxis: Vec3;\n\n/**\n * Computes a 4-by-4 aim transformation.\n *\n * This is a matrix which positions an object aiming down positive Z.\n * toward the target.\n *\n * Note: this is **NOT** the inverse of lookAt as lookAt looks at negative Z.\n *\n * @param position - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The aim matrix.\n */\nexport function aim(position: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(target, position, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = xAxis[1]; dst[ 2] = xAxis[2]; dst[ 3] = 0;\n dst[ 4] = yAxis[0]; dst[ 5] = yAxis[1]; dst[ 6] = yAxis[2]; dst[ 7] = 0;\n dst[ 8] = zAxis[0]; dst[ 9] = zAxis[1]; dst[10] = zAxis[2]; dst[11] = 0;\n dst[12] = position[0]; dst[13] = position[1]; dst[14] = position[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 camera aim transformation.\n *\n * This is a matrix which positions an object aiming down negative Z.\n * toward the target.\n *\n * Note: this is the inverse of `lookAt`\n *\n * @param eye - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The aim matrix.\n */\nexport function cameraAim(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = xAxis[1]; dst[ 2] = xAxis[2]; dst[ 3] = 0;\n dst[ 4] = yAxis[0]; dst[ 5] = yAxis[1]; dst[ 6] = yAxis[2]; dst[ 7] = 0;\n dst[ 8] = zAxis[0]; dst[ 9] = zAxis[1]; dst[10] = zAxis[2]; dst[11] = 0;\n dst[12] = eye[0]; dst[13] = eye[1]; dst[14] = eye[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 view transformation.\n *\n * This is a view matrix which transforms all other objects\n * to be in the space of the view defined by the parameters.\n *\n * @param eye - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The look-at matrix.\n */\nexport function lookAt(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = yAxis[0]; dst[ 2] = zAxis[0]; dst[ 3] = 0;\n dst[ 4] = xAxis[1]; dst[ 5] = yAxis[1]; dst[ 6] = zAxis[1]; dst[ 7] = 0;\n dst[ 8] = xAxis[2]; dst[ 9] = yAxis[2]; dst[10] = zAxis[2]; dst[11] = 0;\n\n dst[12] = -(xAxis[0] * eye[0] + xAxis[1] * eye[1] + xAxis[2] * eye[2]);\n dst[13] = -(yAxis[0] * eye[0] + yAxis[1] * eye[1] + yAxis[2] * eye[2]);\n dst[14] = -(zAxis[0] * eye[0] + zAxis[1] * eye[1] + zAxis[2] * eye[2]);\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which translates by the given vector v.\n * @param v - The vector by\n * which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translation matrix.\n */\nexport function translation(v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = v[0]; dst[13] = v[1]; dst[14] = v[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Translates the given 4-by-4 matrix by the given vector v.\n * @param m - The matrix.\n * @param v - The vector by\n * which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translated matrix.\n */\nexport function translate(m: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m03 = m[3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n if (m !== dst) {\n dst[ 0] = m00;\n dst[ 1] = m01;\n dst[ 2] = m02;\n dst[ 3] = m03;\n dst[ 4] = m10;\n dst[ 5] = m11;\n dst[ 6] = m12;\n dst[ 7] = m13;\n dst[ 8] = m20;\n dst[ 9] = m21;\n dst[10] = m22;\n dst[11] = m23;\n }\n\n dst[12] = m00 * v0 + m10 * v1 + m20 * v2 + m30;\n dst[13] = m01 * v0 + m11 * v1 + m21 * v2 + m31;\n dst[14] = m02 * v0 + m12 * v1 + m22 * v2 + m32;\n dst[15] = m03 * v0 + m13 * v1 + m23 * v2 + m33;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationX(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = c; dst[ 6] = s; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = -s; dst[10] = c; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateX(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m10 = m[4];\n const m11 = m[5];\n const m12 = m[6];\n const m13 = m[7];\n const m20 = m[8];\n const m21 = m[9];\n const m22 = m[10];\n const m23 = m[11];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[4] = c * m10 + s * m20;\n dst[5] = c * m11 + s * m21;\n dst[6] = c * m12 + s * m22;\n dst[7] = c * m13 + s * m23;\n dst[8] = c * m20 - s * m10;\n dst[9] = c * m21 - s * m11;\n dst[10] = c * m22 - s * m12;\n dst[11] = c * m23 - s * m13;\n\n if (m !== dst) {\n dst[ 0] = m[ 0];\n dst[ 1] = m[ 1];\n dst[ 2] = m[ 2];\n dst[ 3] = m[ 3];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationY(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = 0; dst[ 2] = -s; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = s; dst[ 9] = 0; dst[10] = c; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateY(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 - s * m20;\n dst[ 1] = c * m01 - s * m21;\n dst[ 2] = c * m02 - s * m22;\n dst[ 3] = c * m03 - s * m23;\n dst[ 8] = c * m20 + s * m00;\n dst[ 9] = c * m21 + s * m01;\n dst[10] = c * m22 + s * m02;\n dst[11] = c * m23 + s * m03;\n\n if (m !== dst) {\n dst[ 4] = m[ 4];\n dst[ 5] = m[ 5];\n dst[ 6] = m[ 6];\n dst[ 7] = m[ 7];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationZ(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = s; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = -s; dst[ 5] = c; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateZ(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 + s * m10;\n dst[ 1] = c * m01 + s * m11;\n dst[ 2] = c * m02 + s * m12;\n dst[ 3] = c * m03 + s * m13;\n dst[ 4] = c * m10 - s * m00;\n dst[ 5] = c * m11 - s * m01;\n dst[ 6] = c * m12 - s * m02;\n dst[ 7] = c * m13 - s * m03;\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n dst[11] = m[11];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the given axis by the given\n * angle.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A matrix which rotates angle radians\n * around the axis.\n */\nexport function axisRotation(axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n let x = axis[0];\n let y = axis[1];\n let z = axis[2];\n const n = Math.sqrt(x * x + y * y + z * z);\n x /= n;\n y /= n;\n z /= n;\n const xx = x * x;\n const yy = y * y;\n const zz = z * z;\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n const oneMinusCosine = 1 - c;\n\n dst[ 0] = xx + (1 - xx) * c;\n dst[ 1] = x * y * oneMinusCosine + z * s;\n dst[ 2] = x * z * oneMinusCosine - y * s;\n dst[ 3] = 0;\n dst[ 4] = x * y * oneMinusCosine - z * s;\n dst[ 5] = yy + (1 - yy) * c;\n dst[ 6] = y * z * oneMinusCosine + x * s;\n dst[ 7] = 0;\n dst[ 8] = x * z * oneMinusCosine + y * s;\n dst[ 9] = y * z * oneMinusCosine - x * s;\n dst[10] = zz + (1 - zz) * c;\n dst[11] = 0;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = 0;\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the given axis by the given\n * angle. (same as axisRotation)\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A matrix which rotates angle radians\n * around the axis.\n */\nexport const rotation = axisRotation;\n\n/**\n * Rotates the given 4-by-4 matrix around the given axis by the\n * given angle.\n * @param m - The matrix.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function axisRotate(m: Mat4, axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n let x = axis[0];\n let y = axis[1];\n let z = axis[2];\n const n = Math.sqrt(x * x + y * y + z * z);\n x /= n;\n y /= n;\n z /= n;\n const xx = x * x;\n const yy = y * y;\n const zz = z * z;\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n const oneMinusCosine = 1 - c;\n\n const r00 = xx + (1 - xx) * c;\n const r01 = x * y * oneMinusCosine + z * s;\n const r02 = x * z * oneMinusCosine - y * s;\n const r10 = x * y * oneMinusCosine - z * s;\n const r11 = yy + (1 - yy) * c;\n const r12 = y * z * oneMinusCosine + x * s;\n const r20 = x * z * oneMinusCosine + y * s;\n const r21 = y * z * oneMinusCosine - x * s;\n const r22 = zz + (1 - zz) * c;\n\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m03 = m[3];\n const m10 = m[4];\n const m11 = m[5];\n const m12 = m[6];\n const m13 = m[7];\n const m20 = m[8];\n const m21 = m[9];\n const m22 = m[10];\n const m23 = m[11];\n\n dst[ 0] = r00 * m00 + r01 * m10 + r02 * m20;\n dst[ 1] = r00 * m01 + r01 * m11 + r02 * m21;\n dst[ 2] = r00 * m02 + r01 * m12 + r02 * m22;\n dst[ 3] = r00 * m03 + r01 * m13 + r02 * m23;\n dst[ 4] = r10 * m00 + r11 * m10 + r12 * m20;\n dst[ 5] = r10 * m01 + r11 * m11 + r12 * m21;\n dst[ 6] = r10 * m02 + r11 * m12 + r12 * m22;\n dst[ 7] = r10 * m03 + r11 * m13 + r12 * m23;\n dst[ 8] = r20 * m00 + r21 * m10 + r22 * m20;\n dst[ 9] = r20 * m01 + r21 * m11 + r22 * m21;\n dst[10] = r20 * m02 + r21 * m12 + r22 * m22;\n dst[11] = r20 * m03 + r21 * m13 + r22 * m23;\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the given axis by the\n * given angle. (same as rotate)\n * @param m - The matrix.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport const rotate = axisRotate;\n\n/**\n * Creates a 4-by-4 matrix which scales in each dimension by an amount given by\n * the corresponding entry in the given vector; assumes the vector has three\n * entries.\n * @param v - A vector of\n * three entries specifying the factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function scaling(v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = v[0]; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = v[1]; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = v[2]; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount\n * given by the corresponding entry in the given vector; assumes the vector has\n * three entries.\n * @param m - The matrix to be modified.\n * @param v - A vector of three entries specifying the\n * factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function scale(m: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n\n dst[ 0] = v0 * m[0 * 4 + 0];\n dst[ 1] = v0 * m[0 * 4 + 1];\n dst[ 2] = v0 * m[0 * 4 + 2];\n dst[ 3] = v0 * m[0 * 4 + 3];\n dst[ 4] = v1 * m[1 * 4 + 0];\n dst[ 5] = v1 * m[1 * 4 + 1];\n dst[ 6] = v1 * m[1 * 4 + 2];\n dst[ 7] = v1 * m[1 * 4 + 3];\n dst[ 8] = v2 * m[2 * 4 + 0];\n dst[ 9] = v2 * m[2 * 4 + 1];\n dst[10] = v2 * m[2 * 4 + 2];\n dst[11] = v2 * m[2 * 4 + 3];\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which scales a uniform amount in each dimension.\n * @param s - the amount to scale\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function uniformScaling(s: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = s; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = s; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = s; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by a uniform scale.\n * @param m - The matrix to be modified.\n * @param s - The amount to scale.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function uniformScale(m: Mat4, s: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = s * m[0 * 4 + 0];\n dst[ 1] = s * m[0 * 4 + 1];\n dst[ 2] = s * m[0 * 4 + 2];\n dst[ 3] = s * m[0 * 4 + 3];\n dst[ 4] = s * m[1 * 4 + 0];\n dst[ 5] = s * m[1 * 4 + 1];\n dst[ 6] = s * m[1 * 4 + 2];\n dst[ 7] = s * m[1 * 4 + 3];\n dst[ 8] = s * m[2 * 4 + 0];\n dst[ 9] = s * m[2 * 4 + 1];\n dst[10] = s * m[2 * 4 + 2];\n dst[11] = s * m[2 * 4 + 3];\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link quat.setDefaultType}.\n */\nexport type Quat = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Quat4 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Quat4`. In other words you can do this\n *\n * const v = quat4.cross(v1, v2); // Creates a new Quat4 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = quat4.create();\n * quat4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * quat4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let QuatType: new (n: number) => Quat = Float32Array;\n\n/**\n * Sets the type this library creates for a Quat4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Quat4\n */\nexport function setDefaultType(ctor: new (n: number) => Quat) {\n const oldType = QuatType;\n QuatType = ctor;\n return oldType;\n}\n\n/**\n * Creates a quat4; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param w - Initial w value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number, w?: number): Quat {\n const dst = new QuatType(4);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n if (w !== undefined) {\n dst[3] = w;\n }\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Quat, create, setDefaultType, QuatType } from './quat';\nimport { Mat3 } from './mat3.js';\nimport { Mat4 } from './mat4.js';\nimport { Vec3 } from './vec3.js';\nimport * as vec3 from './vec3-impl.js';\n\nexport type RotationOrder = 'xyz' | 'xzy' | 'yxz' | 'yzx' | 'zxy' | 'zyx';\n\nexport default Quat;\nexport { create, setDefaultType };\n\n/**\n * Creates a Quat; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param z - Initial w value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Quat\n * Also see {@link quat.create} and {@link quat.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param w fourth value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, w: number, dst?: Quat) {\n dst = dst || new QuatType(4);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n dst[3] = w;\n\n return dst;\n}\n\n/**\n * Sets a quaternion from the given angle and axis,\n * then returns it.\n *\n * @param axis - the axis to rotate around\n * @param angleInRadians - the angle\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The quaternion that represents the given axis and angle\n **/\nexport function fromAxisAngle(axis: Vec3, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n const s = Math.sin(halfAngle);\n\n dst[0] = s * axis[0];\n dst[1] = s * axis[1];\n dst[2] = s * axis[2];\n dst[3] = Math.cos(halfAngle);\n\n return dst;\n}\n\n/**\n * Gets the rotation axis and angle\n * @param q - quaternion to compute from\n * @param dst - Vec3 to hold result. If not passed in a new one is created.\n * @return angle and axis\n */\nexport function toAxisAngle(q: Quat, dst?: Vec3): { angle: number, axis: Vec3 } {\n dst = dst || vec3.create(4);\n\n const angle = Math.acos(q[3]) * 2;\n const s = Math.sin(angle * 0.5);\n if (s > utils.EPSILON) {\n dst[0] = q[0] / s;\n dst[1] = q[1] / s;\n dst[2] = q[2] / s;\n } else {\n dst[0] = 1;\n dst[1] = 0;\n dst[2] = 0;\n }\n\n return { angle, axis: dst };\n}\n\n/**\n * Returns the angle in degrees between two rotations a and b.\n * @param a - quaternion a\n * @param b - quaternion b\n * @return angle in radians between the two quaternions\n */\nexport function angle(a: Quat, b: Quat) {\n const d = dot(a, b);\n return Math.acos(2 * d * d - 1);\n}\n\n/**\n * Multiplies two quaternions\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function multiply(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const aw = a[3];\n\n const bx = b[0];\n const by = b[1];\n const bz = b[2];\n const bw = b[3];\n\n dst[0] = ax * bw + aw * bx + ay * bz - az * by;\n dst[1] = ay * bw + aw * by + az * bx - ax * bz;\n dst[2] = az * bw + aw * bz + ax * by - ay * bx;\n dst[3] = aw * bw - ax * bx - ay * by - az * bz;\n\n return dst;\n}\n\n/**\n * Multiplies two quaternions\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport const mul = multiply;\n\n/**\n * Rotates the given quaternion around the X axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateX(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const bx = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw + qw * bx;\n dst[1] = qy * bw + qz * bx;\n dst[2] = qz * bw - qy * bx;\n dst[3] = qw * bw - qx * bx;\n\n return dst;\n}\n\n/**\n * Rotates the given quaternion around the Y axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateY(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const by = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw - qz * by;\n dst[1] = qy * bw + qw * by;\n dst[2] = qz * bw + qx * by;\n dst[3] = qw * bw - qy * by;\n\n return dst;\n}\n\n/**\n * Rotates the given quaternion around the Z axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateZ(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const bz = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw + qy * bz;\n dst[1] = qy * bw - qx * bz;\n dst[2] = qz * bw + qw * bz;\n dst[3] = qw * bw - qz * bz;\n\n return dst;\n}\n\n/**\n * Spherically linear interpolate between two quaternions\n *\n * @param a - starting value\n * @param b - ending value\n * @param t - value where 0 = a and 1 = b\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function slerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const aw = a[3];\n\n let bx = b[0];\n let by = b[1];\n let bz = b[2];\n let bw = b[3];\n\n let cosOmega = ax * bx + ay * by + az * bz + aw * bw;\n\n if (cosOmega < 0) {\n cosOmega = -cosOmega;\n bx = -bx;\n by = -by;\n bz = -bz;\n bw = -bw;\n }\n\n let scale0;\n let scale1;\n\n if (1.0 - cosOmega > utils.EPSILON) {\n const omega = Math.acos(cosOmega);\n const sinOmega = Math.sin(omega);\n scale0 = Math.sin((1 - t) * omega) / sinOmega;\n scale1 = Math.sin(t * omega) / sinOmega;\n } else {\n scale0 = 1.0 - t;\n scale1 = t;\n }\n\n dst[0] = scale0 * ax + scale1 * bx;\n dst[1] = scale0 * ay + scale1 * by;\n dst[2] = scale0 * az + scale1 * bz;\n dst[3] = scale0 * aw + scale1 * bw;\n\n return dst;\n}\n\n/**\n * Compute the inverse of a quaternion\n *\n * @param q - quaternion to compute the inverse of\n * @returns A quaternion that is the result of a * b\n */\nexport function inverse(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const a0 = q[0];\n const a1 = q[1];\n const a2 = q[2];\n const a3 = q[3];\n\n const dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;\n const invDot = dot ? 1 / dot : 0;\n\n dst[0] = -a0 * invDot;\n dst[1] = -a1 * invDot;\n dst[2] = -a2 * invDot;\n dst[3] = a3 * invDot;\n\n return dst;\n}\n\n/**\n * Compute the conjugate of a quaternion\n * For quaternions with a magnitude of 1 (a unit quaternion)\n * this returns the same as the inverse but is faster to calculate.\n *\n * @param q - quaternion to compute the conjugate of.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The conjugate of q\n */\nexport function conjugate(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = -q[0];\n dst[1] = -q[1];\n dst[2] = -q[2];\n dst[3] = q[3];\n\n return dst;\n}\n\n/**\n * Creates a quaternion from the given rotation matrix.\n *\n * The created quaternion is not normalized.\n *\n * @param m - rotation matrix\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns the result\n */\nexport function fromMat(m: Mat3 | Mat4, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n /*\n 0 1 2\n 3 4 5\n 6 7 8\n\n 0 1 2\n 4 5 6\n 8 9 10\n */\n\n // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes\n // article \"Quaternion Calculus and Fast Animation\".\n const trace = m[0] + m[5] + m[10];\n\n if (trace > 0.0) {\n // |w| > 1/2, may as well choose w > 1/2\n const root = Math.sqrt(trace + 1); // 2w\n dst[3] = 0.5 * root;\n const invRoot = 0.5 / root; // 1/(4w)\n\n dst[0] = (m[6] - m[9]) * invRoot;\n dst[1] = (m[8] - m[2]) * invRoot;\n dst[2] = (m[1] - m[4]) * invRoot;\n } else {\n // |w| <= 1/2\n let i = 0;\n\n if (m[5] > m[0]) {\n i = 1;\n }\n if (m[10] > m[i * 4 + i]) {\n i = 2;\n }\n\n const j = (i + 1) % 3;\n const k = (i + 2) % 3;\n\n const root = Math.sqrt(m[i * 4 + i] - m[j * 4 + j] - m[k * 4 + k] + 1.0);\n dst[i] = 0.5 * root;\n\n const invRoot = 0.5 / root;\n\n dst[3] = (m[j * 4 + k] - m[k * 4 + j]) * invRoot;\n dst[j] = (m[j * 4 + i] + m[i * 4 + j]) * invRoot;\n dst[k] = (m[k * 4 + i] + m[i * 4 + k]) * invRoot;\n }\n\n return dst;\n}\n\n/**\n * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion.\n *\n * @param xAngleInRadians - angle to rotate around X axis in radians.\n * @param yAngleInRadians - angle to rotate around Y axis in radians.\n * @param zAngleInRadians - angle to rotate around Z axis in radians.\n * @param order - order to apply euler angles\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion representing the same rotation as the euler angles applied in the given order\n */\nexport function fromEuler(\n xAngleInRadians: number,\n yAngleInRadians: number,\n zAngleInRadians: number,\n order: RotationOrder,\n dst?: Quat) {\n dst = dst || new QuatType(4);\n\n const xHalfAngle = xAngleInRadians * 0.5;\n const yHalfAngle = yAngleInRadians * 0.5;\n const zHalfAngle = zAngleInRadians * 0.5;\n\n const sx = Math.sin(xHalfAngle);\n const cx = Math.cos(xHalfAngle);\n const sy = Math.sin(yHalfAngle);\n const cy = Math.cos(yHalfAngle);\n const sz = Math.sin(zHalfAngle);\n const cz = Math.cos(zHalfAngle);\n\n switch (order) {\n case 'xyz':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'xzy':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n case 'yxz':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n case 'yzx':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'zxy':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'zyx':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n default:\n throw new Error(`Unknown rotation order: ${order}`);\n }\n\n return dst;\n}\n\n/**\n * Copies a quaternion. (same as {@link quat.clone})\n * Also see {@link quat.create} and {@link quat.set}\n * @param q - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is a copy of q\n */\nexport function copy(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = q[0];\n dst[1] = q[1];\n dst[2] = q[2];\n dst[3] = q[3];\n\n return dst;\n}\n\n/**\n * Clones a quaternion. (same as {@link quat.copy})\n * Also see {@link quat.create} and {@link quat.set}\n * @param q - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A copy of q.\n */\nexport const clone = copy;\n\n/**\n * Adds two quaternions; assumes a and b have the same dimension.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the sum of a and b.\n */\nexport function add(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n dst[3] = a[3] + b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two quaternions.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the difference of a and b.\n */\nexport function subtract(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n dst[3] = a[3] - b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two quaternions.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Multiplies a quaternion by a scalar.\n * @param v - The quaternion.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport function mulScalar(v: Quat, k: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n dst[3] = v[3] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a quaternion by a scalar. (same as mulScalar)\n * @param v - The quaternion.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport function divScalar(v: Quat, k: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n dst[3] = v[3] / k;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two quaternions\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns dot product\n */\nexport function dot(a: Quat, b: Quat): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]);\n}\n\n/**\n * Performs linear interpolation on two quaternions.\n * Given quaternions a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param t - Interpolation coefficient.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n dst[3] = a[3] + t * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Computes the length of quaternion\n * @param v - quaternion.\n * @returns length of quaternion.\n */\nexport function length(v: Quat): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n}\n\n/**\n * Computes the length of quaternion (same as length)\n * @param v - quaternion.\n * @returns length of quaternion.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of quaternion\n * @param v - quaternion.\n * @returns square of the length of quaternion.\n */\nexport function lengthSq(v: Quat): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3;\n}\n\n/**\n * Computes the square of the length of quaternion (same as lengthSq)\n * @param v - quaternion.\n * @returns square of the length of quaternion.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Divides a quaternion by its Euclidean length and returns the quotient.\n * @param v - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The normalized quaternion.\n */\nexport function normalize(v: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n dst[3] = v3 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n }\n\n return dst;\n}\n\n/**\n * Check if 2 quaternions are approximately equal\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns true if quaternions are approximately equal\n */\nexport function equalsApproximately(a: Quat, b: Quat): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON &&\n Math.abs(a[3] - b[3]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 quaternions are exactly equal\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns true if quaternions are exactly equal\n */\nexport function equals(a: Quat, b: Quat): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Creates an identity quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns an identity quaternion\n */\nexport function identity(dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 1;\n\n return dst;\n}\n\nlet tempVec3: Vec3;\nlet xUnitVec3: Vec3;\nlet yUnitVec3: Vec3;\n\n/**\n * Computes a quaternion to represent the shortest rotation from one vector to another.\n *\n * @param aUnit - the start vector\n * @param bUnit - the end vector\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns the result\n */\nexport function rotationTo(aUnit: Vec3, bUnit: Vec3, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n tempVec3 = tempVec3 || vec3.create();\n xUnitVec3 = xUnitVec3 || vec3.create(1, 0, 0);\n yUnitVec3 = yUnitVec3 || vec3.create(0, 1, 0);\n\n const dot = vec3.dot(aUnit, bUnit);\n if (dot < -0.999999) {\n vec3.cross(xUnitVec3, aUnit, tempVec3);\n if (vec3.len(tempVec3) < 0.000001) {\n vec3.cross(yUnitVec3, aUnit, tempVec3);\n }\n\n vec3.normalize(tempVec3, tempVec3);\n fromAxisAngle(tempVec3, Math.PI, dst);\n\n return dst;\n } else if (dot > 0.999999) {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 1;\n\n return dst;\n } else {\n vec3.cross(aUnit, bUnit, tempVec3);\n\n dst[0] = tempVec3[0];\n dst[1] = tempVec3[1];\n dst[2] = tempVec3[2];\n dst[3] = 1 + dot;\n\n return normalize(dst, dst);\n }\n}\n\nlet tempQuat1: Quat;\nlet tempQuat2: Quat;\n\n/**\n * Performs a spherical linear interpolation with two control points\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param c - the third quaternion\n * @param d - the fourth quaternion\n * @param t - Interpolation coefficient 0 to 1\n * @returns result\n */\nexport function sqlerp(\n a: Quat,\n b: Quat,\n c: Quat,\n d: Quat,\n t: number,\n dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n tempQuat1 = tempQuat1 || new QuatType(4);\n tempQuat2 = tempQuat2 || new QuatType(4);\n\n slerp(a, d, t, tempQuat1);\n slerp(b, c, t, tempQuat2);\n slerp(tempQuat1, tempQuat2, 2 * t * (1 - t), dst);\n\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec4.setDefaultType}.\n */\nexport type Vec4 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec4 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Vec4`. In other words you can do this\n *\n * const v = vec4.cross(v1, v2); // Creates a new Vec4 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec4.create();\n * vec4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec4 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec4\n */\nexport function setDefaultType(ctor: new (n: number) => Vec4) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a vec4; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param w - Initial w value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number, w?: number): Vec4 {\n const dst = new VecType(4);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n if (w !== undefined) {\n dst[3] = w;\n }\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Vec4, create, setDefaultType, VecType } from './vec4';\nimport { Mat4 } from './mat4';\n\nexport default Vec4;\nexport { create, setDefaultType };\n\n/**\n * Creates a vec4; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param z - Initial w value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec4\n * Also see {@link vec4.create} and {@link vec4.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param w fourth value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, w: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n dst[3] = w;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n dst[2] = Math.ceil(v[2]);\n dst[3] = Math.ceil(v[3]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n dst[2] = Math.floor(v[2]);\n dst[3] = Math.floor(v[3]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n dst[2] = Math.round(v[2]);\n dst[3] = Math.round(v[3]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec4, min = 0, max = 1, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n dst[2] = Math.min(max, Math.max(min, v[2]));\n dst[3] = Math.min(max, Math.max(min, v[3]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n dst[3] = a[3] + b[3];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec4, b: Vec4, scale: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n dst[2] = a[2] + b[2] * scale;\n dst[3] = a[3] + b[3] * scale;\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n dst[3] = a[3] - b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec4, b: Vec4): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON &&\n Math.abs(a[3] - b[3]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec4, b: Vec4): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec4, b: Vec4, t: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n dst[3] = a[3] + t * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec4, b: Vec4, t: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n dst[2] = a[2] + t[2] * (b[2] - a[2]);\n dst[3] = a[3] + t[3] * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n dst[2] = Math.max(a[2], b[2]);\n dst[3] = Math.max(a[3], b[3]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n dst[2] = Math.min(a[2], b[2]);\n dst[3] = Math.min(a[3], b[3]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec4, k: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n dst[3] = v[3] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec4, k: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n dst[3] = v[3] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n dst[2] = 1 / v[2];\n dst[3] = 1 / v[3];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the dot product of two vectors\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec4, b: Vec4): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]);\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec4): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec4): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec4, b: Vec4): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n const dw = a[3] - b[3];\n return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec4, b: Vec4): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n const dw = a[3] - b[3];\n return dx * dx + dy * dy + dz * dz + dw * dw;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n dst[3] = v3 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n }\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n dst[2] = -v[2];\n dst[3] = -v[3];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec4.clone})\n * Also see {@link vec4.create} and {@link vec4.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0];\n dst[1] = v[1];\n dst[2] = v[2];\n dst[3] = v[3];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec4.copy})\n * Also see {@link vec4.create} and {@link vec4.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n dst[2] = a[2] * b[2];\n dst[3] = a[3] * b[3];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec4, b: Vec4, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n dst[2] = a[2] / b[2];\n dst[3] = a[3] / b[3];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n return dst;\n}\n\n\n/**\n * transform vec4 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec4 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec4, m: Mat4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n const w = v[3];\n\n dst[0] = m[0] * x + m[4] * y + m[ 8] * z + m[12] * w;\n dst[1] = m[1] * x + m[5] * y + m[ 9] * z + m[13] * w;\n dst[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n dst[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n\n return dst;\n}\n\n\n/**\n * Treat a 4D vector as a direction and set it's length\n *\n * @param a The vec4 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec4, len: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec4 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec4, maxLen: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec4, b: Vec4, dst?: Vec4) {\n dst = dst || new VecType(4);\n return lerp(a, b, 0.5, dst);\n}\n","import Mat3, * as mat3 from './mat3-impl';\nimport Mat4, * as mat4 from './mat4-impl';\nimport Quat, * as quat from './quat-impl';\nimport Vec2, * as vec2 from './vec2-impl';\nimport Vec3, * as vec3 from './vec3-impl';\nimport Vec4, * as vec4 from './vec4-impl';\nimport * as utils from './utils';\n\n/**\n * Sets the type this library creates for all types\n *\n * example:\n *\n * ```\n * setDefaultType(Float64Array);\n * ```\n *\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n */\nexport function setDefaultType(ctor: new (n: number) => Float32Array | Float64Array | number[]) {\n mat3.setDefaultType(ctor);\n mat4.setDefaultType(ctor);\n quat.setDefaultType(ctor);\n vec2.setDefaultType(ctor);\n vec3.setDefaultType(ctor);\n vec4.setDefaultType(ctor);\n}\n\nexport {\n Mat3,\n mat3,\n Mat4,\n mat4,\n Quat,\n quat,\n utils,\n Vec2,\n vec2,\n Vec3,\n vec3,\n Vec4,\n vec4,\n};"],"names":["lerp","VecType","setDefaultType","create","fromValues","set","ceil","floor","round","clamp","add","addScaled","angle","dot","subtract","sub","equalsApproximately","utils.EPSILON","equals","lerpV","max","min","mulScalar","scale","divScalar","inverse","invert","cross","Vec3Type","length","len","lengthSq","lenSq","distance","dist","distanceSq","distSq","normalize","negate","copy","clone","multiply","mul","divide","div","random","zero","transformMat4","transformMat3","rotate","setLength","truncate","midpoint","MatType","fromQuat","identity","transpose","determinant","setTranslation","getTranslation","vec2.create","getAxis","setAxis","getScaling","translation","translate","rotation","scaling","uniformScaling","uniformScale","rotateX","rotateY","rotateZ","vec3.create","vec3.normalize","vec3.subtract","vec3.cross","vec3.dot","vec3.len","mat3.setDefaultType","mat4.setDefaultType","quat.setDefaultType","vec2.setDefaultType","vec3.setDefaultType","vec4.setDefaultType"],"mappings":";;;;;;;IAAA;;;;;;;;;;;;;;;;;;;;IAoBG;IAEI,IAAI,OAAO,GAAG,QAAQ,CAAC;IAE9B;;;;IAIG;IACG,SAAU,UAAU,CAAC,CAAS,EAAA;QAClC,MAAM,GAAG,GAAG,OAAO,CAAC;QACpB,OAAO,GAAG,CAAC,CAAC;IACZ,IAAA,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;IAIG;IACG,SAAU,QAAQ,CAAC,OAAe,EAAA;IACtC,IAAA,OAAO,OAAO,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;IACjC,CAAC;IAED;;;;IAIG;IACG,SAAU,QAAQ,CAAC,OAAe,EAAA;IACtC,IAAA,OAAO,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;IACjC,CAAC;IAED;;;;;;IAMG;aACaA,MAAI,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAA;QAClD,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED;;;;;;;;IAQG;aACa,WAAW,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAA;IACzD,IAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,CAAC,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IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IAE5B,IAAA,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE;YACtB,OAAO,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;SAClC;IAED,IAAA,OAAO,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACtB,CAAC;IAED;;;;;;IAMG;aACa,QAAQ,CAAC,CAAO,EAAE,CAAO,EAAE,GAAU,EAAA;QACnD,GAAG,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IC5pBA;;;;;;;;;;IAUG;IACG,SAAU,cAAc,CAAC,IAA+D,EAAA;IAC5F,IAAA8D,gBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAAC,gBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAAC,gBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAAC,gBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAAC,gBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAAC,gBAAmB,CAAC,IAAI,CAAC,CAAC;IAC5B;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/2.x/wgpu-matrix.min.js b/dist/2.x/wgpu-matrix.min.js new file mode 100644 index 0000000..27518d3 --- /dev/null +++ b/dist/2.x/wgpu-matrix.min.js @@ -0,0 +1,2 @@ +!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).wgpuMatrix={})}(this,(function(n){"use strict";let t=1e-6;var r={__proto__:null,get EPSILON(){return t},degToRad:function(n){return n*Math.PI/180},euclideanModulo:function(n,t){return(n%t+t)%t},inverseLerp:function(n,r,e){const o=r-n;return Math.abs(r-n)1e-5?(t[0]=r/u,t[1]=o/u):(t[0]=0,t[1]=0),t}function b(n,t){return(t=t||new e(2))[0]=n[0],t[1]=n[1],t}function q(n,t,r){return(r=r||new e(2))[0]=n[0]*t[0],r[1]=n[1]*t[1],r}function y(n,t,r){return(r=r||new e(2))[0]=n[0]/t[0],r[1]=n[1]/t[1],r}function x(n,t,r){return p(n,r=r||new e(2)),h(r,t,r)}var g={__proto__:null,add:function(n,t,r){return(r=r||new e(2))[0]=n[0]+t[0],r[1]=n[1]+t[1],r},addScaled:function(n,t,r,o){return(o=o||new e(2))[0]=n[0]+t[0]*r,o[1]=n[1]+t[1]*r,o},angle:function(n,t){const r=n[0],e=n[1],o=t[0],u=t[1],a=Math.sqrt(r*r+e*e)*Math.sqrt(o*o+u*u),i=a&&M(n,t)/a;return Math.acos(i)},ceil:function(n,t){return(t=t||new e(2))[0]=Math.ceil(n[0]),t[1]=Math.ceil(n[1]),t},clamp:function(n,t=0,r=1,o){return(o=o||new e(2))[0]=Math.min(r,Math.max(t,n[0])),o[1]=Math.min(r,Math.max(t,n[1])),o},clone:b,copy:b,create:u,cross:function(n,t,r){r=r||new a(3);const e=n[0]*t[1]-n[1]*t[0];return r[0]=0,r[1]=0,r[2]=e,r},dist:m,distSq:v,distance:m,distanceSq:v,div:y,divScalar:function(n,t,r){return(r=r||new e(2))[0]=n[0]/t,r[1]=n[1]/t,r},divide:y,dot:M,equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]},equalsApproximately:function(n,r){return Math.abs(n[0]-r[0])t?x(n,t,r):b(n,r)},zero:function(n){return(n=n||new e(2))[0]=0,n[1]=0,n}};let S=Float32Array;const A=new Map([[Float32Array,()=>new Float32Array(12)],[Float64Array,()=>new Float64Array(12)],[Array,()=>new Array(12).fill(0)]]);let _=A.get(Float32Array);function T(n){const t=S;return S=n,_=A.get(n),t}function z(n,t){return(t=t||_())[0]=n[0],t[1]=n[1],t[2]=n[2],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[8]=n[8],t[9]=n[9],t[10]=n[10],t}function F(n){return(n=n||_())[0]=1,n[1]=0,n[2]=0,n[4]=0,n[5]=1,n[6]=0,n[8]=0,n[9]=0,n[10]=1,n}function k(n,t){t=t||_();const r=n[0],e=n[1],o=n[2],u=n[4],a=n[5],i=n[6],c=n[8],s=n[9],f=n[10],h=f*a-i*s,l=-f*u+i*c,M=s*u-a*c,w=1/(r*h+e*l+o*M);return t[0]=h*w,t[1]=(-f*e+o*s)*w,t[2]=(i*e-o*a)*w,t[4]=l*w,t[5]=(f*r-o*c)*w,t[6]=(-i*r+o*u)*w,t[8]=M*w,t[9]=(-s*r+e*c)*w,t[10]=(a*r-e*u)*w,t}function D(n,t,r){r=r||_();const e=n[0],o=n[1],u=n[2],a=n[4],i=n[5],c=n[6],s=n[8],f=n[9],h=n[10],l=t[0],M=t[1],w=t[2],d=t[4],m=t[5],v=t[6],p=t[8],b=t[9],q=t[10];return r[0]=e*l+a*M+s*w,r[1]=o*l+i*M+f*w,r[2]=u*l+c*M+h*w,r[4]=e*d+a*m+s*v,r[5]=o*d+i*m+f*v,r[6]=u*d+c*m+h*v,r[8]=e*p+a*b+s*q,r[9]=o*p+i*b+f*q,r[10]=u*p+c*b+h*q,r}var I={__proto__:null,clone:z,copy:z,create:function(n,t,r,e,o,u,a,i,c){const s=_();return s[3]=0,s[7]=0,s[11]=0,void 0!==n&&(s[0]=n,void 0!==t&&(s[1]=t,void 0!==r&&(s[2]=r,void 0!==e&&(s[4]=e,void 0!==o&&(s[5]=o,void 0!==u&&(s[6]=u,void 0!==a&&(s[8]=a,void 0!==i&&(s[9]=i,void 0!==c&&(s[10]=c))))))))),s},determinant:function(n){const t=n[0],r=n[1],e=n[2],o=n[4],u=n[5],a=n[6],i=n[8],c=n[9],s=n[10];return t*(u*s-c*a)-o*(r*s-c*e)+i*(r*a-u*e)},equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[4]===t[4]&&n[5]===t[5]&&n[6]===t[6]&&n[8]===t[8]&&n[9]===t[9]&&n[10]===t[10]},equalsApproximately:function(n,r){return Math.abs(n[0]-r[0])1e-5?(t[0]=r/u,t[1]=e/u,t[2]=o/u):(t[0]=0,t[1]=0,t[2]=0),t}function O(n,t){return(t=t||new a(3))[0]=n[0],t[1]=n[1],t[2]=n[2],t}function $(n,t,r){return(r=r||new a(3))[0]=n[0]*t[0],r[1]=n[1]*t[1],r[2]=n[2]*t[2],r}function B(n,t,r){return(r=r||new a(3))[0]=n[0]/t[0],r[1]=n[1]/t[1],r[2]=n[2]/t[2],r}function C(n,t,r){return U(n,r=r||new a(3)),Z(r,t,r)}var G={__proto__:null,add:function(n,t,r){return(r=r||new a(3))[0]=n[0]+t[0],r[1]=n[1]+t[1],r[2]=n[2]+t[2],r},addScaled:function(n,t,r,e){return(e=e||new a(3))[0]=n[0]+t[0]*r,e[1]=n[1]+t[1]*r,e[2]=n[2]+t[2]*r,e},angle:function(n,t){const r=n[0],e=n[1],o=n[2],u=t[0],a=t[1],i=t[2],c=Math.sqrt(r*r+e*e+o*o)*Math.sqrt(u*u+a*a+i*i),s=c&&E(n,t)/c;return Math.acos(s)},ceil:function(n,t){return(t=t||new a(3))[0]=Math.ceil(n[0]),t[1]=Math.ceil(n[1]),t[2]=Math.ceil(n[2]),t},clamp:function(n,t=0,r=1,e){return(e=e||new a(3))[0]=Math.min(r,Math.max(t,n[0])),e[1]=Math.min(r,Math.max(t,n[1])),e[2]=Math.min(r,Math.max(t,n[2])),e},clone:O,copy:O,create:c,cross:R,dist:j,distSq:N,distance:j,distanceSq:N,div:B,divScalar:function(n,t,r){return(r=r||new a(3))[0]=n[0]/t,r[1]=n[1]/t,r[2]=n[2]/t,r},divide:B,dot:E,equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]},equalsApproximately:function(n,r){return Math.abs(n[0]-r[0])t?C(n,t,r):O(n,r)},zero:function(n){return(n=n||new a(3))[0]=0,n[1]=0,n[2]=0,n}};let H=Float32Array;function J(n){const t=H;return H=n,t}function K(n,t){return(t=t||new H(16))[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],t}function W(n){return(n=n||new H(16))[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function nn(n,t){t=t||new H(16);const r=n[0],e=n[1],o=n[2],u=n[3],a=n[4],i=n[5],c=n[6],s=n[7],f=n[8],h=n[9],l=n[10],M=n[11],w=n[12],d=n[13],m=n[14],v=n[15],p=l*v,b=m*M,q=c*v,y=m*s,x=c*M,g=l*s,S=o*v,A=m*u,_=o*M,T=l*u,z=o*s,F=c*u,k=f*d,D=w*h,I=a*d,P=w*i,V=a*h,Z=f*i,L=r*d,R=w*e,E=r*h,X=f*e,Y=r*i,Q=a*e,j=p*i+y*h+x*d-(b*i+q*h+g*d),N=b*e+S*h+T*d-(p*e+A*h+_*d),U=q*e+A*i+z*d-(y*e+S*i+F*d),O=g*e+_*i+F*h-(x*e+T*i+z*h),$=1/(r*j+a*N+f*U+w*O);return t[0]=$*j,t[1]=$*N,t[2]=$*U,t[3]=$*O,t[4]=$*(b*a+q*f+g*w-(p*a+y*f+x*w)),t[5]=$*(p*r+A*f+_*w-(b*r+S*f+T*w)),t[6]=$*(y*r+S*a+F*w-(q*r+A*a+z*w)),t[7]=$*(x*r+T*a+z*f-(g*r+_*a+F*f)),t[8]=$*(k*s+P*M+V*v-(D*s+I*M+Z*v)),t[9]=$*(D*u+L*M+X*v-(k*u+R*M+E*v)),t[10]=$*(I*u+R*s+Y*v-(P*u+L*s+Q*v)),t[11]=$*(Z*u+E*s+Q*M-(V*u+X*s+Y*M)),t[12]=$*(I*l+Z*m+D*c-(V*m+k*c+P*l)),t[13]=$*(E*m+k*o+R*l-(L*l+X*m+D*o)),t[14]=$*(L*c+Q*m+P*o-(Y*m+I*o+R*c)),t[15]=$*(Y*l+V*o+X*c-(E*c+Q*l+Z*o)),t}function tn(n,t,r){r=r||new H(16);const e=n[0],o=n[1],u=n[2],a=n[3],i=n[4],c=n[5],s=n[6],f=n[7],h=n[8],l=n[9],M=n[10],w=n[11],d=n[12],m=n[13],v=n[14],p=n[15],b=t[0],q=t[1],y=t[2],x=t[3],g=t[4],S=t[5],A=t[6],_=t[7],T=t[8],z=t[9],F=t[10],k=t[11],D=t[12],I=t[13],P=t[14],V=t[15];return r[0]=e*b+i*q+h*y+d*x,r[1]=o*b+c*q+l*y+m*x,r[2]=u*b+s*q+M*y+v*x,r[3]=a*b+f*q+w*y+p*x,r[4]=e*g+i*S+h*A+d*_,r[5]=o*g+c*S+l*A+m*_,r[6]=u*g+s*S+M*A+v*_,r[7]=a*g+f*S+w*A+p*_,r[8]=e*T+i*z+h*F+d*k,r[9]=o*T+c*z+l*F+m*k,r[10]=u*T+s*z+M*F+v*k,r[11]=a*T+f*z+w*F+p*k,r[12]=e*D+i*I+h*P+d*V,r[13]=o*D+c*I+l*P+m*V,r[14]=u*D+s*I+M*P+v*V,r[15]=a*D+f*I+w*P+p*V,r}let rn,en,on;function un(n,t,r){r=r||new H(16);let e=n[0],o=n[1],u=n[2];const a=Math.sqrt(e*e+o*o+u*u);e/=a,o/=a,u/=a;const i=e*e,c=o*o,s=u*u,f=Math.cos(t),h=Math.sin(t),l=1-f;return r[0]=i+(1-i)*f,r[1]=e*o*l+u*h,r[2]=e*u*l-o*h,r[3]=0,r[4]=e*o*l-u*h,r[5]=c+(1-c)*f,r[6]=o*u*l+e*h,r[7]=0,r[8]=e*u*l+o*h,r[9]=o*u*l-e*h,r[10]=s+(1-s)*f,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function an(n,t,r,e){e=e||new H(16);let o=t[0],u=t[1],a=t[2];const i=Math.sqrt(o*o+u*u+a*a);o/=i,u/=i,a/=i;const c=o*o,s=u*u,f=a*a,h=Math.cos(r),l=Math.sin(r),M=1-h,w=c+(1-c)*h,d=o*u*M+a*l,m=o*a*M-u*l,v=o*u*M-a*l,p=s+(1-s)*h,b=u*a*M+o*l,q=o*a*M+u*l,y=u*a*M-o*l,x=f+(1-f)*h,g=n[0],S=n[1],A=n[2],_=n[3],T=n[4],z=n[5],F=n[6],k=n[7],D=n[8],I=n[9],P=n[10],V=n[11];return e[0]=w*g+d*T+m*D,e[1]=w*S+d*z+m*I,e[2]=w*A+d*F+m*P,e[3]=w*_+d*k+m*V,e[4]=v*g+p*T+b*D,e[5]=v*S+p*z+b*I,e[6]=v*A+p*F+b*P,e[7]=v*_+p*k+b*V,e[8]=q*g+y*T+x*D,e[9]=q*S+y*z+x*I,e[10]=q*A+y*F+x*P,e[11]=q*_+y*k+x*V,n!==e&&(e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15]),e}var cn={__proto__:null,aim:function(n,t,r,e){return e=e||new H(16),rn=rn||c(),en=en||c(),on=on||c(),U(P(t,n,on),on),U(R(r,on,rn),rn),U(R(on,rn,en),en),e[0]=rn[0],e[1]=rn[1],e[2]=rn[2],e[3]=0,e[4]=en[0],e[5]=en[1],e[6]=en[2],e[7]=0,e[8]=on[0],e[9]=on[1],e[10]=on[2],e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},axisRotate:an,axisRotation:un,cameraAim:function(n,t,r,e){return e=e||new H(16),rn=rn||c(),en=en||c(),on=on||c(),U(P(n,t,on),on),U(R(r,on,rn),rn),U(R(on,rn,en),en),e[0]=rn[0],e[1]=rn[1],e[2]=rn[2],e[3]=0,e[4]=en[0],e[5]=en[1],e[6]=en[2],e[7]=0,e[8]=on[0],e[9]=on[1],e[10]=on[2],e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},clone:K,copy:K,create:function(n,t,r,e,o,u,a,i,c,s,f,h,l,M,w,d){const m=new H(16);return void 0!==n&&(m[0]=n,void 0!==t&&(m[1]=t,void 0!==r&&(m[2]=r,void 0!==e&&(m[3]=e,void 0!==o&&(m[4]=o,void 0!==u&&(m[5]=u,void 0!==a&&(m[6]=a,void 0!==i&&(m[7]=i,void 0!==c&&(m[8]=c,void 0!==s&&(m[9]=s,void 0!==f&&(m[10]=f,void 0!==h&&(m[11]=h,void 0!==l&&(m[12]=l,void 0!==M&&(m[13]=M,void 0!==w&&(m[14]=w,void 0!==d&&(m[15]=d)))))))))))))))),m},determinant:function(n){const t=n[0],r=n[1],e=n[2],o=n[3],u=n[4],a=n[5],i=n[6],c=n[7],s=n[8],f=n[9],h=n[10],l=n[11],M=n[12],w=n[13],d=n[14],m=n[15],v=h*m,p=d*l,b=i*m,q=d*c,y=i*l,x=h*c,g=e*m,S=d*o,A=e*l,_=h*o,T=e*c,z=i*o;return t*(v*a+q*f+y*w-(p*a+b*f+x*w))+u*(p*r+g*f+_*w-(v*r+S*f+A*w))+s*(b*r+S*a+T*w-(q*r+g*a+z*w))+M*(x*r+A*a+z*f-(y*r+_*a+T*f))},equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]&&n[4]===t[4]&&n[5]===t[5]&&n[6]===t[6]&&n[7]===t[7]&&n[8]===t[8]&&n[9]===t[9]&&n[10]===t[10]&&n[11]===t[11]&&n[12]===t[12]&&n[13]===t[13]&&n[14]===t[14]&&n[15]===t[15]},equalsApproximately:function(n,r){return Math.abs(n[0]-r[0])t){const n=Math.acos(d),t=Math.sin(n);s=Math.sin((1-e)*n)/t,f=Math.sin(e*n)/t}else s=1-e,f=e;return o[0]=s*u+f*h,o[1]=s*a+f*l,o[2]=s*i+f*M,o[3]=s*c+f*w,o}function dn(n,t){return(t=t||new sn(4))[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t}function mn(n,t,r){return(r=r||new sn(4))[0]=n[0]-t[0],r[1]=n[1]-t[1],r[2]=n[2]-t[2],r[3]=n[3]-t[3],r}function vn(n,t,r){return(r=r||new sn(4))[0]=n[0]*t,r[1]=n[1]*t,r[2]=n[2]*t,r[3]=n[3]*t,r}function pn(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]}function bn(n){const t=n[0],r=n[1],e=n[2],o=n[3];return Math.sqrt(t*t+r*r+e*e+o*o)}function qn(n){const t=n[0],r=n[1],e=n[2],o=n[3];return t*t+r*r+e*e+o*o}function yn(n,t){t=t||new sn(4);const r=n[0],e=n[1],o=n[2],u=n[3],a=Math.sqrt(r*r+e*e+o*o+u*u);return a>1e-5?(t[0]=r/a,t[1]=e/a,t[2]=o/a,t[3]=u/a):(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}let xn,gn,Sn,An,_n;var Tn={__proto__:null,add:function(n,t,r){return(r=r||new sn(4))[0]=n[0]+t[0],r[1]=n[1]+t[1],r[2]=n[2]+t[2],r[3]=n[3]+t[3],r},angle:function(n,t){const r=pn(n,t);return Math.acos(2*r*r-1)},clone:dn,conjugate:function(n,t){return(t=t||new sn(4))[0]=-n[0],t[1]=-n[1],t[2]=-n[2],t[3]=n[3],t},copy:dn,create:hn,divScalar:function(n,t,r){return(r=r||new sn(4))[0]=n[0]/t,r[1]=n[1]/t,r[2]=n[2]/t,r[3]=n[3]/t,r},dot:pn,equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]},equalsApproximately:function(n,r){return Math.abs(n[0]-r[0])0){const e=Math.sqrt(r+1);t[3]=.5*e;const o=.5/e;t[0]=(n[6]-n[9])*o,t[1]=(n[8]-n[2])*o,t[2]=(n[1]-n[4])*o}else{let r=0;n[5]>n[0]&&(r=1),n[10]>n[4*r+r]&&(r=2);const e=(r+1)%3,o=(r+2)%3,u=Math.sqrt(n[4*r+r]-n[4*e+e]-n[4*o+o]+1);t[r]=.5*u;const a=.5/u;t[3]=(n[4*e+o]-n[4*o+e])*a,t[e]=(n[4*e+r]+n[4*r+e])*a,t[o]=(n[4*o+r]+n[4*r+o])*a}return t},fromValues:hn,identity:function(n){return(n=n||new sn(4))[0]=0,n[1]=0,n[2]=0,n[3]=1,n},inverse:function(n,t){t=t||new sn(4);const r=n[0],e=n[1],o=n[2],u=n[3],a=r*r+e*e+o*o+u*u,i=a?1/a:0;return t[0]=-r*i,t[1]=-e*i,t[2]=-o*i,t[3]=u*i,t},len:bn,lenSq:qn,length:bn,lengthSq:qn,lerp:function(n,t,r,e){return(e=e||new sn(4))[0]=n[0]+r*(t[0]-n[0]),e[1]=n[1]+r*(t[1]-n[1]),e[2]=n[2]+r*(t[2]-n[2]),e[3]=n[3]+r*(t[3]-n[3]),e},mul:Mn,mulScalar:vn,multiply:Mn,normalize:yn,rotateX:function(n,t,r){r=r||new sn(4);const e=.5*t,o=n[0],u=n[1],a=n[2],i=n[3],c=Math.sin(e),s=Math.cos(e);return r[0]=o*s+i*c,r[1]=u*s+a*c,r[2]=a*s-u*c,r[3]=i*s-o*c,r},rotateY:function(n,t,r){r=r||new sn(4);const e=.5*t,o=n[0],u=n[1],a=n[2],i=n[3],c=Math.sin(e),s=Math.cos(e);return r[0]=o*s-a*c,r[1]=u*s+i*c,r[2]=a*s+o*c,r[3]=i*s-u*c,r},rotateZ:function(n,t,r){r=r||new sn(4);const e=.5*t,o=n[0],u=n[1],a=n[2],i=n[3],c=Math.sin(e),s=Math.cos(e);return r[0]=o*s+u*c,r[1]=u*s-o*c,r[2]=a*s+i*c,r[3]=i*s-a*c,r},rotationTo:function(n,t,r){r=r||new sn(4),xn=xn||c(),gn=gn||c(1,0,0),Sn=Sn||c(0,1,0);const e=E(n,t);return e<-.999999?(R(gn,n,xn),Y(xn)<1e-6&&R(Sn,n,xn),U(xn,xn),ln(xn,Math.PI,r),r):e>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(R(n,t,xn),r[0]=xn[0],r[1]=xn[1],r[2]=xn[2],r[3]=1+e,yn(r,r))},scale:vn,set:function(n,t,r,e,o){return(o=o||new sn(4))[0]=n,o[1]=t,o[2]=r,o[3]=e,o},setDefaultType:fn,slerp:wn,sqlerp:function(n,t,r,e,o,u){return u=u||new sn(4),An=An||new sn(4),_n=_n||new sn(4),wn(n,e,o,An),wn(t,r,o,_n),wn(An,_n,2*o*(1-o),u),u},sub:mn,subtract:mn,toAxisAngle:function(n,r){r=r||c(4);const e=2*Math.acos(n[3]),o=Math.sin(.5*e);return o>t?(r[0]=n[0]/o,r[1]=n[1]/o,r[2]=n[2]/o):(r[0]=1,r[1]=0,r[2]=0),{angle:e,axis:r}}};let zn=Float32Array;function Fn(n){const t=zn;return zn=n,t}function kn(n,t,r,e){const o=new zn(4);return void 0!==n&&(o[0]=n,void 0!==t&&(o[1]=t,void 0!==r&&(o[2]=r,void 0!==e&&(o[3]=e)))),o}function Dn(n,t,r){return(r=r||new zn(4))[0]=n[0]-t[0],r[1]=n[1]-t[1],r[2]=n[2]-t[2],r[3]=n[3]-t[3],r}function In(n,t,r,e){return(e=e||new zn(4))[0]=n[0]+r*(t[0]-n[0]),e[1]=n[1]+r*(t[1]-n[1]),e[2]=n[2]+r*(t[2]-n[2]),e[3]=n[3]+r*(t[3]-n[3]),e}function Pn(n,t,r){return(r=r||new zn(4))[0]=n[0]*t,r[1]=n[1]*t,r[2]=n[2]*t,r[3]=n[3]*t,r}function Vn(n,t){return(t=t||new zn(4))[0]=1/n[0],t[1]=1/n[1],t[2]=1/n[2],t[3]=1/n[3],t}function Zn(n){const t=n[0],r=n[1],e=n[2],o=n[3];return Math.sqrt(t*t+r*r+e*e+o*o)}function Ln(n){const t=n[0],r=n[1],e=n[2],o=n[3];return t*t+r*r+e*e+o*o}function Rn(n,t){const r=n[0]-t[0],e=n[1]-t[1],o=n[2]-t[2],u=n[3]-t[3];return Math.sqrt(r*r+e*e+o*o+u*u)}function En(n,t){const r=n[0]-t[0],e=n[1]-t[1],o=n[2]-t[2],u=n[3]-t[3];return r*r+e*e+o*o+u*u}function Xn(n,t){t=t||new zn(4);const r=n[0],e=n[1],o=n[2],u=n[3],a=Math.sqrt(r*r+e*e+o*o+u*u);return a>1e-5?(t[0]=r/a,t[1]=e/a,t[2]=o/a,t[3]=u/a):(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function Yn(n,t){return(t=t||new zn(4))[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t}function Qn(n,t,r){return(r=r||new zn(4))[0]=n[0]*t[0],r[1]=n[1]*t[1],r[2]=n[2]*t[2],r[3]=n[3]*t[3],r}function jn(n,t,r){return(r=r||new zn(4))[0]=n[0]/t[0],r[1]=n[1]/t[1],r[2]=n[2]/t[2],r[3]=n[3]/t[3],r}function Nn(n,t,r){return Xn(n,r=r||new zn(4)),Pn(r,t,r)}var Un={__proto__:null,add:function(n,t,r){return(r=r||new zn(4))[0]=n[0]+t[0],r[1]=n[1]+t[1],r[2]=n[2]+t[2],r[3]=n[3]+t[3],r},addScaled:function(n,t,r,e){return(e=e||new zn(4))[0]=n[0]+t[0]*r,e[1]=n[1]+t[1]*r,e[2]=n[2]+t[2]*r,e[3]=n[3]+t[3]*r,e},ceil:function(n,t){return(t=t||new zn(4))[0]=Math.ceil(n[0]),t[1]=Math.ceil(n[1]),t[2]=Math.ceil(n[2]),t[3]=Math.ceil(n[3]),t},clamp:function(n,t=0,r=1,e){return(e=e||new zn(4))[0]=Math.min(r,Math.max(t,n[0])),e[1]=Math.min(r,Math.max(t,n[1])),e[2]=Math.min(r,Math.max(t,n[2])),e[3]=Math.min(r,Math.max(t,n[3])),e},clone:Yn,copy:Yn,create:kn,dist:Rn,distSq:En,distance:Rn,distanceSq:En,div:jn,divScalar:function(n,t,r){return(r=r||new zn(4))[0]=n[0]/t,r[1]=n[1]/t,r[2]=n[2]/t,r[3]=n[3]/t,r},divide:jn,dot:function(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]},equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]},equalsApproximately:function(n,r){return Math.abs(n[0]-r[0])t?Nn(n,t,r):Yn(n,r)},zero:function(n){return(n=n||new zn(4))[0]=0,n[1]=0,n[2]=0,n[3]=0,n}};n.mat3=I,n.mat4=cn,n.quat=Tn,n.setDefaultType=function(n){T(n),J(n),fn(n),o(n),i(n),Fn(n)},n.utils=r,n.vec2=g,n.vec3=G,n.vec4=Un})); +//# sourceMappingURL=wgpu-matrix.min.js.map diff --git a/dist/2.x/wgpu-matrix.min.js.map b/dist/2.x/wgpu-matrix.min.js.map new file mode 100644 index 0000000..6ef0d74 --- /dev/null +++ b/dist/2.x/wgpu-matrix.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wgpu-matrix.min.js","sources":["../../../src/utils.ts","../../../src/vec2.ts","../../../src/vec3.ts","../../../src/vec2-impl.ts","../../../src/mat3-impl.ts","../../../src/vec3-impl.ts","../../../src/mat4-impl.ts","../../../src/quat.ts","../../../src/quat-impl.ts","../../../src/vec4.ts","../../../src/vec4-impl.ts","../../../src/wgpu-matrix.ts"],"sourcesContent":["/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nexport let EPSILON = 0.000001;\n\n/**\n * Set the value for EPSILON for various checks\n * @param v - Value to use for EPSILON.\n * @returns previous value of EPSILON;\n */\nexport function setEpsilon(v: number): number {\n const old = EPSILON;\n EPSILON = v;\n return old;\n}\n\n/**\n * Convert degrees to radians\n * @param degrees - Angle in degrees\n * @returns angle converted to radians\n */\nexport function degToRad(degrees: number): number {\n return degrees * Math.PI / 180;\n}\n\n/**\n * Convert radians to degrees\n * @param radians - Angle in radians\n * @returns angle converted to degrees\n */\nexport function radToDeg(radians: number): number {\n return radians * 180 / Math.PI;\n}\n\n/**\n * Lerps between a and b via t\n * @param a - starting value\n * @param b - ending value\n * @param t - value where 0 = a and 1 = b\n * @returns a + (b - a) * t\n */\nexport function lerp(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\n/**\n * Compute the opposite of lerp. Given a and b and a value between\n * a and b returns a value between 0 and 1. 0 if a, 1 if b.\n * Note: no clamping is done.\n * @param a - start value\n * @param b - end value\n * @param v - value between a and b\n * @returns (v - a) / (b - a)\n */\nexport function inverseLerp(a: number, b: number, v: number): number {\n const d = b - a;\n return (Math.abs(b - a) < EPSILON)\n ? a\n : (v - a) / d;\n}\n\n/**\n * Compute the euclidean modulo\n *\n * ```\n * // table for n / 3\n * -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 <- n\n * ------------------------------------\n * -2 -1 -0 -2 -1 0, 1, 2, 0, 1, 2 <- n % 3\n * 1 2 0 1 2 0, 1, 2, 0, 1, 2 <- euclideanModule(n, 3)\n * ```\n *\n * @param n - dividend\n * @param m - divisor\n * @returns the euclidean modulo of n / m\n */\nexport function euclideanModulo(n: number, m: number) {\n return ((n % m) + m) % m;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 2 values, Float32Array with 2 values, or a Float64Array with 2 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec2.setDefaultType}.\n */\nexport type Vec2 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec2 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new Vec2. In other words you can do this\n *\n * const v = vec2.cross(v1, v2); // Creates a new Vec2 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec2.create();\n * vec2.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec2.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec2 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec2\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec2\n */\nexport function setDefaultType(ctor: new (n: number) => Vec2) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a Vec2; may be called with x, y, z to set initial values.\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Vec2's specified type\n * it would be faster to use\n *\n * ```\n * const v = vec2.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Vec2Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `vec2.create` is usually used\n * to create a Vec2 to be filled out as in\n *\n * ```\n * const sum = vec2.create();\n * vec2.add(v1, v2, sum);\n * ```\n *\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @returns the created vector\n */\nexport function create(x = 0, y = 0): Vec2 {\n const dst = new VecType(2);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n }\n }\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 3 values, Float32Array with 3 values, or a Float64Array with 3 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec3.setDefaultType}.\n */\nexport type Vec3 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec3 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Vec3`. In other words you can do this\n *\n * const v = vec3.cross(v1, v2); // Creates a new Vec3 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec3.create();\n * vec3.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec3.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec3 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec3\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec3\n */\nexport function setDefaultType(ctor: new (n: number) => Vec3) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a vec3; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number): Vec3 {\n const dst = new VecType(3);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Vec2, create, setDefaultType, VecType } from './vec2';\nimport { Vec3, VecType as Vec3Type } from './vec3';\n\nexport default Vec2;\nexport { create, setDefaultType };\n\n/**\n * Creates a Vec2; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec2\n * Also see {@link vec2.create} and {@link vec2.copy}\n *\n * @param x first value\n * @param y second value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = x;\n dst[1] = y;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec2, min = 0, max = 1, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec2, b: Vec2, scale: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n\n return dst;\n}\n\n/**\n * Returns the angle in radians between two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns The angle in radians between the 2 vectors.\n */\nexport function angle(a: Vec2, b: Vec2): number {\n const ax = a[0];\n const ay = a[1];\n const bx = b[0];\n const by = b[1];\n const mag1 = Math.sqrt(ax * ax + ay * ay);\n const mag2 = Math.sqrt(bx * bx + by * by);\n const mag = mag1 * mag2;\n const cosine = mag && dot(a, b) / mag;\n return Math.acos(cosine);\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec2, b: Vec2): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec2, b: Vec2): boolean {\n return a[0] === b[0] && a[1] === b[1];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec2, b: Vec2, t: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec2, b: Vec2, t: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec2, k: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec2, k: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the cross product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of a cross b.\n */\nexport function cross(a: Vec2, b: Vec2, dst?: Vec3): Vec3 {\n dst = dst || new Vec3Type(3);\n const z = a[0] * b[1] - a[1] * b[0];\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = z;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec2, b: Vec2): number {\n return a[0] * b[0] + a[1] * b[1];\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec2): number {\n const v0 = v[0];\n const v1 = v[1];\n return Math.sqrt(v0 * v0 + v1 * v1);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec2): number {\n const v0 = v[0];\n const v1 = v[1];\n return v0 * v0 + v1 * v1;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec2, b: Vec2): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n return Math.sqrt(dx * dx + dy * dy);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec2, b: Vec2): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n return dx * dx + dy * dy;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const v0 = v[0];\n const v1 = v[1];\n const len = Math.sqrt(v0 * v0 + v1 * v1);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n }\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec2.clone})\n * Also see {@link vec2.create} and {@link vec2.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0];\n dst[1] = v[1];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec2.copy})\n * Also see {@link vec2.create} and {@link vec2.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec2, b: Vec2, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Creates a random unit vector * scale\n * @param scale - Default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The random vector.\n */\nexport function random(scale = 1, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const angle = Math.random() * 2 * Math.PI;\n dst[0] = Math.cos(angle) * scale;\n dst[1] = Math.sin(angle) * scale;\n\n return dst;\n}\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = 0;\n dst[1] = 0;\n\n return dst;\n}\n\n\n/**\n * transform Vec2 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional Vec2 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec2, m: Mat4, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const x = v[0];\n const y = v[1];\n\n dst[0] = x * m[0] + y * m[4] + m[12];\n dst[1] = x * m[1] + y * m[5] + m[13];\n\n return dst;\n}\n\n/**\n * Transforms vec4 by 3x3 matrix\n *\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional Vec2 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat3(v: Vec2, m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const x = v[0];\n const y = v[1];\n\n dst[0] = m[0] * x + m[4] * y + m[8];\n dst[1] = m[1] * x + m[5] * y + m[9];\n\n return dst;\n}\n\n/**\n * Rotate a 2D vector\n *\n * @param a The vec2 point to rotate\n * @param b The origin of the rotation\n * @param rad The angle of rotation in radians\n * @returns the rotated vector\n */\nexport function rotate(a: Vec2, b: Vec2, rad: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n // Translate point to the origin\n const p0 = a[0] - b[0];\n const p1 = a[1] - b[1];\n const sinC = Math.sin(rad);\n const cosC = Math.cos(rad);\n\n //perform rotation and translate to correct position\n dst[0] = p0 * cosC - p1 * sinC + b[0];\n dst[1] = p0 * sinC + p1 * cosC + b[1];\n\n return dst;\n}\n\n/**\n * Treat a 2D vector as a direction and set it's length\n *\n * @param a The vec2 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec2, len: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec2 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec2, maxLen: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec2, b: Vec2, dst?: Vec2) {\n dst = dst || new VecType(2);\n return lerp(a, b, 0.5, dst);\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nimport * as utils from './utils.js';\nimport { Quat } from './quat';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport Vec2, * as vec2 from './vec2-impl';\n\nexport default Mat3;\n\nexport type Mat3LikeCtor = new (n: number) => Mat3;\n\n/**\n * 3x3 Matrix math math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new matrix. In other words you can do this\n *\n * const mat = mat3.translation([1, 2, 3]); // Creates a new translation matrix\n *\n * or\n *\n * const mat = mat3.create();\n * mat3.translation([1, 2, 3], mat); // Puts translation matrix in mat.\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always save to pass any matrix as the destination. So for example\n *\n * const mat = mat3.identity();\n * const trans = mat3.translation([1, 2, 3]);\n * mat3.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat.\n *\n */\nlet MatType: Mat3LikeCtor = Float32Array;\n\n// This mess is because with Mat3 we have 3 unused elements.\n// For Float32Array and Float64Array that's not an issue\n// but for Array it's troublesome\nconst ctorMap = new Map Mat3>([\n [Float32Array, () => new Float32Array(12)],\n [Float64Array, () => new Float64Array(12)],\n [Array, () => new Array(12).fill(0)],\n]);\nlet newMat3: () => Mat3 = ctorMap.get(Float32Array)!;\n\n/**\n * Sets the type this library creates for a Mat3\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Mat3\n */\nexport function setDefaultType(ctor: new (n: number) => Mat3) {\n const oldType = MatType;\n MatType = ctor;\n newMat3 = ctorMap.get(ctor)!;\n return oldType;\n}\n\n/**\n * Create a Mat3 from values\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Mat3's specified type\n * it would be faster to use\n *\n * ```\n * const m = mat3.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Mat3Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `mat3.create` is usually used\n * to create a Mat3 to be filled out as in\n *\n * ```\n * const m = mat3.create();\n * mat3.perspective(fov, aspect, near, far, m);\n * ```\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @returns matrix created from values.\n */\nexport function create(\n v0?: number, v1?: number, v2?: number,\n v3?: number, v4?: number, v5?: number,\n v6?: number, v7?: number, v8?: number): Mat3 {\n const dst = newMat3();\n // to make the array homogenous\n dst[3] = 0;\n dst[7] = 0;\n dst[11] = 0;\n\n if (v0 !== undefined) {\n dst[0] = v0;\n if (v1 !== undefined) {\n dst[1] = v1;\n if (v2 !== undefined) {\n dst[2] = v2;\n if (v3 !== undefined) {\n dst[4] = v3;\n if (v4 !== undefined) {\n dst[5] = v4;\n if (v5 !== undefined) {\n dst[6] = v5;\n if (v6 !== undefined) {\n dst[8] = v6;\n if (v7 !== undefined) {\n dst[9] = v7;\n if (v8 !== undefined) {\n dst[10] = v8;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n return dst;\n}\n\n/**\n * Sets the values of a Mat3\n * Also see {@link mat3.create} and {@link mat3.copy}\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 set from values.\n */\nexport function set(\n v0: number, v1: number, v2: number,\n v3: number, v4: number, v5: number,\n v6: number, v7: number, v8: number, dst?: Mat3) {\n dst = dst || newMat3();\n\n dst[0] = v0; dst[1] = v1; dst[ 2] = v2; dst[ 3] = 0;\n dst[4] = v3; dst[5] = v4; dst[ 6] = v5; dst[ 7] = 0;\n dst[8] = v6; dst[9] = v7; dst[10] = v8; dst[11] = 0;\n\n return dst;\n}\n\n/**\n * Creates a Mat3 from the upper left 3x3 part of a Mat4\n * @param m4 - source matrix\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 made from m4\n */\nexport function fromMat4(m4: Mat4, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n dst[0] = m4[0]; dst[1] = m4[1]; dst[ 2] = m4[ 2]; dst[ 3] = 0;\n dst[4] = m4[4]; dst[5] = m4[5]; dst[ 6] = m4[ 6]; dst[ 7] = 0;\n dst[8] = m4[8]; dst[9] = m4[9]; dst[10] = m4[10]; dst[11] = 0;\n return dst;\n}\n\n/**\n * Creates a Mat3 rotation matrix from a quaternion\n * @param q - quaternion to create matrix from\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 made from q\n */\nexport function fromQuat(q: Quat, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3];\n const x2 = x + x; const y2 = y + y; const z2 = z + z;\n\n const xx = x * x2;\n const yx = y * x2;\n const yy = y * y2;\n const zx = z * x2;\n const zy = z * y2;\n const zz = z * z2;\n const wx = w * x2;\n const wy = w * y2;\n const wz = w * z2;\n\n dst[ 0] = 1 - yy - zz; dst[ 1] = yx + wz; dst[ 2] = zx - wy; dst[ 3] = 0;\n dst[ 4] = yx - wz; dst[ 5] = 1 - xx - zz; dst[ 6] = zy + wx; dst[ 7] = 0;\n dst[ 8] = zx + wy; dst[ 9] = zy - wx; dst[10] = 1 - xx - yy; dst[11] = 0;\n\n return dst;\n}\n\n/**\n * Negates a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns -m.\n */\nexport function negate(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = -m[ 0]; dst[ 1] = -m[ 1]; dst[ 2] = -m[ 2];\n dst[ 4] = -m[ 4]; dst[ 5] = -m[ 5]; dst[ 6] = -m[ 6];\n dst[ 8] = -m[ 8]; dst[ 9] = -m[ 9]; dst[10] = -m[10];\n\n return dst;\n}\n\n/**\n * Copies a matrix. (same as {@link mat3.clone})\n * Also see {@link mat3.create} and {@link mat3.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport function copy(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = m[ 0]; dst[ 1] = m[ 1]; dst[ 2] = m[ 2];\n dst[ 4] = m[ 4]; dst[ 5] = m[ 5]; dst[ 6] = m[ 6];\n dst[ 8] = m[ 8]; dst[ 9] = m[ 9]; dst[10] = m[10];\n\n return dst;\n}\n\n/**\n * Copies a matrix (same as {@link mat3.copy})\n * Also see {@link mat3.create} and {@link mat3.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport const clone = copy;\n\n/**\n * Check if 2 matrices are approximately equal\n * @param a Operand matrix.\n * @param b Operand matrix.\n * @returns true if matrices are approximately equal\n */\nexport function equalsApproximately(a: Mat3, b: Mat3): boolean {\n return Math.abs(a[ 0] - b[ 0]) < utils.EPSILON &&\n Math.abs(a[ 1] - b[ 1]) < utils.EPSILON &&\n Math.abs(a[ 2] - b[ 2]) < utils.EPSILON &&\n Math.abs(a[ 4] - b[ 4]) < utils.EPSILON &&\n Math.abs(a[ 5] - b[ 5]) < utils.EPSILON &&\n Math.abs(a[ 6] - b[ 6]) < utils.EPSILON &&\n Math.abs(a[ 8] - b[ 8]) < utils.EPSILON &&\n Math.abs(a[ 9] - b[ 9]) < utils.EPSILON &&\n Math.abs(a[10] - b[10]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 matrices are exactly equal\n * @param a Operand matrix.\n * @param b Operand matrix.\n * @returns true if matrices are exactly equal\n */\nexport function equals(a: Mat3, b: Mat3): boolean {\n return a[ 0] === b[ 0] &&\n a[ 1] === b[ 1] &&\n a[ 2] === b[ 2] &&\n a[ 4] === b[ 4] &&\n a[ 5] === b[ 5] &&\n a[ 6] === b[ 6] &&\n a[ 8] === b[ 8] &&\n a[ 9] === b[ 9] &&\n a[10] === b[10];\n}\n\n/**\n * Creates a 3-by-3 identity matrix.\n *\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A 3-by-3 identity matrix.\n */\nexport function identity(dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Takes the transpose of a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The transpose of m.\n */\nexport function transpose(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n if (dst === m) {\n let t: number;\n\n // 0 1 2\n // 4 5 6\n // 8 9 10\n\n t = m[1];\n m[1] = m[4];\n m[4] = t;\n\n t = m[2];\n m[2] = m[8];\n m[8] = t;\n\n t = m[6];\n m[6] = m[9];\n m[9] = t;\n\n return dst;\n }\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n dst[ 0] = m00; dst[ 1] = m10; dst[ 2] = m20;\n dst[ 4] = m01; dst[ 5] = m11; dst[ 6] = m21;\n dst[ 8] = m02; dst[ 9] = m12; dst[10] = m22;\n\n return dst;\n}\n\n/**\n * Computes the inverse of a 3-by-3 matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport function inverse(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n const b01 = m22 * m11 - m12 * m21;\n const b11 = -m22 * m10 + m12 * m20;\n const b21 = m21 * m10 - m11 * m20;\n\n const invDet = 1 / (m00 * b01 + m01 * b11 + m02 * b21);\n\n dst[ 0] = b01 * invDet;\n dst[ 1] = (-m22 * m01 + m02 * m21) * invDet;\n dst[ 2] = ( m12 * m01 - m02 * m11) * invDet;\n dst[ 4] = b11 * invDet;\n dst[ 5] = ( m22 * m00 - m02 * m20) * invDet;\n dst[ 6] = (-m12 * m00 + m02 * m10) * invDet;\n dst[ 8] = b21 * invDet;\n dst[ 9] = (-m21 * m00 + m01 * m20) * invDet;\n dst[10] = ( m11 * m00 - m01 * m10) * invDet;\n\n return dst;\n}\n\n/**\n * Compute the determinant of a matrix\n * @param m - the matrix\n * @returns the determinant\n */\nexport function determinant(m: Mat3): number {\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n return m00 * (m11 * m22 - m21 * m12) -\n m10 * (m01 * m22 - m21 * m02) +\n m20 * (m01 * m12 - m11 * m02);\n}\n\n/**\n * Computes the inverse of a 3-by-3 matrix. (same as inverse)\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport const invert = inverse;\n\n/**\n * Multiplies two 3-by-3 matrices with a on the left and b on the right\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport function multiply(a: Mat3, b: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const a00 = a[0];\n const a01 = a[1];\n const a02 = a[2];\n const a10 = a[ 4 + 0];\n const a11 = a[ 4 + 1];\n const a12 = a[ 4 + 2];\n const a20 = a[ 8 + 0];\n const a21 = a[ 8 + 1];\n const a22 = a[ 8 + 2];\n const b00 = b[0];\n const b01 = b[1];\n const b02 = b[2];\n const b10 = b[ 4 + 0];\n const b11 = b[ 4 + 1];\n const b12 = b[ 4 + 2];\n const b20 = b[ 8 + 0];\n const b21 = b[ 8 + 1];\n const b22 = b[ 8 + 2];\n\n dst[ 0] = a00 * b00 + a10 * b01 + a20 * b02;\n dst[ 1] = a01 * b00 + a11 * b01 + a21 * b02;\n dst[ 2] = a02 * b00 + a12 * b01 + a22 * b02;\n dst[ 4] = a00 * b10 + a10 * b11 + a20 * b12;\n dst[ 5] = a01 * b10 + a11 * b11 + a21 * b12;\n dst[ 6] = a02 * b10 + a12 * b11 + a22 * b12;\n dst[ 8] = a00 * b20 + a10 * b21 + a20 * b22;\n dst[ 9] = a01 * b20 + a11 * b21 + a21 * b22;\n dst[10] = a02 * b20 + a12 * b21 + a22 * b22;\n\n return dst;\n}\n\n/**\n * Multiplies two 3-by-3 matrices with a on the left and b on the right (same as multiply)\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Sets the translation component of a 3-by-3 matrix to the given\n * vector.\n * @param a - The matrix.\n * @param v - The vector.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix with translation set.\n */\nexport function setTranslation(a: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || identity();\n if (a !== dst) {\n dst[ 0] = a[ 0];\n dst[ 1] = a[ 1];\n dst[ 2] = a[ 2];\n dst[ 4] = a[ 4];\n dst[ 5] = a[ 5];\n dst[ 6] = a[ 6];\n }\n dst[ 8] = v[0];\n dst[ 9] = v[1];\n dst[10] = 1;\n return dst;\n}\n\n/**\n * Returns the translation component of a 3-by-3 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n dst[0] = m[8];\n dst[1] = m[9];\n return dst;\n}\n\n/**\n * Returns an axis of a 3x3 matrix as a vector with 2 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y,\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat3, axis: number, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n return dst;\n}\n\n/**\n * Sets an axis of a 3x3 matrix as a vector with 2 entries\n * @param m - The matrix.\n * @param v - the axis vector\n * @param axis - The axis 0 = x, 1 = y;\n * @param dst - The matrix to set. If not passed a new one is created.\n * @returns The matrix with axis set.\n */\nexport function setAxis(m: Mat3, v: Vec2, axis: number, dst?: Mat3): Mat3 {\n if (dst !== m) {\n dst = copy(m, dst);\n }\n const off = axis * 4;\n dst[off + 0] = v[0];\n dst[off + 1] = v[1];\n return dst;\n}\n\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n\n const xx = m[0];\n const xy = m[1];\n const yx = m[4];\n const yy = m[5];\n\n dst[0] = Math.sqrt(xx * xx + xy * xy);\n dst[1] = Math.sqrt(yx * yx + yy * yy);\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which translates by the given vector v.\n * @param v - The vector by which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translation matrix.\n */\nexport function translation(v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0;\n dst[ 8] = v[0]; dst[ 9] = v[1]; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Translates the given 3-by-3 matrix by the given vector v.\n * @param m - The matrix.\n * @param v - The vector by which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translated matrix.\n */\nexport function translate(m: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const v0 = v[0];\n const v1 = v[1];\n\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n if (m !== dst) {\n dst[ 0] = m00;\n dst[ 1] = m01;\n dst[ 2] = m02;\n dst[ 4] = m10;\n dst[ 5] = m11;\n dst[ 6] = m12;\n }\n\n dst[ 8] = m00 * v0 + m10 * v1 + m20;\n dst[ 9] = m01 * v0 + m11 * v1 + m21;\n dst[10] = m02 * v0 + m12 * v1 + m22;\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which rotates by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotation(angleInRadians: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = s; dst[ 2] = 0;\n dst[ 4] = -s; dst[ 5] = c; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 3-by-3 matrix by the given angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotate(m: Mat3, angleInRadians: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 + s * m10;\n dst[ 1] = c * m01 + s * m11;\n dst[ 2] = c * m02 + s * m12;\n\n dst[ 4] = c * m10 - s * m00;\n dst[ 5] = c * m11 - s * m01;\n dst[ 6] = c * m12 - s * m02;\n\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which scales in each dimension by an amount given by\n * the corresponding entry in the given vector; assumes the vector has three\n * entries.\n * @param v - A vector of\n * 2 entries specifying the factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function scaling(v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = v[0]; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = v[1]; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 3-by-3 matrix in each dimension by an amount\n * given by the corresponding entry in the given vector; assumes the vector has\n * three entries.\n * @param m - The matrix to be modified.\n * @param v - A vector of 2 entries specifying the\n * factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function scale(m: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const v0 = v[0];\n const v1 = v[1];\n\n dst[ 0] = v0 * m[0 * 4 + 0];\n dst[ 1] = v0 * m[0 * 4 + 1];\n dst[ 2] = v0 * m[0 * 4 + 2];\n\n dst[ 4] = v1 * m[1 * 4 + 0];\n dst[ 5] = v1 * m[1 * 4 + 1];\n dst[ 6] = v1 * m[1 * 4 + 2];\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which scales uniformly in each dimension\n * @param s - Amount to scale\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function uniformScaling(s: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = s; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = s; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 3-by-3 matrix in each dimension by an amount\n * given.\n * @param m - The matrix to be modified.\n * @param s - Amount to scale.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function uniformScale(m: Mat3, s: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = s * m[0 * 4 + 0];\n dst[ 1] = s * m[0 * 4 + 1];\n dst[ 2] = s * m[0 * 4 + 2];\n\n dst[ 4] = s * m[1 * 4 + 0];\n dst[ 5] = s * m[1 * 4 + 1];\n dst[ 6] = s * m[1 * 4 + 2];\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Vec3, create, setDefaultType, VecType } from './vec3';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Quat } from './quat';\n\nexport default Vec3;\nexport { create, setDefaultType };\n\n/**\n * Creates a vec3; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec3\n * Also see {@link vec3.create} and {@link vec3.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n dst[2] = Math.ceil(v[2]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n dst[2] = Math.floor(v[2]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n dst[2] = Math.round(v[2]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec3, min = 0, max = 1, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n dst[2] = Math.min(max, Math.max(min, v[2]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec3, b: Vec3, scale: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n dst[2] = a[2] + b[2] * scale;\n\n return dst;\n}\n\n/**\n * Returns the angle in radians between two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns The angle in radians between the 2 vectors.\n */\nexport function angle(a: Vec3, b: Vec3): number {\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const bx = b[0];\n const by = b[1];\n const bz = b[2];\n const mag1 = Math.sqrt(ax * ax + ay * ay + az * az);\n const mag2 = Math.sqrt(bx * bx + by * by + bz * bz);\n const mag = mag1 * mag2;\n const cosine = mag && dot(a, b) / mag;\n return Math.acos(cosine);\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec3, b: Vec3): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec3, b: Vec3): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec3, b: Vec3, t: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec3, b: Vec3, t: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n dst[2] = a[2] + t[2] * (b[2] - a[2]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n dst[2] = Math.max(a[2], b[2]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n dst[2] = Math.min(a[2], b[2]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec3, k: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec3, k: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n dst[2] = 1 / v[2];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the cross product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of a cross b.\n */\nexport function cross(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const t1 = a[2] * b[0] - a[0] * b[2];\n const t2 = a[0] * b[1] - a[1] * b[0];\n dst[0] = a[1] * b[2] - a[2] * b[1];\n dst[1] = t1;\n dst[2] = t2;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec3, b: Vec3): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]);\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec3): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec3): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n return v0 * v0 + v1 * v1 + v2 * v2;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec3, b: Vec3): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n return Math.sqrt(dx * dx + dy * dy + dz * dz);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec3, b: Vec3): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n return dx * dx + dy * dy + dz * dz;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n }\n\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n dst[2] = -v[2];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec3.clone})\n * Also see {@link vec3.create} and {@link vec3.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0];\n dst[1] = v[1];\n dst[2] = v[2];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec3.copy})\n * Also see {@link vec3.create} and {@link vec3.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n dst[2] = a[2] * b[2];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n dst[2] = a[2] / b[2];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Creates a random vector\n * @param scale - Default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The random vector.\n */\nexport function random(scale = 1, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const angle = Math.random() * 2 * Math.PI;\n const z = Math.random() * 2 - 1;\n const zScale = Math.sqrt(1 - z * z) * scale;\n dst[0] = Math.cos(angle) * zScale;\n dst[1] = Math.sin(angle) * zScale;\n dst[2] = z * scale;\n\n return dst;\n}\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n\n return dst;\n}\n\n\n/**\n * transform vec3 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec3, m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n const w = (m[3] * x + m[7] * y + m[11] * z + m[15]) || 1;\n\n dst[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n dst[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n dst[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n\n return dst;\n}\n\n/**\n * Transform vec4 by upper 3x3 matrix inside 4x4 matrix.\n * @param v - The direction.\n * @param m - The matrix.\n * @param dst - optional Vec3 to store result. If not passed a new one is created.\n * @returns The transformed vector.\n */\nexport function transformMat4Upper3x3(v: Vec3, m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n\n dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0];\n dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1];\n dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v2 * m[2 * 4 + 2];\n\n return dst;\n}\n\n/**\n * Transforms vec3 by 3x3 matrix\n *\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat3(v: Vec3, m: Mat3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n\n dst[0] = x * m[0] + y * m[4] + z * m[8];\n dst[1] = x * m[1] + y * m[5] + z * m[9];\n dst[2] = x * m[2] + y * m[6] + z * m[10];\n\n return dst;\n}\n\n/**\n * Transforms vec3 by Quaternion\n * @param v - the vector to transform\n * @param q - the quaternion to transform by\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed\n */\nexport function transformQuat(v: Vec3, q: Quat, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const w2 = q[3] * 2;\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n\n const uvX = qy * z - qz * y;\n const uvY = qz * x - qx * z;\n const uvZ = qx * y - qy * x;\n\n dst[0] = x + uvX * w2 + (qy * uvZ - qz * uvY) * 2;\n dst[1] = y + uvY * w2 + (qz * uvX - qx * uvZ) * 2;\n dst[2] = z + uvZ * w2 + (qx * uvY - qy * uvX) * 2;\n\n return dst;\n}\n\n/**\n * Returns the translation component of a 4-by-4 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat3, dst?: Vec3) {\n dst = dst || new VecType(3);\n dst[0] = m[12];\n dst[1] = m[13];\n dst[2] = m[14];\n return dst;\n}\n/**\n * Returns an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat4, axis: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n dst[2] = m[off + 2];\n return dst;\n}\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat4, dst: Vec3) {\n dst = dst || new VecType(3);\n const xx = m[0];\n const xy = m[1];\n const xz = m[2];\n const yx = m[4];\n const yy = m[5];\n const yz = m[6];\n const zx = m[8];\n const zy = m[9];\n const zz = m[10];\n dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz);\n dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz);\n dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz);\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the x-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns the rotated vector\n */\nexport function rotateX(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n //Translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n //perform rotation\n r[0] = p[0];\n r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);\n r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad);\n\n //translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the y-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns the rotated vector\n */\nexport function rotateY(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n // translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n // perform rotation\n r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);\n r[1] = p[1];\n r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad);\n\n // translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the z-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns {vec3} out\n */\nexport function rotateZ(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n // translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n // perform rotation\n r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);\n r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);\n r[2] = p[2];\n\n // translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Treat a 3D vector as a direction and set it's length\n *\n * @param a The vec3 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec3, len: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec3 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec3, maxLen: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n return lerp(a, b, 0.5, dst);\n}\n","\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Quat } from './quat';\nimport Vec3, * as vec3 from './vec3-impl';\nimport * as utils from './utils';\n\nexport default Mat4;\n\nexport type Mat4LikeCtor = new (n: number) => Mat4;\n\n/**\n * 4x4 Matrix math math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new matrix. In other words you can do this\n *\n * const mat = mat4.translation([1, 2, 3]); // Creates a new translation matrix\n *\n * or\n *\n * const mat = mat4.create();\n * mat4.translation([1, 2, 3], mat); // Puts translation matrix in mat.\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always save to pass any matrix as the destination. So for example\n *\n * const mat = mat4.identity();\n * const trans = mat4.translation([1, 2, 3]);\n * mat4.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat.\n *\n */\nlet MatType: Mat4LikeCtor = Float32Array;\n\n/**\n * Sets the type this library creates for a Mat4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Mat4\n */\nexport function setDefaultType(ctor: new (n: number) => Mat4) {\n const oldType = MatType;\n MatType = ctor;\n return oldType;\n}\n\n/**\n * Create a Mat4 from values\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Mat4's specified type\n * it would be faster to use\n *\n * ```\n * const m = mat4.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Mat4Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `mat4.create` is usually used\n * to create a Mat4 to be filled out as in\n *\n * ```\n * const m = mat4.create();\n * mat4.perspective(fov, aspect, near, far, m);\n * ```\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param v9 - value for element 9\n * @param v10 - value for element 10\n * @param v11 - value for element 11\n * @param v12 - value for element 12\n * @param v13 - value for element 13\n * @param v14 - value for element 14\n * @param v15 - value for element 15\n * @returns created from values.\n */\nexport function create(\n v0?: number, v1?: number, v2?: number, v3?: number,\n v4?: number, v5?: number, v6?: number, v7?: number,\n v8?: number, v9?: number, v10?: number, v11?: number,\n v12?: number, v13?: number, v14?: number, v15?: number): Mat4 {\n const dst = new MatType(16);\n if (v0 !== undefined) {\n dst[0] = v0;\n if (v1 !== undefined) {\n dst[1] = v1;\n if (v2 !== undefined) {\n dst[2] = v2;\n if (v3 !== undefined) {\n dst[3] = v3;\n if (v4 !== undefined) {\n dst[4] = v4;\n if (v5 !== undefined) {\n dst[5] = v5;\n if (v6 !== undefined) {\n dst[6] = v6;\n if (v7 !== undefined) {\n dst[7] = v7;\n if (v8 !== undefined) {\n dst[8] = v8;\n if (v9 !== undefined) {\n dst[9] = v9;\n if (v10 !== undefined) {\n dst[10] = v10;\n if (v11 !== undefined) {\n dst[11] = v11;\n if (v12 !== undefined) {\n dst[12] = v12;\n if (v13 !== undefined) {\n dst[13] = v13;\n if (v14 !== undefined) {\n dst[14] = v14;\n if (v15 !== undefined) {\n dst[15] = v15;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n return dst;\n}\n\n/**\n * Sets the values of a Mat4\n * Also see {@link mat4.create} and {@link mat4.copy}\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param v9 - value for element 9\n * @param v10 - value for element 10\n * @param v11 - value for element 11\n * @param v12 - value for element 12\n * @param v13 - value for element 13\n * @param v14 - value for element 14\n * @param v15 - value for element 15\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 created from values.\n */\nexport function set(\n v0: number, v1: number, v2: number, v3: number,\n v4: number, v5: number, v6: number, v7: number,\n v8: number, v9: number, v10: number, v11: number,\n v12: number, v13: number, v14: number, v15: number,\n dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = v0; dst[ 1] = v1; dst[ 2] = v2; dst[ 3] = v3;\n dst[ 4] = v4; dst[ 5] = v5; dst[ 6] = v6; dst[ 7] = v7;\n dst[ 8] = v8; dst[ 9] = v9; dst[10] = v10; dst[11] = v11;\n dst[12] = v12; dst[13] = v13; dst[14] = v14; dst[15] = v15;\n\n return dst;\n}\n\n/**\n * Creates a Mat4 from a Mat3\n * @param m3 - source matrix\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 made from m3\n */\nexport function fromMat3(m3: Mat3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = m3[0]; dst[ 1] = m3[1]; dst[ 2] = m3[ 2]; dst[ 3] = 0;\n dst[ 4] = m3[4]; dst[ 5] = m3[5]; dst[ 6] = m3[ 6]; dst[ 7] = 0;\n dst[ 8] = m3[8]; dst[ 9] = m3[9]; dst[10] = m3[10]; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a Mat4 rotation matrix from a quaternion\n * @param q - quaternion to create matrix from\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 made from q\n */\nexport function fromQuat(q: Quat, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3];\n const x2 = x + x; const y2 = y + y; const z2 = z + z;\n\n const xx = x * x2;\n const yx = y * x2;\n const yy = y * y2;\n const zx = z * x2;\n const zy = z * y2;\n const zz = z * z2;\n const wx = w * x2;\n const wy = w * y2;\n const wz = w * z2;\n\n dst[ 0] = 1 - yy - zz; dst[ 1] = yx + wz; dst[ 2] = zx - wy; dst[ 3] = 0;\n dst[ 4] = yx - wz; dst[ 5] = 1 - xx - zz; dst[ 6] = zy + wx; dst[ 7] = 0;\n dst[ 8] = zx + wy; dst[ 9] = zy - wx; dst[10] = 1 - xx - yy; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Negates a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns -m.\n */\nexport function negate(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = -m[ 0]; dst[ 1] = -m[ 1]; dst[ 2] = -m[ 2]; dst[ 3] = -m[ 3];\n dst[ 4] = -m[ 4]; dst[ 5] = -m[ 5]; dst[ 6] = -m[ 6]; dst[ 7] = -m[ 7];\n dst[ 8] = -m[ 8]; dst[ 9] = -m[ 9]; dst[10] = -m[10]; dst[11] = -m[11];\n dst[12] = -m[12]; dst[13] = -m[13]; dst[14] = -m[14]; dst[15] = -m[15];\n\n return dst;\n}\n\n/**\n * Copies a matrix. (same as {@link mat4.clone})\n * Also see {@link mat4.create} and {@link mat4.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport function copy(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = m[ 0]; dst[ 1] = m[ 1]; dst[ 2] = m[ 2]; dst[ 3] = m[ 3];\n dst[ 4] = m[ 4]; dst[ 5] = m[ 5]; dst[ 6] = m[ 6]; dst[ 7] = m[ 7];\n dst[ 8] = m[ 8]; dst[ 9] = m[ 9]; dst[10] = m[10]; dst[11] = m[11];\n dst[12] = m[12]; dst[13] = m[13]; dst[14] = m[14]; dst[15] = m[15];\n\n return dst;\n}\n\n/**\n * Copies a matrix (same as {@link mat4.copy})\n * Also see {@link mat4.create} and {@link mat4.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport const clone = copy;\n\n/**\n * Check if 2 matrices are approximately equal\n * @param a - Operand matrix.\n * @param b - Operand matrix.\n * @returns true if matrices are approximately equal\n */\nexport function equalsApproximately(a: Mat4, b: Mat4): boolean {\n return Math.abs(a[ 0] - b[ 0]) < utils.EPSILON &&\n Math.abs(a[ 1] - b[ 1]) < utils.EPSILON &&\n Math.abs(a[ 2] - b[ 2]) < utils.EPSILON &&\n Math.abs(a[ 3] - b[ 3]) < utils.EPSILON &&\n Math.abs(a[ 4] - b[ 4]) < utils.EPSILON &&\n Math.abs(a[ 5] - b[ 5]) < utils.EPSILON &&\n Math.abs(a[ 6] - b[ 6]) < utils.EPSILON &&\n Math.abs(a[ 7] - b[ 7]) < utils.EPSILON &&\n Math.abs(a[ 8] - b[ 8]) < utils.EPSILON &&\n Math.abs(a[ 9] - b[ 9]) < utils.EPSILON &&\n Math.abs(a[10] - b[10]) < utils.EPSILON &&\n Math.abs(a[11] - b[11]) < utils.EPSILON &&\n Math.abs(a[12] - b[12]) < utils.EPSILON &&\n Math.abs(a[13] - b[13]) < utils.EPSILON &&\n Math.abs(a[14] - b[14]) < utils.EPSILON &&\n Math.abs(a[15] - b[15]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 matrices are exactly equal\n * @param a - Operand matrix.\n * @param b - Operand matrix.\n * @returns true if matrices are exactly equal\n */\nexport function equals(a: Mat4, b: Mat4): boolean {\n return a[ 0] === b[ 0] &&\n a[ 1] === b[ 1] &&\n a[ 2] === b[ 2] &&\n a[ 3] === b[ 3] &&\n a[ 4] === b[ 4] &&\n a[ 5] === b[ 5] &&\n a[ 6] === b[ 6] &&\n a[ 7] === b[ 7] &&\n a[ 8] === b[ 8] &&\n a[ 9] === b[ 9] &&\n a[10] === b[10] &&\n a[11] === b[11] &&\n a[12] === b[12] &&\n a[13] === b[13] &&\n a[14] === b[14] &&\n a[15] === b[15];\n}\n\n/**\n * Creates a 4-by-4 identity matrix.\n *\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A 4-by-4 identity matrix.\n */\nexport function identity(dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Takes the transpose of a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The transpose of m.\n */\nexport function transpose(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n if (dst === m) {\n let t;\n\n t = m[1];\n m[1] = m[4];\n m[4] = t;\n\n t = m[2];\n m[2] = m[8];\n m[8] = t;\n\n t = m[3];\n m[3] = m[12];\n m[12] = t;\n\n t = m[6];\n m[6] = m[9];\n m[9] = t;\n\n t = m[7];\n m[7] = m[13];\n m[13] = t;\n\n t = m[11];\n m[11] = m[14];\n m[14] = t;\n return dst;\n }\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n dst[ 0] = m00; dst[ 1] = m10; dst[ 2] = m20; dst[ 3] = m30;\n dst[ 4] = m01; dst[ 5] = m11; dst[ 6] = m21; dst[ 7] = m31;\n dst[ 8] = m02; dst[ 9] = m12; dst[10] = m22; dst[11] = m32;\n dst[12] = m03; dst[13] = m13; dst[14] = m23; dst[15] = m33;\n\n return dst;\n}\n\n/**\n * Computes the inverse of a 4-by-4 matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport function inverse(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n const tmp0 = m22 * m33;\n const tmp1 = m32 * m23;\n const tmp2 = m12 * m33;\n const tmp3 = m32 * m13;\n const tmp4 = m12 * m23;\n const tmp5 = m22 * m13;\n const tmp6 = m02 * m33;\n const tmp7 = m32 * m03;\n const tmp8 = m02 * m23;\n const tmp9 = m22 * m03;\n const tmp10 = m02 * m13;\n const tmp11 = m12 * m03;\n const tmp12 = m20 * m31;\n const tmp13 = m30 * m21;\n const tmp14 = m10 * m31;\n const tmp15 = m30 * m11;\n const tmp16 = m10 * m21;\n const tmp17 = m20 * m11;\n const tmp18 = m00 * m31;\n const tmp19 = m30 * m01;\n const tmp20 = m00 * m21;\n const tmp21 = m20 * m01;\n const tmp22 = m00 * m11;\n const tmp23 = m10 * m01;\n\n const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) -\n (tmp1 * m11 + tmp2 * m21 + tmp5 * m31);\n const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) -\n (tmp0 * m01 + tmp7 * m21 + tmp8 * m31);\n const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) -\n (tmp3 * m01 + tmp6 * m11 + tmp11 * m31);\n const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) -\n (tmp4 * m01 + tmp9 * m11 + tmp10 * m21);\n\n const d = 1 / (m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3);\n\n dst[ 0] = d * t0;\n dst[ 1] = d * t1;\n dst[ 2] = d * t2;\n dst[ 3] = d * t3;\n dst[ 4] = d * ((tmp1 * m10 + tmp2 * m20 + tmp5 * m30) -\n (tmp0 * m10 + tmp3 * m20 + tmp4 * m30));\n dst[ 5] = d * ((tmp0 * m00 + tmp7 * m20 + tmp8 * m30) -\n (tmp1 * m00 + tmp6 * m20 + tmp9 * m30));\n dst[ 6] = d * ((tmp3 * m00 + tmp6 * m10 + tmp11 * m30) -\n (tmp2 * m00 + tmp7 * m10 + tmp10 * m30));\n dst[ 7] = d * ((tmp4 * m00 + tmp9 * m10 + tmp10 * m20) -\n (tmp5 * m00 + tmp8 * m10 + tmp11 * m20));\n dst[ 8] = d * ((tmp12 * m13 + tmp15 * m23 + tmp16 * m33) -\n (tmp13 * m13 + tmp14 * m23 + tmp17 * m33));\n dst[ 9] = d * ((tmp13 * m03 + tmp18 * m23 + tmp21 * m33) -\n (tmp12 * m03 + tmp19 * m23 + tmp20 * m33));\n dst[10] = d * ((tmp14 * m03 + tmp19 * m13 + tmp22 * m33) -\n (tmp15 * m03 + tmp18 * m13 + tmp23 * m33));\n dst[11] = d * ((tmp17 * m03 + tmp20 * m13 + tmp23 * m23) -\n (tmp16 * m03 + tmp21 * m13 + tmp22 * m23));\n dst[12] = d * ((tmp14 * m22 + tmp17 * m32 + tmp13 * m12) -\n (tmp16 * m32 + tmp12 * m12 + tmp15 * m22));\n dst[13] = d * ((tmp20 * m32 + tmp12 * m02 + tmp19 * m22) -\n (tmp18 * m22 + tmp21 * m32 + tmp13 * m02));\n dst[14] = d * ((tmp18 * m12 + tmp23 * m32 + tmp15 * m02) -\n (tmp22 * m32 + tmp14 * m02 + tmp19 * m12));\n dst[15] = d * ((tmp22 * m22 + tmp16 * m02 + tmp21 * m12) -\n (tmp20 * m12 + tmp23 * m22 + tmp17 * m02));\n\n return dst;\n}\n\n/**\n * Compute the determinant of a matrix\n * @param m - the matrix\n * @returns the determinant\n */\nexport function determinant(m: Mat4): number {\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n const tmp0 = m22 * m33;\n const tmp1 = m32 * m23;\n const tmp2 = m12 * m33;\n const tmp3 = m32 * m13;\n const tmp4 = m12 * m23;\n const tmp5 = m22 * m13;\n const tmp6 = m02 * m33;\n const tmp7 = m32 * m03;\n const tmp8 = m02 * m23;\n const tmp9 = m22 * m03;\n const tmp10 = m02 * m13;\n const tmp11 = m12 * m03;\n\n const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) -\n (tmp1 * m11 + tmp2 * m21 + tmp5 * m31);\n const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) -\n (tmp0 * m01 + tmp7 * m21 + tmp8 * m31);\n const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) -\n (tmp3 * m01 + tmp6 * m11 + tmp11 * m31);\n const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) -\n (tmp4 * m01 + tmp9 * m11 + tmp10 * m21);\n\n return m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3;\n}\n\n/**\n * Computes the inverse of a 4-by-4 matrix. (same as inverse)\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport const invert = inverse;\n\n/**\n * Multiplies two 4-by-4 matrices with a on the left and b on the right\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport function multiply(a: Mat4, b: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const a00 = a[0];\n const a01 = a[1];\n const a02 = a[2];\n const a03 = a[3];\n const a10 = a[ 4 + 0];\n const a11 = a[ 4 + 1];\n const a12 = a[ 4 + 2];\n const a13 = a[ 4 + 3];\n const a20 = a[ 8 + 0];\n const a21 = a[ 8 + 1];\n const a22 = a[ 8 + 2];\n const a23 = a[ 8 + 3];\n const a30 = a[12 + 0];\n const a31 = a[12 + 1];\n const a32 = a[12 + 2];\n const a33 = a[12 + 3];\n const b00 = b[0];\n const b01 = b[1];\n const b02 = b[2];\n const b03 = b[3];\n const b10 = b[ 4 + 0];\n const b11 = b[ 4 + 1];\n const b12 = b[ 4 + 2];\n const b13 = b[ 4 + 3];\n const b20 = b[ 8 + 0];\n const b21 = b[ 8 + 1];\n const b22 = b[ 8 + 2];\n const b23 = b[ 8 + 3];\n const b30 = b[12 + 0];\n const b31 = b[12 + 1];\n const b32 = b[12 + 2];\n const b33 = b[12 + 3];\n\n dst[ 0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03;\n dst[ 1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03;\n dst[ 2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03;\n dst[ 3] = a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03;\n dst[ 4] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13;\n dst[ 5] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13;\n dst[ 6] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13;\n dst[ 7] = a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13;\n dst[ 8] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23;\n dst[ 9] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23;\n dst[10] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23;\n dst[11] = a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23;\n dst[12] = a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33;\n dst[13] = a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33;\n dst[14] = a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33;\n dst[15] = a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33;\n\n return dst;\n}\n\n/**\n * Multiplies two 4-by-4 matrices with a on the left and b on the right (same as multiply)\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Sets the translation component of a 4-by-4 matrix to the given\n * vector.\n * @param a - The matrix.\n * @param v - The vector.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix with translation set.\n */\nexport function setTranslation(a: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || identity();\n if (a !== dst) {\n dst[ 0] = a[ 0];\n dst[ 1] = a[ 1];\n dst[ 2] = a[ 2];\n dst[ 3] = a[ 3];\n dst[ 4] = a[ 4];\n dst[ 5] = a[ 5];\n dst[ 6] = a[ 6];\n dst[ 7] = a[ 7];\n dst[ 8] = a[ 8];\n dst[ 9] = a[ 9];\n dst[10] = a[10];\n dst[11] = a[11];\n }\n dst[12] = v[0];\n dst[13] = v[1];\n dst[14] = v[2];\n dst[15] = 1;\n return dst;\n}\n\n/**\n * Returns the translation component of a 4-by-4 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n dst[0] = m[12];\n dst[1] = m[13];\n dst[2] = m[14];\n return dst;\n}\n\n/**\n * Returns an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat4, axis: number, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n dst[2] = m[off + 2];\n return dst;\n}\n\n/**\n * Sets an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param v - the axis vector\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @param dst - The matrix to set. If not passed a new one is created.\n * @returns The matrix with axis set.\n */\nexport function setAxis(m: Mat4, v: Vec3, axis: number, dst: Mat4): Mat4 {\n if (dst !== m) {\n dst = copy(m, dst);\n }\n const off = axis * 4;\n dst[off + 0] = v[0];\n dst[off + 1] = v[1];\n dst[off + 2] = v[2];\n return dst;\n}\n\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n\n const xx = m[0];\n const xy = m[1];\n const xz = m[2];\n const yx = m[4];\n const yy = m[5];\n const yz = m[6];\n const zx = m[8];\n const zy = m[9];\n const zz = m[10];\n\n dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz);\n dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz);\n dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz);\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 perspective transformation matrix given the angular height\n * of the frustum, the aspect ratio, and the near and far clipping planes. The\n * arguments define a frustum extending in the negative z direction. The given\n * angle is the vertical angle of the frustum, and the horizontal angle is\n * determined to produce the given aspect ratio. The arguments near and far are\n * the distances to the near and far clipping planes. Note that near and far\n * are not z coordinates, but rather they are distances along the negative\n * z-axis. The matrix generated sends the viewing frustum to the unit box.\n * We assume a unit box extending from -1 to 1 in the x and y dimensions and\n * from 0 to 1 in the z dimension.\n *\n * Note: If you pass `Infinity` for zFar then it will produce a projection matrix\n * returns -Infinity for Z when transforming coordinates with Z <= 0 and +Infinity for Z\n * otherwise.\n *\n * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians).\n * @param aspect - The aspect ratio width / height.\n * @param zNear - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param zFar - The depth (negative z coordinate)\n * of the far clipping plane.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The perspective matrix.\n */\nexport function perspective(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians);\n\n dst[0] = f / aspect;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n dst[4] = 0;\n dst[5] = f;\n dst[6] = 0;\n dst[7] = 0;\n\n dst[8] = 0;\n dst[9] = 0;\n dst[11] = -1;\n\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (Number.isFinite(zFar)) {\n const rangeInv = 1 / (zNear - zFar);\n dst[10] = zFar * rangeInv;\n dst[14] = zFar * zNear * rangeInv;\n } else {\n dst[10] = -1;\n dst[14] = -zNear;\n }\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 reverse-z perspective transformation matrix given the angular height\n * of the frustum, the aspect ratio, and the near and far clipping planes. The\n * arguments define a frustum extending in the negative z direction. The given\n * angle is the vertical angle of the frustum, and the horizontal angle is\n * determined to produce the given aspect ratio. The arguments near and far are\n * the distances to the near and far clipping planes. Note that near and far\n * are not z coordinates, but rather they are distances along the negative\n * z-axis. The matrix generated sends the viewing frustum to the unit box.\n * We assume a unit box extending from -1 to 1 in the x and y dimensions and\n * from 1 (at -zNear) to 0 (at -zFar) in the z dimension.\n *\n * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians).\n * @param aspect - The aspect ratio width / height.\n * @param zNear - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param zFar - The depth (negative z coordinate)\n * of the far clipping plane. (default = Infinity)\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The perspective matrix.\n */export function perspectiveReverseZ(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar = Infinity, dst?: Mat4) {\n dst = dst || new MatType(16);\n\n const f = 1 / Math.tan(fieldOfViewYInRadians * 0.5);\n\n dst[ 0] = f / aspect;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n\n dst[ 4] = 0;\n dst[ 5] = f;\n dst[ 6] = 0;\n dst[ 7] = 0;\n\n dst[ 8] = 0;\n dst[ 9] = 0;\n dst[11] = -1;\n\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (zFar === Infinity) {\n dst[10] = 0;\n dst[14] = zNear;\n } else {\n const rangeInv = 1 / (zFar - zNear);\n dst[10] = zNear * rangeInv;\n dst[14] = zFar * zNear * rangeInv;\n }\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 orthogonal transformation matrix that transforms from\n * the given the left, right, bottom, and top dimensions to -1 +1 in x, and y\n * and 0 to +1 in z.\n * @param left - Left side of the near clipping plane viewport.\n * @param right - Right side of the near clipping plane viewport.\n * @param bottom - Bottom of the near clipping plane viewport.\n * @param top - Top of the near clipping plane viewport.\n * @param near - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param far - The depth (negative z coordinate)\n * of the far clipping plane.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The orthographic projection matrix.\n */\nexport function ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[0] = 2 / (right - left);\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n dst[4] = 0;\n dst[5] = 2 / (top - bottom);\n dst[6] = 0;\n dst[7] = 0;\n\n dst[8] = 0;\n dst[9] = 0;\n dst[10] = 1 / (near - far);\n dst[11] = 0;\n\n dst[12] = (right + left) / (left - right);\n dst[13] = (top + bottom) / (bottom - top);\n dst[14] = near / (near - far);\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 perspective transformation matrix given the left, right,\n * top, bottom, near and far clipping planes. The arguments define a frustum\n * extending in the negative z direction. The arguments near and far are the\n * distances to the near and far clipping planes. Note that near and far are not\n * z coordinates, but rather they are distances along the negative z-axis. The\n * matrix generated sends the viewing frustum to the unit box. We assume a unit\n * box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z\n * dimension.\n * @param left - The x coordinate of the left plane of the box.\n * @param right - The x coordinate of the right plane of the box.\n * @param bottom - The y coordinate of the bottom plane of the box.\n * @param top - The y coordinate of the right plane of the box.\n * @param near - The negative z coordinate of the near plane of the box.\n * @param far - The negative z coordinate of the far plane of the box.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The perspective projection matrix.\n */\nexport function frustum(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const dx = (right - left);\n const dy = (top - bottom);\n const dz = (near - far);\n\n dst[ 0] = 2 * near / dx;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 2 * near / dy;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = (left + right) / dx;\n dst[ 9] = (top + bottom) / dy;\n dst[10] = far / dz;\n dst[11] = -1;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = near * far / dz;\n dst[15] = 0;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 reverse-z perspective transformation matrix given the left, right,\n * top, bottom, near and far clipping planes. The arguments define a frustum\n * extending in the negative z direction. The arguments near and far are the\n * distances to the near and far clipping planes. Note that near and far are not\n * z coordinates, but rather they are distances along the negative z-axis. The\n * matrix generated sends the viewing frustum to the unit box. We assume a unit\n * box extending from -1 to 1 in the x and y dimensions and from 1 (-near) to 0 (-far) in the z\n * dimension.\n * @param left - The x coordinate of the left plane of the box.\n * @param right - The x coordinate of the right plane of the box.\n * @param bottom - The y coordinate of the bottom plane of the box.\n * @param top - The y coordinate of the right plane of the box.\n * @param near - The negative z coordinate of the near plane of the box.\n * @param far - The negative z coordinate of the far plane of the box.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The perspective projection matrix.\n */\nexport function frustumReverseZ(left: number, right: number, bottom: number, top: number, near: number, far = Infinity, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const dx = (right - left);\n const dy = (top - bottom);\n\n dst[ 0] = 2 * near / dx;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 2 * near / dy;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = (left + right) / dx;\n dst[ 9] = (top + bottom) / dy;\n dst[11] = -1;\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (far === Infinity) {\n dst[10] = 0;\n dst[14] = near;\n } else {\n const rangeInv = 1 / (far - near);\n dst[10] = near * rangeInv;\n dst[14] = far * near * rangeInv;\n }\n\n return dst;\n}\n\nlet xAxis: Vec3;\nlet yAxis: Vec3;\nlet zAxis: Vec3;\n\n/**\n * Computes a 4-by-4 aim transformation.\n *\n * This is a matrix which positions an object aiming down positive Z.\n * toward the target.\n *\n * Note: this is **NOT** the inverse of lookAt as lookAt looks at negative Z.\n *\n * @param position - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The aim matrix.\n */\nexport function aim(position: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(target, position, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = xAxis[1]; dst[ 2] = xAxis[2]; dst[ 3] = 0;\n dst[ 4] = yAxis[0]; dst[ 5] = yAxis[1]; dst[ 6] = yAxis[2]; dst[ 7] = 0;\n dst[ 8] = zAxis[0]; dst[ 9] = zAxis[1]; dst[10] = zAxis[2]; dst[11] = 0;\n dst[12] = position[0]; dst[13] = position[1]; dst[14] = position[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 camera aim transformation.\n *\n * This is a matrix which positions an object aiming down negative Z.\n * toward the target.\n *\n * Note: this is the inverse of `lookAt`\n *\n * @param eye - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The aim matrix.\n */\nexport function cameraAim(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = xAxis[1]; dst[ 2] = xAxis[2]; dst[ 3] = 0;\n dst[ 4] = yAxis[0]; dst[ 5] = yAxis[1]; dst[ 6] = yAxis[2]; dst[ 7] = 0;\n dst[ 8] = zAxis[0]; dst[ 9] = zAxis[1]; dst[10] = zAxis[2]; dst[11] = 0;\n dst[12] = eye[0]; dst[13] = eye[1]; dst[14] = eye[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 view transformation.\n *\n * This is a view matrix which transforms all other objects\n * to be in the space of the view defined by the parameters.\n *\n * @param eye - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The look-at matrix.\n */\nexport function lookAt(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = yAxis[0]; dst[ 2] = zAxis[0]; dst[ 3] = 0;\n dst[ 4] = xAxis[1]; dst[ 5] = yAxis[1]; dst[ 6] = zAxis[1]; dst[ 7] = 0;\n dst[ 8] = xAxis[2]; dst[ 9] = yAxis[2]; dst[10] = zAxis[2]; dst[11] = 0;\n\n dst[12] = -(xAxis[0] * eye[0] + xAxis[1] * eye[1] + xAxis[2] * eye[2]);\n dst[13] = -(yAxis[0] * eye[0] + yAxis[1] * eye[1] + yAxis[2] * eye[2]);\n dst[14] = -(zAxis[0] * eye[0] + zAxis[1] * eye[1] + zAxis[2] * eye[2]);\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which translates by the given vector v.\n * @param v - The vector by\n * which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translation matrix.\n */\nexport function translation(v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = v[0]; dst[13] = v[1]; dst[14] = v[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Translates the given 4-by-4 matrix by the given vector v.\n * @param m - The matrix.\n * @param v - The vector by\n * which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translated matrix.\n */\nexport function translate(m: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m03 = m[3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n if (m !== dst) {\n dst[ 0] = m00;\n dst[ 1] = m01;\n dst[ 2] = m02;\n dst[ 3] = m03;\n dst[ 4] = m10;\n dst[ 5] = m11;\n dst[ 6] = m12;\n dst[ 7] = m13;\n dst[ 8] = m20;\n dst[ 9] = m21;\n dst[10] = m22;\n dst[11] = m23;\n }\n\n dst[12] = m00 * v0 + m10 * v1 + m20 * v2 + m30;\n dst[13] = m01 * v0 + m11 * v1 + m21 * v2 + m31;\n dst[14] = m02 * v0 + m12 * v1 + m22 * v2 + m32;\n dst[15] = m03 * v0 + m13 * v1 + m23 * v2 + m33;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationX(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = c; dst[ 6] = s; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = -s; dst[10] = c; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateX(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m10 = m[4];\n const m11 = m[5];\n const m12 = m[6];\n const m13 = m[7];\n const m20 = m[8];\n const m21 = m[9];\n const m22 = m[10];\n const m23 = m[11];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[4] = c * m10 + s * m20;\n dst[5] = c * m11 + s * m21;\n dst[6] = c * m12 + s * m22;\n dst[7] = c * m13 + s * m23;\n dst[8] = c * m20 - s * m10;\n dst[9] = c * m21 - s * m11;\n dst[10] = c * m22 - s * m12;\n dst[11] = c * m23 - s * m13;\n\n if (m !== dst) {\n dst[ 0] = m[ 0];\n dst[ 1] = m[ 1];\n dst[ 2] = m[ 2];\n dst[ 3] = m[ 3];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationY(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = 0; dst[ 2] = -s; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = s; dst[ 9] = 0; dst[10] = c; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateY(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 - s * m20;\n dst[ 1] = c * m01 - s * m21;\n dst[ 2] = c * m02 - s * m22;\n dst[ 3] = c * m03 - s * m23;\n dst[ 8] = c * m20 + s * m00;\n dst[ 9] = c * m21 + s * m01;\n dst[10] = c * m22 + s * m02;\n dst[11] = c * m23 + s * m03;\n\n if (m !== dst) {\n dst[ 4] = m[ 4];\n dst[ 5] = m[ 5];\n dst[ 6] = m[ 6];\n dst[ 7] = m[ 7];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationZ(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = s; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = -s; dst[ 5] = c; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateZ(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 + s * m10;\n dst[ 1] = c * m01 + s * m11;\n dst[ 2] = c * m02 + s * m12;\n dst[ 3] = c * m03 + s * m13;\n dst[ 4] = c * m10 - s * m00;\n dst[ 5] = c * m11 - s * m01;\n dst[ 6] = c * m12 - s * m02;\n dst[ 7] = c * m13 - s * m03;\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n dst[11] = m[11];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the given axis by the given\n * angle.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A matrix which rotates angle radians\n * around the axis.\n */\nexport function axisRotation(axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n let x = axis[0];\n let y = axis[1];\n let z = axis[2];\n const n = Math.sqrt(x * x + y * y + z * z);\n x /= n;\n y /= n;\n z /= n;\n const xx = x * x;\n const yy = y * y;\n const zz = z * z;\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n const oneMinusCosine = 1 - c;\n\n dst[ 0] = xx + (1 - xx) * c;\n dst[ 1] = x * y * oneMinusCosine + z * s;\n dst[ 2] = x * z * oneMinusCosine - y * s;\n dst[ 3] = 0;\n dst[ 4] = x * y * oneMinusCosine - z * s;\n dst[ 5] = yy + (1 - yy) * c;\n dst[ 6] = y * z * oneMinusCosine + x * s;\n dst[ 7] = 0;\n dst[ 8] = x * z * oneMinusCosine + y * s;\n dst[ 9] = y * z * oneMinusCosine - x * s;\n dst[10] = zz + (1 - zz) * c;\n dst[11] = 0;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = 0;\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the given axis by the given\n * angle. (same as axisRotation)\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A matrix which rotates angle radians\n * around the axis.\n */\nexport const rotation = axisRotation;\n\n/**\n * Rotates the given 4-by-4 matrix around the given axis by the\n * given angle.\n * @param m - The matrix.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function axisRotate(m: Mat4, axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n let x = axis[0];\n let y = axis[1];\n let z = axis[2];\n const n = Math.sqrt(x * x + y * y + z * z);\n x /= n;\n y /= n;\n z /= n;\n const xx = x * x;\n const yy = y * y;\n const zz = z * z;\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n const oneMinusCosine = 1 - c;\n\n const r00 = xx + (1 - xx) * c;\n const r01 = x * y * oneMinusCosine + z * s;\n const r02 = x * z * oneMinusCosine - y * s;\n const r10 = x * y * oneMinusCosine - z * s;\n const r11 = yy + (1 - yy) * c;\n const r12 = y * z * oneMinusCosine + x * s;\n const r20 = x * z * oneMinusCosine + y * s;\n const r21 = y * z * oneMinusCosine - x * s;\n const r22 = zz + (1 - zz) * c;\n\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m03 = m[3];\n const m10 = m[4];\n const m11 = m[5];\n const m12 = m[6];\n const m13 = m[7];\n const m20 = m[8];\n const m21 = m[9];\n const m22 = m[10];\n const m23 = m[11];\n\n dst[ 0] = r00 * m00 + r01 * m10 + r02 * m20;\n dst[ 1] = r00 * m01 + r01 * m11 + r02 * m21;\n dst[ 2] = r00 * m02 + r01 * m12 + r02 * m22;\n dst[ 3] = r00 * m03 + r01 * m13 + r02 * m23;\n dst[ 4] = r10 * m00 + r11 * m10 + r12 * m20;\n dst[ 5] = r10 * m01 + r11 * m11 + r12 * m21;\n dst[ 6] = r10 * m02 + r11 * m12 + r12 * m22;\n dst[ 7] = r10 * m03 + r11 * m13 + r12 * m23;\n dst[ 8] = r20 * m00 + r21 * m10 + r22 * m20;\n dst[ 9] = r20 * m01 + r21 * m11 + r22 * m21;\n dst[10] = r20 * m02 + r21 * m12 + r22 * m22;\n dst[11] = r20 * m03 + r21 * m13 + r22 * m23;\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the given axis by the\n * given angle. (same as rotate)\n * @param m - The matrix.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport const rotate = axisRotate;\n\n/**\n * Creates a 4-by-4 matrix which scales in each dimension by an amount given by\n * the corresponding entry in the given vector; assumes the vector has three\n * entries.\n * @param v - A vector of\n * three entries specifying the factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function scaling(v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = v[0]; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = v[1]; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = v[2]; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount\n * given by the corresponding entry in the given vector; assumes the vector has\n * three entries.\n * @param m - The matrix to be modified.\n * @param v - A vector of three entries specifying the\n * factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function scale(m: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n\n dst[ 0] = v0 * m[0 * 4 + 0];\n dst[ 1] = v0 * m[0 * 4 + 1];\n dst[ 2] = v0 * m[0 * 4 + 2];\n dst[ 3] = v0 * m[0 * 4 + 3];\n dst[ 4] = v1 * m[1 * 4 + 0];\n dst[ 5] = v1 * m[1 * 4 + 1];\n dst[ 6] = v1 * m[1 * 4 + 2];\n dst[ 7] = v1 * m[1 * 4 + 3];\n dst[ 8] = v2 * m[2 * 4 + 0];\n dst[ 9] = v2 * m[2 * 4 + 1];\n dst[10] = v2 * m[2 * 4 + 2];\n dst[11] = v2 * m[2 * 4 + 3];\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which scales a uniform amount in each dimension.\n * @param s - the amount to scale\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function uniformScaling(s: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = s; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = s; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = s; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by a uniform scale.\n * @param m - The matrix to be modified.\n * @param s - The amount to scale.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function uniformScale(m: Mat4, s: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = s * m[0 * 4 + 0];\n dst[ 1] = s * m[0 * 4 + 1];\n dst[ 2] = s * m[0 * 4 + 2];\n dst[ 3] = s * m[0 * 4 + 3];\n dst[ 4] = s * m[1 * 4 + 0];\n dst[ 5] = s * m[1 * 4 + 1];\n dst[ 6] = s * m[1 * 4 + 2];\n dst[ 7] = s * m[1 * 4 + 3];\n dst[ 8] = s * m[2 * 4 + 0];\n dst[ 9] = s * m[2 * 4 + 1];\n dst[10] = s * m[2 * 4 + 2];\n dst[11] = s * m[2 * 4 + 3];\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link quat.setDefaultType}.\n */\nexport type Quat = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Quat4 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Quat4`. In other words you can do this\n *\n * const v = quat4.cross(v1, v2); // Creates a new Quat4 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = quat4.create();\n * quat4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * quat4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let QuatType: new (n: number) => Quat = Float32Array;\n\n/**\n * Sets the type this library creates for a Quat4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Quat4\n */\nexport function setDefaultType(ctor: new (n: number) => Quat) {\n const oldType = QuatType;\n QuatType = ctor;\n return oldType;\n}\n\n/**\n * Creates a quat4; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param w - Initial w value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number, w?: number): Quat {\n const dst = new QuatType(4);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n if (w !== undefined) {\n dst[3] = w;\n }\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Quat, create, setDefaultType, QuatType } from './quat';\nimport { Mat3 } from './mat3.js';\nimport { Mat4 } from './mat4.js';\nimport { Vec3 } from './vec3.js';\nimport * as vec3 from './vec3-impl.js';\n\nexport type RotationOrder = 'xyz' | 'xzy' | 'yxz' | 'yzx' | 'zxy' | 'zyx';\n\nexport default Quat;\nexport { create, setDefaultType };\n\n/**\n * Creates a Quat; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param z - Initial w value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Quat\n * Also see {@link quat.create} and {@link quat.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param w fourth value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, w: number, dst?: Quat) {\n dst = dst || new QuatType(4);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n dst[3] = w;\n\n return dst;\n}\n\n/**\n * Sets a quaternion from the given angle and axis,\n * then returns it.\n *\n * @param axis - the axis to rotate around\n * @param angleInRadians - the angle\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The quaternion that represents the given axis and angle\n **/\nexport function fromAxisAngle(axis: Vec3, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n const s = Math.sin(halfAngle);\n\n dst[0] = s * axis[0];\n dst[1] = s * axis[1];\n dst[2] = s * axis[2];\n dst[3] = Math.cos(halfAngle);\n\n return dst;\n}\n\n/**\n * Gets the rotation axis and angle\n * @param q - quaternion to compute from\n * @param dst - Vec3 to hold result. If not passed in a new one is created.\n * @return angle and axis\n */\nexport function toAxisAngle(q: Quat, dst?: Vec3): { angle: number, axis: Vec3 } {\n dst = dst || vec3.create(4);\n\n const angle = Math.acos(q[3]) * 2;\n const s = Math.sin(angle * 0.5);\n if (s > utils.EPSILON) {\n dst[0] = q[0] / s;\n dst[1] = q[1] / s;\n dst[2] = q[2] / s;\n } else {\n dst[0] = 1;\n dst[1] = 0;\n dst[2] = 0;\n }\n\n return { angle, axis: dst };\n}\n\n/**\n * Returns the angle in degrees between two rotations a and b.\n * @param a - quaternion a\n * @param b - quaternion b\n * @return angle in radians between the two quaternions\n */\nexport function angle(a: Quat, b: Quat) {\n const d = dot(a, b);\n return Math.acos(2 * d * d - 1);\n}\n\n/**\n * Multiplies two quaternions\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function multiply(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const aw = a[3];\n\n const bx = b[0];\n const by = b[1];\n const bz = b[2];\n const bw = b[3];\n\n dst[0] = ax * bw + aw * bx + ay * bz - az * by;\n dst[1] = ay * bw + aw * by + az * bx - ax * bz;\n dst[2] = az * bw + aw * bz + ax * by - ay * bx;\n dst[3] = aw * bw - ax * bx - ay * by - az * bz;\n\n return dst;\n}\n\n/**\n * Multiplies two quaternions\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport const mul = multiply;\n\n/**\n * Rotates the given quaternion around the X axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateX(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const bx = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw + qw * bx;\n dst[1] = qy * bw + qz * bx;\n dst[2] = qz * bw - qy * bx;\n dst[3] = qw * bw - qx * bx;\n\n return dst;\n}\n\n/**\n * Rotates the given quaternion around the Y axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateY(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const by = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw - qz * by;\n dst[1] = qy * bw + qw * by;\n dst[2] = qz * bw + qx * by;\n dst[3] = qw * bw - qy * by;\n\n return dst;\n}\n\n/**\n * Rotates the given quaternion around the Z axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateZ(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const bz = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw + qy * bz;\n dst[1] = qy * bw - qx * bz;\n dst[2] = qz * bw + qw * bz;\n dst[3] = qw * bw - qz * bz;\n\n return dst;\n}\n\n/**\n * Spherically linear interpolate between two quaternions\n *\n * @param a - starting value\n * @param b - ending value\n * @param t - value where 0 = a and 1 = b\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function slerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const aw = a[3];\n\n let bx = b[0];\n let by = b[1];\n let bz = b[2];\n let bw = b[3];\n\n let cosOmega = ax * bx + ay * by + az * bz + aw * bw;\n\n if (cosOmega < 0) {\n cosOmega = -cosOmega;\n bx = -bx;\n by = -by;\n bz = -bz;\n bw = -bw;\n }\n\n let scale0;\n let scale1;\n\n if (1.0 - cosOmega > utils.EPSILON) {\n const omega = Math.acos(cosOmega);\n const sinOmega = Math.sin(omega);\n scale0 = Math.sin((1 - t) * omega) / sinOmega;\n scale1 = Math.sin(t * omega) / sinOmega;\n } else {\n scale0 = 1.0 - t;\n scale1 = t;\n }\n\n dst[0] = scale0 * ax + scale1 * bx;\n dst[1] = scale0 * ay + scale1 * by;\n dst[2] = scale0 * az + scale1 * bz;\n dst[3] = scale0 * aw + scale1 * bw;\n\n return dst;\n}\n\n/**\n * Compute the inverse of a quaternion\n *\n * @param q - quaternion to compute the inverse of\n * @returns A quaternion that is the result of a * b\n */\nexport function inverse(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const a0 = q[0];\n const a1 = q[1];\n const a2 = q[2];\n const a3 = q[3];\n\n const dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;\n const invDot = dot ? 1 / dot : 0;\n\n dst[0] = -a0 * invDot;\n dst[1] = -a1 * invDot;\n dst[2] = -a2 * invDot;\n dst[3] = a3 * invDot;\n\n return dst;\n}\n\n/**\n * Compute the conjugate of a quaternion\n * For quaternions with a magnitude of 1 (a unit quaternion)\n * this returns the same as the inverse but is faster to calculate.\n *\n * @param q - quaternion to compute the conjugate of.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The conjugate of q\n */\nexport function conjugate(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = -q[0];\n dst[1] = -q[1];\n dst[2] = -q[2];\n dst[3] = q[3];\n\n return dst;\n}\n\n/**\n * Creates a quaternion from the given rotation matrix.\n *\n * The created quaternion is not normalized.\n *\n * @param m - rotation matrix\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns the result\n */\nexport function fromMat(m: Mat3 | Mat4, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n /*\n 0 1 2\n 3 4 5\n 6 7 8\n\n 0 1 2\n 4 5 6\n 8 9 10\n */\n\n // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes\n // article \"Quaternion Calculus and Fast Animation\".\n const trace = m[0] + m[5] + m[10];\n\n if (trace > 0.0) {\n // |w| > 1/2, may as well choose w > 1/2\n const root = Math.sqrt(trace + 1); // 2w\n dst[3] = 0.5 * root;\n const invRoot = 0.5 / root; // 1/(4w)\n\n dst[0] = (m[6] - m[9]) * invRoot;\n dst[1] = (m[8] - m[2]) * invRoot;\n dst[2] = (m[1] - m[4]) * invRoot;\n } else {\n // |w| <= 1/2\n let i = 0;\n\n if (m[5] > m[0]) {\n i = 1;\n }\n if (m[10] > m[i * 4 + i]) {\n i = 2;\n }\n\n const j = (i + 1) % 3;\n const k = (i + 2) % 3;\n\n const root = Math.sqrt(m[i * 4 + i] - m[j * 4 + j] - m[k * 4 + k] + 1.0);\n dst[i] = 0.5 * root;\n\n const invRoot = 0.5 / root;\n\n dst[3] = (m[j * 4 + k] - m[k * 4 + j]) * invRoot;\n dst[j] = (m[j * 4 + i] + m[i * 4 + j]) * invRoot;\n dst[k] = (m[k * 4 + i] + m[i * 4 + k]) * invRoot;\n }\n\n return dst;\n}\n\n/**\n * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion.\n *\n * @param xAngleInRadians - angle to rotate around X axis in radians.\n * @param yAngleInRadians - angle to rotate around Y axis in radians.\n * @param zAngleInRadians - angle to rotate around Z axis in radians.\n * @param order - order to apply euler angles\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion representing the same rotation as the euler angles applied in the given order\n */\nexport function fromEuler(\n xAngleInRadians: number,\n yAngleInRadians: number,\n zAngleInRadians: number,\n order: RotationOrder,\n dst?: Quat) {\n dst = dst || new QuatType(4);\n\n const xHalfAngle = xAngleInRadians * 0.5;\n const yHalfAngle = yAngleInRadians * 0.5;\n const zHalfAngle = zAngleInRadians * 0.5;\n\n const sx = Math.sin(xHalfAngle);\n const cx = Math.cos(xHalfAngle);\n const sy = Math.sin(yHalfAngle);\n const cy = Math.cos(yHalfAngle);\n const sz = Math.sin(zHalfAngle);\n const cz = Math.cos(zHalfAngle);\n\n switch (order) {\n case 'xyz':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'xzy':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n case 'yxz':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n case 'yzx':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'zxy':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'zyx':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n default:\n throw new Error(`Unknown rotation order: ${order}`);\n }\n\n return dst;\n}\n\n/**\n * Copies a quaternion. (same as {@link quat.clone})\n * Also see {@link quat.create} and {@link quat.set}\n * @param q - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is a copy of q\n */\nexport function copy(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = q[0];\n dst[1] = q[1];\n dst[2] = q[2];\n dst[3] = q[3];\n\n return dst;\n}\n\n/**\n * Clones a quaternion. (same as {@link quat.copy})\n * Also see {@link quat.create} and {@link quat.set}\n * @param q - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A copy of q.\n */\nexport const clone = copy;\n\n/**\n * Adds two quaternions; assumes a and b have the same dimension.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the sum of a and b.\n */\nexport function add(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n dst[3] = a[3] + b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two quaternions.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the difference of a and b.\n */\nexport function subtract(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n dst[3] = a[3] - b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two quaternions.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Multiplies a quaternion by a scalar.\n * @param v - The quaternion.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport function mulScalar(v: Quat, k: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n dst[3] = v[3] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a quaternion by a scalar. (same as mulScalar)\n * @param v - The quaternion.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport function divScalar(v: Quat, k: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n dst[3] = v[3] / k;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two quaternions\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns dot product\n */\nexport function dot(a: Quat, b: Quat): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]);\n}\n\n/**\n * Performs linear interpolation on two quaternions.\n * Given quaternions a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param t - Interpolation coefficient.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n dst[3] = a[3] + t * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Computes the length of quaternion\n * @param v - quaternion.\n * @returns length of quaternion.\n */\nexport function length(v: Quat): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n}\n\n/**\n * Computes the length of quaternion (same as length)\n * @param v - quaternion.\n * @returns length of quaternion.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of quaternion\n * @param v - quaternion.\n * @returns square of the length of quaternion.\n */\nexport function lengthSq(v: Quat): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3;\n}\n\n/**\n * Computes the square of the length of quaternion (same as lengthSq)\n * @param v - quaternion.\n * @returns square of the length of quaternion.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Divides a quaternion by its Euclidean length and returns the quotient.\n * @param v - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The normalized quaternion.\n */\nexport function normalize(v: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n dst[3] = v3 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n }\n\n return dst;\n}\n\n/**\n * Check if 2 quaternions are approximately equal\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns true if quaternions are approximately equal\n */\nexport function equalsApproximately(a: Quat, b: Quat): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON &&\n Math.abs(a[3] - b[3]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 quaternions are exactly equal\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns true if quaternions are exactly equal\n */\nexport function equals(a: Quat, b: Quat): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Creates an identity quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns an identity quaternion\n */\nexport function identity(dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 1;\n\n return dst;\n}\n\nlet tempVec3: Vec3;\nlet xUnitVec3: Vec3;\nlet yUnitVec3: Vec3;\n\n/**\n * Computes a quaternion to represent the shortest rotation from one vector to another.\n *\n * @param aUnit - the start vector\n * @param bUnit - the end vector\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns the result\n */\nexport function rotationTo(aUnit: Vec3, bUnit: Vec3, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n tempVec3 = tempVec3 || vec3.create();\n xUnitVec3 = xUnitVec3 || vec3.create(1, 0, 0);\n yUnitVec3 = yUnitVec3 || vec3.create(0, 1, 0);\n\n const dot = vec3.dot(aUnit, bUnit);\n if (dot < -0.999999) {\n vec3.cross(xUnitVec3, aUnit, tempVec3);\n if (vec3.len(tempVec3) < 0.000001) {\n vec3.cross(yUnitVec3, aUnit, tempVec3);\n }\n\n vec3.normalize(tempVec3, tempVec3);\n fromAxisAngle(tempVec3, Math.PI, dst);\n\n return dst;\n } else if (dot > 0.999999) {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 1;\n\n return dst;\n } else {\n vec3.cross(aUnit, bUnit, tempVec3);\n\n dst[0] = tempVec3[0];\n dst[1] = tempVec3[1];\n dst[2] = tempVec3[2];\n dst[3] = 1 + dot;\n\n return normalize(dst, dst);\n }\n}\n\nlet tempQuat1: Quat;\nlet tempQuat2: Quat;\n\n/**\n * Performs a spherical linear interpolation with two control points\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param c - the third quaternion\n * @param d - the fourth quaternion\n * @param t - Interpolation coefficient 0 to 1\n * @returns result\n */\nexport function sqlerp(\n a: Quat,\n b: Quat,\n c: Quat,\n d: Quat,\n t: number,\n dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n tempQuat1 = tempQuat1 || new QuatType(4);\n tempQuat2 = tempQuat2 || new QuatType(4);\n\n slerp(a, d, t, tempQuat1);\n slerp(b, c, t, tempQuat2);\n slerp(tempQuat1, tempQuat2, 2 * t * (1 - t), dst);\n\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec4.setDefaultType}.\n */\nexport type Vec4 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec4 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Vec4`. In other words you can do this\n *\n * const v = vec4.cross(v1, v2); // Creates a new Vec4 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec4.create();\n * vec4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec4 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec4\n */\nexport function setDefaultType(ctor: new (n: number) => Vec4) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a vec4; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param w - Initial w value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number, w?: number): Vec4 {\n const dst = new VecType(4);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n if (w !== undefined) {\n dst[3] = w;\n }\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Vec4, create, setDefaultType, VecType } from './vec4';\nimport { Mat4 } from './mat4';\n\nexport default Vec4;\nexport { create, setDefaultType };\n\n/**\n * Creates a vec4; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param z - Initial w value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec4\n * Also see {@link vec4.create} and {@link vec4.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param w fourth value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, w: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n dst[3] = w;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n dst[2] = Math.ceil(v[2]);\n dst[3] = Math.ceil(v[3]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n dst[2] = Math.floor(v[2]);\n dst[3] = Math.floor(v[3]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n dst[2] = Math.round(v[2]);\n dst[3] = Math.round(v[3]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec4, min = 0, max = 1, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n dst[2] = Math.min(max, Math.max(min, v[2]));\n dst[3] = Math.min(max, Math.max(min, v[3]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n dst[3] = a[3] + b[3];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec4, b: Vec4, scale: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n dst[2] = a[2] + b[2] * scale;\n dst[3] = a[3] + b[3] * scale;\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n dst[3] = a[3] - b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec4, b: Vec4): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON &&\n Math.abs(a[3] - b[3]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec4, b: Vec4): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec4, b: Vec4, t: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n dst[3] = a[3] + t * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec4, b: Vec4, t: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n dst[2] = a[2] + t[2] * (b[2] - a[2]);\n dst[3] = a[3] + t[3] * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n dst[2] = Math.max(a[2], b[2]);\n dst[3] = Math.max(a[3], b[3]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n dst[2] = Math.min(a[2], b[2]);\n dst[3] = Math.min(a[3], b[3]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec4, k: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n dst[3] = v[3] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec4, k: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n dst[3] = v[3] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n dst[2] = 1 / v[2];\n dst[3] = 1 / v[3];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the dot product of two vectors\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec4, b: Vec4): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]);\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec4): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec4): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec4, b: Vec4): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n const dw = a[3] - b[3];\n return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec4, b: Vec4): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n const dw = a[3] - b[3];\n return dx * dx + dy * dy + dz * dz + dw * dw;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n dst[3] = v3 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n }\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n dst[2] = -v[2];\n dst[3] = -v[3];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec4.clone})\n * Also see {@link vec4.create} and {@link vec4.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0];\n dst[1] = v[1];\n dst[2] = v[2];\n dst[3] = v[3];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec4.copy})\n * Also see {@link vec4.create} and {@link vec4.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n dst[2] = a[2] * b[2];\n dst[3] = a[3] * b[3];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec4, b: Vec4, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n dst[2] = a[2] / b[2];\n dst[3] = a[3] / b[3];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n return dst;\n}\n\n\n/**\n * transform vec4 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec4 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec4, m: Mat4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n const w = v[3];\n\n dst[0] = m[0] * x + m[4] * y + m[ 8] * z + m[12] * w;\n dst[1] = m[1] * x + m[5] * y + m[ 9] * z + m[13] * w;\n dst[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n dst[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n\n return dst;\n}\n\n\n/**\n * Treat a 4D vector as a direction and set it's length\n *\n * @param a The vec4 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec4, len: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec4 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec4, maxLen: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec4, b: Vec4, dst?: Vec4) {\n dst = dst || new VecType(4);\n return lerp(a, b, 0.5, dst);\n}\n","import Mat3, * as mat3 from './mat3-impl';\nimport Mat4, * as mat4 from './mat4-impl';\nimport Quat, * as quat from './quat-impl';\nimport Vec2, * as vec2 from './vec2-impl';\nimport Vec3, * as vec3 from './vec3-impl';\nimport Vec4, * as vec4 from './vec4-impl';\nimport * as utils from './utils';\n\n/**\n * Sets the type this library creates for all types\n *\n * example:\n *\n * ```\n * setDefaultType(Float64Array);\n * ```\n *\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n */\nexport function setDefaultType(ctor: new (n: number) => Float32Array | Float64Array | number[]) {\n mat3.setDefaultType(ctor);\n mat4.setDefaultType(ctor);\n quat.setDefaultType(ctor);\n vec2.setDefaultType(ctor);\n vec3.setDefaultType(ctor);\n vec4.setDefaultType(ctor);\n}\n\nexport {\n Mat3,\n mat3,\n Mat4,\n mat4,\n Quat,\n quat,\n utils,\n Vec2,\n vec2,\n Vec3,\n vec3,\n Vec4,\n vec4,\n};"],"names":["EPSILON","degrees","Math","PI","n","m","a","b","v","d","abs","t","radians","old","VecType","Float32Array","setDefaultType","ctor","oldType","create","x","y","dst","undefined","z","subtract","lerp","mulScalar","k","inverse","dot","length","v0","v1","sqrt","lengthSq","distance","dx","dy","distanceSq","normalize","len","copy","multiply","divide","setLength","scale","ax","ay","bx","by","mag","cosine","acos","ceil","min","max","Vec3Type","utils.EPSILON","floor","angle","random","cos","sin","rad","p0","p1","sinC","cosC","round","maxLen","MatType","ctorMap","Map","Float64Array","Array","fill","newMat3","get","identity","m00","m01","m02","m10","m11","m12","m20","m21","m22","b01","b11","b21","invDet","a00","a01","a02","a10","a11","a12","a20","a21","a22","b00","b02","b10","b12","b20","b22","v2","v3","v4","v5","v6","v7","v8","m4","q","w","x2","y2","z2","xx","yx","yy","zx","zy","zz","wx","wy","wz","axis","off","vec2.create","xy","angleInRadians","c","s","cross","t1","t2","dz","az","bz","xz","yz","zScale","p","r","qx","qy","qz","w2","uvX","uvY","uvZ","m03","m13","m23","m30","m31","m32","m33","tmp0","tmp1","tmp2","tmp3","tmp4","tmp5","tmp6","tmp7","tmp8","tmp9","tmp10","tmp11","tmp12","tmp13","tmp14","tmp15","tmp16","tmp17","tmp18","tmp19","tmp20","tmp21","tmp22","tmp23","t0","t3","a03","a13","a23","a30","a31","a32","a33","b03","b13","b23","b30","b31","b32","b33","xAxis","yAxis","zAxis","axisRotation","oneMinusCosine","axisRotate","r00","r01","r02","r10","r11","r12","r20","r21","r22","position","target","up","vec3.create","vec3.normalize","vec3.subtract","vec3.cross","eye","v9","v10","v11","v12","v13","v14","v15","m3","left","right","bottom","top","near","far","Infinity","rangeInv","fieldOfViewYInRadians","aspect","zNear","zFar","f","tan","Number","isFinite","QuatType","fromAxisAngle","halfAngle","aw","bw","slerp","scale0","scale1","cosOmega","omega","sinOmega","tempVec3","xUnitVec3","yUnitVec3","tempQuat1","tempQuat2","xAngleInRadians","yAngleInRadians","zAngleInRadians","order","xHalfAngle","yHalfAngle","zHalfAngle","sx","cx","sy","cy","sz","cz","Error","trace","root","invRoot","i","j","a0","a1","a2","a3","invDot","qw","aUnit","bUnit","vec3.dot","vec3.len","dw","mat3.setDefaultType","mat4.setDefaultType","quat.setDefaultType","vec2.setDefaultType","vec3.setDefaultType","vec4.setDefaultType"],"mappings":"kPAsBO,IAAIA,EAAU,4DAkBf,SAAmBC,GACvB,OAAOA,EAAUC,KAAKC,GAAK,GAC7B,kBAqDgB,SAAgBC,EAAWC,GACzC,OAASD,EAAIC,EAAKA,GAAKA,CACzB,uBAxB4BC,EAAWC,EAAWC,GAChD,MAAMC,EAAIF,EAAID,EACd,OAAQJ,KAAKQ,IAAIH,EAAID,GAAKN,EACrBM,GACCE,EAAIF,GAAKG,CACjB,gBAlBqBH,EAAWC,EAAWI,GACzC,OAAOL,GAAKC,EAAID,GAAKK,CACvB,WAbM,SAAmBC,GACvB,OAAiB,IAAVA,EAAgBV,KAAKC,EAC9B,aAtBM,SAAqBK,GACzB,MAAMK,EAAMb,EAEZ,OADAA,EAAUQ,EACHK,CACT,GCmBO,IAAIC,EAAmCC,aAOxC,SAAUC,EAAeC,GAC7B,MAAMC,EAAUJ,EAEhB,OADAA,EAAUG,EACHC,CACT,CA6BM,SAAUC,EAAOC,EAAI,EAAGC,EAAI,GAChC,MAAMC,EAAM,IAAIR,EAAQ,GAOxB,YANUS,IAANH,IACFE,EAAI,GAAKF,OACCG,IAANF,IACFC,EAAI,GAAKD,IAGNC,CACT,CCjDO,IAAIR,EAAmCC,aAOxC,SAAUC,EAAeC,GAC7B,MAAMC,EAAUJ,EAEhB,OADAA,EAAUG,EACHC,CACT,UASgBC,EAAOC,EAAYC,EAAYG,GAC7C,MAAMF,EAAM,IAAIR,EAAQ,GAUxB,YATUS,IAANH,IACFE,EAAI,GAAKF,OACCG,IAANF,IACFC,EAAI,GAAKD,OACCE,IAANC,IACFF,EAAI,GA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OZ,OALAc,EAAI,GAAKjB,EAAE,GAAKe,EAAIf,EAAE,GAAKgB,EAAIhB,EAAG,GAAKmB,EAAInB,EAAE,IAAMgH,EACnD/F,EAAI,GAAKjB,EAAE,GAAKe,EAAIf,EAAE,GAAKgB,EAAIhB,EAAG,GAAKmB,EAAInB,EAAE,IAAMgH,EACnD/F,EAAI,GAAKjB,EAAE,GAAKe,EAAIf,EAAE,GAAKgB,EAAIhB,EAAE,IAAMmB,EAAInB,EAAE,IAAMgH,EACnD/F,EAAI,GAAKjB,EAAE,GAAKe,EAAIf,EAAE,GAAKgB,EAAIhB,EAAE,IAAMmB,EAAInB,EAAE,IAAMgH,EAE5C/F,CACT,oBAuByBhB,EAASgE,EAAgBhD,GAGhD,OAFAA,EAAMA,GAAO,IAAIR,GAAQ,GAErBiB,GAAOzB,GAAKgE,EACPzB,GAAUvC,EAAGgE,EAAQhD,GAGvBoB,GAAKpC,EAAGgB,EACjB,OAhEM,SAAeA,GAQnB,OAPAA,EAAMA,GAAO,IAAIR,GAAQ,IAErB,GAAK,EACTQ,EAAI,GAAK,EACTA,EAAI,GAAK,EACTA,EAAI,GAAK,EAEFA,CACT,iDC9kBM,SAAyBL,GAC7BsR,EAAoBtR,GACpBuR,EAAoBvR,GACpBwR,GAAoBxR,GACpByR,EAAoBzR,GACpB0R,EAAoB1R,GACpB2R,GAAoB3R,EACtB"} \ No newline at end of file diff --git a/dist/2.x/wgpu-matrix.module.js b/dist/2.x/wgpu-matrix.module.js new file mode 100644 index 0000000..4b5d5c9 --- /dev/null +++ b/dist/2.x/wgpu-matrix.module.js @@ -0,0 +1,5758 @@ +/* wgpu-matrix@2.9.1, license MIT */ +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +let EPSILON = 0.000001; +/** + * Set the value for EPSILON for various checks + * @param v - Value to use for EPSILON. + * @returns previous value of EPSILON; + */ +function setEpsilon(v) { + const old = EPSILON; + EPSILON = v; + return old; +} +/** + * Convert degrees to radians + * @param degrees - Angle in degrees + * @returns angle converted to radians + */ +function degToRad(degrees) { + return degrees * Math.PI / 180; +} +/** + * Convert radians to degrees + * @param radians - Angle in radians + * @returns angle converted to degrees + */ +function radToDeg(radians) { + return radians * 180 / Math.PI; +} +/** + * Lerps between a and b via t + * @param a - starting value + * @param b - ending value + * @param t - value where 0 = a and 1 = b + * @returns a + (b - a) * t + */ +function lerp$4(a, b, t) { + return a + (b - a) * t; +} +/** + * Compute the opposite of lerp. Given a and b and a value between + * a and b returns a value between 0 and 1. 0 if a, 1 if b. + * Note: no clamping is done. + * @param a - start value + * @param b - end value + * @param v - value between a and b + * @returns (v - a) / (b - a) + */ +function inverseLerp(a, b, v) { + const d = b - a; + return (Math.abs(b - a) < EPSILON) + ? a + : (v - a) / d; +} +/** + * Compute the euclidean modulo + * + * ``` + * // table for n / 3 + * -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 <- n + * ------------------------------------ + * -2 -1 -0 -2 -1 0, 1, 2, 0, 1, 2 <- n % 3 + * 1 2 0 1 2 0, 1, 2, 0, 1, 2 <- euclideanModule(n, 3) + * ``` + * + * @param n - dividend + * @param m - divisor + * @returns the euclidean modulo of n / m + */ +function euclideanModulo(n, m) { + return ((n % m) + m) % m; +} + +var utils = { + __proto__: null, + get EPSILON () { return EPSILON; }, + degToRad: degToRad, + euclideanModulo: euclideanModulo, + inverseLerp: inverseLerp, + lerp: lerp$4, + radToDeg: radToDeg, + setEpsilon: setEpsilon +}; + +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * + * Vec2 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new Vec2. In other words you can do this + * + * const v = vec2.cross(v1, v2); // Creates a new Vec2 with the cross product of v1 x v2. + * + * or + * + * const v = vec2.create(); + * vec2.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec2.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +let VecType$2 = Float32Array; +/** + * Sets the type this library creates for a Vec2 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec2 + */ +function setDefaultType$6(ctor) { + const oldType = VecType$2; + VecType$2 = ctor; + return oldType; +} +/** + * Creates a Vec2; may be called with x, y, z to set initial values. + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Vec2's specified type + * it would be faster to use + * + * ``` + * const v = vec2.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Vec2Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `vec2.create` is usually used + * to create a Vec2 to be filled out as in + * + * ``` + * const sum = vec2.create(); + * vec2.add(v1, v2, sum); + * ``` + * + * @param x - Initial x value. + * @param y - Initial y value. + * @returns the created vector + */ +function create$5(x = 0, y = 0) { + const dst = new VecType$2(2); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + } + } + return dst; +} + +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * + * Vec3 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Vec3`. In other words you can do this + * + * const v = vec3.cross(v1, v2); // Creates a new Vec3 with the cross product of v1 x v2. + * + * or + * + * const v = vec3.create(); + * vec3.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec3.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +let VecType$1 = Float32Array; +/** + * Sets the type this library creates for a Vec3 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec3 + */ +function setDefaultType$5(ctor) { + const oldType = VecType$1; + VecType$1 = ctor; + return oldType; +} +/** + * Creates a vec3; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @returns the created vector + */ +function create$4(x, y, z) { + const dst = new VecType$1(3); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + if (z !== undefined) { + dst[2] = z; + } + } + } + return dst; +} + +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * Creates a Vec2; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @returns the created vector + */ +const fromValues$3 = create$5; +/** + * Sets the values of a Vec2 + * Also see {@link vec2.create} and {@link vec2.copy} + * + * @param x first value + * @param y second value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +function set$5(x, y, dst) { + dst = dst || new VecType$2(2); + dst[0] = x; + dst[1] = y; + return dst; +} +/** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ +function ceil$2(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.ceil(v[0]); + dst[1] = Math.ceil(v[1]); + return dst; +} +/** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ +function floor$2(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.floor(v[0]); + dst[1] = Math.floor(v[1]); + return dst; +} +/** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ +function round$2(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.round(v[0]); + dst[1] = Math.round(v[1]); + return dst; +} +/** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ +function clamp$2(v, min = 0, max = 1, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.min(max, Math.max(min, v[0])); + dst[1] = Math.min(max, Math.max(min, v[1])); + return dst; +} +/** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ +function add$3(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + return dst; +} +/** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ +function addScaled$2(a, b, scale, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] + b[0] * scale; + dst[1] = a[1] + b[1] * scale; + return dst; +} +/** + * Returns the angle in radians between two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns The angle in radians between the 2 vectors. + */ +function angle$2(a, b) { + const ax = a[0]; + const ay = a[1]; + const bx = b[0]; + const by = b[1]; + const mag1 = Math.sqrt(ax * ax + ay * ay); + const mag2 = Math.sqrt(bx * bx + by * by); + const mag = mag1 * mag2; + const cosine = mag && dot$3(a, b) / mag; + return Math.acos(cosine); +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +function subtract$3(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + return dst; +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +const sub$3 = subtract$3; +/** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ +function equalsApproximately$5(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON; +} +/** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ +function equals$5(a, b) { + return a[0] === b[0] && a[1] === b[1]; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +function lerp$3(a, b, t, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + return dst; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ +function lerpV$2(a, b, t, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] + t[0] * (b[0] - a[0]); + dst[1] = a[1] + t[1] * (b[1] - a[1]); + return dst; +} +/** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ +function max$2(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.max(a[0], b[0]); + dst[1] = Math.max(a[1], b[1]); + return dst; +} +/** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ +function min$2(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = Math.min(a[0], b[0]); + dst[1] = Math.min(a[1], b[1]); + return dst; +} +/** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +function mulScalar$3(v, k, dst) { + dst = dst || new VecType$2(2); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + return dst; +} +/** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +const scale$5 = mulScalar$3; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +function divScalar$3(v, k, dst) { + dst = dst || new VecType$2(2); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + return dst; +} +/** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +function inverse$5(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = 1 / v[0]; + dst[1] = 1 / v[1]; + return dst; +} +/** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +const invert$4 = inverse$5; +/** + * Computes the cross product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of a cross b. + */ +function cross$1(a, b, dst) { + dst = dst || new VecType$1(3); + const z = a[0] * b[1] - a[1] * b[0]; + dst[0] = 0; + dst[1] = 0; + dst[2] = z; + return dst; +} +/** + * Computes the dot product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ +function dot$3(a, b) { + return a[0] * b[0] + a[1] * b[1]; +} +/** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ +function length$3(v) { + const v0 = v[0]; + const v1 = v[1]; + return Math.sqrt(v0 * v0 + v1 * v1); +} +/** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ +const len$3 = length$3; +/** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ +function lengthSq$3(v) { + const v0 = v[0]; + const v1 = v[1]; + return v0 * v0 + v1 * v1; +} +/** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ +const lenSq$3 = lengthSq$3; +/** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +function distance$2(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + return Math.sqrt(dx * dx + dy * dy); +} +/** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +const dist$2 = distance$2; +/** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +function distanceSq$2(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + return dx * dx + dy * dy; +} +/** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +const distSq$2 = distanceSq$2; +/** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ +function normalize$3(v, dst) { + dst = dst || new VecType$2(2); + const v0 = v[0]; + const v1 = v[1]; + const len = Math.sqrt(v0 * v0 + v1 * v1); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + } + return dst; +} +/** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ +function negate$4(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = -v[0]; + dst[1] = -v[1]; + return dst; +} +/** + * Copies a vector. (same as {@link vec2.clone}) + * Also see {@link vec2.create} and {@link vec2.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +function copy$5(v, dst) { + dst = dst || new VecType$2(2); + dst[0] = v[0]; + dst[1] = v[1]; + return dst; +} +/** + * Clones a vector. (same as {@link vec2.copy}) + * Also see {@link vec2.create} and {@link vec2.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +const clone$5 = copy$5; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +function multiply$5(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + return dst; +} +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +const mul$5 = multiply$5; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +function divide$2(a, b, dst) { + dst = dst || new VecType$2(2); + dst[0] = a[0] / b[0]; + dst[1] = a[1] / b[1]; + return dst; +} +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +const div$2 = divide$2; +/** + * Creates a random unit vector * scale + * @param scale - Default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The random vector. + */ +function random$1(scale = 1, dst) { + dst = dst || new VecType$2(2); + const angle = Math.random() * 2 * Math.PI; + dst[0] = Math.cos(angle) * scale; + dst[1] = Math.sin(angle) * scale; + return dst; +} +/** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ +function zero$2(dst) { + dst = dst || new VecType$2(2); + dst[0] = 0; + dst[1] = 0; + return dst; +} +/** + * transform Vec2 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional Vec2 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +function transformMat4$2(v, m, dst) { + dst = dst || new VecType$2(2); + const x = v[0]; + const y = v[1]; + dst[0] = x * m[0] + y * m[4] + m[12]; + dst[1] = x * m[1] + y * m[5] + m[13]; + return dst; +} +/** + * Transforms vec4 by 3x3 matrix + * + * @param v - the vector + * @param m - The matrix. + * @param dst - optional Vec2 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +function transformMat3$1(v, m, dst) { + dst = dst || new VecType$2(2); + const x = v[0]; + const y = v[1]; + dst[0] = m[0] * x + m[4] * y + m[8]; + dst[1] = m[1] * x + m[5] * y + m[9]; + return dst; +} +/** + * Rotate a 2D vector + * + * @param a The vec2 point to rotate + * @param b The origin of the rotation + * @param rad The angle of rotation in radians + * @returns the rotated vector + */ +function rotate$2(a, b, rad, dst) { + dst = dst || new VecType$2(2); + // Translate point to the origin + const p0 = a[0] - b[0]; + const p1 = a[1] - b[1]; + const sinC = Math.sin(rad); + const cosC = Math.cos(rad); + //perform rotation and translate to correct position + dst[0] = p0 * cosC - p1 * sinC + b[0]; + dst[1] = p0 * sinC + p1 * cosC + b[1]; + return dst; +} +/** + * Treat a 2D vector as a direction and set it's length + * + * @param a The vec2 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ +function setLength$2(a, len, dst) { + dst = dst || new VecType$2(2); + normalize$3(a, dst); + return mulScalar$3(dst, len, dst); +} +/** + * Ensure a vector is not longer than a max length + * + * @param a The vec2 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ +function truncate$2(a, maxLen, dst) { + dst = dst || new VecType$2(2); + if (length$3(a) > maxLen) { + return setLength$2(a, maxLen, dst); + } + return copy$5(a, dst); +} +/** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ +function midpoint$2(a, b, dst) { + dst = dst || new VecType$2(2); + return lerp$3(a, b, 0.5, dst); +} + +var vec2Impl = { + __proto__: null, + add: add$3, + addScaled: addScaled$2, + angle: angle$2, + ceil: ceil$2, + clamp: clamp$2, + clone: clone$5, + copy: copy$5, + create: create$5, + cross: cross$1, + dist: dist$2, + distSq: distSq$2, + distance: distance$2, + distanceSq: distanceSq$2, + div: div$2, + divScalar: divScalar$3, + divide: divide$2, + dot: dot$3, + equals: equals$5, + equalsApproximately: equalsApproximately$5, + floor: floor$2, + fromValues: fromValues$3, + inverse: inverse$5, + invert: invert$4, + len: len$3, + lenSq: lenSq$3, + length: length$3, + lengthSq: lengthSq$3, + lerp: lerp$3, + lerpV: lerpV$2, + max: max$2, + midpoint: midpoint$2, + min: min$2, + mul: mul$5, + mulScalar: mulScalar$3, + multiply: multiply$5, + negate: negate$4, + normalize: normalize$3, + random: random$1, + rotate: rotate$2, + round: round$2, + scale: scale$5, + set: set$5, + setDefaultType: setDefaultType$6, + setLength: setLength$2, + sub: sub$3, + subtract: subtract$3, + transformMat3: transformMat3$1, + transformMat4: transformMat4$2, + truncate: truncate$2, + zero: zero$2 +}; + +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * 3x3 Matrix math math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new matrix. In other words you can do this + * + * const mat = mat3.translation([1, 2, 3]); // Creates a new translation matrix + * + * or + * + * const mat = mat3.create(); + * mat3.translation([1, 2, 3], mat); // Puts translation matrix in mat. + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always save to pass any matrix as the destination. So for example + * + * const mat = mat3.identity(); + * const trans = mat3.translation([1, 2, 3]); + * mat3.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat. + * + */ +let MatType$1 = Float32Array; +// This mess is because with Mat3 we have 3 unused elements. +// For Float32Array and Float64Array that's not an issue +// but for Array it's troublesome +const ctorMap = new Map([ + [Float32Array, () => new Float32Array(12)], + [Float64Array, () => new Float64Array(12)], + [Array, () => new Array(12).fill(0)], +]); +let newMat3 = ctorMap.get(Float32Array); +/** + * Sets the type this library creates for a Mat3 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Mat3 + */ +function setDefaultType$4(ctor) { + const oldType = MatType$1; + MatType$1 = ctor; + newMat3 = ctorMap.get(ctor); + return oldType; +} +/** + * Create a Mat3 from values + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Mat3's specified type + * it would be faster to use + * + * ``` + * const m = mat3.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Mat3Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `mat3.create` is usually used + * to create a Mat3 to be filled out as in + * + * ``` + * const m = mat3.create(); + * mat3.perspective(fov, aspect, near, far, m); + * ``` + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @returns matrix created from values. + */ +function create$3(v0, v1, v2, v3, v4, v5, v6, v7, v8) { + const dst = newMat3(); + // to make the array homogenous + dst[3] = 0; + dst[7] = 0; + dst[11] = 0; + if (v0 !== undefined) { + dst[0] = v0; + if (v1 !== undefined) { + dst[1] = v1; + if (v2 !== undefined) { + dst[2] = v2; + if (v3 !== undefined) { + dst[4] = v3; + if (v4 !== undefined) { + dst[5] = v4; + if (v5 !== undefined) { + dst[6] = v5; + if (v6 !== undefined) { + dst[8] = v6; + if (v7 !== undefined) { + dst[9] = v7; + if (v8 !== undefined) { + dst[10] = v8; + } + } + } + } + } + } + } + } + } + return dst; +} +/** + * Sets the values of a Mat3 + * Also see {@link mat3.create} and {@link mat3.copy} + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 set from values. + */ +function set$4(v0, v1, v2, v3, v4, v5, v6, v7, v8, dst) { + dst = dst || newMat3(); + dst[0] = v0; + dst[1] = v1; + dst[2] = v2; + dst[3] = 0; + dst[4] = v3; + dst[5] = v4; + dst[6] = v5; + dst[7] = 0; + dst[8] = v6; + dst[9] = v7; + dst[10] = v8; + dst[11] = 0; + return dst; +} +/** + * Creates a Mat3 from the upper left 3x3 part of a Mat4 + * @param m4 - source matrix + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 made from m4 + */ +function fromMat4(m4, dst) { + dst = dst || newMat3(); + dst[0] = m4[0]; + dst[1] = m4[1]; + dst[2] = m4[2]; + dst[3] = 0; + dst[4] = m4[4]; + dst[5] = m4[5]; + dst[6] = m4[6]; + dst[7] = 0; + dst[8] = m4[8]; + dst[9] = m4[9]; + dst[10] = m4[10]; + dst[11] = 0; + return dst; +} +/** + * Creates a Mat3 rotation matrix from a quaternion + * @param q - quaternion to create matrix from + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat3 made from q + */ +function fromQuat$1(q, dst) { + dst = dst || newMat3(); + const x = q[0]; + const y = q[1]; + const z = q[2]; + const w = q[3]; + const x2 = x + x; + const y2 = y + y; + const z2 = z + z; + const xx = x * x2; + const yx = y * x2; + const yy = y * y2; + const zx = z * x2; + const zy = z * y2; + const zz = z * z2; + const wx = w * x2; + const wy = w * y2; + const wz = w * z2; + dst[0] = 1 - yy - zz; + dst[1] = yx + wz; + dst[2] = zx - wy; + dst[3] = 0; + dst[4] = yx - wz; + dst[5] = 1 - xx - zz; + dst[6] = zy + wx; + dst[7] = 0; + dst[8] = zx + wy; + dst[9] = zy - wx; + dst[10] = 1 - xx - yy; + dst[11] = 0; + return dst; +} +/** + * Negates a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns -m. + */ +function negate$3(m, dst) { + dst = dst || newMat3(); + dst[0] = -m[0]; + dst[1] = -m[1]; + dst[2] = -m[2]; + dst[4] = -m[4]; + dst[5] = -m[5]; + dst[6] = -m[6]; + dst[8] = -m[8]; + dst[9] = -m[9]; + dst[10] = -m[10]; + return dst; +} +/** + * Copies a matrix. (same as {@link mat3.clone}) + * Also see {@link mat3.create} and {@link mat3.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +function copy$4(m, dst) { + dst = dst || newMat3(); + dst[0] = m[0]; + dst[1] = m[1]; + dst[2] = m[2]; + dst[4] = m[4]; + dst[5] = m[5]; + dst[6] = m[6]; + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + return dst; +} +/** + * Copies a matrix (same as {@link mat3.copy}) + * Also see {@link mat3.create} and {@link mat3.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +const clone$4 = copy$4; +/** + * Check if 2 matrices are approximately equal + * @param a Operand matrix. + * @param b Operand matrix. + * @returns true if matrices are approximately equal + */ +function equalsApproximately$4(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON && + Math.abs(a[4] - b[4]) < EPSILON && + Math.abs(a[5] - b[5]) < EPSILON && + Math.abs(a[6] - b[6]) < EPSILON && + Math.abs(a[8] - b[8]) < EPSILON && + Math.abs(a[9] - b[9]) < EPSILON && + Math.abs(a[10] - b[10]) < EPSILON; +} +/** + * Check if 2 matrices are exactly equal + * @param a Operand matrix. + * @param b Operand matrix. + * @returns true if matrices are exactly equal + */ +function equals$4(a, b) { + return a[0] === b[0] && + a[1] === b[1] && + a[2] === b[2] && + a[4] === b[4] && + a[5] === b[5] && + a[6] === b[6] && + a[8] === b[8] && + a[9] === b[9] && + a[10] === b[10]; +} +/** + * Creates a 3-by-3 identity matrix. + * + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A 3-by-3 identity matrix. + */ +function identity$2(dst) { + dst = dst || newMat3(); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; +} +/** + * Takes the transpose of a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The transpose of m. + */ +function transpose$1(m, dst) { + dst = dst || newMat3(); + if (dst === m) { + let t; + // 0 1 2 + // 4 5 6 + // 8 9 10 + t = m[1]; + m[1] = m[4]; + m[4] = t; + t = m[2]; + m[2] = m[8]; + m[8] = t; + t = m[6]; + m[6] = m[9]; + m[9] = t; + return dst; + } + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + dst[0] = m00; + dst[1] = m10; + dst[2] = m20; + dst[4] = m01; + dst[5] = m11; + dst[6] = m21; + dst[8] = m02; + dst[9] = m12; + dst[10] = m22; + return dst; +} +/** + * Computes the inverse of a 3-by-3 matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +function inverse$4(m, dst) { + dst = dst || newMat3(); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const b01 = m22 * m11 - m12 * m21; + const b11 = -m22 * m10 + m12 * m20; + const b21 = m21 * m10 - m11 * m20; + const invDet = 1 / (m00 * b01 + m01 * b11 + m02 * b21); + dst[0] = b01 * invDet; + dst[1] = (-m22 * m01 + m02 * m21) * invDet; + dst[2] = (m12 * m01 - m02 * m11) * invDet; + dst[4] = b11 * invDet; + dst[5] = (m22 * m00 - m02 * m20) * invDet; + dst[6] = (-m12 * m00 + m02 * m10) * invDet; + dst[8] = b21 * invDet; + dst[9] = (-m21 * m00 + m01 * m20) * invDet; + dst[10] = (m11 * m00 - m01 * m10) * invDet; + return dst; +} +/** + * Compute the determinant of a matrix + * @param m - the matrix + * @returns the determinant + */ +function determinant$1(m) { + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + return m00 * (m11 * m22 - m21 * m12) - + m10 * (m01 * m22 - m21 * m02) + + m20 * (m01 * m12 - m11 * m02); +} +/** + * Computes the inverse of a 3-by-3 matrix. (same as inverse) + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +const invert$3 = inverse$4; +/** + * Multiplies two 3-by-3 matrices with a on the left and b on the right + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +function multiply$4(a, b, dst) { + dst = dst || newMat3(); + const a00 = a[0]; + const a01 = a[1]; + const a02 = a[2]; + const a10 = a[4 + 0]; + const a11 = a[4 + 1]; + const a12 = a[4 + 2]; + const a20 = a[8 + 0]; + const a21 = a[8 + 1]; + const a22 = a[8 + 2]; + const b00 = b[0]; + const b01 = b[1]; + const b02 = b[2]; + const b10 = b[4 + 0]; + const b11 = b[4 + 1]; + const b12 = b[4 + 2]; + const b20 = b[8 + 0]; + const b21 = b[8 + 1]; + const b22 = b[8 + 2]; + dst[0] = a00 * b00 + a10 * b01 + a20 * b02; + dst[1] = a01 * b00 + a11 * b01 + a21 * b02; + dst[2] = a02 * b00 + a12 * b01 + a22 * b02; + dst[4] = a00 * b10 + a10 * b11 + a20 * b12; + dst[5] = a01 * b10 + a11 * b11 + a21 * b12; + dst[6] = a02 * b10 + a12 * b11 + a22 * b12; + dst[8] = a00 * b20 + a10 * b21 + a20 * b22; + dst[9] = a01 * b20 + a11 * b21 + a21 * b22; + dst[10] = a02 * b20 + a12 * b21 + a22 * b22; + return dst; +} +/** + * Multiplies two 3-by-3 matrices with a on the left and b on the right (same as multiply) + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +const mul$4 = multiply$4; +/** + * Sets the translation component of a 3-by-3 matrix to the given + * vector. + * @param a - The matrix. + * @param v - The vector. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix with translation set. + */ +function setTranslation$1(a, v, dst) { + dst = dst || identity$2(); + if (a !== dst) { + dst[0] = a[0]; + dst[1] = a[1]; + dst[2] = a[2]; + dst[4] = a[4]; + dst[5] = a[5]; + dst[6] = a[6]; + } + dst[8] = v[0]; + dst[9] = v[1]; + dst[10] = 1; + return dst; +} +/** + * Returns the translation component of a 3-by-3 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ +function getTranslation$2(m, dst) { + dst = dst || create$5(); + dst[0] = m[8]; + dst[1] = m[9]; + return dst; +} +/** + * Returns an axis of a 3x3 matrix as a vector with 2 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, + * @returns The axis component of m. + */ +function getAxis$2(m, axis, dst) { + dst = dst || create$5(); + const off = axis * 4; + dst[0] = m[off + 0]; + dst[1] = m[off + 1]; + return dst; +} +/** + * Sets an axis of a 3x3 matrix as a vector with 2 entries + * @param m - The matrix. + * @param v - the axis vector + * @param axis - The axis 0 = x, 1 = y; + * @param dst - The matrix to set. If not passed a new one is created. + * @returns The matrix with axis set. + */ +function setAxis$1(m, v, axis, dst) { + if (dst !== m) { + dst = copy$4(m, dst); + } + const off = axis * 4; + dst[off + 0] = v[0]; + dst[off + 1] = v[1]; + return dst; +} +/** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ +function getScaling$2(m, dst) { + dst = dst || create$5(); + const xx = m[0]; + const xy = m[1]; + const yx = m[4]; + const yy = m[5]; + dst[0] = Math.sqrt(xx * xx + xy * xy); + dst[1] = Math.sqrt(yx * yx + yy * yy); + return dst; +} +/** + * Creates a 3-by-3 matrix which translates by the given vector v. + * @param v - The vector by which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translation matrix. + */ +function translation$1(v, dst) { + dst = dst || newMat3(); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[8] = v[0]; + dst[9] = v[1]; + dst[10] = 1; + return dst; +} +/** + * Translates the given 3-by-3 matrix by the given vector v. + * @param m - The matrix. + * @param v - The vector by which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translated matrix. + */ +function translate$1(m, v, dst) { + dst = dst || newMat3(); + const v0 = v[0]; + const v1 = v[1]; + const m00 = m[0]; + const m01 = m[1]; + const m02 = m[2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + if (m !== dst) { + dst[0] = m00; + dst[1] = m01; + dst[2] = m02; + dst[4] = m10; + dst[5] = m11; + dst[6] = m12; + } + dst[8] = m00 * v0 + m10 * v1 + m20; + dst[9] = m01 * v0 + m11 * v1 + m21; + dst[10] = m02 * v0 + m12 * v1 + m22; + return dst; +} +/** + * Creates a 3-by-3 matrix which rotates by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +function rotation$1(angleInRadians, dst) { + dst = dst || newMat3(); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c; + dst[1] = s; + dst[2] = 0; + dst[4] = -s; + dst[5] = c; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; +} +/** + * Rotates the given 3-by-3 matrix by the given angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +function rotate$1(m, angleInRadians, dst) { + dst = dst || newMat3(); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c * m00 + s * m10; + dst[1] = c * m01 + s * m11; + dst[2] = c * m02 + s * m12; + dst[4] = c * m10 - s * m00; + dst[5] = c * m11 - s * m01; + dst[6] = c * m12 - s * m02; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + } + return dst; +} +/** + * Creates a 3-by-3 matrix which scales in each dimension by an amount given by + * the corresponding entry in the given vector; assumes the vector has three + * entries. + * @param v - A vector of + * 2 entries specifying the factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +function scaling$1(v, dst) { + dst = dst || newMat3(); + dst[0] = v[0]; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = v[1]; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; +} +/** + * Scales the given 3-by-3 matrix in each dimension by an amount + * given by the corresponding entry in the given vector; assumes the vector has + * three entries. + * @param m - The matrix to be modified. + * @param v - A vector of 2 entries specifying the + * factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +function scale$4(m, v, dst) { + dst = dst || newMat3(); + const v0 = v[0]; + const v1 = v[1]; + dst[0] = v0 * m[0 * 4 + 0]; + dst[1] = v0 * m[0 * 4 + 1]; + dst[2] = v0 * m[0 * 4 + 2]; + dst[4] = v1 * m[1 * 4 + 0]; + dst[5] = v1 * m[1 * 4 + 1]; + dst[6] = v1 * m[1 * 4 + 2]; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + } + return dst; +} +/** + * Creates a 3-by-3 matrix which scales uniformly in each dimension + * @param s - Amount to scale + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +function uniformScaling$1(s, dst) { + dst = dst || newMat3(); + dst[0] = s; + dst[1] = 0; + dst[2] = 0; + dst[4] = 0; + dst[5] = s; + dst[6] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + return dst; +} +/** + * Scales the given 3-by-3 matrix in each dimension by an amount + * given. + * @param m - The matrix to be modified. + * @param s - Amount to scale. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +function uniformScale$1(m, s, dst) { + dst = dst || newMat3(); + dst[0] = s * m[0 * 4 + 0]; + dst[1] = s * m[0 * 4 + 1]; + dst[2] = s * m[0 * 4 + 2]; + dst[4] = s * m[1 * 4 + 0]; + dst[5] = s * m[1 * 4 + 1]; + dst[6] = s * m[1 * 4 + 2]; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + } + return dst; +} + +var mat3Impl = { + __proto__: null, + clone: clone$4, + copy: copy$4, + create: create$3, + determinant: determinant$1, + equals: equals$4, + equalsApproximately: equalsApproximately$4, + fromMat4: fromMat4, + fromQuat: fromQuat$1, + getAxis: getAxis$2, + getScaling: getScaling$2, + getTranslation: getTranslation$2, + identity: identity$2, + inverse: inverse$4, + invert: invert$3, + mul: mul$4, + multiply: multiply$4, + negate: negate$3, + rotate: rotate$1, + rotation: rotation$1, + scale: scale$4, + scaling: scaling$1, + set: set$4, + setAxis: setAxis$1, + setDefaultType: setDefaultType$4, + setTranslation: setTranslation$1, + translate: translate$1, + translation: translation$1, + transpose: transpose$1, + uniformScale: uniformScale$1, + uniformScaling: uniformScaling$1 +}; + +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * Creates a vec3; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @returns the created vector + */ +const fromValues$2 = create$4; +/** + * Sets the values of a Vec3 + * Also see {@link vec3.create} and {@link vec3.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +function set$3(x, y, z, dst) { + dst = dst || new VecType$1(3); + dst[0] = x; + dst[1] = y; + dst[2] = z; + return dst; +} +/** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ +function ceil$1(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.ceil(v[0]); + dst[1] = Math.ceil(v[1]); + dst[2] = Math.ceil(v[2]); + return dst; +} +/** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ +function floor$1(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.floor(v[0]); + dst[1] = Math.floor(v[1]); + dst[2] = Math.floor(v[2]); + return dst; +} +/** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ +function round$1(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.round(v[0]); + dst[1] = Math.round(v[1]); + dst[2] = Math.round(v[2]); + return dst; +} +/** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ +function clamp$1(v, min = 0, max = 1, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.min(max, Math.max(min, v[0])); + dst[1] = Math.min(max, Math.max(min, v[1])); + dst[2] = Math.min(max, Math.max(min, v[2])); + return dst; +} +/** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ +function add$2(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + dst[2] = a[2] + b[2]; + return dst; +} +/** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ +function addScaled$1(a, b, scale, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] + b[0] * scale; + dst[1] = a[1] + b[1] * scale; + dst[2] = a[2] + b[2] * scale; + return dst; +} +/** + * Returns the angle in radians between two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns The angle in radians between the 2 vectors. + */ +function angle$1(a, b) { + const ax = a[0]; + const ay = a[1]; + const az = a[2]; + const bx = b[0]; + const by = b[1]; + const bz = b[2]; + const mag1 = Math.sqrt(ax * ax + ay * ay + az * az); + const mag2 = Math.sqrt(bx * bx + by * by + bz * bz); + const mag = mag1 * mag2; + const cosine = mag && dot$2(a, b) / mag; + return Math.acos(cosine); +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +function subtract$2(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + dst[2] = a[2] - b[2]; + return dst; +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +const sub$2 = subtract$2; +/** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ +function equalsApproximately$3(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON; +} +/** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ +function equals$3(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +function lerp$2(a, b, t, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + dst[2] = a[2] + t * (b[2] - a[2]); + return dst; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ +function lerpV$1(a, b, t, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] + t[0] * (b[0] - a[0]); + dst[1] = a[1] + t[1] * (b[1] - a[1]); + dst[2] = a[2] + t[2] * (b[2] - a[2]); + return dst; +} +/** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ +function max$1(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.max(a[0], b[0]); + dst[1] = Math.max(a[1], b[1]); + dst[2] = Math.max(a[2], b[2]); + return dst; +} +/** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ +function min$1(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = Math.min(a[0], b[0]); + dst[1] = Math.min(a[1], b[1]); + dst[2] = Math.min(a[2], b[2]); + return dst; +} +/** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +function mulScalar$2(v, k, dst) { + dst = dst || new VecType$1(3); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + dst[2] = v[2] * k; + return dst; +} +/** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +const scale$3 = mulScalar$2; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +function divScalar$2(v, k, dst) { + dst = dst || new VecType$1(3); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + dst[2] = v[2] / k; + return dst; +} +/** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +function inverse$3(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = 1 / v[0]; + dst[1] = 1 / v[1]; + dst[2] = 1 / v[2]; + return dst; +} +/** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +const invert$2 = inverse$3; +/** + * Computes the cross product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of a cross b. + */ +function cross(a, b, dst) { + dst = dst || new VecType$1(3); + const t1 = a[2] * b[0] - a[0] * b[2]; + const t2 = a[0] * b[1] - a[1] * b[0]; + dst[0] = a[1] * b[2] - a[2] * b[1]; + dst[1] = t1; + dst[2] = t2; + return dst; +} +/** + * Computes the dot product of two vectors; assumes both vectors have + * three entries. + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ +function dot$2(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]); +} +/** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ +function length$2(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2); +} +/** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ +const len$2 = length$2; +/** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ +function lengthSq$2(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + return v0 * v0 + v1 * v1 + v2 * v2; +} +/** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ +const lenSq$2 = lengthSq$2; +/** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +function distance$1(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + return Math.sqrt(dx * dx + dy * dy + dz * dz); +} +/** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +const dist$1 = distance$1; +/** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +function distanceSq$1(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + return dx * dx + dy * dy + dz * dz; +} +/** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +const distSq$1 = distanceSq$1; +/** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ +function normalize$2(v, dst) { + dst = dst || new VecType$1(3); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + dst[2] = v2 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + } + return dst; +} +/** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ +function negate$2(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = -v[0]; + dst[1] = -v[1]; + dst[2] = -v[2]; + return dst; +} +/** + * Copies a vector. (same as {@link vec3.clone}) + * Also see {@link vec3.create} and {@link vec3.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +function copy$3(v, dst) { + dst = dst || new VecType$1(3); + dst[0] = v[0]; + dst[1] = v[1]; + dst[2] = v[2]; + return dst; +} +/** + * Clones a vector. (same as {@link vec3.copy}) + * Also see {@link vec3.create} and {@link vec3.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +const clone$3 = copy$3; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +function multiply$3(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + dst[2] = a[2] * b[2]; + return dst; +} +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +const mul$3 = multiply$3; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +function divide$1(a, b, dst) { + dst = dst || new VecType$1(3); + dst[0] = a[0] / b[0]; + dst[1] = a[1] / b[1]; + dst[2] = a[2] / b[2]; + return dst; +} +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +const div$1 = divide$1; +/** + * Creates a random vector + * @param scale - Default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The random vector. + */ +function random(scale = 1, dst) { + dst = dst || new VecType$1(3); + const angle = Math.random() * 2 * Math.PI; + const z = Math.random() * 2 - 1; + const zScale = Math.sqrt(1 - z * z) * scale; + dst[0] = Math.cos(angle) * zScale; + dst[1] = Math.sin(angle) * zScale; + dst[2] = z * scale; + return dst; +} +/** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ +function zero$1(dst) { + dst = dst || new VecType$1(3); + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + return dst; +} +/** + * transform vec3 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +function transformMat4$1(v, m, dst) { + dst = dst || new VecType$1(3); + const x = v[0]; + const y = v[1]; + const z = v[2]; + const w = (m[3] * x + m[7] * y + m[11] * z + m[15]) || 1; + dst[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; + dst[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; + dst[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; + return dst; +} +/** + * Transform vec4 by upper 3x3 matrix inside 4x4 matrix. + * @param v - The direction. + * @param m - The matrix. + * @param dst - optional Vec3 to store result. If not passed a new one is created. + * @returns The transformed vector. + */ +function transformMat4Upper3x3(v, m, dst) { + dst = dst || new VecType$1(3); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0]; + dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1]; + dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v2 * m[2 * 4 + 2]; + return dst; +} +/** + * Transforms vec3 by 3x3 matrix + * + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +function transformMat3(v, m, dst) { + dst = dst || new VecType$1(3); + const x = v[0]; + const y = v[1]; + const z = v[2]; + dst[0] = x * m[0] + y * m[4] + z * m[8]; + dst[1] = x * m[1] + y * m[5] + z * m[9]; + dst[2] = x * m[2] + y * m[6] + z * m[10]; + return dst; +} +/** + * Transforms vec3 by Quaternion + * @param v - the vector to transform + * @param q - the quaternion to transform by + * @param dst - optional vec3 to store result. If not passed a new one is created. + * @returns the transformed + */ +function transformQuat(v, q, dst) { + dst = dst || new VecType$1(3); + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const w2 = q[3] * 2; + const x = v[0]; + const y = v[1]; + const z = v[2]; + const uvX = qy * z - qz * y; + const uvY = qz * x - qx * z; + const uvZ = qx * y - qy * x; + dst[0] = x + uvX * w2 + (qy * uvZ - qz * uvY) * 2; + dst[1] = y + uvY * w2 + (qz * uvX - qx * uvZ) * 2; + dst[2] = z + uvZ * w2 + (qx * uvY - qy * uvX) * 2; + return dst; +} +/** + * Returns the translation component of a 4-by-4 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ +function getTranslation$1(m, dst) { + dst = dst || new VecType$1(3); + dst[0] = m[12]; + dst[1] = m[13]; + dst[2] = m[14]; + return dst; +} +/** + * Returns an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @returns The axis component of m. + */ +function getAxis$1(m, axis, dst) { + dst = dst || new VecType$1(3); + const off = axis * 4; + dst[0] = m[off + 0]; + dst[1] = m[off + 1]; + dst[2] = m[off + 2]; + return dst; +} +/** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ +function getScaling$1(m, dst) { + dst = dst || new VecType$1(3); + const xx = m[0]; + const xy = m[1]; + const xz = m[2]; + const yx = m[4]; + const yy = m[5]; + const yz = m[6]; + const zx = m[8]; + const zy = m[9]; + const zz = m[10]; + dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz); + dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz); + dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz); + return dst; +} +/** + * Rotate a 3D vector around the x-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns the rotated vector + */ +function rotateX$2(a, b, rad, dst) { + dst = dst || new VecType$1(3); + const p = []; + const r = []; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + //perform rotation + r[0] = p[0]; + r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad); + r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); + //translate to correct position + dst[0] = r[0] + b[0]; + dst[1] = r[1] + b[1]; + dst[2] = r[2] + b[2]; + return dst; +} +/** + * Rotate a 3D vector around the y-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns the rotated vector + */ +function rotateY$2(a, b, rad, dst) { + dst = dst || new VecType$1(3); + const p = []; + const r = []; + // translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + // perform rotation + r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad); + r[1] = p[1]; + r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); + // translate to correct position + dst[0] = r[0] + b[0]; + dst[1] = r[1] + b[1]; + dst[2] = r[2] + b[2]; + return dst; +} +/** + * Rotate a 3D vector around the z-axis + * + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @param dst - The vector to set. If not passed a new one is created. + * @returns {vec3} out + */ +function rotateZ$2(a, b, rad, dst) { + dst = dst || new VecType$1(3); + const p = []; + const r = []; + // translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + // perform rotation + r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad); + r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad); + r[2] = p[2]; + // translate to correct position + dst[0] = r[0] + b[0]; + dst[1] = r[1] + b[1]; + dst[2] = r[2] + b[2]; + return dst; +} +/** + * Treat a 3D vector as a direction and set it's length + * + * @param a The vec3 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ +function setLength$1(a, len, dst) { + dst = dst || new VecType$1(3); + normalize$2(a, dst); + return mulScalar$2(dst, len, dst); +} +/** + * Ensure a vector is not longer than a max length + * + * @param a The vec3 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ +function truncate$1(a, maxLen, dst) { + dst = dst || new VecType$1(3); + if (length$2(a) > maxLen) { + return setLength$1(a, maxLen, dst); + } + return copy$3(a, dst); +} +/** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ +function midpoint$1(a, b, dst) { + dst = dst || new VecType$1(3); + return lerp$2(a, b, 0.5, dst); +} + +var vec3Impl = { + __proto__: null, + add: add$2, + addScaled: addScaled$1, + angle: angle$1, + ceil: ceil$1, + clamp: clamp$1, + clone: clone$3, + copy: copy$3, + create: create$4, + cross: cross, + dist: dist$1, + distSq: distSq$1, + distance: distance$1, + distanceSq: distanceSq$1, + div: div$1, + divScalar: divScalar$2, + divide: divide$1, + dot: dot$2, + equals: equals$3, + equalsApproximately: equalsApproximately$3, + floor: floor$1, + fromValues: fromValues$2, + getAxis: getAxis$1, + getScaling: getScaling$1, + getTranslation: getTranslation$1, + inverse: inverse$3, + invert: invert$2, + len: len$2, + lenSq: lenSq$2, + length: length$2, + lengthSq: lengthSq$2, + lerp: lerp$2, + lerpV: lerpV$1, + max: max$1, + midpoint: midpoint$1, + min: min$1, + mul: mul$3, + mulScalar: mulScalar$2, + multiply: multiply$3, + negate: negate$2, + normalize: normalize$2, + random: random, + rotateX: rotateX$2, + rotateY: rotateY$2, + rotateZ: rotateZ$2, + round: round$1, + scale: scale$3, + set: set$3, + setDefaultType: setDefaultType$5, + setLength: setLength$1, + sub: sub$2, + subtract: subtract$2, + transformMat3: transformMat3, + transformMat4: transformMat4$1, + transformMat4Upper3x3: transformMat4Upper3x3, + transformQuat: transformQuat, + truncate: truncate$1, + zero: zero$1 +}; + +/** + * 4x4 Matrix math math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new matrix. In other words you can do this + * + * const mat = mat4.translation([1, 2, 3]); // Creates a new translation matrix + * + * or + * + * const mat = mat4.create(); + * mat4.translation([1, 2, 3], mat); // Puts translation matrix in mat. + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always save to pass any matrix as the destination. So for example + * + * const mat = mat4.identity(); + * const trans = mat4.translation([1, 2, 3]); + * mat4.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat. + * + */ +let MatType = Float32Array; +/** + * Sets the type this library creates for a Mat4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Mat4 + */ +function setDefaultType$3(ctor) { + const oldType = MatType; + MatType = ctor; + return oldType; +} +/** + * Create a Mat4 from values + * + * Note: Since passing in a raw JavaScript array + * is valid in all circumstances, if you want to + * force a JavaScript array into a Mat4's specified type + * it would be faster to use + * + * ``` + * const m = mat4.clone(someJSArray); + * ``` + * + * Note: a consequence of the implementation is if your Mat4Type = `Array` + * instead of `Float32Array` or `Float64Array` then any values you + * don't pass in will be undefined. Usually this is not an issue since + * (a) using `Array` is rare and (b) using `mat4.create` is usually used + * to create a Mat4 to be filled out as in + * + * ``` + * const m = mat4.create(); + * mat4.perspective(fov, aspect, near, far, m); + * ``` + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param v9 - value for element 9 + * @param v10 - value for element 10 + * @param v11 - value for element 11 + * @param v12 - value for element 12 + * @param v13 - value for element 13 + * @param v14 - value for element 14 + * @param v15 - value for element 15 + * @returns created from values. + */ +function create$2(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) { + const dst = new MatType(16); + if (v0 !== undefined) { + dst[0] = v0; + if (v1 !== undefined) { + dst[1] = v1; + if (v2 !== undefined) { + dst[2] = v2; + if (v3 !== undefined) { + dst[3] = v3; + if (v4 !== undefined) { + dst[4] = v4; + if (v5 !== undefined) { + dst[5] = v5; + if (v6 !== undefined) { + dst[6] = v6; + if (v7 !== undefined) { + dst[7] = v7; + if (v8 !== undefined) { + dst[8] = v8; + if (v9 !== undefined) { + dst[9] = v9; + if (v10 !== undefined) { + dst[10] = v10; + if (v11 !== undefined) { + dst[11] = v11; + if (v12 !== undefined) { + dst[12] = v12; + if (v13 !== undefined) { + dst[13] = v13; + if (v14 !== undefined) { + dst[14] = v14; + if (v15 !== undefined) { + dst[15] = v15; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return dst; +} +/** + * Sets the values of a Mat4 + * Also see {@link mat4.create} and {@link mat4.copy} + * + * @param v0 - value for element 0 + * @param v1 - value for element 1 + * @param v2 - value for element 2 + * @param v3 - value for element 3 + * @param v4 - value for element 4 + * @param v5 - value for element 5 + * @param v6 - value for element 6 + * @param v7 - value for element 7 + * @param v8 - value for element 8 + * @param v9 - value for element 9 + * @param v10 - value for element 10 + * @param v11 - value for element 11 + * @param v12 - value for element 12 + * @param v13 - value for element 13 + * @param v14 - value for element 14 + * @param v15 - value for element 15 + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 created from values. + */ +function set$2(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, dst) { + dst = dst || new MatType(16); + dst[0] = v0; + dst[1] = v1; + dst[2] = v2; + dst[3] = v3; + dst[4] = v4; + dst[5] = v5; + dst[6] = v6; + dst[7] = v7; + dst[8] = v8; + dst[9] = v9; + dst[10] = v10; + dst[11] = v11; + dst[12] = v12; + dst[13] = v13; + dst[14] = v14; + dst[15] = v15; + return dst; +} +/** + * Creates a Mat4 from a Mat3 + * @param m3 - source matrix + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 made from m3 + */ +function fromMat3(m3, dst) { + dst = dst || new MatType(16); + dst[0] = m3[0]; + dst[1] = m3[1]; + dst[2] = m3[2]; + dst[3] = 0; + dst[4] = m3[4]; + dst[5] = m3[5]; + dst[6] = m3[6]; + dst[7] = 0; + dst[8] = m3[8]; + dst[9] = m3[9]; + dst[10] = m3[10]; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Creates a Mat4 rotation matrix from a quaternion + * @param q - quaternion to create matrix from + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns Mat4 made from q + */ +function fromQuat(q, dst) { + dst = dst || new MatType(16); + const x = q[0]; + const y = q[1]; + const z = q[2]; + const w = q[3]; + const x2 = x + x; + const y2 = y + y; + const z2 = z + z; + const xx = x * x2; + const yx = y * x2; + const yy = y * y2; + const zx = z * x2; + const zy = z * y2; + const zz = z * z2; + const wx = w * x2; + const wy = w * y2; + const wz = w * z2; + dst[0] = 1 - yy - zz; + dst[1] = yx + wz; + dst[2] = zx - wy; + dst[3] = 0; + dst[4] = yx - wz; + dst[5] = 1 - xx - zz; + dst[6] = zy + wx; + dst[7] = 0; + dst[8] = zx + wy; + dst[9] = zy - wx; + dst[10] = 1 - xx - yy; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Negates a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns -m. + */ +function negate$1(m, dst) { + dst = dst || new MatType(16); + dst[0] = -m[0]; + dst[1] = -m[1]; + dst[2] = -m[2]; + dst[3] = -m[3]; + dst[4] = -m[4]; + dst[5] = -m[5]; + dst[6] = -m[6]; + dst[7] = -m[7]; + dst[8] = -m[8]; + dst[9] = -m[9]; + dst[10] = -m[10]; + dst[11] = -m[11]; + dst[12] = -m[12]; + dst[13] = -m[13]; + dst[14] = -m[14]; + dst[15] = -m[15]; + return dst; +} +/** + * Copies a matrix. (same as {@link mat4.clone}) + * Also see {@link mat4.create} and {@link mat4.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +function copy$2(m, dst) { + dst = dst || new MatType(16); + dst[0] = m[0]; + dst[1] = m[1]; + dst[2] = m[2]; + dst[3] = m[3]; + dst[4] = m[4]; + dst[5] = m[5]; + dst[6] = m[6]; + dst[7] = m[7]; + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + dst[11] = m[11]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + return dst; +} +/** + * Copies a matrix (same as {@link mat4.copy}) + * Also see {@link mat4.create} and {@link mat4.set} + * @param m - The matrix. + * @param dst - The matrix. If not passed a new one is created. + * @returns A copy of m. + */ +const clone$2 = copy$2; +/** + * Check if 2 matrices are approximately equal + * @param a - Operand matrix. + * @param b - Operand matrix. + * @returns true if matrices are approximately equal + */ +function equalsApproximately$2(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON && + Math.abs(a[3] - b[3]) < EPSILON && + Math.abs(a[4] - b[4]) < EPSILON && + Math.abs(a[5] - b[5]) < EPSILON && + Math.abs(a[6] - b[6]) < EPSILON && + Math.abs(a[7] - b[7]) < EPSILON && + Math.abs(a[8] - b[8]) < EPSILON && + Math.abs(a[9] - b[9]) < EPSILON && + Math.abs(a[10] - b[10]) < EPSILON && + Math.abs(a[11] - b[11]) < EPSILON && + Math.abs(a[12] - b[12]) < EPSILON && + Math.abs(a[13] - b[13]) < EPSILON && + Math.abs(a[14] - b[14]) < EPSILON && + Math.abs(a[15] - b[15]) < EPSILON; +} +/** + * Check if 2 matrices are exactly equal + * @param a - Operand matrix. + * @param b - Operand matrix. + * @returns true if matrices are exactly equal + */ +function equals$2(a, b) { + return a[0] === b[0] && + a[1] === b[1] && + a[2] === b[2] && + a[3] === b[3] && + a[4] === b[4] && + a[5] === b[5] && + a[6] === b[6] && + a[7] === b[7] && + a[8] === b[8] && + a[9] === b[9] && + a[10] === b[10] && + a[11] === b[11] && + a[12] === b[12] && + a[13] === b[13] && + a[14] === b[14] && + a[15] === b[15]; +} +/** + * Creates a 4-by-4 identity matrix. + * + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A 4-by-4 identity matrix. + */ +function identity$1(dst) { + dst = dst || new MatType(16); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Takes the transpose of a matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The transpose of m. + */ +function transpose(m, dst) { + dst = dst || new MatType(16); + if (dst === m) { + let t; + t = m[1]; + m[1] = m[4]; + m[4] = t; + t = m[2]; + m[2] = m[8]; + m[8] = t; + t = m[3]; + m[3] = m[12]; + m[12] = t; + t = m[6]; + m[6] = m[9]; + m[9] = t; + t = m[7]; + m[7] = m[13]; + m[13] = t; + t = m[11]; + m[11] = m[14]; + m[14] = t; + return dst; + } + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + dst[0] = m00; + dst[1] = m10; + dst[2] = m20; + dst[3] = m30; + dst[4] = m01; + dst[5] = m11; + dst[6] = m21; + dst[7] = m31; + dst[8] = m02; + dst[9] = m12; + dst[10] = m22; + dst[11] = m32; + dst[12] = m03; + dst[13] = m13; + dst[14] = m23; + dst[15] = m33; + return dst; +} +/** + * Computes the inverse of a 4-by-4 matrix. + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +function inverse$2(m, dst) { + dst = dst || new MatType(16); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + const tmp0 = m22 * m33; + const tmp1 = m32 * m23; + const tmp2 = m12 * m33; + const tmp3 = m32 * m13; + const tmp4 = m12 * m23; + const tmp5 = m22 * m13; + const tmp6 = m02 * m33; + const tmp7 = m32 * m03; + const tmp8 = m02 * m23; + const tmp9 = m22 * m03; + const tmp10 = m02 * m13; + const tmp11 = m12 * m03; + const tmp12 = m20 * m31; + const tmp13 = m30 * m21; + const tmp14 = m10 * m31; + const tmp15 = m30 * m11; + const tmp16 = m10 * m21; + const tmp17 = m20 * m11; + const tmp18 = m00 * m31; + const tmp19 = m30 * m01; + const tmp20 = m00 * m21; + const tmp21 = m20 * m01; + const tmp22 = m00 * m11; + const tmp23 = m10 * m01; + const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) - + (tmp1 * m11 + tmp2 * m21 + tmp5 * m31); + const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) - + (tmp0 * m01 + tmp7 * m21 + tmp8 * m31); + const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) - + (tmp3 * m01 + tmp6 * m11 + tmp11 * m31); + const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) - + (tmp4 * m01 + tmp9 * m11 + tmp10 * m21); + const d = 1 / (m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3); + dst[0] = d * t0; + dst[1] = d * t1; + dst[2] = d * t2; + dst[3] = d * t3; + dst[4] = d * ((tmp1 * m10 + tmp2 * m20 + tmp5 * m30) - + (tmp0 * m10 + tmp3 * m20 + tmp4 * m30)); + dst[5] = d * ((tmp0 * m00 + tmp7 * m20 + tmp8 * m30) - + (tmp1 * m00 + tmp6 * m20 + tmp9 * m30)); + dst[6] = d * ((tmp3 * m00 + tmp6 * m10 + tmp11 * m30) - + (tmp2 * m00 + tmp7 * m10 + tmp10 * m30)); + dst[7] = d * ((tmp4 * m00 + tmp9 * m10 + tmp10 * m20) - + (tmp5 * m00 + tmp8 * m10 + tmp11 * m20)); + dst[8] = d * ((tmp12 * m13 + tmp15 * m23 + tmp16 * m33) - + (tmp13 * m13 + tmp14 * m23 + tmp17 * m33)); + dst[9] = d * ((tmp13 * m03 + tmp18 * m23 + tmp21 * m33) - + (tmp12 * m03 + tmp19 * m23 + tmp20 * m33)); + dst[10] = d * ((tmp14 * m03 + tmp19 * m13 + tmp22 * m33) - + (tmp15 * m03 + tmp18 * m13 + tmp23 * m33)); + dst[11] = d * ((tmp17 * m03 + tmp20 * m13 + tmp23 * m23) - + (tmp16 * m03 + tmp21 * m13 + tmp22 * m23)); + dst[12] = d * ((tmp14 * m22 + tmp17 * m32 + tmp13 * m12) - + (tmp16 * m32 + tmp12 * m12 + tmp15 * m22)); + dst[13] = d * ((tmp20 * m32 + tmp12 * m02 + tmp19 * m22) - + (tmp18 * m22 + tmp21 * m32 + tmp13 * m02)); + dst[14] = d * ((tmp18 * m12 + tmp23 * m32 + tmp15 * m02) - + (tmp22 * m32 + tmp14 * m02 + tmp19 * m12)); + dst[15] = d * ((tmp22 * m22 + tmp16 * m02 + tmp21 * m12) - + (tmp20 * m12 + tmp23 * m22 + tmp17 * m02)); + return dst; +} +/** + * Compute the determinant of a matrix + * @param m - the matrix + * @returns the determinant + */ +function determinant(m) { + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + const tmp0 = m22 * m33; + const tmp1 = m32 * m23; + const tmp2 = m12 * m33; + const tmp3 = m32 * m13; + const tmp4 = m12 * m23; + const tmp5 = m22 * m13; + const tmp6 = m02 * m33; + const tmp7 = m32 * m03; + const tmp8 = m02 * m23; + const tmp9 = m22 * m03; + const tmp10 = m02 * m13; + const tmp11 = m12 * m03; + const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) - + (tmp1 * m11 + tmp2 * m21 + tmp5 * m31); + const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) - + (tmp0 * m01 + tmp7 * m21 + tmp8 * m31); + const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) - + (tmp3 * m01 + tmp6 * m11 + tmp11 * m31); + const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) - + (tmp4 * m01 + tmp9 * m11 + tmp10 * m21); + return m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3; +} +/** + * Computes the inverse of a 4-by-4 matrix. (same as inverse) + * @param m - The matrix. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The inverse of m. + */ +const invert$1 = inverse$2; +/** + * Multiplies two 4-by-4 matrices with a on the left and b on the right + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +function multiply$2(a, b, dst) { + dst = dst || new MatType(16); + const a00 = a[0]; + const a01 = a[1]; + const a02 = a[2]; + const a03 = a[3]; + const a10 = a[4 + 0]; + const a11 = a[4 + 1]; + const a12 = a[4 + 2]; + const a13 = a[4 + 3]; + const a20 = a[8 + 0]; + const a21 = a[8 + 1]; + const a22 = a[8 + 2]; + const a23 = a[8 + 3]; + const a30 = a[12 + 0]; + const a31 = a[12 + 1]; + const a32 = a[12 + 2]; + const a33 = a[12 + 3]; + const b00 = b[0]; + const b01 = b[1]; + const b02 = b[2]; + const b03 = b[3]; + const b10 = b[4 + 0]; + const b11 = b[4 + 1]; + const b12 = b[4 + 2]; + const b13 = b[4 + 3]; + const b20 = b[8 + 0]; + const b21 = b[8 + 1]; + const b22 = b[8 + 2]; + const b23 = b[8 + 3]; + const b30 = b[12 + 0]; + const b31 = b[12 + 1]; + const b32 = b[12 + 2]; + const b33 = b[12 + 3]; + dst[0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03; + dst[1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03; + dst[2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03; + dst[3] = a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03; + dst[4] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13; + dst[5] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13; + dst[6] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13; + dst[7] = a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13; + dst[8] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23; + dst[9] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23; + dst[10] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23; + dst[11] = a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23; + dst[12] = a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33; + dst[13] = a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33; + dst[14] = a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33; + dst[15] = a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33; + return dst; +} +/** + * Multiplies two 4-by-4 matrices with a on the left and b on the right (same as multiply) + * @param a - The matrix on the left. + * @param b - The matrix on the right. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix product of a and b. + */ +const mul$2 = multiply$2; +/** + * Sets the translation component of a 4-by-4 matrix to the given + * vector. + * @param a - The matrix. + * @param v - The vector. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The matrix with translation set. + */ +function setTranslation(a, v, dst) { + dst = dst || identity$1(); + if (a !== dst) { + dst[0] = a[0]; + dst[1] = a[1]; + dst[2] = a[2]; + dst[3] = a[3]; + dst[4] = a[4]; + dst[5] = a[5]; + dst[6] = a[6]; + dst[7] = a[7]; + dst[8] = a[8]; + dst[9] = a[9]; + dst[10] = a[10]; + dst[11] = a[11]; + } + dst[12] = v[0]; + dst[13] = v[1]; + dst[14] = v[2]; + dst[15] = 1; + return dst; +} +/** + * Returns the translation component of a 4-by-4 matrix as a vector with 3 + * entries. + * @param m - The matrix. + * @param dst - vector to hold result. If not passed a new one is created. + * @returns The translation component of m. + */ +function getTranslation(m, dst) { + dst = dst || create$4(); + dst[0] = m[12]; + dst[1] = m[13]; + dst[2] = m[14]; + return dst; +} +/** + * Returns an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @returns The axis component of m. + */ +function getAxis(m, axis, dst) { + dst = dst || create$4(); + const off = axis * 4; + dst[0] = m[off + 0]; + dst[1] = m[off + 1]; + dst[2] = m[off + 2]; + return dst; +} +/** + * Sets an axis of a 4x4 matrix as a vector with 3 entries + * @param m - The matrix. + * @param v - the axis vector + * @param axis - The axis 0 = x, 1 = y, 2 = z; + * @param dst - The matrix to set. If not passed a new one is created. + * @returns The matrix with axis set. + */ +function setAxis(m, v, axis, dst) { + if (dst !== m) { + dst = copy$2(m, dst); + } + const off = axis * 4; + dst[off + 0] = v[0]; + dst[off + 1] = v[1]; + dst[off + 2] = v[2]; + return dst; +} +/** + * Returns the scaling component of the matrix + * @param m - The Matrix + * @param dst - The vector to set. If not passed a new one is created. + */ +function getScaling(m, dst) { + dst = dst || create$4(); + const xx = m[0]; + const xy = m[1]; + const xz = m[2]; + const yx = m[4]; + const yy = m[5]; + const yz = m[6]; + const zx = m[8]; + const zy = m[9]; + const zz = m[10]; + dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz); + dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz); + dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz); + return dst; +} +/** + * Computes a 4-by-4 perspective transformation matrix given the angular height + * of the frustum, the aspect ratio, and the near and far clipping planes. The + * arguments define a frustum extending in the negative z direction. The given + * angle is the vertical angle of the frustum, and the horizontal angle is + * determined to produce the given aspect ratio. The arguments near and far are + * the distances to the near and far clipping planes. Note that near and far + * are not z coordinates, but rather they are distances along the negative + * z-axis. The matrix generated sends the viewing frustum to the unit box. + * We assume a unit box extending from -1 to 1 in the x and y dimensions and + * from 0 to 1 in the z dimension. + * + * Note: If you pass `Infinity` for zFar then it will produce a projection matrix + * returns -Infinity for Z when transforming coordinates with Z <= 0 and +Infinity for Z + * otherwise. + * + * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians). + * @param aspect - The aspect ratio width / height. + * @param zNear - The depth (negative z coordinate) + * of the near clipping plane. + * @param zFar - The depth (negative z coordinate) + * of the far clipping plane. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The perspective matrix. + */ +function perspective(fieldOfViewYInRadians, aspect, zNear, zFar, dst) { + dst = dst || new MatType(16); + const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians); + dst[0] = f / aspect; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = f; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[15] = 0; + if (Number.isFinite(zFar)) { + const rangeInv = 1 / (zNear - zFar); + dst[10] = zFar * rangeInv; + dst[14] = zFar * zNear * rangeInv; + } + else { + dst[10] = -1; + dst[14] = -zNear; + } + return dst; +} +/** + * Computes a 4-by-4 reverse-z perspective transformation matrix given the angular height + * of the frustum, the aspect ratio, and the near and far clipping planes. The + * arguments define a frustum extending in the negative z direction. The given + * angle is the vertical angle of the frustum, and the horizontal angle is + * determined to produce the given aspect ratio. The arguments near and far are + * the distances to the near and far clipping planes. Note that near and far + * are not z coordinates, but rather they are distances along the negative + * z-axis. The matrix generated sends the viewing frustum to the unit box. + * We assume a unit box extending from -1 to 1 in the x and y dimensions and + * from 1 (at -zNear) to 0 (at -zFar) in the z dimension. + * + * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians). + * @param aspect - The aspect ratio width / height. + * @param zNear - The depth (negative z coordinate) + * of the near clipping plane. + * @param zFar - The depth (negative z coordinate) + * of the far clipping plane. (default = Infinity) + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The perspective matrix. + */ function perspectiveReverseZ(fieldOfViewYInRadians, aspect, zNear, zFar = Infinity, dst) { + dst = dst || new MatType(16); + const f = 1 / Math.tan(fieldOfViewYInRadians * 0.5); + dst[0] = f / aspect; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = f; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[15] = 0; + if (zFar === Infinity) { + dst[10] = 0; + dst[14] = zNear; + } + else { + const rangeInv = 1 / (zFar - zNear); + dst[10] = zNear * rangeInv; + dst[14] = zFar * zNear * rangeInv; + } + return dst; +} +/** + * Computes a 4-by-4 orthogonal transformation matrix that transforms from + * the given the left, right, bottom, and top dimensions to -1 +1 in x, and y + * and 0 to +1 in z. + * @param left - Left side of the near clipping plane viewport. + * @param right - Right side of the near clipping plane viewport. + * @param bottom - Bottom of the near clipping plane viewport. + * @param top - Top of the near clipping plane viewport. + * @param near - The depth (negative z coordinate) + * of the near clipping plane. + * @param far - The depth (negative z coordinate) + * of the far clipping plane. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The orthographic projection matrix. + */ +function ortho(left, right, bottom, top, near, far, dst) { + dst = dst || new MatType(16); + dst[0] = 2 / (right - left); + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 2 / (top - bottom); + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1 / (near - far); + dst[11] = 0; + dst[12] = (right + left) / (left - right); + dst[13] = (top + bottom) / (bottom - top); + dst[14] = near / (near - far); + dst[15] = 1; + return dst; +} +/** + * Computes a 4-by-4 perspective transformation matrix given the left, right, + * top, bottom, near and far clipping planes. The arguments define a frustum + * extending in the negative z direction. The arguments near and far are the + * distances to the near and far clipping planes. Note that near and far are not + * z coordinates, but rather they are distances along the negative z-axis. The + * matrix generated sends the viewing frustum to the unit box. We assume a unit + * box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z + * dimension. + * @param left - The x coordinate of the left plane of the box. + * @param right - The x coordinate of the right plane of the box. + * @param bottom - The y coordinate of the bottom plane of the box. + * @param top - The y coordinate of the right plane of the box. + * @param near - The negative z coordinate of the near plane of the box. + * @param far - The negative z coordinate of the far plane of the box. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The perspective projection matrix. + */ +function frustum(left, right, bottom, top, near, far, dst) { + dst = dst || new MatType(16); + const dx = (right - left); + const dy = (top - bottom); + const dz = (near - far); + dst[0] = 2 * near / dx; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 2 * near / dy; + dst[6] = 0; + dst[7] = 0; + dst[8] = (left + right) / dx; + dst[9] = (top + bottom) / dy; + dst[10] = far / dz; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[14] = near * far / dz; + dst[15] = 0; + return dst; +} +/** + * Computes a 4-by-4 reverse-z perspective transformation matrix given the left, right, + * top, bottom, near and far clipping planes. The arguments define a frustum + * extending in the negative z direction. The arguments near and far are the + * distances to the near and far clipping planes. Note that near and far are not + * z coordinates, but rather they are distances along the negative z-axis. The + * matrix generated sends the viewing frustum to the unit box. We assume a unit + * box extending from -1 to 1 in the x and y dimensions and from 1 (-near) to 0 (-far) in the z + * dimension. + * @param left - The x coordinate of the left plane of the box. + * @param right - The x coordinate of the right plane of the box. + * @param bottom - The y coordinate of the bottom plane of the box. + * @param top - The y coordinate of the right plane of the box. + * @param near - The negative z coordinate of the near plane of the box. + * @param far - The negative z coordinate of the far plane of the box. + * @param dst - Output matrix. If not passed a new one is created. + * @returns The perspective projection matrix. + */ +function frustumReverseZ(left, right, bottom, top, near, far = Infinity, dst) { + dst = dst || new MatType(16); + const dx = (right - left); + const dy = (top - bottom); + dst[0] = 2 * near / dx; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 2 * near / dy; + dst[6] = 0; + dst[7] = 0; + dst[8] = (left + right) / dx; + dst[9] = (top + bottom) / dy; + dst[11] = -1; + dst[12] = 0; + dst[13] = 0; + dst[15] = 0; + if (far === Infinity) { + dst[10] = 0; + dst[14] = near; + } + else { + const rangeInv = 1 / (far - near); + dst[10] = near * rangeInv; + dst[14] = far * near * rangeInv; + } + return dst; +} +let xAxis; +let yAxis; +let zAxis; +/** + * Computes a 4-by-4 aim transformation. + * + * This is a matrix which positions an object aiming down positive Z. + * toward the target. + * + * Note: this is **NOT** the inverse of lookAt as lookAt looks at negative Z. + * + * @param position - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The aim matrix. + */ +function aim(position, target, up, dst) { + dst = dst || new MatType(16); + xAxis = xAxis || create$4(); + yAxis = yAxis || create$4(); + zAxis = zAxis || create$4(); + normalize$2(subtract$2(target, position, zAxis), zAxis); + normalize$2(cross(up, zAxis, xAxis), xAxis); + normalize$2(cross(zAxis, xAxis, yAxis), yAxis); + dst[0] = xAxis[0]; + dst[1] = xAxis[1]; + dst[2] = xAxis[2]; + dst[3] = 0; + dst[4] = yAxis[0]; + dst[5] = yAxis[1]; + dst[6] = yAxis[2]; + dst[7] = 0; + dst[8] = zAxis[0]; + dst[9] = zAxis[1]; + dst[10] = zAxis[2]; + dst[11] = 0; + dst[12] = position[0]; + dst[13] = position[1]; + dst[14] = position[2]; + dst[15] = 1; + return dst; +} +/** + * Computes a 4-by-4 camera aim transformation. + * + * This is a matrix which positions an object aiming down negative Z. + * toward the target. + * + * Note: this is the inverse of `lookAt` + * + * @param eye - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The aim matrix. + */ +function cameraAim(eye, target, up, dst) { + dst = dst || new MatType(16); + xAxis = xAxis || create$4(); + yAxis = yAxis || create$4(); + zAxis = zAxis || create$4(); + normalize$2(subtract$2(eye, target, zAxis), zAxis); + normalize$2(cross(up, zAxis, xAxis), xAxis); + normalize$2(cross(zAxis, xAxis, yAxis), yAxis); + dst[0] = xAxis[0]; + dst[1] = xAxis[1]; + dst[2] = xAxis[2]; + dst[3] = 0; + dst[4] = yAxis[0]; + dst[5] = yAxis[1]; + dst[6] = yAxis[2]; + dst[7] = 0; + dst[8] = zAxis[0]; + dst[9] = zAxis[1]; + dst[10] = zAxis[2]; + dst[11] = 0; + dst[12] = eye[0]; + dst[13] = eye[1]; + dst[14] = eye[2]; + dst[15] = 1; + return dst; +} +/** + * Computes a 4-by-4 view transformation. + * + * This is a view matrix which transforms all other objects + * to be in the space of the view defined by the parameters. + * + * @param eye - The position of the object. + * @param target - The position meant to be aimed at. + * @param up - A vector pointing up. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The look-at matrix. + */ +function lookAt(eye, target, up, dst) { + dst = dst || new MatType(16); + xAxis = xAxis || create$4(); + yAxis = yAxis || create$4(); + zAxis = zAxis || create$4(); + normalize$2(subtract$2(eye, target, zAxis), zAxis); + normalize$2(cross(up, zAxis, xAxis), xAxis); + normalize$2(cross(zAxis, xAxis, yAxis), yAxis); + dst[0] = xAxis[0]; + dst[1] = yAxis[0]; + dst[2] = zAxis[0]; + dst[3] = 0; + dst[4] = xAxis[1]; + dst[5] = yAxis[1]; + dst[6] = zAxis[1]; + dst[7] = 0; + dst[8] = xAxis[2]; + dst[9] = yAxis[2]; + dst[10] = zAxis[2]; + dst[11] = 0; + dst[12] = -(xAxis[0] * eye[0] + xAxis[1] * eye[1] + xAxis[2] * eye[2]); + dst[13] = -(yAxis[0] * eye[0] + yAxis[1] * eye[1] + yAxis[2] * eye[2]); + dst[14] = -(zAxis[0] * eye[0] + zAxis[1] * eye[1] + zAxis[2] * eye[2]); + dst[15] = 1; + return dst; +} +/** + * Creates a 4-by-4 matrix which translates by the given vector v. + * @param v - The vector by + * which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translation matrix. + */ +function translation(v, dst) { + dst = dst || new MatType(16); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + dst[11] = 0; + dst[12] = v[0]; + dst[13] = v[1]; + dst[14] = v[2]; + dst[15] = 1; + return dst; +} +/** + * Translates the given 4-by-4 matrix by the given vector v. + * @param m - The matrix. + * @param v - The vector by + * which to translate. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The translated matrix. + */ +function translate(m, v, dst) { + dst = dst || new MatType(16); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const m00 = m[0]; + const m01 = m[1]; + const m02 = m[2]; + const m03 = m[3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const m30 = m[3 * 4 + 0]; + const m31 = m[3 * 4 + 1]; + const m32 = m[3 * 4 + 2]; + const m33 = m[3 * 4 + 3]; + if (m !== dst) { + dst[0] = m00; + dst[1] = m01; + dst[2] = m02; + dst[3] = m03; + dst[4] = m10; + dst[5] = m11; + dst[6] = m12; + dst[7] = m13; + dst[8] = m20; + dst[9] = m21; + dst[10] = m22; + dst[11] = m23; + } + dst[12] = m00 * v0 + m10 * v1 + m20 * v2 + m30; + dst[13] = m01 * v0 + m11 * v1 + m21 * v2 + m31; + dst[14] = m02 * v0 + m12 * v1 + m22 * v2 + m32; + dst[15] = m03 * v0 + m13 * v1 + m23 * v2 + m33; + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +function rotationX(angleInRadians, dst) { + dst = dst || new MatType(16); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = c; + dst[6] = s; + dst[7] = 0; + dst[8] = 0; + dst[9] = -s; + dst[10] = c; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Rotates the given 4-by-4 matrix around the x-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +function rotateX$1(m, angleInRadians, dst) { + dst = dst || new MatType(16); + const m10 = m[4]; + const m11 = m[5]; + const m12 = m[6]; + const m13 = m[7]; + const m20 = m[8]; + const m21 = m[9]; + const m22 = m[10]; + const m23 = m[11]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[4] = c * m10 + s * m20; + dst[5] = c * m11 + s * m21; + dst[6] = c * m12 + s * m22; + dst[7] = c * m13 + s * m23; + dst[8] = c * m20 - s * m10; + dst[9] = c * m21 - s * m11; + dst[10] = c * m22 - s * m12; + dst[11] = c * m23 - s * m13; + if (m !== dst) { + dst[0] = m[0]; + dst[1] = m[1]; + dst[2] = m[2]; + dst[3] = m[3]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +function rotationY(angleInRadians, dst) { + dst = dst || new MatType(16); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c; + dst[1] = 0; + dst[2] = -s; + dst[3] = 0; + dst[4] = 0; + dst[5] = 1; + dst[6] = 0; + dst[7] = 0; + dst[8] = s; + dst[9] = 0; + dst[10] = c; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Rotates the given 4-by-4 matrix around the y-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +function rotateY$1(m, angleInRadians, dst) { + dst = dst || new MatType(16); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m20 = m[2 * 4 + 0]; + const m21 = m[2 * 4 + 1]; + const m22 = m[2 * 4 + 2]; + const m23 = m[2 * 4 + 3]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c * m00 - s * m20; + dst[1] = c * m01 - s * m21; + dst[2] = c * m02 - s * m22; + dst[3] = c * m03 - s * m23; + dst[8] = c * m20 + s * m00; + dst[9] = c * m21 + s * m01; + dst[10] = c * m22 + s * m02; + dst[11] = c * m23 + s * m03; + if (m !== dst) { + dst[4] = m[4]; + dst[5] = m[5]; + dst[6] = m[6]; + dst[7] = m[7]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotation matrix. + */ +function rotationZ(angleInRadians, dst) { + dst = dst || new MatType(16); + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c; + dst[1] = s; + dst[2] = 0; + dst[3] = 0; + dst[4] = -s; + dst[5] = c; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = 1; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Rotates the given 4-by-4 matrix around the z-axis by the given + * angle. + * @param m - The matrix. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +function rotateZ$1(m, angleInRadians, dst) { + dst = dst || new MatType(16); + const m00 = m[0 * 4 + 0]; + const m01 = m[0 * 4 + 1]; + const m02 = m[0 * 4 + 2]; + const m03 = m[0 * 4 + 3]; + const m10 = m[1 * 4 + 0]; + const m11 = m[1 * 4 + 1]; + const m12 = m[1 * 4 + 2]; + const m13 = m[1 * 4 + 3]; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + dst[0] = c * m00 + s * m10; + dst[1] = c * m01 + s * m11; + dst[2] = c * m02 + s * m12; + dst[3] = c * m03 + s * m13; + dst[4] = c * m10 - s * m00; + dst[5] = c * m11 - s * m01; + dst[6] = c * m12 - s * m02; + dst[7] = c * m13 - s * m03; + if (m !== dst) { + dst[8] = m[8]; + dst[9] = m[9]; + dst[10] = m[10]; + dst[11] = m[11]; + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the given axis by the given + * angle. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A matrix which rotates angle radians + * around the axis. + */ +function axisRotation(axis, angleInRadians, dst) { + dst = dst || new MatType(16); + let x = axis[0]; + let y = axis[1]; + let z = axis[2]; + const n = Math.sqrt(x * x + y * y + z * z); + x /= n; + y /= n; + z /= n; + const xx = x * x; + const yy = y * y; + const zz = z * z; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + const oneMinusCosine = 1 - c; + dst[0] = xx + (1 - xx) * c; + dst[1] = x * y * oneMinusCosine + z * s; + dst[2] = x * z * oneMinusCosine - y * s; + dst[3] = 0; + dst[4] = x * y * oneMinusCosine - z * s; + dst[5] = yy + (1 - yy) * c; + dst[6] = y * z * oneMinusCosine + x * s; + dst[7] = 0; + dst[8] = x * z * oneMinusCosine + y * s; + dst[9] = y * z * oneMinusCosine - x * s; + dst[10] = zz + (1 - zz) * c; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Creates a 4-by-4 matrix which rotates around the given axis by the given + * angle. (same as axisRotation) + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns A matrix which rotates angle radians + * around the axis. + */ +const rotation = axisRotation; +/** + * Rotates the given 4-by-4 matrix around the given axis by the + * given angle. + * @param m - The matrix. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +function axisRotate(m, axis, angleInRadians, dst) { + dst = dst || new MatType(16); + let x = axis[0]; + let y = axis[1]; + let z = axis[2]; + const n = Math.sqrt(x * x + y * y + z * z); + x /= n; + y /= n; + z /= n; + const xx = x * x; + const yy = y * y; + const zz = z * z; + const c = Math.cos(angleInRadians); + const s = Math.sin(angleInRadians); + const oneMinusCosine = 1 - c; + const r00 = xx + (1 - xx) * c; + const r01 = x * y * oneMinusCosine + z * s; + const r02 = x * z * oneMinusCosine - y * s; + const r10 = x * y * oneMinusCosine - z * s; + const r11 = yy + (1 - yy) * c; + const r12 = y * z * oneMinusCosine + x * s; + const r20 = x * z * oneMinusCosine + y * s; + const r21 = y * z * oneMinusCosine - x * s; + const r22 = zz + (1 - zz) * c; + const m00 = m[0]; + const m01 = m[1]; + const m02 = m[2]; + const m03 = m[3]; + const m10 = m[4]; + const m11 = m[5]; + const m12 = m[6]; + const m13 = m[7]; + const m20 = m[8]; + const m21 = m[9]; + const m22 = m[10]; + const m23 = m[11]; + dst[0] = r00 * m00 + r01 * m10 + r02 * m20; + dst[1] = r00 * m01 + r01 * m11 + r02 * m21; + dst[2] = r00 * m02 + r01 * m12 + r02 * m22; + dst[3] = r00 * m03 + r01 * m13 + r02 * m23; + dst[4] = r10 * m00 + r11 * m10 + r12 * m20; + dst[5] = r10 * m01 + r11 * m11 + r12 * m21; + dst[6] = r10 * m02 + r11 * m12 + r12 * m22; + dst[7] = r10 * m03 + r11 * m13 + r12 * m23; + dst[8] = r20 * m00 + r21 * m10 + r22 * m20; + dst[9] = r20 * m01 + r21 * m11 + r22 * m21; + dst[10] = r20 * m02 + r21 * m12 + r22 * m22; + dst[11] = r20 * m03 + r21 * m13 + r22 * m23; + if (m !== dst) { + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Rotates the given 4-by-4 matrix around the given axis by the + * given angle. (same as rotate) + * @param m - The matrix. + * @param axis - The axis + * about which to rotate. + * @param angleInRadians - The angle by which to rotate (in radians). + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The rotated matrix. + */ +const rotate = axisRotate; +/** + * Creates a 4-by-4 matrix which scales in each dimension by an amount given by + * the corresponding entry in the given vector; assumes the vector has three + * entries. + * @param v - A vector of + * three entries specifying the factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +function scaling(v, dst) { + dst = dst || new MatType(16); + dst[0] = v[0]; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = v[1]; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = v[2]; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Scales the given 4-by-4 matrix in each dimension by an amount + * given by the corresponding entry in the given vector; assumes the vector has + * three entries. + * @param m - The matrix to be modified. + * @param v - A vector of three entries specifying the + * factor by which to scale in each dimension. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +function scale$2(m, v, dst) { + dst = dst || new MatType(16); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + dst[0] = v0 * m[0 * 4 + 0]; + dst[1] = v0 * m[0 * 4 + 1]; + dst[2] = v0 * m[0 * 4 + 2]; + dst[3] = v0 * m[0 * 4 + 3]; + dst[4] = v1 * m[1 * 4 + 0]; + dst[5] = v1 * m[1 * 4 + 1]; + dst[6] = v1 * m[1 * 4 + 2]; + dst[7] = v1 * m[1 * 4 + 3]; + dst[8] = v2 * m[2 * 4 + 0]; + dst[9] = v2 * m[2 * 4 + 1]; + dst[10] = v2 * m[2 * 4 + 2]; + dst[11] = v2 * m[2 * 4 + 3]; + if (m !== dst) { + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} +/** + * Creates a 4-by-4 matrix which scales a uniform amount in each dimension. + * @param s - the amount to scale + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaling matrix. + */ +function uniformScaling(s, dst) { + dst = dst || new MatType(16); + dst[0] = s; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + dst[4] = 0; + dst[5] = s; + dst[6] = 0; + dst[7] = 0; + dst[8] = 0; + dst[9] = 0; + dst[10] = s; + dst[11] = 0; + dst[12] = 0; + dst[13] = 0; + dst[14] = 0; + dst[15] = 1; + return dst; +} +/** + * Scales the given 4-by-4 matrix in each dimension by a uniform scale. + * @param m - The matrix to be modified. + * @param s - The amount to scale. + * @param dst - matrix to hold result. If not passed a new one is created. + * @returns The scaled matrix. + */ +function uniformScale(m, s, dst) { + dst = dst || new MatType(16); + dst[0] = s * m[0 * 4 + 0]; + dst[1] = s * m[0 * 4 + 1]; + dst[2] = s * m[0 * 4 + 2]; + dst[3] = s * m[0 * 4 + 3]; + dst[4] = s * m[1 * 4 + 0]; + dst[5] = s * m[1 * 4 + 1]; + dst[6] = s * m[1 * 4 + 2]; + dst[7] = s * m[1 * 4 + 3]; + dst[8] = s * m[2 * 4 + 0]; + dst[9] = s * m[2 * 4 + 1]; + dst[10] = s * m[2 * 4 + 2]; + dst[11] = s * m[2 * 4 + 3]; + if (m !== dst) { + dst[12] = m[12]; + dst[13] = m[13]; + dst[14] = m[14]; + dst[15] = m[15]; + } + return dst; +} + +var mat4Impl = { + __proto__: null, + aim: aim, + axisRotate: axisRotate, + axisRotation: axisRotation, + cameraAim: cameraAim, + clone: clone$2, + copy: copy$2, + create: create$2, + determinant: determinant, + equals: equals$2, + equalsApproximately: equalsApproximately$2, + fromMat3: fromMat3, + fromQuat: fromQuat, + frustum: frustum, + frustumReverseZ: frustumReverseZ, + getAxis: getAxis, + getScaling: getScaling, + getTranslation: getTranslation, + identity: identity$1, + inverse: inverse$2, + invert: invert$1, + lookAt: lookAt, + mul: mul$2, + multiply: multiply$2, + negate: negate$1, + ortho: ortho, + perspective: perspective, + perspectiveReverseZ: perspectiveReverseZ, + rotate: rotate, + rotateX: rotateX$1, + rotateY: rotateY$1, + rotateZ: rotateZ$1, + rotation: rotation, + rotationX: rotationX, + rotationY: rotationY, + rotationZ: rotationZ, + scale: scale$2, + scaling: scaling, + set: set$2, + setAxis: setAxis, + setDefaultType: setDefaultType$3, + setTranslation: setTranslation, + translate: translate, + translation: translation, + transpose: transpose, + uniformScale: uniformScale, + uniformScaling: uniformScaling +}; + +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * + * Quat4 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Quat4`. In other words you can do this + * + * const v = quat4.cross(v1, v2); // Creates a new Quat4 with the cross product of v1 x v2. + * + * or + * + * const v = quat4.create(); + * quat4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * quat4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +let QuatType = Float32Array; +/** + * Sets the type this library creates for a Quat4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Quat4 + */ +function setDefaultType$2(ctor) { + const oldType = QuatType; + QuatType = ctor; + return oldType; +} +/** + * Creates a quat4; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param w - Initial w value. + * @returns the created vector + */ +function create$1(x, y, z, w) { + const dst = new QuatType(4); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + if (z !== undefined) { + dst[2] = z; + if (w !== undefined) { + dst[3] = w; + } + } + } + } + return dst; +} + +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * Creates a Quat; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param z - Initial w value. + * @returns the created vector + */ +const fromValues$1 = create$1; +/** + * Sets the values of a Quat + * Also see {@link quat.create} and {@link quat.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param w fourth value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +function set$1(x, y, z, w, dst) { + dst = dst || new QuatType(4); + dst[0] = x; + dst[1] = y; + dst[2] = z; + dst[3] = w; + return dst; +} +/** + * Sets a quaternion from the given angle and axis, + * then returns it. + * + * @param axis - the axis to rotate around + * @param angleInRadians - the angle + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The quaternion that represents the given axis and angle + **/ +function fromAxisAngle(axis, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const s = Math.sin(halfAngle); + dst[0] = s * axis[0]; + dst[1] = s * axis[1]; + dst[2] = s * axis[2]; + dst[3] = Math.cos(halfAngle); + return dst; +} +/** + * Gets the rotation axis and angle + * @param q - quaternion to compute from + * @param dst - Vec3 to hold result. If not passed in a new one is created. + * @return angle and axis + */ +function toAxisAngle(q, dst) { + dst = dst || create$4(4); + const angle = Math.acos(q[3]) * 2; + const s = Math.sin(angle * 0.5); + if (s > EPSILON) { + dst[0] = q[0] / s; + dst[1] = q[1] / s; + dst[2] = q[2] / s; + } + else { + dst[0] = 1; + dst[1] = 0; + dst[2] = 0; + } + return { angle, axis: dst }; +} +/** + * Returns the angle in degrees between two rotations a and b. + * @param a - quaternion a + * @param b - quaternion b + * @return angle in radians between the two quaternions + */ +function angle(a, b) { + const d = dot$1(a, b); + return Math.acos(2 * d * d - 1); +} +/** + * Multiplies two quaternions + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +function multiply$1(a, b, dst) { + dst = dst || new QuatType(4); + const ax = a[0]; + const ay = a[1]; + const az = a[2]; + const aw = a[3]; + const bx = b[0]; + const by = b[1]; + const bz = b[2]; + const bw = b[3]; + dst[0] = ax * bw + aw * bx + ay * bz - az * by; + dst[1] = ay * bw + aw * by + az * bx - ax * bz; + dst[2] = az * bw + aw * bz + ax * by - ay * bx; + dst[3] = aw * bw - ax * bx - ay * by - az * bz; + return dst; +} +/** + * Multiplies two quaternions + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +const mul$1 = multiply$1; +/** + * Rotates the given quaternion around the X axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +function rotateX(q, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const qw = q[3]; + const bx = Math.sin(halfAngle); + const bw = Math.cos(halfAngle); + dst[0] = qx * bw + qw * bx; + dst[1] = qy * bw + qz * bx; + dst[2] = qz * bw - qy * bx; + dst[3] = qw * bw - qx * bx; + return dst; +} +/** + * Rotates the given quaternion around the Y axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +function rotateY(q, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const qw = q[3]; + const by = Math.sin(halfAngle); + const bw = Math.cos(halfAngle); + dst[0] = qx * bw - qz * by; + dst[1] = qy * bw + qw * by; + dst[2] = qz * bw + qx * by; + dst[3] = qw * bw - qy * by; + return dst; +} +/** + * Rotates the given quaternion around the Z axis by the given angle. + * @param q - quaternion to rotate + * @param angleInRadians - The angle by which to rotate + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +function rotateZ(q, angleInRadians, dst) { + dst = dst || new QuatType(4); + const halfAngle = angleInRadians * 0.5; + const qx = q[0]; + const qy = q[1]; + const qz = q[2]; + const qw = q[3]; + const bz = Math.sin(halfAngle); + const bw = Math.cos(halfAngle); + dst[0] = qx * bw + qy * bz; + dst[1] = qy * bw - qx * bz; + dst[2] = qz * bw + qw * bz; + dst[3] = qw * bw - qz * bz; + return dst; +} +/** + * Spherically linear interpolate between two quaternions + * + * @param a - starting value + * @param b - ending value + * @param t - value where 0 = a and 1 = b + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the result of a * b + */ +function slerp(a, b, t, dst) { + dst = dst || new QuatType(4); + const ax = a[0]; + const ay = a[1]; + const az = a[2]; + const aw = a[3]; + let bx = b[0]; + let by = b[1]; + let bz = b[2]; + let bw = b[3]; + let cosOmega = ax * bx + ay * by + az * bz + aw * bw; + if (cosOmega < 0) { + cosOmega = -cosOmega; + bx = -bx; + by = -by; + bz = -bz; + bw = -bw; + } + let scale0; + let scale1; + if (1.0 - cosOmega > EPSILON) { + const omega = Math.acos(cosOmega); + const sinOmega = Math.sin(omega); + scale0 = Math.sin((1 - t) * omega) / sinOmega; + scale1 = Math.sin(t * omega) / sinOmega; + } + else { + scale0 = 1.0 - t; + scale1 = t; + } + dst[0] = scale0 * ax + scale1 * bx; + dst[1] = scale0 * ay + scale1 * by; + dst[2] = scale0 * az + scale1 * bz; + dst[3] = scale0 * aw + scale1 * bw; + return dst; +} +/** + * Compute the inverse of a quaternion + * + * @param q - quaternion to compute the inverse of + * @returns A quaternion that is the result of a * b + */ +function inverse$1(q, dst) { + dst = dst || new QuatType(4); + const a0 = q[0]; + const a1 = q[1]; + const a2 = q[2]; + const a3 = q[3]; + const dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + const invDot = dot ? 1 / dot : 0; + dst[0] = -a0 * invDot; + dst[1] = -a1 * invDot; + dst[2] = -a2 * invDot; + dst[3] = a3 * invDot; + return dst; +} +/** + * Compute the conjugate of a quaternion + * For quaternions with a magnitude of 1 (a unit quaternion) + * this returns the same as the inverse but is faster to calculate. + * + * @param q - quaternion to compute the conjugate of. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The conjugate of q + */ +function conjugate(q, dst) { + dst = dst || new QuatType(4); + dst[0] = -q[0]; + dst[1] = -q[1]; + dst[2] = -q[2]; + dst[3] = q[3]; + return dst; +} +/** + * Creates a quaternion from the given rotation matrix. + * + * The created quaternion is not normalized. + * + * @param m - rotation matrix + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns the result + */ +function fromMat(m, dst) { + dst = dst || new QuatType(4); + /* + 0 1 2 + 3 4 5 + 6 7 8 + + 0 1 2 + 4 5 6 + 8 9 10 + */ + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + const trace = m[0] + m[5] + m[10]; + if (trace > 0.0) { + // |w| > 1/2, may as well choose w > 1/2 + const root = Math.sqrt(trace + 1); // 2w + dst[3] = 0.5 * root; + const invRoot = 0.5 / root; // 1/(4w) + dst[0] = (m[6] - m[9]) * invRoot; + dst[1] = (m[8] - m[2]) * invRoot; + dst[2] = (m[1] - m[4]) * invRoot; + } + else { + // |w| <= 1/2 + let i = 0; + if (m[5] > m[0]) { + i = 1; + } + if (m[10] > m[i * 4 + i]) { + i = 2; + } + const j = (i + 1) % 3; + const k = (i + 2) % 3; + const root = Math.sqrt(m[i * 4 + i] - m[j * 4 + j] - m[k * 4 + k] + 1.0); + dst[i] = 0.5 * root; + const invRoot = 0.5 / root; + dst[3] = (m[j * 4 + k] - m[k * 4 + j]) * invRoot; + dst[j] = (m[j * 4 + i] + m[i * 4 + j]) * invRoot; + dst[k] = (m[k * 4 + i] + m[i * 4 + k]) * invRoot; + } + return dst; +} +/** + * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion. + * + * @param xAngleInRadians - angle to rotate around X axis in radians. + * @param yAngleInRadians - angle to rotate around Y axis in radians. + * @param zAngleInRadians - angle to rotate around Z axis in radians. + * @param order - order to apply euler angles + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion representing the same rotation as the euler angles applied in the given order + */ +function fromEuler(xAngleInRadians, yAngleInRadians, zAngleInRadians, order, dst) { + dst = dst || new QuatType(4); + const xHalfAngle = xAngleInRadians * 0.5; + const yHalfAngle = yAngleInRadians * 0.5; + const zHalfAngle = zAngleInRadians * 0.5; + const sx = Math.sin(xHalfAngle); + const cx = Math.cos(xHalfAngle); + const sy = Math.sin(yHalfAngle); + const cy = Math.cos(yHalfAngle); + const sz = Math.sin(zHalfAngle); + const cz = Math.cos(zHalfAngle); + switch (order) { + case 'xyz': + dst[0] = sx * cy * cz + cx * sy * sz; + dst[1] = cx * sy * cz - sx * cy * sz; + dst[2] = cx * cy * sz + sx * sy * cz; + dst[3] = cx * cy * cz - sx * sy * sz; + break; + case 'xzy': + dst[0] = sx * cy * cz - cx * sy * sz; + dst[1] = cx * sy * cz - sx * cy * sz; + dst[2] = cx * cy * sz + sx * sy * cz; + dst[3] = cx * cy * cz + sx * sy * sz; + break; + case 'yxz': + dst[0] = sx * cy * cz + cx * sy * sz; + dst[1] = cx * sy * cz - sx * cy * sz; + dst[2] = cx * cy * sz - sx * sy * cz; + dst[3] = cx * cy * cz + sx * sy * sz; + break; + case 'yzx': + dst[0] = sx * cy * cz + cx * sy * sz; + dst[1] = cx * sy * cz + sx * cy * sz; + dst[2] = cx * cy * sz - sx * sy * cz; + dst[3] = cx * cy * cz - sx * sy * sz; + break; + case 'zxy': + dst[0] = sx * cy * cz - cx * sy * sz; + dst[1] = cx * sy * cz + sx * cy * sz; + dst[2] = cx * cy * sz + sx * sy * cz; + dst[3] = cx * cy * cz - sx * sy * sz; + break; + case 'zyx': + dst[0] = sx * cy * cz - cx * sy * sz; + dst[1] = cx * sy * cz + sx * cy * sz; + dst[2] = cx * cy * sz - sx * sy * cz; + dst[3] = cx * cy * cz + sx * sy * sz; + break; + default: + throw new Error(`Unknown rotation order: ${order}`); + } + return dst; +} +/** + * Copies a quaternion. (same as {@link quat.clone}) + * Also see {@link quat.create} and {@link quat.set} + * @param q - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is a copy of q + */ +function copy$1(q, dst) { + dst = dst || new QuatType(4); + dst[0] = q[0]; + dst[1] = q[1]; + dst[2] = q[2]; + dst[3] = q[3]; + return dst; +} +/** + * Clones a quaternion. (same as {@link quat.copy}) + * Also see {@link quat.create} and {@link quat.set} + * @param q - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A copy of q. + */ +const clone$1 = copy$1; +/** + * Adds two quaternions; assumes a and b have the same dimension. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the sum of a and b. + */ +function add$1(a, b, dst) { + dst = dst || new QuatType(4); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + dst[2] = a[2] + b[2]; + dst[3] = a[3] + b[3]; + return dst; +} +/** + * Subtracts two quaternions. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the difference of a and b. + */ +function subtract$1(a, b, dst) { + dst = dst || new QuatType(4); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + dst[2] = a[2] - b[2]; + dst[3] = a[3] - b[3]; + return dst; +} +/** + * Subtracts two quaternions. + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns A quaternion that is the difference of a and b. + */ +const sub$1 = subtract$1; +/** + * Multiplies a quaternion by a scalar. + * @param v - The quaternion. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ +function mulScalar$1(v, k, dst) { + dst = dst || new QuatType(4); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + dst[2] = v[2] * k; + dst[3] = v[3] * k; + return dst; +} +/** + * Multiplies a quaternion by a scalar. (same as mulScalar) + * @param v - The quaternion. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ +const scale$1 = mulScalar$1; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The scaled quaternion. + */ +function divScalar$1(v, k, dst) { + dst = dst || new QuatType(4); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + dst[2] = v[2] / k; + dst[3] = v[3] / k; + return dst; +} +/** + * Computes the dot product of two quaternions + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns dot product + */ +function dot$1(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]); +} +/** + * Performs linear interpolation on two quaternions. + * Given quaternions a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @param t - Interpolation coefficient. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +function lerp$1(a, b, t, dst) { + dst = dst || new QuatType(4); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + dst[2] = a[2] + t * (b[2] - a[2]); + dst[3] = a[3] + t * (b[3] - a[3]); + return dst; +} +/** + * Computes the length of quaternion + * @param v - quaternion. + * @returns length of quaternion. + */ +function length$1(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); +} +/** + * Computes the length of quaternion (same as length) + * @param v - quaternion. + * @returns length of quaternion. + */ +const len$1 = length$1; +/** + * Computes the square of the length of quaternion + * @param v - quaternion. + * @returns square of the length of quaternion. + */ +function lengthSq$1(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3; +} +/** + * Computes the square of the length of quaternion (same as lengthSq) + * @param v - quaternion. + * @returns square of the length of quaternion. + */ +const lenSq$1 = lengthSq$1; +/** + * Divides a quaternion by its Euclidean length and returns the quotient. + * @param v - The quaternion. + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns The normalized quaternion. + */ +function normalize$1(v, dst) { + dst = dst || new QuatType(4); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + dst[2] = v2 / len; + dst[3] = v3 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + } + return dst; +} +/** + * Check if 2 quaternions are approximately equal + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns true if quaternions are approximately equal + */ +function equalsApproximately$1(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON && + Math.abs(a[3] - b[3]) < EPSILON; +} +/** + * Check if 2 quaternions are exactly equal + * @param a - Operand quaternion. + * @param b - Operand quaternion. + * @returns true if quaternions are exactly equal + */ +function equals$1(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} +/** + * Creates an identity quaternion + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns an identity quaternion + */ +function identity(dst) { + dst = dst || new QuatType(4); + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 1; + return dst; +} +let tempVec3; +let xUnitVec3; +let yUnitVec3; +/** + * Computes a quaternion to represent the shortest rotation from one vector to another. + * + * @param aUnit - the start vector + * @param bUnit - the end vector + * @param dst - quaternion to hold result. If not passed in a new one is created. + * @returns the result + */ +function rotationTo(aUnit, bUnit, dst) { + dst = dst || new QuatType(4); + tempVec3 = tempVec3 || create$4(); + xUnitVec3 = xUnitVec3 || create$4(1, 0, 0); + yUnitVec3 = yUnitVec3 || create$4(0, 1, 0); + const dot = dot$2(aUnit, bUnit); + if (dot < -0.999999) { + cross(xUnitVec3, aUnit, tempVec3); + if (len$2(tempVec3) < 0.000001) { + cross(yUnitVec3, aUnit, tempVec3); + } + normalize$2(tempVec3, tempVec3); + fromAxisAngle(tempVec3, Math.PI, dst); + return dst; + } + else if (dot > 0.999999) { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 1; + return dst; + } + else { + cross(aUnit, bUnit, tempVec3); + dst[0] = tempVec3[0]; + dst[1] = tempVec3[1]; + dst[2] = tempVec3[2]; + dst[3] = 1 + dot; + return normalize$1(dst, dst); + } +} +let tempQuat1; +let tempQuat2; +/** + * Performs a spherical linear interpolation with two control points + * + * @param a - the first quaternion + * @param b - the second quaternion + * @param c - the third quaternion + * @param d - the fourth quaternion + * @param t - Interpolation coefficient 0 to 1 + * @returns result + */ +function sqlerp(a, b, c, d, t, dst) { + dst = dst || new QuatType(4); + tempQuat1 = tempQuat1 || new QuatType(4); + tempQuat2 = tempQuat2 || new QuatType(4); + slerp(a, d, t, tempQuat1); + slerp(b, c, t, tempQuat2); + slerp(tempQuat1, tempQuat2, 2 * t * (1 - t), dst); + return dst; +} + +var quatImpl = { + __proto__: null, + add: add$1, + angle: angle, + clone: clone$1, + conjugate: conjugate, + copy: copy$1, + create: create$1, + divScalar: divScalar$1, + dot: dot$1, + equals: equals$1, + equalsApproximately: equalsApproximately$1, + fromAxisAngle: fromAxisAngle, + fromEuler: fromEuler, + fromMat: fromMat, + fromValues: fromValues$1, + identity: identity, + inverse: inverse$1, + len: len$1, + lenSq: lenSq$1, + length: length$1, + lengthSq: lengthSq$1, + lerp: lerp$1, + mul: mul$1, + mulScalar: mulScalar$1, + multiply: multiply$1, + normalize: normalize$1, + rotateX: rotateX, + rotateY: rotateY, + rotateZ: rotateZ, + rotationTo: rotationTo, + scale: scale$1, + set: set$1, + setDefaultType: setDefaultType$2, + slerp: slerp, + sqlerp: sqlerp, + sub: sub$1, + subtract: subtract$1, + toAxisAngle: toAxisAngle +}; + +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * + * Vec4 math functions. + * + * Almost all functions take an optional `dst` argument. If it is not passed in the + * functions will create a new `Vec4`. In other words you can do this + * + * const v = vec4.cross(v1, v2); // Creates a new Vec4 with the cross product of v1 x v2. + * + * or + * + * const v = vec4.create(); + * vec4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v + * + * The first style is often easier but depending on where it's used it generates garbage where + * as there is almost never allocation with the second style. + * + * It is always safe to pass any vector as the destination. So for example + * + * vec4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1 + * + */ +let VecType = Float32Array; +/** + * Sets the type this library creates for a Vec4 + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + * @returns previous constructor for Vec4 + */ +function setDefaultType$1(ctor) { + const oldType = VecType; + VecType = ctor; + return oldType; +} +/** + * Creates a vec4; may be called with x, y, z to set initial values. + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param w - Initial w value. + * @returns the created vector + */ +function create(x, y, z, w) { + const dst = new VecType(4); + if (x !== undefined) { + dst[0] = x; + if (y !== undefined) { + dst[1] = y; + if (z !== undefined) { + dst[2] = z; + if (w !== undefined) { + dst[3] = w; + } + } + } + } + return dst; +} + +/* + * Copyright 2022 Gregg Tavares + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/** + * Creates a vec4; may be called with x, y, z to set initial values. (same as create) + * @param x - Initial x value. + * @param y - Initial y value. + * @param z - Initial z value. + * @param z - Initial w value. + * @returns the created vector + */ +const fromValues = create; +/** + * Sets the values of a Vec4 + * Also see {@link vec4.create} and {@link vec4.copy} + * + * @param x first value + * @param y second value + * @param z third value + * @param w fourth value + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector with its elements set. + */ +function set(x, y, z, w, dst) { + dst = dst || new VecType(4); + dst[0] = x; + dst[1] = y; + dst[2] = z; + dst[3] = w; + return dst; +} +/** + * Applies Math.ceil to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the ceil of each element of v. + */ +function ceil(v, dst) { + dst = dst || new VecType(4); + dst[0] = Math.ceil(v[0]); + dst[1] = Math.ceil(v[1]); + dst[2] = Math.ceil(v[2]); + dst[3] = Math.ceil(v[3]); + return dst; +} +/** + * Applies Math.floor to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the floor of each element of v. + */ +function floor(v, dst) { + dst = dst || new VecType(4); + dst[0] = Math.floor(v[0]); + dst[1] = Math.floor(v[1]); + dst[2] = Math.floor(v[2]); + dst[3] = Math.floor(v[3]); + return dst; +} +/** + * Applies Math.round to each element of vector + * @param v - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the round of each element of v. + */ +function round(v, dst) { + dst = dst || new VecType(4); + dst[0] = Math.round(v[0]); + dst[1] = Math.round(v[1]); + dst[2] = Math.round(v[2]); + dst[3] = Math.round(v[3]); + return dst; +} +/** + * Clamp each element of vector between min and max + * @param v - Operand vector. + * @param max - Min value, default 0 + * @param min - Max value, default 1 + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that the clamped value of each element of v. + */ +function clamp(v, min = 0, max = 1, dst) { + dst = dst || new VecType(4); + dst[0] = Math.min(max, Math.max(min, v[0])); + dst[1] = Math.min(max, Math.max(min, v[1])); + dst[2] = Math.min(max, Math.max(min, v[2])); + dst[3] = Math.min(max, Math.max(min, v[3])); + return dst; +} +/** + * Adds two vectors; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a and b. + */ +function add(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + b[0]; + dst[1] = a[1] + b[1]; + dst[2] = a[2] + b[2]; + dst[3] = a[3] + b[3]; + return dst; +} +/** + * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension. + * @param a - Operand vector. + * @param b - Operand vector. + * @param scale - Amount to scale b + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the sum of a + b * scale. + */ +function addScaled(a, b, scale, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + b[0] * scale; + dst[1] = a[1] + b[1] * scale; + dst[2] = a[2] + b[2] * scale; + dst[3] = a[3] + b[3] * scale; + return dst; +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +function subtract(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] - b[0]; + dst[1] = a[1] - b[1]; + dst[2] = a[2] - b[2]; + dst[3] = a[3] - b[3]; + return dst; +} +/** + * Subtracts two vectors. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A vector that is the difference of a and b. + */ +const sub = subtract; +/** + * Check if 2 vectors are approximately equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are approximately equal + */ +function equalsApproximately(a, b) { + return Math.abs(a[0] - b[0]) < EPSILON && + Math.abs(a[1] - b[1]) < EPSILON && + Math.abs(a[2] - b[2]) < EPSILON && + Math.abs(a[3] - b[3]) < EPSILON; +} +/** + * Check if 2 vectors are exactly equal + * @param a - Operand vector. + * @param b - Operand vector. + * @returns true if vectors are exactly equal + */ +function equals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficient. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The linear interpolated result. + */ +function lerp(a, b, t, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + t * (b[0] - a[0]); + dst[1] = a[1] + t * (b[1] - a[1]); + dst[2] = a[2] + t * (b[2] - a[2]); + dst[3] = a[3] + t * (b[3] - a[3]); + return dst; +} +/** + * Performs linear interpolation on two vectors. + * Given vectors a and b and interpolation coefficient vector t, returns + * a + t * (b - a). + * @param a - Operand vector. + * @param b - Operand vector. + * @param t - Interpolation coefficients vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns the linear interpolated result. + */ +function lerpV(a, b, t, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] + t[0] * (b[0] - a[0]); + dst[1] = a[1] + t[1] * (b[1] - a[1]); + dst[2] = a[2] + t[2] * (b[2] - a[2]); + dst[3] = a[3] + t[3] * (b[3] - a[3]); + return dst; +} +/** + * Return max values of two vectors. + * Given vectors a and b returns + * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The max components vector. + */ +function max(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = Math.max(a[0], b[0]); + dst[1] = Math.max(a[1], b[1]); + dst[2] = Math.max(a[2], b[2]); + dst[3] = Math.max(a[3], b[3]); + return dst; +} +/** + * Return min values of two vectors. + * Given vectors a and b returns + * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])]. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The min components vector. + */ +function min(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = Math.min(a[0], b[0]); + dst[1] = Math.min(a[1], b[1]); + dst[2] = Math.min(a[2], b[2]); + dst[3] = Math.min(a[3], b[3]); + return dst; +} +/** + * Multiplies a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +function mulScalar(v, k, dst) { + dst = dst || new VecType(4); + dst[0] = v[0] * k; + dst[1] = v[1] * k; + dst[2] = v[2] * k; + dst[3] = v[3] * k; + return dst; +} +/** + * Multiplies a vector by a scalar. (same as mulScalar) + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +const scale = mulScalar; +/** + * Divides a vector by a scalar. + * @param v - The vector. + * @param k - The scalar. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The scaled vector. + */ +function divScalar(v, k, dst) { + dst = dst || new VecType(4); + dst[0] = v[0] / k; + dst[1] = v[1] / k; + dst[2] = v[2] / k; + dst[3] = v[3] / k; + return dst; +} +/** + * Inverse a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +function inverse(v, dst) { + dst = dst || new VecType(4); + dst[0] = 1 / v[0]; + dst[1] = 1 / v[1]; + dst[2] = 1 / v[2]; + dst[3] = 1 / v[3]; + return dst; +} +/** + * Invert a vector. (same as inverse) + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The inverted vector. + */ +const invert = inverse; +/** + * Computes the dot product of two vectors + * @param a - Operand vector. + * @param b - Operand vector. + * @returns dot product + */ +function dot(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]); +} +/** + * Computes the length of vector + * @param v - vector. + * @returns length of vector. + */ +function length(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); +} +/** + * Computes the length of vector (same as length) + * @param v - vector. + * @returns length of vector. + */ +const len = length; +/** + * Computes the square of the length of vector + * @param v - vector. + * @returns square of the length of vector. + */ +function lengthSq(v) { + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3; +} +/** + * Computes the square of the length of vector (same as lengthSq) + * @param v - vector. + * @returns square of the length of vector. + */ +const lenSq = lengthSq; +/** + * Computes the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +function distance(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + const dw = a[3] - b[3]; + return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); +} +/** + * Computes the distance between 2 points (same as distance) + * @param a - vector. + * @param b - vector. + * @returns distance between a and b + */ +const dist = distance; +/** + * Computes the square of the distance between 2 points + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +function distanceSq(a, b) { + const dx = a[0] - b[0]; + const dy = a[1] - b[1]; + const dz = a[2] - b[2]; + const dw = a[3] - b[3]; + return dx * dx + dy * dy + dz * dz + dw * dw; +} +/** + * Computes the square of the distance between 2 points (same as distanceSq) + * @param a - vector. + * @param b - vector. + * @returns square of the distance between a and b + */ +const distSq = distanceSq; +/** + * Divides a vector by its Euclidean length and returns the quotient. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The normalized vector. + */ +function normalize(v, dst) { + dst = dst || new VecType(4); + const v0 = v[0]; + const v1 = v[1]; + const v2 = v[2]; + const v3 = v[3]; + const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3); + if (len > 0.00001) { + dst[0] = v0 / len; + dst[1] = v1 / len; + dst[2] = v2 / len; + dst[3] = v3 / len; + } + else { + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + } + return dst; +} +/** + * Negates a vector. + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns -v. + */ +function negate(v, dst) { + dst = dst || new VecType(4); + dst[0] = -v[0]; + dst[1] = -v[1]; + dst[2] = -v[2]; + dst[3] = -v[3]; + return dst; +} +/** + * Copies a vector. (same as {@link vec4.clone}) + * Also see {@link vec4.create} and {@link vec4.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +function copy(v, dst) { + dst = dst || new VecType(4); + dst[0] = v[0]; + dst[1] = v[1]; + dst[2] = v[2]; + dst[3] = v[3]; + return dst; +} +/** + * Clones a vector. (same as {@link vec4.copy}) + * Also see {@link vec4.create} and {@link vec4.set} + * @param v - The vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns A copy of v. + */ +const clone = copy; +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +function multiply(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + dst[2] = a[2] * b[2]; + dst[3] = a[3] * b[3]; + return dst; +} +/** + * Multiplies a vector by another vector (component-wise); assumes a and + * b have the same length. (same as mul) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of products of entries of a and b. + */ +const mul = multiply; +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +function divide(a, b, dst) { + dst = dst || new VecType(4); + dst[0] = a[0] / b[0]; + dst[1] = a[1] / b[1]; + dst[2] = a[2] / b[2]; + dst[3] = a[3] / b[3]; + return dst; +} +/** + * Divides a vector by another vector (component-wise); assumes a and + * b have the same length. (same as divide) + * @param a - Operand vector. + * @param b - Operand vector. + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The vector of quotients of entries of a and b. + */ +const div = divide; +/** + * Zero's a vector + * @param dst - vector to hold result. If not passed in a new one is created. + * @returns The zeroed vector. + */ +function zero(dst) { + dst = dst || new VecType(4); + dst[0] = 0; + dst[1] = 0; + dst[2] = 0; + dst[3] = 0; + return dst; +} +/** + * transform vec4 by 4x4 matrix + * @param v - the vector + * @param m - The matrix. + * @param dst - optional vec4 to store result. If not passed a new one is created. + * @returns the transformed vector + */ +function transformMat4(v, m, dst) { + dst = dst || new VecType(4); + const x = v[0]; + const y = v[1]; + const z = v[2]; + const w = v[3]; + dst[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + dst[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + dst[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + dst[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + return dst; +} +/** + * Treat a 4D vector as a direction and set it's length + * + * @param a The vec4 to lengthen + * @param len The length of the resulting vector + * @returns The lengthened vector + */ +function setLength(a, len, dst) { + dst = dst || new VecType(4); + normalize(a, dst); + return mulScalar(dst, len, dst); +} +/** + * Ensure a vector is not longer than a max length + * + * @param a The vec4 to limit + * @param maxLen The longest length of the resulting vector + * @returns The vector, shortened to maxLen if it's too long + */ +function truncate(a, maxLen, dst) { + dst = dst || new VecType(4); + if (length(a) > maxLen) { + return setLength(a, maxLen, dst); + } + return copy(a, dst); +} +/** + * Return the vector exactly between 2 endpoint vectors + * + * @param a Endpoint 1 + * @param b Endpoint 2 + * @returns The vector exactly residing between endpoints 1 and 2 + */ +function midpoint(a, b, dst) { + dst = dst || new VecType(4); + return lerp(a, b, 0.5, dst); +} + +var vec4Impl = { + __proto__: null, + add: add, + addScaled: addScaled, + ceil: ceil, + clamp: clamp, + clone: clone, + copy: copy, + create: create, + dist: dist, + distSq: distSq, + distance: distance, + distanceSq: distanceSq, + div: div, + divScalar: divScalar, + divide: divide, + dot: dot, + equals: equals, + equalsApproximately: equalsApproximately, + floor: floor, + fromValues: fromValues, + inverse: inverse, + invert: invert, + len: len, + lenSq: lenSq, + length: length, + lengthSq: lengthSq, + lerp: lerp, + lerpV: lerpV, + max: max, + midpoint: midpoint, + min: min, + mul: mul, + mulScalar: mulScalar, + multiply: multiply, + negate: negate, + normalize: normalize, + round: round, + scale: scale, + set: set, + setDefaultType: setDefaultType$1, + setLength: setLength, + sub: sub, + subtract: subtract, + transformMat4: transformMat4, + truncate: truncate, + zero: zero +}; + +/** + * Sets the type this library creates for all types + * + * example: + * + * ``` + * setDefaultType(Float64Array); + * ``` + * + * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array` + */ +function setDefaultType(ctor) { + setDefaultType$4(ctor); + setDefaultType$3(ctor); + setDefaultType$2(ctor); + setDefaultType$6(ctor); + setDefaultType$5(ctor); + setDefaultType$1(ctor); +} + +export { mat3Impl as mat3, mat4Impl as mat4, quatImpl as quat, setDefaultType, utils, vec2Impl as vec2, vec3Impl as vec3, vec4Impl as vec4 }; +//# sourceMappingURL=wgpu-matrix.module.js.map diff --git a/dist/2.x/wgpu-matrix.module.js.map b/dist/2.x/wgpu-matrix.module.js.map new file mode 100644 index 0000000..ead4068 --- /dev/null +++ b/dist/2.x/wgpu-matrix.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wgpu-matrix.module.js","sources":["../../../src/utils.ts","../../../src/vec2.ts","../../../src/vec3.ts","../../../src/vec2-impl.ts","../../../src/mat3-impl.ts","../../../src/vec3-impl.ts","../../../src/mat4-impl.ts","../../../src/quat.ts","../../../src/quat-impl.ts","../../../src/vec4.ts","../../../src/vec4-impl.ts","../../../src/wgpu-matrix.ts"],"sourcesContent":["/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nexport let EPSILON = 0.000001;\n\n/**\n * Set the value for EPSILON for various checks\n * @param v - Value to use for EPSILON.\n * @returns previous value of EPSILON;\n */\nexport function setEpsilon(v: number): number {\n const old = EPSILON;\n EPSILON = v;\n return old;\n}\n\n/**\n * Convert degrees to radians\n * @param degrees - Angle in degrees\n * @returns angle converted to radians\n */\nexport function degToRad(degrees: number): number {\n return degrees * Math.PI / 180;\n}\n\n/**\n * Convert radians to degrees\n * @param radians - Angle in radians\n * @returns angle converted to degrees\n */\nexport function radToDeg(radians: number): number {\n return radians * 180 / Math.PI;\n}\n\n/**\n * Lerps between a and b via t\n * @param a - starting value\n * @param b - ending value\n * @param t - value where 0 = a and 1 = b\n * @returns a + (b - a) * t\n */\nexport function lerp(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\n/**\n * Compute the opposite of lerp. Given a and b and a value between\n * a and b returns a value between 0 and 1. 0 if a, 1 if b.\n * Note: no clamping is done.\n * @param a - start value\n * @param b - end value\n * @param v - value between a and b\n * @returns (v - a) / (b - a)\n */\nexport function inverseLerp(a: number, b: number, v: number): number {\n const d = b - a;\n return (Math.abs(b - a) < EPSILON)\n ? a\n : (v - a) / d;\n}\n\n/**\n * Compute the euclidean modulo\n *\n * ```\n * // table for n / 3\n * -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 <- n\n * ------------------------------------\n * -2 -1 -0 -2 -1 0, 1, 2, 0, 1, 2 <- n % 3\n * 1 2 0 1 2 0, 1, 2, 0, 1, 2 <- euclideanModule(n, 3)\n * ```\n *\n * @param n - dividend\n * @param m - divisor\n * @returns the euclidean modulo of n / m\n */\nexport function euclideanModulo(n: number, m: number) {\n return ((n % m) + m) % m;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 2 values, Float32Array with 2 values, or a Float64Array with 2 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec2.setDefaultType}.\n */\nexport type Vec2 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec2 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new Vec2. In other words you can do this\n *\n * const v = vec2.cross(v1, v2); // Creates a new Vec2 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec2.create();\n * vec2.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec2.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec2 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec2\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec2\n */\nexport function setDefaultType(ctor: new (n: number) => Vec2) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a Vec2; may be called with x, y, z to set initial values.\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Vec2's specified type\n * it would be faster to use\n *\n * ```\n * const v = vec2.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Vec2Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `vec2.create` is usually used\n * to create a Vec2 to be filled out as in\n *\n * ```\n * const sum = vec2.create();\n * vec2.add(v1, v2, sum);\n * ```\n *\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @returns the created vector\n */\nexport function create(x = 0, y = 0): Vec2 {\n const dst = new VecType(2);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n }\n }\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 3 values, Float32Array with 3 values, or a Float64Array with 3 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec3.setDefaultType}.\n */\nexport type Vec3 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec3 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Vec3`. In other words you can do this\n *\n * const v = vec3.cross(v1, v2); // Creates a new Vec3 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec3.create();\n * vec3.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec3.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec3 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec3\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec3\n */\nexport function setDefaultType(ctor: new (n: number) => Vec3) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a vec3; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number): Vec3 {\n const dst = new VecType(3);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Vec2, create, setDefaultType, VecType } from './vec2';\nimport { Vec3, VecType as Vec3Type } from './vec3';\n\nexport default Vec2;\nexport { create, setDefaultType };\n\n/**\n * Creates a Vec2; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec2\n * Also see {@link vec2.create} and {@link vec2.copy}\n *\n * @param x first value\n * @param y second value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = x;\n dst[1] = y;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec2, min = 0, max = 1, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec2, b: Vec2, scale: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n\n return dst;\n}\n\n/**\n * Returns the angle in radians between two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns The angle in radians between the 2 vectors.\n */\nexport function angle(a: Vec2, b: Vec2): number {\n const ax = a[0];\n const ay = a[1];\n const bx = b[0];\n const by = b[1];\n const mag1 = Math.sqrt(ax * ax + ay * ay);\n const mag2 = Math.sqrt(bx * bx + by * by);\n const mag = mag1 * mag2;\n const cosine = mag && dot(a, b) / mag;\n return Math.acos(cosine);\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec2, b: Vec2): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec2, b: Vec2): boolean {\n return a[0] === b[0] && a[1] === b[1];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec2, b: Vec2, t: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec2, b: Vec2, t: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec2, k: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec2, k: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the cross product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of a cross b.\n */\nexport function cross(a: Vec2, b: Vec2, dst?: Vec3): Vec3 {\n dst = dst || new Vec3Type(3);\n const z = a[0] * b[1] - a[1] * b[0];\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = z;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec2, b: Vec2): number {\n return a[0] * b[0] + a[1] * b[1];\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec2): number {\n const v0 = v[0];\n const v1 = v[1];\n return Math.sqrt(v0 * v0 + v1 * v1);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec2): number {\n const v0 = v[0];\n const v1 = v[1];\n return v0 * v0 + v1 * v1;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec2, b: Vec2): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n return Math.sqrt(dx * dx + dy * dy);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec2, b: Vec2): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n return dx * dx + dy * dy;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const v0 = v[0];\n const v1 = v[1];\n const len = Math.sqrt(v0 * v0 + v1 * v1);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n }\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec2.clone})\n * Also see {@link vec2.create} and {@link vec2.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0];\n dst[1] = v[1];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec2.copy})\n * Also see {@link vec2.create} and {@link vec2.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec2, b: Vec2, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Creates a random unit vector * scale\n * @param scale - Default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The random vector.\n */\nexport function random(scale = 1, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const angle = Math.random() * 2 * Math.PI;\n dst[0] = Math.cos(angle) * scale;\n dst[1] = Math.sin(angle) * scale;\n\n return dst;\n}\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = 0;\n dst[1] = 0;\n\n return dst;\n}\n\n\n/**\n * transform Vec2 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional Vec2 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec2, m: Mat4, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const x = v[0];\n const y = v[1];\n\n dst[0] = x * m[0] + y * m[4] + m[12];\n dst[1] = x * m[1] + y * m[5] + m[13];\n\n return dst;\n}\n\n/**\n * Transforms vec4 by 3x3 matrix\n *\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional Vec2 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat3(v: Vec2, m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const x = v[0];\n const y = v[1];\n\n dst[0] = m[0] * x + m[4] * y + m[8];\n dst[1] = m[1] * x + m[5] * y + m[9];\n\n return dst;\n}\n\n/**\n * Rotate a 2D vector\n *\n * @param a The vec2 point to rotate\n * @param b The origin of the rotation\n * @param rad The angle of rotation in radians\n * @returns the rotated vector\n */\nexport function rotate(a: Vec2, b: Vec2, rad: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n // Translate point to the origin\n const p0 = a[0] - b[0];\n const p1 = a[1] - b[1];\n const sinC = Math.sin(rad);\n const cosC = Math.cos(rad);\n\n //perform rotation and translate to correct position\n dst[0] = p0 * cosC - p1 * sinC + b[0];\n dst[1] = p0 * sinC + p1 * cosC + b[1];\n\n return dst;\n}\n\n/**\n * Treat a 2D vector as a direction and set it's length\n *\n * @param a The vec2 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec2, len: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec2 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec2, maxLen: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec2, b: Vec2, dst?: Vec2) {\n dst = dst || new VecType(2);\n return lerp(a, b, 0.5, dst);\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nimport * as utils from './utils.js';\nimport { Quat } from './quat';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport Vec2, * as vec2 from './vec2-impl';\n\nexport default Mat3;\n\nexport type Mat3LikeCtor = new (n: number) => Mat3;\n\n/**\n * 3x3 Matrix math math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new matrix. In other words you can do this\n *\n * const mat = mat3.translation([1, 2, 3]); // Creates a new translation matrix\n *\n * or\n *\n * const mat = mat3.create();\n * mat3.translation([1, 2, 3], mat); // Puts translation matrix in mat.\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always save to pass any matrix as the destination. So for example\n *\n * const mat = mat3.identity();\n * const trans = mat3.translation([1, 2, 3]);\n * mat3.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat.\n *\n */\nlet MatType: Mat3LikeCtor = Float32Array;\n\n// This mess is because with Mat3 we have 3 unused elements.\n// For Float32Array and Float64Array that's not an issue\n// but for Array it's troublesome\nconst ctorMap = new Map Mat3>([\n [Float32Array, () => new Float32Array(12)],\n [Float64Array, () => new Float64Array(12)],\n [Array, () => new Array(12).fill(0)],\n]);\nlet newMat3: () => Mat3 = ctorMap.get(Float32Array)!;\n\n/**\n * Sets the type this library creates for a Mat3\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Mat3\n */\nexport function setDefaultType(ctor: new (n: number) => Mat3) {\n const oldType = MatType;\n MatType = ctor;\n newMat3 = ctorMap.get(ctor)!;\n return oldType;\n}\n\n/**\n * Create a Mat3 from values\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Mat3's specified type\n * it would be faster to use\n *\n * ```\n * const m = mat3.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Mat3Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `mat3.create` is usually used\n * to create a Mat3 to be filled out as in\n *\n * ```\n * const m = mat3.create();\n * mat3.perspective(fov, aspect, near, far, m);\n * ```\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @returns matrix created from values.\n */\nexport function create(\n v0?: number, v1?: number, v2?: number,\n v3?: number, v4?: number, v5?: number,\n v6?: number, v7?: number, v8?: number): Mat3 {\n const dst = newMat3();\n // to make the array homogenous\n dst[3] = 0;\n dst[7] = 0;\n dst[11] = 0;\n\n if (v0 !== undefined) {\n dst[0] = v0;\n if (v1 !== undefined) {\n dst[1] = v1;\n if (v2 !== undefined) {\n dst[2] = v2;\n if (v3 !== undefined) {\n dst[4] = v3;\n if (v4 !== undefined) {\n dst[5] = v4;\n if (v5 !== undefined) {\n dst[6] = v5;\n if (v6 !== undefined) {\n dst[8] = v6;\n if (v7 !== undefined) {\n dst[9] = v7;\n if (v8 !== undefined) {\n dst[10] = v8;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n return dst;\n}\n\n/**\n * Sets the values of a Mat3\n * Also see {@link mat3.create} and {@link mat3.copy}\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 set from values.\n */\nexport function set(\n v0: number, v1: number, v2: number,\n v3: number, v4: number, v5: number,\n v6: number, v7: number, v8: number, dst?: Mat3) {\n dst = dst || newMat3();\n\n dst[0] = v0; dst[1] = v1; dst[ 2] = v2; dst[ 3] = 0;\n dst[4] = v3; dst[5] = v4; dst[ 6] = v5; dst[ 7] = 0;\n dst[8] = v6; dst[9] = v7; dst[10] = v8; dst[11] = 0;\n\n return dst;\n}\n\n/**\n * Creates a Mat3 from the upper left 3x3 part of a Mat4\n * @param m4 - source matrix\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 made from m4\n */\nexport function fromMat4(m4: Mat4, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n dst[0] = m4[0]; dst[1] = m4[1]; dst[ 2] = m4[ 2]; dst[ 3] = 0;\n dst[4] = m4[4]; dst[5] = m4[5]; dst[ 6] = m4[ 6]; dst[ 7] = 0;\n dst[8] = m4[8]; dst[9] = m4[9]; dst[10] = m4[10]; dst[11] = 0;\n return dst;\n}\n\n/**\n * Creates a Mat3 rotation matrix from a quaternion\n * @param q - quaternion to create matrix from\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 made from q\n */\nexport function fromQuat(q: Quat, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3];\n const x2 = x + x; const y2 = y + y; const z2 = z + z;\n\n const xx = x * x2;\n const yx = y * x2;\n const yy = y * y2;\n const zx = z * x2;\n const zy = z * y2;\n const zz = z * z2;\n const wx = w * x2;\n const wy = w * y2;\n const wz = w * z2;\n\n dst[ 0] = 1 - yy - zz; dst[ 1] = yx + wz; dst[ 2] = zx - wy; dst[ 3] = 0;\n dst[ 4] = yx - wz; dst[ 5] = 1 - xx - zz; dst[ 6] = zy + wx; dst[ 7] = 0;\n dst[ 8] = zx + wy; dst[ 9] = zy - wx; dst[10] = 1 - xx - yy; dst[11] = 0;\n\n return dst;\n}\n\n/**\n * Negates a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns -m.\n */\nexport function negate(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = -m[ 0]; dst[ 1] = -m[ 1]; dst[ 2] = -m[ 2];\n dst[ 4] = -m[ 4]; dst[ 5] = -m[ 5]; dst[ 6] = -m[ 6];\n dst[ 8] = -m[ 8]; dst[ 9] = -m[ 9]; dst[10] = -m[10];\n\n return dst;\n}\n\n/**\n * Copies a matrix. (same as {@link mat3.clone})\n * Also see {@link mat3.create} and {@link mat3.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport function copy(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = m[ 0]; dst[ 1] = m[ 1]; dst[ 2] = m[ 2];\n dst[ 4] = m[ 4]; dst[ 5] = m[ 5]; dst[ 6] = m[ 6];\n dst[ 8] = m[ 8]; dst[ 9] = m[ 9]; dst[10] = m[10];\n\n return dst;\n}\n\n/**\n * Copies a matrix (same as {@link mat3.copy})\n * Also see {@link mat3.create} and {@link mat3.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport const clone = copy;\n\n/**\n * Check if 2 matrices are approximately equal\n * @param a Operand matrix.\n * @param b Operand matrix.\n * @returns true if matrices are approximately equal\n */\nexport function equalsApproximately(a: Mat3, b: Mat3): boolean {\n return Math.abs(a[ 0] - b[ 0]) < utils.EPSILON &&\n Math.abs(a[ 1] - b[ 1]) < utils.EPSILON &&\n Math.abs(a[ 2] - b[ 2]) < utils.EPSILON &&\n Math.abs(a[ 4] - b[ 4]) < utils.EPSILON &&\n Math.abs(a[ 5] - b[ 5]) < utils.EPSILON &&\n Math.abs(a[ 6] - b[ 6]) < utils.EPSILON &&\n Math.abs(a[ 8] - b[ 8]) < utils.EPSILON &&\n Math.abs(a[ 9] - b[ 9]) < utils.EPSILON &&\n Math.abs(a[10] - b[10]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 matrices are exactly equal\n * @param a Operand matrix.\n * @param b Operand matrix.\n * @returns true if matrices are exactly equal\n */\nexport function equals(a: Mat3, b: Mat3): boolean {\n return a[ 0] === b[ 0] &&\n a[ 1] === b[ 1] &&\n a[ 2] === b[ 2] &&\n a[ 4] === b[ 4] &&\n a[ 5] === b[ 5] &&\n a[ 6] === b[ 6] &&\n a[ 8] === b[ 8] &&\n a[ 9] === b[ 9] &&\n a[10] === b[10];\n}\n\n/**\n * Creates a 3-by-3 identity matrix.\n *\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A 3-by-3 identity matrix.\n */\nexport function identity(dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Takes the transpose of a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The transpose of m.\n */\nexport function transpose(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n if (dst === m) {\n let t: number;\n\n // 0 1 2\n // 4 5 6\n // 8 9 10\n\n t = m[1];\n m[1] = m[4];\n m[4] = t;\n\n t = m[2];\n m[2] = m[8];\n m[8] = t;\n\n t = m[6];\n m[6] = m[9];\n m[9] = t;\n\n return dst;\n }\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n dst[ 0] = m00; dst[ 1] = m10; dst[ 2] = m20;\n dst[ 4] = m01; dst[ 5] = m11; dst[ 6] = m21;\n dst[ 8] = m02; dst[ 9] = m12; dst[10] = m22;\n\n return dst;\n}\n\n/**\n * Computes the inverse of a 3-by-3 matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport function inverse(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n const b01 = m22 * m11 - m12 * m21;\n const b11 = -m22 * m10 + m12 * m20;\n const b21 = m21 * m10 - m11 * m20;\n\n const invDet = 1 / (m00 * b01 + m01 * b11 + m02 * b21);\n\n dst[ 0] = b01 * invDet;\n dst[ 1] = (-m22 * m01 + m02 * m21) * invDet;\n dst[ 2] = ( m12 * m01 - m02 * m11) * invDet;\n dst[ 4] = b11 * invDet;\n dst[ 5] = ( m22 * m00 - m02 * m20) * invDet;\n dst[ 6] = (-m12 * m00 + m02 * m10) * invDet;\n dst[ 8] = b21 * invDet;\n dst[ 9] = (-m21 * m00 + m01 * m20) * invDet;\n dst[10] = ( m11 * m00 - m01 * m10) * invDet;\n\n return dst;\n}\n\n/**\n * Compute the determinant of a matrix\n * @param m - the matrix\n * @returns the determinant\n */\nexport function determinant(m: Mat3): number {\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n return m00 * (m11 * m22 - m21 * m12) -\n m10 * (m01 * m22 - m21 * m02) +\n m20 * (m01 * m12 - m11 * m02);\n}\n\n/**\n * Computes the inverse of a 3-by-3 matrix. (same as inverse)\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport const invert = inverse;\n\n/**\n * Multiplies two 3-by-3 matrices with a on the left and b on the right\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport function multiply(a: Mat3, b: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const a00 = a[0];\n const a01 = a[1];\n const a02 = a[2];\n const a10 = a[ 4 + 0];\n const a11 = a[ 4 + 1];\n const a12 = a[ 4 + 2];\n const a20 = a[ 8 + 0];\n const a21 = a[ 8 + 1];\n const a22 = a[ 8 + 2];\n const b00 = b[0];\n const b01 = b[1];\n const b02 = b[2];\n const b10 = b[ 4 + 0];\n const b11 = b[ 4 + 1];\n const b12 = b[ 4 + 2];\n const b20 = b[ 8 + 0];\n const b21 = b[ 8 + 1];\n const b22 = b[ 8 + 2];\n\n dst[ 0] = a00 * b00 + a10 * b01 + a20 * b02;\n dst[ 1] = a01 * b00 + a11 * b01 + a21 * b02;\n dst[ 2] = a02 * b00 + a12 * b01 + a22 * b02;\n dst[ 4] = a00 * b10 + a10 * b11 + a20 * b12;\n dst[ 5] = a01 * b10 + a11 * b11 + a21 * b12;\n dst[ 6] = a02 * b10 + a12 * b11 + a22 * b12;\n dst[ 8] = a00 * b20 + a10 * b21 + a20 * b22;\n dst[ 9] = a01 * b20 + a11 * b21 + a21 * b22;\n dst[10] = a02 * b20 + a12 * b21 + a22 * b22;\n\n return dst;\n}\n\n/**\n * Multiplies two 3-by-3 matrices with a on the left and b on the right (same as multiply)\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Sets the translation component of a 3-by-3 matrix to the given\n * vector.\n * @param a - The matrix.\n * @param v - The vector.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix with translation set.\n */\nexport function setTranslation(a: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || identity();\n if (a !== dst) {\n dst[ 0] = a[ 0];\n dst[ 1] = a[ 1];\n dst[ 2] = a[ 2];\n dst[ 4] = a[ 4];\n dst[ 5] = a[ 5];\n dst[ 6] = a[ 6];\n }\n dst[ 8] = v[0];\n dst[ 9] = v[1];\n dst[10] = 1;\n return dst;\n}\n\n/**\n * Returns the translation component of a 3-by-3 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n dst[0] = m[8];\n dst[1] = m[9];\n return dst;\n}\n\n/**\n * Returns an axis of a 3x3 matrix as a vector with 2 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y,\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat3, axis: number, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n return dst;\n}\n\n/**\n * Sets an axis of a 3x3 matrix as a vector with 2 entries\n * @param m - The matrix.\n * @param v - the axis vector\n * @param axis - The axis 0 = x, 1 = y;\n * @param dst - The matrix to set. If not passed a new one is created.\n * @returns The matrix with axis set.\n */\nexport function setAxis(m: Mat3, v: Vec2, axis: number, dst?: Mat3): Mat3 {\n if (dst !== m) {\n dst = copy(m, dst);\n }\n const off = axis * 4;\n dst[off + 0] = v[0];\n dst[off + 1] = v[1];\n return dst;\n}\n\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n\n const xx = m[0];\n const xy = m[1];\n const yx = m[4];\n const yy = m[5];\n\n dst[0] = Math.sqrt(xx * xx + xy * xy);\n dst[1] = Math.sqrt(yx * yx + yy * yy);\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which translates by the given vector v.\n * @param v - The vector by which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translation matrix.\n */\nexport function translation(v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0;\n dst[ 8] = v[0]; dst[ 9] = v[1]; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Translates the given 3-by-3 matrix by the given vector v.\n * @param m - The matrix.\n * @param v - The vector by which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translated matrix.\n */\nexport function translate(m: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const v0 = v[0];\n const v1 = v[1];\n\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n if (m !== dst) {\n dst[ 0] = m00;\n dst[ 1] = m01;\n dst[ 2] = m02;\n dst[ 4] = m10;\n dst[ 5] = m11;\n dst[ 6] = m12;\n }\n\n dst[ 8] = m00 * v0 + m10 * v1 + m20;\n dst[ 9] = m01 * v0 + m11 * v1 + m21;\n dst[10] = m02 * v0 + m12 * v1 + m22;\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which rotates by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotation(angleInRadians: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = s; dst[ 2] = 0;\n dst[ 4] = -s; dst[ 5] = c; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 3-by-3 matrix by the given angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotate(m: Mat3, angleInRadians: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 + s * m10;\n dst[ 1] = c * m01 + s * m11;\n dst[ 2] = c * m02 + s * m12;\n\n dst[ 4] = c * m10 - s * m00;\n dst[ 5] = c * m11 - s * m01;\n dst[ 6] = c * m12 - s * m02;\n\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which scales in each dimension by an amount given by\n * the corresponding entry in the given vector; assumes the vector has three\n * entries.\n * @param v - A vector of\n * 2 entries specifying the factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function scaling(v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = v[0]; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = v[1]; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 3-by-3 matrix in each dimension by an amount\n * given by the corresponding entry in the given vector; assumes the vector has\n * three entries.\n * @param m - The matrix to be modified.\n * @param v - A vector of 2 entries specifying the\n * factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function scale(m: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const v0 = v[0];\n const v1 = v[1];\n\n dst[ 0] = v0 * m[0 * 4 + 0];\n dst[ 1] = v0 * m[0 * 4 + 1];\n dst[ 2] = v0 * m[0 * 4 + 2];\n\n dst[ 4] = v1 * m[1 * 4 + 0];\n dst[ 5] = v1 * m[1 * 4 + 1];\n dst[ 6] = v1 * m[1 * 4 + 2];\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which scales uniformly in each dimension\n * @param s - Amount to scale\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function uniformScaling(s: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = s; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = s; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 3-by-3 matrix in each dimension by an amount\n * given.\n * @param m - The matrix to be modified.\n * @param s - Amount to scale.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function uniformScale(m: Mat3, s: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = s * m[0 * 4 + 0];\n dst[ 1] = s * m[0 * 4 + 1];\n dst[ 2] = s * m[0 * 4 + 2];\n\n dst[ 4] = s * m[1 * 4 + 0];\n dst[ 5] = s * m[1 * 4 + 1];\n dst[ 6] = s * m[1 * 4 + 2];\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Vec3, create, setDefaultType, VecType } from './vec3';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Quat } from './quat';\n\nexport default Vec3;\nexport { create, setDefaultType };\n\n/**\n * Creates a vec3; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec3\n * Also see {@link vec3.create} and {@link vec3.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n dst[2] = Math.ceil(v[2]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n dst[2] = Math.floor(v[2]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n dst[2] = Math.round(v[2]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec3, min = 0, max = 1, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n dst[2] = Math.min(max, Math.max(min, v[2]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec3, b: Vec3, scale: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n dst[2] = a[2] + b[2] * scale;\n\n return dst;\n}\n\n/**\n * Returns the angle in radians between two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns The angle in radians between the 2 vectors.\n */\nexport function angle(a: Vec3, b: Vec3): number {\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const bx = b[0];\n const by = b[1];\n const bz = b[2];\n const mag1 = Math.sqrt(ax * ax + ay * ay + az * az);\n const mag2 = Math.sqrt(bx * bx + by * by + bz * bz);\n const mag = mag1 * mag2;\n const cosine = mag && dot(a, b) / mag;\n return Math.acos(cosine);\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec3, b: Vec3): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec3, b: Vec3): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec3, b: Vec3, t: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec3, b: Vec3, t: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n dst[2] = a[2] + t[2] * (b[2] - a[2]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n dst[2] = Math.max(a[2], b[2]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n dst[2] = Math.min(a[2], b[2]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec3, k: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec3, k: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n dst[2] = 1 / v[2];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the cross product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of a cross b.\n */\nexport function cross(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const t1 = a[2] * b[0] - a[0] * b[2];\n const t2 = a[0] * b[1] - a[1] * b[0];\n dst[0] = a[1] * b[2] - a[2] * b[1];\n dst[1] = t1;\n dst[2] = t2;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec3, b: Vec3): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]);\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec3): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec3): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n return v0 * v0 + v1 * v1 + v2 * v2;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec3, b: Vec3): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n return Math.sqrt(dx * dx + dy * dy + dz * dz);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec3, b: Vec3): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n return dx * dx + dy * dy + dz * dz;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n }\n\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n dst[2] = -v[2];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec3.clone})\n * Also see {@link vec3.create} and {@link vec3.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0];\n dst[1] = v[1];\n dst[2] = v[2];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec3.copy})\n * Also see {@link vec3.create} and {@link vec3.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n dst[2] = a[2] * b[2];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n dst[2] = a[2] / b[2];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Creates a random vector\n * @param scale - Default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The random vector.\n */\nexport function random(scale = 1, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const angle = Math.random() * 2 * Math.PI;\n const z = Math.random() * 2 - 1;\n const zScale = Math.sqrt(1 - z * z) * scale;\n dst[0] = Math.cos(angle) * zScale;\n dst[1] = Math.sin(angle) * zScale;\n dst[2] = z * scale;\n\n return dst;\n}\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n\n return dst;\n}\n\n\n/**\n * transform vec3 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec3, m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n const w = (m[3] * x + m[7] * y + m[11] * z + m[15]) || 1;\n\n dst[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n dst[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n dst[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n\n return dst;\n}\n\n/**\n * Transform vec4 by upper 3x3 matrix inside 4x4 matrix.\n * @param v - The direction.\n * @param m - The matrix.\n * @param dst - optional Vec3 to store result. If not passed a new one is created.\n * @returns The transformed vector.\n */\nexport function transformMat4Upper3x3(v: Vec3, m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n\n dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0];\n dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1];\n dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v2 * m[2 * 4 + 2];\n\n return dst;\n}\n\n/**\n * Transforms vec3 by 3x3 matrix\n *\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat3(v: Vec3, m: Mat3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n\n dst[0] = x * m[0] + y * m[4] + z * m[8];\n dst[1] = x * m[1] + y * m[5] + z * m[9];\n dst[2] = x * m[2] + y * m[6] + z * m[10];\n\n return dst;\n}\n\n/**\n * Transforms vec3 by Quaternion\n * @param v - the vector to transform\n * @param q - the quaternion to transform by\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed\n */\nexport function transformQuat(v: Vec3, q: Quat, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const w2 = q[3] * 2;\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n\n const uvX = qy * z - qz * y;\n const uvY = qz * x - qx * z;\n const uvZ = qx * y - qy * x;\n\n dst[0] = x + uvX * w2 + (qy * uvZ - qz * uvY) * 2;\n dst[1] = y + uvY * w2 + (qz * uvX - qx * uvZ) * 2;\n dst[2] = z + uvZ * w2 + (qx * uvY - qy * uvX) * 2;\n\n return dst;\n}\n\n/**\n * Returns the translation component of a 4-by-4 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat3, dst?: Vec3) {\n dst = dst || new VecType(3);\n dst[0] = m[12];\n dst[1] = m[13];\n dst[2] = m[14];\n return dst;\n}\n/**\n * Returns an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat4, axis: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n dst[2] = m[off + 2];\n return dst;\n}\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat4, dst: Vec3) {\n dst = dst || new VecType(3);\n const xx = m[0];\n const xy = m[1];\n const xz = m[2];\n const yx = m[4];\n const yy = m[5];\n const yz = m[6];\n const zx = m[8];\n const zy = m[9];\n const zz = m[10];\n dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz);\n dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz);\n dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz);\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the x-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns the rotated vector\n */\nexport function rotateX(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n //Translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n //perform rotation\n r[0] = p[0];\n r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);\n r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad);\n\n //translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the y-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns the rotated vector\n */\nexport function rotateY(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n // translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n // perform rotation\n r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);\n r[1] = p[1];\n r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad);\n\n // translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the z-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns {vec3} out\n */\nexport function rotateZ(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n // translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n // perform rotation\n r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);\n r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);\n r[2] = p[2];\n\n // translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Treat a 3D vector as a direction and set it's length\n *\n * @param a The vec3 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec3, len: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec3 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec3, maxLen: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n return lerp(a, b, 0.5, dst);\n}\n","\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Quat } from './quat';\nimport Vec3, * as vec3 from './vec3-impl';\nimport * as utils from './utils';\n\nexport default Mat4;\n\nexport type Mat4LikeCtor = new (n: number) => Mat4;\n\n/**\n * 4x4 Matrix math math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new matrix. In other words you can do this\n *\n * const mat = mat4.translation([1, 2, 3]); // Creates a new translation matrix\n *\n * or\n *\n * const mat = mat4.create();\n * mat4.translation([1, 2, 3], mat); // Puts translation matrix in mat.\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always save to pass any matrix as the destination. So for example\n *\n * const mat = mat4.identity();\n * const trans = mat4.translation([1, 2, 3]);\n * mat4.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat.\n *\n */\nlet MatType: Mat4LikeCtor = Float32Array;\n\n/**\n * Sets the type this library creates for a Mat4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Mat4\n */\nexport function setDefaultType(ctor: new (n: number) => Mat4) {\n const oldType = MatType;\n MatType = ctor;\n return oldType;\n}\n\n/**\n * Create a Mat4 from values\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Mat4's specified type\n * it would be faster to use\n *\n * ```\n * const m = mat4.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Mat4Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `mat4.create` is usually used\n * to create a Mat4 to be filled out as in\n *\n * ```\n * const m = mat4.create();\n * mat4.perspective(fov, aspect, near, far, m);\n * ```\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param v9 - value for element 9\n * @param v10 - value for element 10\n * @param v11 - value for element 11\n * @param v12 - value for element 12\n * @param v13 - value for element 13\n * @param v14 - value for element 14\n * @param v15 - value for element 15\n * @returns created from values.\n */\nexport function create(\n v0?: number, v1?: number, v2?: number, v3?: number,\n v4?: number, v5?: number, v6?: number, v7?: number,\n v8?: number, v9?: number, v10?: number, v11?: number,\n v12?: number, v13?: number, v14?: number, v15?: number): Mat4 {\n const dst = new MatType(16);\n if (v0 !== undefined) {\n dst[0] = v0;\n if (v1 !== undefined) {\n dst[1] = v1;\n if (v2 !== undefined) {\n dst[2] = v2;\n if (v3 !== undefined) {\n dst[3] = v3;\n if (v4 !== undefined) {\n dst[4] = v4;\n if (v5 !== undefined) {\n dst[5] = v5;\n if (v6 !== undefined) {\n dst[6] = v6;\n if (v7 !== undefined) {\n dst[7] = v7;\n if (v8 !== undefined) {\n dst[8] = v8;\n if (v9 !== undefined) {\n dst[9] = v9;\n if (v10 !== undefined) {\n dst[10] = v10;\n if (v11 !== undefined) {\n dst[11] = v11;\n if (v12 !== undefined) {\n dst[12] = v12;\n if (v13 !== undefined) {\n dst[13] = v13;\n if (v14 !== undefined) {\n dst[14] = v14;\n if (v15 !== undefined) {\n dst[15] = v15;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n return dst;\n}\n\n/**\n * Sets the values of a Mat4\n * Also see {@link mat4.create} and {@link mat4.copy}\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param v9 - value for element 9\n * @param v10 - value for element 10\n * @param v11 - value for element 11\n * @param v12 - value for element 12\n * @param v13 - value for element 13\n * @param v14 - value for element 14\n * @param v15 - value for element 15\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 created from values.\n */\nexport function set(\n v0: number, v1: number, v2: number, v3: number,\n v4: number, v5: number, v6: number, v7: number,\n v8: number, v9: number, v10: number, v11: number,\n v12: number, v13: number, v14: number, v15: number,\n dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = v0; dst[ 1] = v1; dst[ 2] = v2; dst[ 3] = v3;\n dst[ 4] = v4; dst[ 5] = v5; dst[ 6] = v6; dst[ 7] = v7;\n dst[ 8] = v8; dst[ 9] = v9; dst[10] = v10; dst[11] = v11;\n dst[12] = v12; dst[13] = v13; dst[14] = v14; dst[15] = v15;\n\n return dst;\n}\n\n/**\n * Creates a Mat4 from a Mat3\n * @param m3 - source matrix\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 made from m3\n */\nexport function fromMat3(m3: Mat3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = m3[0]; dst[ 1] = m3[1]; dst[ 2] = m3[ 2]; dst[ 3] = 0;\n dst[ 4] = m3[4]; dst[ 5] = m3[5]; dst[ 6] = m3[ 6]; dst[ 7] = 0;\n dst[ 8] = m3[8]; dst[ 9] = m3[9]; dst[10] = m3[10]; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a Mat4 rotation matrix from a quaternion\n * @param q - quaternion to create matrix from\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 made from q\n */\nexport function fromQuat(q: Quat, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3];\n const x2 = x + x; const y2 = y + y; const z2 = z + z;\n\n const xx = x * x2;\n const yx = y * x2;\n const yy = y * y2;\n const zx = z * x2;\n const zy = z * y2;\n const zz = z * z2;\n const wx = w * x2;\n const wy = w * y2;\n const wz = w * z2;\n\n dst[ 0] = 1 - yy - zz; dst[ 1] = yx + wz; dst[ 2] = zx - wy; dst[ 3] = 0;\n dst[ 4] = yx - wz; dst[ 5] = 1 - xx - zz; dst[ 6] = zy + wx; dst[ 7] = 0;\n dst[ 8] = zx + wy; dst[ 9] = zy - wx; dst[10] = 1 - xx - yy; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Negates a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns -m.\n */\nexport function negate(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = -m[ 0]; dst[ 1] = -m[ 1]; dst[ 2] = -m[ 2]; dst[ 3] = -m[ 3];\n dst[ 4] = -m[ 4]; dst[ 5] = -m[ 5]; dst[ 6] = -m[ 6]; dst[ 7] = -m[ 7];\n dst[ 8] = -m[ 8]; dst[ 9] = -m[ 9]; dst[10] = -m[10]; dst[11] = -m[11];\n dst[12] = -m[12]; dst[13] = -m[13]; dst[14] = -m[14]; dst[15] = -m[15];\n\n return dst;\n}\n\n/**\n * Copies a matrix. (same as {@link mat4.clone})\n * Also see {@link mat4.create} and {@link mat4.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport function copy(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = m[ 0]; dst[ 1] = m[ 1]; dst[ 2] = m[ 2]; dst[ 3] = m[ 3];\n dst[ 4] = m[ 4]; dst[ 5] = m[ 5]; dst[ 6] = m[ 6]; dst[ 7] = m[ 7];\n dst[ 8] = m[ 8]; dst[ 9] = m[ 9]; dst[10] = m[10]; dst[11] = m[11];\n dst[12] = m[12]; dst[13] = m[13]; dst[14] = m[14]; dst[15] = m[15];\n\n return dst;\n}\n\n/**\n * Copies a matrix (same as {@link mat4.copy})\n * Also see {@link mat4.create} and {@link mat4.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport const clone = copy;\n\n/**\n * Check if 2 matrices are approximately equal\n * @param a - Operand matrix.\n * @param b - Operand matrix.\n * @returns true if matrices are approximately equal\n */\nexport function equalsApproximately(a: Mat4, b: Mat4): boolean {\n return Math.abs(a[ 0] - b[ 0]) < utils.EPSILON &&\n Math.abs(a[ 1] - b[ 1]) < utils.EPSILON &&\n Math.abs(a[ 2] - b[ 2]) < utils.EPSILON &&\n Math.abs(a[ 3] - b[ 3]) < utils.EPSILON &&\n Math.abs(a[ 4] - b[ 4]) < utils.EPSILON &&\n Math.abs(a[ 5] - b[ 5]) < utils.EPSILON &&\n Math.abs(a[ 6] - b[ 6]) < utils.EPSILON &&\n Math.abs(a[ 7] - b[ 7]) < utils.EPSILON &&\n Math.abs(a[ 8] - b[ 8]) < utils.EPSILON &&\n Math.abs(a[ 9] - b[ 9]) < utils.EPSILON &&\n Math.abs(a[10] - b[10]) < utils.EPSILON &&\n Math.abs(a[11] - b[11]) < utils.EPSILON &&\n Math.abs(a[12] - b[12]) < utils.EPSILON &&\n Math.abs(a[13] - b[13]) < utils.EPSILON &&\n Math.abs(a[14] - b[14]) < utils.EPSILON &&\n Math.abs(a[15] - b[15]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 matrices are exactly equal\n * @param a - Operand matrix.\n * @param b - Operand matrix.\n * @returns true if matrices are exactly equal\n */\nexport function equals(a: Mat4, b: Mat4): boolean {\n return a[ 0] === b[ 0] &&\n a[ 1] === b[ 1] &&\n a[ 2] === b[ 2] &&\n a[ 3] === b[ 3] &&\n a[ 4] === b[ 4] &&\n a[ 5] === b[ 5] &&\n a[ 6] === b[ 6] &&\n a[ 7] === b[ 7] &&\n a[ 8] === b[ 8] &&\n a[ 9] === b[ 9] &&\n a[10] === b[10] &&\n a[11] === b[11] &&\n a[12] === b[12] &&\n a[13] === b[13] &&\n a[14] === b[14] &&\n a[15] === b[15];\n}\n\n/**\n * Creates a 4-by-4 identity matrix.\n *\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A 4-by-4 identity matrix.\n */\nexport function identity(dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Takes the transpose of a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The transpose of m.\n */\nexport function transpose(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n if (dst === m) {\n let t;\n\n t = m[1];\n m[1] = m[4];\n m[4] = t;\n\n t = m[2];\n m[2] = m[8];\n m[8] = t;\n\n t = m[3];\n m[3] = m[12];\n m[12] = t;\n\n t = m[6];\n m[6] = m[9];\n m[9] = t;\n\n t = m[7];\n m[7] = m[13];\n m[13] = t;\n\n t = m[11];\n m[11] = m[14];\n m[14] = t;\n return dst;\n }\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n dst[ 0] = m00; dst[ 1] = m10; dst[ 2] = m20; dst[ 3] = m30;\n dst[ 4] = m01; dst[ 5] = m11; dst[ 6] = m21; dst[ 7] = m31;\n dst[ 8] = m02; dst[ 9] = m12; dst[10] = m22; dst[11] = m32;\n dst[12] = m03; dst[13] = m13; dst[14] = m23; dst[15] = m33;\n\n return dst;\n}\n\n/**\n * Computes the inverse of a 4-by-4 matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport function inverse(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n const tmp0 = m22 * m33;\n const tmp1 = m32 * m23;\n const tmp2 = m12 * m33;\n const tmp3 = m32 * m13;\n const tmp4 = m12 * m23;\n const tmp5 = m22 * m13;\n const tmp6 = m02 * m33;\n const tmp7 = m32 * m03;\n const tmp8 = m02 * m23;\n const tmp9 = m22 * m03;\n const tmp10 = m02 * m13;\n const tmp11 = m12 * m03;\n const tmp12 = m20 * m31;\n const tmp13 = m30 * m21;\n const tmp14 = m10 * m31;\n const tmp15 = m30 * m11;\n const tmp16 = m10 * m21;\n const tmp17 = m20 * m11;\n const tmp18 = m00 * m31;\n const tmp19 = m30 * m01;\n const tmp20 = m00 * m21;\n const tmp21 = m20 * m01;\n const tmp22 = m00 * m11;\n const tmp23 = m10 * m01;\n\n const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) -\n (tmp1 * m11 + tmp2 * m21 + tmp5 * m31);\n const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) -\n (tmp0 * m01 + tmp7 * m21 + tmp8 * m31);\n const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) -\n (tmp3 * m01 + tmp6 * m11 + tmp11 * m31);\n const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) -\n (tmp4 * m01 + tmp9 * m11 + tmp10 * m21);\n\n const d = 1 / (m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3);\n\n dst[ 0] = d * t0;\n dst[ 1] = d * t1;\n dst[ 2] = d * t2;\n dst[ 3] = d * t3;\n dst[ 4] = d * ((tmp1 * m10 + tmp2 * m20 + tmp5 * m30) -\n (tmp0 * m10 + tmp3 * m20 + tmp4 * m30));\n dst[ 5] = d * ((tmp0 * m00 + tmp7 * m20 + tmp8 * m30) -\n (tmp1 * m00 + tmp6 * m20 + tmp9 * m30));\n dst[ 6] = d * ((tmp3 * m00 + tmp6 * m10 + tmp11 * m30) -\n (tmp2 * m00 + tmp7 * m10 + tmp10 * m30));\n dst[ 7] = d * ((tmp4 * m00 + tmp9 * m10 + tmp10 * m20) -\n (tmp5 * m00 + tmp8 * m10 + tmp11 * m20));\n dst[ 8] = d * ((tmp12 * m13 + tmp15 * m23 + tmp16 * m33) -\n (tmp13 * m13 + tmp14 * m23 + tmp17 * m33));\n dst[ 9] = d * ((tmp13 * m03 + tmp18 * m23 + tmp21 * m33) -\n (tmp12 * m03 + tmp19 * m23 + tmp20 * m33));\n dst[10] = d * ((tmp14 * m03 + tmp19 * m13 + tmp22 * m33) -\n (tmp15 * m03 + tmp18 * m13 + tmp23 * m33));\n dst[11] = d * ((tmp17 * m03 + tmp20 * m13 + tmp23 * m23) -\n (tmp16 * m03 + tmp21 * m13 + tmp22 * m23));\n dst[12] = d * ((tmp14 * m22 + tmp17 * m32 + tmp13 * m12) -\n (tmp16 * m32 + tmp12 * m12 + tmp15 * m22));\n dst[13] = d * ((tmp20 * m32 + tmp12 * m02 + tmp19 * m22) -\n (tmp18 * m22 + tmp21 * m32 + tmp13 * m02));\n dst[14] = d * ((tmp18 * m12 + tmp23 * m32 + tmp15 * m02) -\n (tmp22 * m32 + tmp14 * m02 + tmp19 * m12));\n dst[15] = d * ((tmp22 * m22 + tmp16 * m02 + tmp21 * m12) -\n (tmp20 * m12 + tmp23 * m22 + tmp17 * m02));\n\n return dst;\n}\n\n/**\n * Compute the determinant of a matrix\n * @param m - the matrix\n * @returns the determinant\n */\nexport function determinant(m: Mat4): number {\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n const tmp0 = m22 * m33;\n const tmp1 = m32 * m23;\n const tmp2 = m12 * m33;\n const tmp3 = m32 * m13;\n const tmp4 = m12 * m23;\n const tmp5 = m22 * m13;\n const tmp6 = m02 * m33;\n const tmp7 = m32 * m03;\n const tmp8 = m02 * m23;\n const tmp9 = m22 * m03;\n const tmp10 = m02 * m13;\n const tmp11 = m12 * m03;\n\n const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) -\n (tmp1 * m11 + tmp2 * m21 + tmp5 * m31);\n const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) -\n (tmp0 * m01 + tmp7 * m21 + tmp8 * m31);\n const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) -\n (tmp3 * m01 + tmp6 * m11 + tmp11 * m31);\n const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) -\n (tmp4 * m01 + tmp9 * m11 + tmp10 * m21);\n\n return m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3;\n}\n\n/**\n * Computes the inverse of a 4-by-4 matrix. (same as inverse)\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport const invert = inverse;\n\n/**\n * Multiplies two 4-by-4 matrices with a on the left and b on the right\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport function multiply(a: Mat4, b: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const a00 = a[0];\n const a01 = a[1];\n const a02 = a[2];\n const a03 = a[3];\n const a10 = a[ 4 + 0];\n const a11 = a[ 4 + 1];\n const a12 = a[ 4 + 2];\n const a13 = a[ 4 + 3];\n const a20 = a[ 8 + 0];\n const a21 = a[ 8 + 1];\n const a22 = a[ 8 + 2];\n const a23 = a[ 8 + 3];\n const a30 = a[12 + 0];\n const a31 = a[12 + 1];\n const a32 = a[12 + 2];\n const a33 = a[12 + 3];\n const b00 = b[0];\n const b01 = b[1];\n const b02 = b[2];\n const b03 = b[3];\n const b10 = b[ 4 + 0];\n const b11 = b[ 4 + 1];\n const b12 = b[ 4 + 2];\n const b13 = b[ 4 + 3];\n const b20 = b[ 8 + 0];\n const b21 = b[ 8 + 1];\n const b22 = b[ 8 + 2];\n const b23 = b[ 8 + 3];\n const b30 = b[12 + 0];\n const b31 = b[12 + 1];\n const b32 = b[12 + 2];\n const b33 = b[12 + 3];\n\n dst[ 0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03;\n dst[ 1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03;\n dst[ 2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03;\n dst[ 3] = a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03;\n dst[ 4] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13;\n dst[ 5] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13;\n dst[ 6] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13;\n dst[ 7] = a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13;\n dst[ 8] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23;\n dst[ 9] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23;\n dst[10] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23;\n dst[11] = a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23;\n dst[12] = a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33;\n dst[13] = a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33;\n dst[14] = a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33;\n dst[15] = a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33;\n\n return dst;\n}\n\n/**\n * Multiplies two 4-by-4 matrices with a on the left and b on the right (same as multiply)\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Sets the translation component of a 4-by-4 matrix to the given\n * vector.\n * @param a - The matrix.\n * @param v - The vector.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix with translation set.\n */\nexport function setTranslation(a: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || identity();\n if (a !== dst) {\n dst[ 0] = a[ 0];\n dst[ 1] = a[ 1];\n dst[ 2] = a[ 2];\n dst[ 3] = a[ 3];\n dst[ 4] = a[ 4];\n dst[ 5] = a[ 5];\n dst[ 6] = a[ 6];\n dst[ 7] = a[ 7];\n dst[ 8] = a[ 8];\n dst[ 9] = a[ 9];\n dst[10] = a[10];\n dst[11] = a[11];\n }\n dst[12] = v[0];\n dst[13] = v[1];\n dst[14] = v[2];\n dst[15] = 1;\n return dst;\n}\n\n/**\n * Returns the translation component of a 4-by-4 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n dst[0] = m[12];\n dst[1] = m[13];\n dst[2] = m[14];\n return dst;\n}\n\n/**\n * Returns an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat4, axis: number, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n dst[2] = m[off + 2];\n return dst;\n}\n\n/**\n * Sets an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param v - the axis vector\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @param dst - The matrix to set. If not passed a new one is created.\n * @returns The matrix with axis set.\n */\nexport function setAxis(m: Mat4, v: Vec3, axis: number, dst: Mat4): Mat4 {\n if (dst !== m) {\n dst = copy(m, dst);\n }\n const off = axis * 4;\n dst[off + 0] = v[0];\n dst[off + 1] = v[1];\n dst[off + 2] = v[2];\n return dst;\n}\n\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n\n const xx = m[0];\n const xy = m[1];\n const xz = m[2];\n const yx = m[4];\n const yy = m[5];\n const yz = m[6];\n const zx = m[8];\n const zy = m[9];\n const zz = m[10];\n\n dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz);\n dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz);\n dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz);\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 perspective transformation matrix given the angular height\n * of the frustum, the aspect ratio, and the near and far clipping planes. The\n * arguments define a frustum extending in the negative z direction. The given\n * angle is the vertical angle of the frustum, and the horizontal angle is\n * determined to produce the given aspect ratio. The arguments near and far are\n * the distances to the near and far clipping planes. Note that near and far\n * are not z coordinates, but rather they are distances along the negative\n * z-axis. The matrix generated sends the viewing frustum to the unit box.\n * We assume a unit box extending from -1 to 1 in the x and y dimensions and\n * from 0 to 1 in the z dimension.\n *\n * Note: If you pass `Infinity` for zFar then it will produce a projection matrix\n * returns -Infinity for Z when transforming coordinates with Z <= 0 and +Infinity for Z\n * otherwise.\n *\n * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians).\n * @param aspect - The aspect ratio width / height.\n * @param zNear - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param zFar - The depth (negative z coordinate)\n * of the far clipping plane.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The perspective matrix.\n */\nexport function perspective(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians);\n\n dst[0] = f / aspect;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n dst[4] = 0;\n dst[5] = f;\n dst[6] = 0;\n dst[7] = 0;\n\n dst[8] = 0;\n dst[9] = 0;\n dst[11] = -1;\n\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (Number.isFinite(zFar)) {\n const rangeInv = 1 / (zNear - zFar);\n dst[10] = zFar * rangeInv;\n dst[14] = zFar * zNear * rangeInv;\n } else {\n dst[10] = -1;\n dst[14] = -zNear;\n }\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 reverse-z perspective transformation matrix given the angular height\n * of the frustum, the aspect ratio, and the near and far clipping planes. The\n * arguments define a frustum extending in the negative z direction. The given\n * angle is the vertical angle of the frustum, and the horizontal angle is\n * determined to produce the given aspect ratio. The arguments near and far are\n * the distances to the near and far clipping planes. Note that near and far\n * are not z coordinates, but rather they are distances along the negative\n * z-axis. The matrix generated sends the viewing frustum to the unit box.\n * We assume a unit box extending from -1 to 1 in the x and y dimensions and\n * from 1 (at -zNear) to 0 (at -zFar) in the z dimension.\n *\n * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians).\n * @param aspect - The aspect ratio width / height.\n * @param zNear - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param zFar - The depth (negative z coordinate)\n * of the far clipping plane. (default = Infinity)\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The perspective matrix.\n */export function perspectiveReverseZ(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar = Infinity, dst?: Mat4) {\n dst = dst || new MatType(16);\n\n const f = 1 / Math.tan(fieldOfViewYInRadians * 0.5);\n\n dst[ 0] = f / aspect;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n\n dst[ 4] = 0;\n dst[ 5] = f;\n dst[ 6] = 0;\n dst[ 7] = 0;\n\n dst[ 8] = 0;\n dst[ 9] = 0;\n dst[11] = -1;\n\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (zFar === Infinity) {\n dst[10] = 0;\n dst[14] = zNear;\n } else {\n const rangeInv = 1 / (zFar - zNear);\n dst[10] = zNear * rangeInv;\n dst[14] = zFar * zNear * rangeInv;\n }\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 orthogonal transformation matrix that transforms from\n * the given the left, right, bottom, and top dimensions to -1 +1 in x, and y\n * and 0 to +1 in z.\n * @param left - Left side of the near clipping plane viewport.\n * @param right - Right side of the near clipping plane viewport.\n * @param bottom - Bottom of the near clipping plane viewport.\n * @param top - Top of the near clipping plane viewport.\n * @param near - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param far - The depth (negative z coordinate)\n * of the far clipping plane.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The orthographic projection matrix.\n */\nexport function ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[0] = 2 / (right - left);\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n dst[4] = 0;\n dst[5] = 2 / (top - bottom);\n dst[6] = 0;\n dst[7] = 0;\n\n dst[8] = 0;\n dst[9] = 0;\n dst[10] = 1 / (near - far);\n dst[11] = 0;\n\n dst[12] = (right + left) / (left - right);\n dst[13] = (top + bottom) / (bottom - top);\n dst[14] = near / (near - far);\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 perspective transformation matrix given the left, right,\n * top, bottom, near and far clipping planes. The arguments define a frustum\n * extending in the negative z direction. The arguments near and far are the\n * distances to the near and far clipping planes. Note that near and far are not\n * z coordinates, but rather they are distances along the negative z-axis. The\n * matrix generated sends the viewing frustum to the unit box. We assume a unit\n * box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z\n * dimension.\n * @param left - The x coordinate of the left plane of the box.\n * @param right - The x coordinate of the right plane of the box.\n * @param bottom - The y coordinate of the bottom plane of the box.\n * @param top - The y coordinate of the right plane of the box.\n * @param near - The negative z coordinate of the near plane of the box.\n * @param far - The negative z coordinate of the far plane of the box.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The perspective projection matrix.\n */\nexport function frustum(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const dx = (right - left);\n const dy = (top - bottom);\n const dz = (near - far);\n\n dst[ 0] = 2 * near / dx;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 2 * near / dy;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = (left + right) / dx;\n dst[ 9] = (top + bottom) / dy;\n dst[10] = far / dz;\n dst[11] = -1;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = near * far / dz;\n dst[15] = 0;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 reverse-z perspective transformation matrix given the left, right,\n * top, bottom, near and far clipping planes. The arguments define a frustum\n * extending in the negative z direction. The arguments near and far are the\n * distances to the near and far clipping planes. Note that near and far are not\n * z coordinates, but rather they are distances along the negative z-axis. The\n * matrix generated sends the viewing frustum to the unit box. We assume a unit\n * box extending from -1 to 1 in the x and y dimensions and from 1 (-near) to 0 (-far) in the z\n * dimension.\n * @param left - The x coordinate of the left plane of the box.\n * @param right - The x coordinate of the right plane of the box.\n * @param bottom - The y coordinate of the bottom plane of the box.\n * @param top - The y coordinate of the right plane of the box.\n * @param near - The negative z coordinate of the near plane of the box.\n * @param far - The negative z coordinate of the far plane of the box.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The perspective projection matrix.\n */\nexport function frustumReverseZ(left: number, right: number, bottom: number, top: number, near: number, far = Infinity, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const dx = (right - left);\n const dy = (top - bottom);\n\n dst[ 0] = 2 * near / dx;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 2 * near / dy;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = (left + right) / dx;\n dst[ 9] = (top + bottom) / dy;\n dst[11] = -1;\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (far === Infinity) {\n dst[10] = 0;\n dst[14] = near;\n } else {\n const rangeInv = 1 / (far - near);\n dst[10] = near * rangeInv;\n dst[14] = far * near * rangeInv;\n }\n\n return dst;\n}\n\nlet xAxis: Vec3;\nlet yAxis: Vec3;\nlet zAxis: Vec3;\n\n/**\n * Computes a 4-by-4 aim transformation.\n *\n * This is a matrix which positions an object aiming down positive Z.\n * toward the target.\n *\n * Note: this is **NOT** the inverse of lookAt as lookAt looks at negative Z.\n *\n * @param position - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The aim matrix.\n */\nexport function aim(position: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(target, position, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = xAxis[1]; dst[ 2] = xAxis[2]; dst[ 3] = 0;\n dst[ 4] = yAxis[0]; dst[ 5] = yAxis[1]; dst[ 6] = yAxis[2]; dst[ 7] = 0;\n dst[ 8] = zAxis[0]; dst[ 9] = zAxis[1]; dst[10] = zAxis[2]; dst[11] = 0;\n dst[12] = position[0]; dst[13] = position[1]; dst[14] = position[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 camera aim transformation.\n *\n * This is a matrix which positions an object aiming down negative Z.\n * toward the target.\n *\n * Note: this is the inverse of `lookAt`\n *\n * @param eye - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The aim matrix.\n */\nexport function cameraAim(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = xAxis[1]; dst[ 2] = xAxis[2]; dst[ 3] = 0;\n dst[ 4] = yAxis[0]; dst[ 5] = yAxis[1]; dst[ 6] = yAxis[2]; dst[ 7] = 0;\n dst[ 8] = zAxis[0]; dst[ 9] = zAxis[1]; dst[10] = zAxis[2]; dst[11] = 0;\n dst[12] = eye[0]; dst[13] = eye[1]; dst[14] = eye[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 view transformation.\n *\n * This is a view matrix which transforms all other objects\n * to be in the space of the view defined by the parameters.\n *\n * @param eye - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The look-at matrix.\n */\nexport function lookAt(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = yAxis[0]; dst[ 2] = zAxis[0]; dst[ 3] = 0;\n dst[ 4] = xAxis[1]; dst[ 5] = yAxis[1]; dst[ 6] = zAxis[1]; dst[ 7] = 0;\n dst[ 8] = xAxis[2]; dst[ 9] = yAxis[2]; dst[10] = zAxis[2]; dst[11] = 0;\n\n dst[12] = -(xAxis[0] * eye[0] + xAxis[1] * eye[1] + xAxis[2] * eye[2]);\n dst[13] = -(yAxis[0] * eye[0] + yAxis[1] * eye[1] + yAxis[2] * eye[2]);\n dst[14] = -(zAxis[0] * eye[0] + zAxis[1] * eye[1] + zAxis[2] * eye[2]);\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which translates by the given vector v.\n * @param v - The vector by\n * which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translation matrix.\n */\nexport function translation(v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = v[0]; dst[13] = v[1]; dst[14] = v[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Translates the given 4-by-4 matrix by the given vector v.\n * @param m - The matrix.\n * @param v - The vector by\n * which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translated matrix.\n */\nexport function translate(m: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m03 = m[3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n if (m !== dst) {\n dst[ 0] = m00;\n dst[ 1] = m01;\n dst[ 2] = m02;\n dst[ 3] = m03;\n dst[ 4] = m10;\n dst[ 5] = m11;\n dst[ 6] = m12;\n dst[ 7] = m13;\n dst[ 8] = m20;\n dst[ 9] = m21;\n dst[10] = m22;\n dst[11] = m23;\n }\n\n dst[12] = m00 * v0 + m10 * v1 + m20 * v2 + m30;\n dst[13] = m01 * v0 + m11 * v1 + m21 * v2 + m31;\n dst[14] = m02 * v0 + m12 * v1 + m22 * v2 + m32;\n dst[15] = m03 * v0 + m13 * v1 + m23 * v2 + m33;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationX(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = c; dst[ 6] = s; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = -s; dst[10] = c; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateX(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m10 = m[4];\n const m11 = m[5];\n const m12 = m[6];\n const m13 = m[7];\n const m20 = m[8];\n const m21 = m[9];\n const m22 = m[10];\n const m23 = m[11];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[4] = c * m10 + s * m20;\n dst[5] = c * m11 + s * m21;\n dst[6] = c * m12 + s * m22;\n dst[7] = c * m13 + s * m23;\n dst[8] = c * m20 - s * m10;\n dst[9] = c * m21 - s * m11;\n dst[10] = c * m22 - s * m12;\n dst[11] = c * m23 - s * m13;\n\n if (m !== dst) {\n dst[ 0] = m[ 0];\n dst[ 1] = m[ 1];\n dst[ 2] = m[ 2];\n dst[ 3] = m[ 3];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationY(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = 0; dst[ 2] = -s; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = s; dst[ 9] = 0; dst[10] = c; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateY(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 - s * m20;\n dst[ 1] = c * m01 - s * m21;\n dst[ 2] = c * m02 - s * m22;\n dst[ 3] = c * m03 - s * m23;\n dst[ 8] = c * m20 + s * m00;\n dst[ 9] = c * m21 + s * m01;\n dst[10] = c * m22 + s * m02;\n dst[11] = c * m23 + s * m03;\n\n if (m !== dst) {\n dst[ 4] = m[ 4];\n dst[ 5] = m[ 5];\n dst[ 6] = m[ 6];\n dst[ 7] = m[ 7];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationZ(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = s; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = -s; dst[ 5] = c; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateZ(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 + s * m10;\n dst[ 1] = c * m01 + s * m11;\n dst[ 2] = c * m02 + s * m12;\n dst[ 3] = c * m03 + s * m13;\n dst[ 4] = c * m10 - s * m00;\n dst[ 5] = c * m11 - s * m01;\n dst[ 6] = c * m12 - s * m02;\n dst[ 7] = c * m13 - s * m03;\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n dst[11] = m[11];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the given axis by the given\n * angle.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A matrix which rotates angle radians\n * around the axis.\n */\nexport function axisRotation(axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n let x = axis[0];\n let y = axis[1];\n let z = axis[2];\n const n = Math.sqrt(x * x + y * y + z * z);\n x /= n;\n y /= n;\n z /= n;\n const xx = x * x;\n const yy = y * y;\n const zz = z * z;\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n const oneMinusCosine = 1 - c;\n\n dst[ 0] = xx + (1 - xx) * c;\n dst[ 1] = x * y * oneMinusCosine + z * s;\n dst[ 2] = x * z * oneMinusCosine - y * s;\n dst[ 3] = 0;\n dst[ 4] = x * y * oneMinusCosine - z * s;\n dst[ 5] = yy + (1 - yy) * c;\n dst[ 6] = y * z * oneMinusCosine + x * s;\n dst[ 7] = 0;\n dst[ 8] = x * z * oneMinusCosine + y * s;\n dst[ 9] = y * z * oneMinusCosine - x * s;\n dst[10] = zz + (1 - zz) * c;\n dst[11] = 0;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = 0;\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the given axis by the given\n * angle. (same as axisRotation)\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A matrix which rotates angle radians\n * around the axis.\n */\nexport const rotation = axisRotation;\n\n/**\n * Rotates the given 4-by-4 matrix around the given axis by the\n * given angle.\n * @param m - The matrix.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function axisRotate(m: Mat4, axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n let x = axis[0];\n let y = axis[1];\n let z = axis[2];\n const n = Math.sqrt(x * x + y * y + z * z);\n x /= n;\n y /= n;\n z /= n;\n const xx = x * x;\n const yy = y * y;\n const zz = z * z;\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n const oneMinusCosine = 1 - c;\n\n const r00 = xx + (1 - xx) * c;\n const r01 = x * y * oneMinusCosine + z * s;\n const r02 = x * z * oneMinusCosine - y * s;\n const r10 = x * y * oneMinusCosine - z * s;\n const r11 = yy + (1 - yy) * c;\n const r12 = y * z * oneMinusCosine + x * s;\n const r20 = x * z * oneMinusCosine + y * s;\n const r21 = y * z * oneMinusCosine - x * s;\n const r22 = zz + (1 - zz) * c;\n\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m03 = m[3];\n const m10 = m[4];\n const m11 = m[5];\n const m12 = m[6];\n const m13 = m[7];\n const m20 = m[8];\n const m21 = m[9];\n const m22 = m[10];\n const m23 = m[11];\n\n dst[ 0] = r00 * m00 + r01 * m10 + r02 * m20;\n dst[ 1] = r00 * m01 + r01 * m11 + r02 * m21;\n dst[ 2] = r00 * m02 + r01 * m12 + r02 * m22;\n dst[ 3] = r00 * m03 + r01 * m13 + r02 * m23;\n dst[ 4] = r10 * m00 + r11 * m10 + r12 * m20;\n dst[ 5] = r10 * m01 + r11 * m11 + r12 * m21;\n dst[ 6] = r10 * m02 + r11 * m12 + r12 * m22;\n dst[ 7] = r10 * m03 + r11 * m13 + r12 * m23;\n dst[ 8] = r20 * m00 + r21 * m10 + r22 * m20;\n dst[ 9] = r20 * m01 + r21 * m11 + r22 * m21;\n dst[10] = r20 * m02 + r21 * m12 + r22 * m22;\n dst[11] = r20 * m03 + r21 * m13 + r22 * m23;\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the given axis by the\n * given angle. (same as rotate)\n * @param m - The matrix.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport const rotate = axisRotate;\n\n/**\n * Creates a 4-by-4 matrix which scales in each dimension by an amount given by\n * the corresponding entry in the given vector; assumes the vector has three\n * entries.\n * @param v - A vector of\n * three entries specifying the factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function scaling(v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = v[0]; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = v[1]; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = v[2]; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount\n * given by the corresponding entry in the given vector; assumes the vector has\n * three entries.\n * @param m - The matrix to be modified.\n * @param v - A vector of three entries specifying the\n * factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function scale(m: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n\n dst[ 0] = v0 * m[0 * 4 + 0];\n dst[ 1] = v0 * m[0 * 4 + 1];\n dst[ 2] = v0 * m[0 * 4 + 2];\n dst[ 3] = v0 * m[0 * 4 + 3];\n dst[ 4] = v1 * m[1 * 4 + 0];\n dst[ 5] = v1 * m[1 * 4 + 1];\n dst[ 6] = v1 * m[1 * 4 + 2];\n dst[ 7] = v1 * m[1 * 4 + 3];\n dst[ 8] = v2 * m[2 * 4 + 0];\n dst[ 9] = v2 * m[2 * 4 + 1];\n dst[10] = v2 * m[2 * 4 + 2];\n dst[11] = v2 * m[2 * 4 + 3];\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which scales a uniform amount in each dimension.\n * @param s - the amount to scale\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function uniformScaling(s: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = s; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = s; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = s; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by a uniform scale.\n * @param m - The matrix to be modified.\n * @param s - The amount to scale.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function uniformScale(m: Mat4, s: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = s * m[0 * 4 + 0];\n dst[ 1] = s * m[0 * 4 + 1];\n dst[ 2] = s * m[0 * 4 + 2];\n dst[ 3] = s * m[0 * 4 + 3];\n dst[ 4] = s * m[1 * 4 + 0];\n dst[ 5] = s * m[1 * 4 + 1];\n dst[ 6] = s * m[1 * 4 + 2];\n dst[ 7] = s * m[1 * 4 + 3];\n dst[ 8] = s * m[2 * 4 + 0];\n dst[ 9] = s * m[2 * 4 + 1];\n dst[10] = s * m[2 * 4 + 2];\n dst[11] = s * m[2 * 4 + 3];\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link quat.setDefaultType}.\n */\nexport type Quat = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Quat4 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Quat4`. In other words you can do this\n *\n * const v = quat4.cross(v1, v2); // Creates a new Quat4 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = quat4.create();\n * quat4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * quat4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let QuatType: new (n: number) => Quat = Float32Array;\n\n/**\n * Sets the type this library creates for a Quat4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Quat4\n */\nexport function setDefaultType(ctor: new (n: number) => Quat) {\n const oldType = QuatType;\n QuatType = ctor;\n return oldType;\n}\n\n/**\n * Creates a quat4; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param w - Initial w value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number, w?: number): Quat {\n const dst = new QuatType(4);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n if (w !== undefined) {\n dst[3] = w;\n }\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Quat, create, setDefaultType, QuatType } from './quat';\nimport { Mat3 } from './mat3.js';\nimport { Mat4 } from './mat4.js';\nimport { Vec3 } from './vec3.js';\nimport * as vec3 from './vec3-impl.js';\n\nexport type RotationOrder = 'xyz' | 'xzy' | 'yxz' | 'yzx' | 'zxy' | 'zyx';\n\nexport default Quat;\nexport { create, setDefaultType };\n\n/**\n * Creates a Quat; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param z - Initial w value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Quat\n * Also see {@link quat.create} and {@link quat.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param w fourth value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, w: number, dst?: Quat) {\n dst = dst || new QuatType(4);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n dst[3] = w;\n\n return dst;\n}\n\n/**\n * Sets a quaternion from the given angle and axis,\n * then returns it.\n *\n * @param axis - the axis to rotate around\n * @param angleInRadians - the angle\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The quaternion that represents the given axis and angle\n **/\nexport function fromAxisAngle(axis: Vec3, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n const s = Math.sin(halfAngle);\n\n dst[0] = s * axis[0];\n dst[1] = s * axis[1];\n dst[2] = s * axis[2];\n dst[3] = Math.cos(halfAngle);\n\n return dst;\n}\n\n/**\n * Gets the rotation axis and angle\n * @param q - quaternion to compute from\n * @param dst - Vec3 to hold result. If not passed in a new one is created.\n * @return angle and axis\n */\nexport function toAxisAngle(q: Quat, dst?: Vec3): { angle: number, axis: Vec3 } {\n dst = dst || vec3.create(4);\n\n const angle = Math.acos(q[3]) * 2;\n const s = Math.sin(angle * 0.5);\n if (s > utils.EPSILON) {\n dst[0] = q[0] / s;\n dst[1] = q[1] / s;\n dst[2] = q[2] / s;\n } else {\n dst[0] = 1;\n dst[1] = 0;\n dst[2] = 0;\n }\n\n return { angle, axis: dst };\n}\n\n/**\n * Returns the angle in degrees between two rotations a and b.\n * @param a - quaternion a\n * @param b - quaternion b\n * @return angle in radians between the two quaternions\n */\nexport function angle(a: Quat, b: Quat) {\n const d = dot(a, b);\n return Math.acos(2 * d * d - 1);\n}\n\n/**\n * Multiplies two quaternions\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function multiply(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const aw = a[3];\n\n const bx = b[0];\n const by = b[1];\n const bz = b[2];\n const bw = b[3];\n\n dst[0] = ax * bw + aw * bx + ay * bz - az * by;\n dst[1] = ay * bw + aw * by + az * bx - ax * bz;\n dst[2] = az * bw + aw * bz + ax * by - ay * bx;\n dst[3] = aw * bw - ax * bx - ay * by - az * bz;\n\n return dst;\n}\n\n/**\n * Multiplies two quaternions\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport const mul = multiply;\n\n/**\n * Rotates the given quaternion around the X axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateX(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const bx = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw + qw * bx;\n dst[1] = qy * bw + qz * bx;\n dst[2] = qz * bw - qy * bx;\n dst[3] = qw * bw - qx * bx;\n\n return dst;\n}\n\n/**\n * Rotates the given quaternion around the Y axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateY(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const by = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw - qz * by;\n dst[1] = qy * bw + qw * by;\n dst[2] = qz * bw + qx * by;\n dst[3] = qw * bw - qy * by;\n\n return dst;\n}\n\n/**\n * Rotates the given quaternion around the Z axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateZ(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const bz = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw + qy * bz;\n dst[1] = qy * bw - qx * bz;\n dst[2] = qz * bw + qw * bz;\n dst[3] = qw * bw - qz * bz;\n\n return dst;\n}\n\n/**\n * Spherically linear interpolate between two quaternions\n *\n * @param a - starting value\n * @param b - ending value\n * @param t - value where 0 = a and 1 = b\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function slerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const aw = a[3];\n\n let bx = b[0];\n let by = b[1];\n let bz = b[2];\n let bw = b[3];\n\n let cosOmega = ax * bx + ay * by + az * bz + aw * bw;\n\n if (cosOmega < 0) {\n cosOmega = -cosOmega;\n bx = -bx;\n by = -by;\n bz = -bz;\n bw = -bw;\n }\n\n let scale0;\n let scale1;\n\n if (1.0 - cosOmega > utils.EPSILON) {\n const omega = Math.acos(cosOmega);\n const sinOmega = Math.sin(omega);\n scale0 = Math.sin((1 - t) * omega) / sinOmega;\n scale1 = Math.sin(t * omega) / sinOmega;\n } else {\n scale0 = 1.0 - t;\n scale1 = t;\n }\n\n dst[0] = scale0 * ax + scale1 * bx;\n dst[1] = scale0 * ay + scale1 * by;\n dst[2] = scale0 * az + scale1 * bz;\n dst[3] = scale0 * aw + scale1 * bw;\n\n return dst;\n}\n\n/**\n * Compute the inverse of a quaternion\n *\n * @param q - quaternion to compute the inverse of\n * @returns A quaternion that is the result of a * b\n */\nexport function inverse(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const a0 = q[0];\n const a1 = q[1];\n const a2 = q[2];\n const a3 = q[3];\n\n const dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;\n const invDot = dot ? 1 / dot : 0;\n\n dst[0] = -a0 * invDot;\n dst[1] = -a1 * invDot;\n dst[2] = -a2 * invDot;\n dst[3] = a3 * invDot;\n\n return dst;\n}\n\n/**\n * Compute the conjugate of a quaternion\n * For quaternions with a magnitude of 1 (a unit quaternion)\n * this returns the same as the inverse but is faster to calculate.\n *\n * @param q - quaternion to compute the conjugate of.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The conjugate of q\n */\nexport function conjugate(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = -q[0];\n dst[1] = -q[1];\n dst[2] = -q[2];\n dst[3] = q[3];\n\n return dst;\n}\n\n/**\n * Creates a quaternion from the given rotation matrix.\n *\n * The created quaternion is not normalized.\n *\n * @param m - rotation matrix\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns the result\n */\nexport function fromMat(m: Mat3 | Mat4, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n /*\n 0 1 2\n 3 4 5\n 6 7 8\n\n 0 1 2\n 4 5 6\n 8 9 10\n */\n\n // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes\n // article \"Quaternion Calculus and Fast Animation\".\n const trace = m[0] + m[5] + m[10];\n\n if (trace > 0.0) {\n // |w| > 1/2, may as well choose w > 1/2\n const root = Math.sqrt(trace + 1); // 2w\n dst[3] = 0.5 * root;\n const invRoot = 0.5 / root; // 1/(4w)\n\n dst[0] = (m[6] - m[9]) * invRoot;\n dst[1] = (m[8] - m[2]) * invRoot;\n dst[2] = (m[1] - m[4]) * invRoot;\n } else {\n // |w| <= 1/2\n let i = 0;\n\n if (m[5] > m[0]) {\n i = 1;\n }\n if (m[10] > m[i * 4 + i]) {\n i = 2;\n }\n\n const j = (i + 1) % 3;\n const k = (i + 2) % 3;\n\n const root = Math.sqrt(m[i * 4 + i] - m[j * 4 + j] - m[k * 4 + k] + 1.0);\n dst[i] = 0.5 * root;\n\n const invRoot = 0.5 / root;\n\n dst[3] = (m[j * 4 + k] - m[k * 4 + j]) * invRoot;\n dst[j] = (m[j * 4 + i] + m[i * 4 + j]) * invRoot;\n dst[k] = (m[k * 4 + i] + m[i * 4 + k]) * invRoot;\n }\n\n return dst;\n}\n\n/**\n * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion.\n *\n * @param xAngleInRadians - angle to rotate around X axis in radians.\n * @param yAngleInRadians - angle to rotate around Y axis in radians.\n * @param zAngleInRadians - angle to rotate around Z axis in radians.\n * @param order - order to apply euler angles\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion representing the same rotation as the euler angles applied in the given order\n */\nexport function fromEuler(\n xAngleInRadians: number,\n yAngleInRadians: number,\n zAngleInRadians: number,\n order: RotationOrder,\n dst?: Quat) {\n dst = dst || new QuatType(4);\n\n const xHalfAngle = xAngleInRadians * 0.5;\n const yHalfAngle = yAngleInRadians * 0.5;\n const zHalfAngle = zAngleInRadians * 0.5;\n\n const sx = Math.sin(xHalfAngle);\n const cx = Math.cos(xHalfAngle);\n const sy = Math.sin(yHalfAngle);\n const cy = Math.cos(yHalfAngle);\n const sz = Math.sin(zHalfAngle);\n const cz = Math.cos(zHalfAngle);\n\n switch (order) {\n case 'xyz':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'xzy':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n case 'yxz':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n case 'yzx':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'zxy':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'zyx':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n default:\n throw new Error(`Unknown rotation order: ${order}`);\n }\n\n return dst;\n}\n\n/**\n * Copies a quaternion. (same as {@link quat.clone})\n * Also see {@link quat.create} and {@link quat.set}\n * @param q - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is a copy of q\n */\nexport function copy(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = q[0];\n dst[1] = q[1];\n dst[2] = q[2];\n dst[3] = q[3];\n\n return dst;\n}\n\n/**\n * Clones a quaternion. (same as {@link quat.copy})\n * Also see {@link quat.create} and {@link quat.set}\n * @param q - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A copy of q.\n */\nexport const clone = copy;\n\n/**\n * Adds two quaternions; assumes a and b have the same dimension.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the sum of a and b.\n */\nexport function add(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n dst[3] = a[3] + b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two quaternions.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the difference of a and b.\n */\nexport function subtract(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n dst[3] = a[3] - b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two quaternions.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Multiplies a quaternion by a scalar.\n * @param v - The quaternion.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport function mulScalar(v: Quat, k: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n dst[3] = v[3] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a quaternion by a scalar. (same as mulScalar)\n * @param v - The quaternion.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport function divScalar(v: Quat, k: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n dst[3] = v[3] / k;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two quaternions\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns dot product\n */\nexport function dot(a: Quat, b: Quat): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]);\n}\n\n/**\n * Performs linear interpolation on two quaternions.\n * Given quaternions a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param t - Interpolation coefficient.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n dst[3] = a[3] + t * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Computes the length of quaternion\n * @param v - quaternion.\n * @returns length of quaternion.\n */\nexport function length(v: Quat): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n}\n\n/**\n * Computes the length of quaternion (same as length)\n * @param v - quaternion.\n * @returns length of quaternion.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of quaternion\n * @param v - quaternion.\n * @returns square of the length of quaternion.\n */\nexport function lengthSq(v: Quat): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3;\n}\n\n/**\n * Computes the square of the length of quaternion (same as lengthSq)\n * @param v - quaternion.\n * @returns square of the length of quaternion.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Divides a quaternion by its Euclidean length and returns the quotient.\n * @param v - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The normalized quaternion.\n */\nexport function normalize(v: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n dst[3] = v3 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n }\n\n return dst;\n}\n\n/**\n * Check if 2 quaternions are approximately equal\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns true if quaternions are approximately equal\n */\nexport function equalsApproximately(a: Quat, b: Quat): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON &&\n Math.abs(a[3] - b[3]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 quaternions are exactly equal\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns true if quaternions are exactly equal\n */\nexport function equals(a: Quat, b: Quat): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Creates an identity quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns an identity quaternion\n */\nexport function identity(dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 1;\n\n return dst;\n}\n\nlet tempVec3: Vec3;\nlet xUnitVec3: Vec3;\nlet yUnitVec3: Vec3;\n\n/**\n * Computes a quaternion to represent the shortest rotation from one vector to another.\n *\n * @param aUnit - the start vector\n * @param bUnit - the end vector\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns the result\n */\nexport function rotationTo(aUnit: Vec3, bUnit: Vec3, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n tempVec3 = tempVec3 || vec3.create();\n xUnitVec3 = xUnitVec3 || vec3.create(1, 0, 0);\n yUnitVec3 = yUnitVec3 || vec3.create(0, 1, 0);\n\n const dot = vec3.dot(aUnit, bUnit);\n if (dot < -0.999999) {\n vec3.cross(xUnitVec3, aUnit, tempVec3);\n if (vec3.len(tempVec3) < 0.000001) {\n vec3.cross(yUnitVec3, aUnit, tempVec3);\n }\n\n vec3.normalize(tempVec3, tempVec3);\n fromAxisAngle(tempVec3, Math.PI, dst);\n\n return dst;\n } else if (dot > 0.999999) {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 1;\n\n return dst;\n } else {\n vec3.cross(aUnit, bUnit, tempVec3);\n\n dst[0] = tempVec3[0];\n dst[1] = tempVec3[1];\n dst[2] = tempVec3[2];\n dst[3] = 1 + dot;\n\n return normalize(dst, dst);\n }\n}\n\nlet tempQuat1: Quat;\nlet tempQuat2: Quat;\n\n/**\n * Performs a spherical linear interpolation with two control points\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param c - the third quaternion\n * @param d - the fourth quaternion\n * @param t - Interpolation coefficient 0 to 1\n * @returns result\n */\nexport function sqlerp(\n a: Quat,\n b: Quat,\n c: Quat,\n d: Quat,\n t: number,\n dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n tempQuat1 = tempQuat1 || new QuatType(4);\n tempQuat2 = tempQuat2 || new QuatType(4);\n\n slerp(a, d, t, tempQuat1);\n slerp(b, c, t, tempQuat2);\n slerp(tempQuat1, tempQuat2, 2 * t * (1 - t), dst);\n\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec4.setDefaultType}.\n */\nexport type Vec4 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec4 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Vec4`. In other words you can do this\n *\n * const v = vec4.cross(v1, v2); // Creates a new Vec4 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec4.create();\n * vec4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec4 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec4\n */\nexport function setDefaultType(ctor: new (n: number) => Vec4) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a vec4; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param w - Initial w value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number, w?: number): Vec4 {\n const dst = new VecType(4);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n if (w !== undefined) {\n dst[3] = w;\n }\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Vec4, create, setDefaultType, VecType } from './vec4';\nimport { Mat4 } from './mat4';\n\nexport default Vec4;\nexport { create, setDefaultType };\n\n/**\n * Creates a vec4; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param z - Initial w value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec4\n * Also see {@link vec4.create} and {@link vec4.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param w fourth value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, w: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n dst[3] = w;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n dst[2] = Math.ceil(v[2]);\n dst[3] = Math.ceil(v[3]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n dst[2] = Math.floor(v[2]);\n dst[3] = Math.floor(v[3]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n dst[2] = Math.round(v[2]);\n dst[3] = Math.round(v[3]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec4, min = 0, max = 1, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n dst[2] = Math.min(max, Math.max(min, v[2]));\n dst[3] = Math.min(max, Math.max(min, v[3]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n dst[3] = a[3] + b[3];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec4, b: Vec4, scale: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n dst[2] = a[2] + b[2] * scale;\n dst[3] = a[3] + b[3] * scale;\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n dst[3] = a[3] - b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec4, b: Vec4): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON &&\n Math.abs(a[3] - b[3]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec4, b: Vec4): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec4, b: Vec4, t: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n dst[3] = a[3] + t * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec4, b: Vec4, t: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n dst[2] = a[2] + t[2] * (b[2] - a[2]);\n dst[3] = a[3] + t[3] * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n dst[2] = Math.max(a[2], b[2]);\n dst[3] = Math.max(a[3], b[3]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n dst[2] = Math.min(a[2], b[2]);\n dst[3] = Math.min(a[3], b[3]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec4, k: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n dst[3] = v[3] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec4, k: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n dst[3] = v[3] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n dst[2] = 1 / v[2];\n dst[3] = 1 / v[3];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the dot product of two vectors\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec4, b: Vec4): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]);\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec4): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec4): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec4, b: Vec4): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n const dw = a[3] - b[3];\n return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec4, b: Vec4): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n const dw = a[3] - b[3];\n return dx * dx + dy * dy + dz * dz + dw * dw;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n dst[3] = v3 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n }\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n dst[2] = -v[2];\n dst[3] = -v[3];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec4.clone})\n * Also see {@link vec4.create} and {@link vec4.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0];\n dst[1] = v[1];\n dst[2] = v[2];\n dst[3] = v[3];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec4.copy})\n * Also see {@link vec4.create} and {@link vec4.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n dst[2] = a[2] * b[2];\n dst[3] = a[3] * b[3];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec4, b: Vec4, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n dst[2] = a[2] / b[2];\n dst[3] = a[3] / b[3];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n return dst;\n}\n\n\n/**\n * transform vec4 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec4 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec4, m: Mat4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n const w = v[3];\n\n dst[0] = m[0] * x + m[4] * y + m[ 8] * z + m[12] * w;\n dst[1] = m[1] * x + m[5] * y + m[ 9] * z + m[13] * w;\n dst[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n dst[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n\n return dst;\n}\n\n\n/**\n * Treat a 4D vector as a direction and set it's length\n *\n * @param a The vec4 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec4, len: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec4 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec4, maxLen: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec4, b: Vec4, dst?: Vec4) {\n dst = dst || new VecType(4);\n return lerp(a, b, 0.5, dst);\n}\n","import Mat3, * as mat3 from './mat3-impl';\nimport Mat4, * as mat4 from './mat4-impl';\nimport Quat, * as quat from './quat-impl';\nimport Vec2, * as vec2 from './vec2-impl';\nimport Vec3, * as vec3 from './vec3-impl';\nimport Vec4, * as vec4 from './vec4-impl';\nimport * as utils from './utils';\n\n/**\n * Sets the type this library creates for all types\n *\n * example:\n *\n * ```\n * setDefaultType(Float64Array);\n * ```\n *\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n */\nexport function setDefaultType(ctor: new (n: number) => Float32Array | Float64Array | number[]) {\n mat3.setDefaultType(ctor);\n mat4.setDefaultType(ctor);\n quat.setDefaultType(ctor);\n vec2.setDefaultType(ctor);\n vec3.setDefaultType(ctor);\n vec4.setDefaultType(ctor);\n}\n\nexport {\n Mat3,\n mat3,\n Mat4,\n mat4,\n Quat,\n quat,\n utils,\n Vec2,\n vec2,\n Vec3,\n vec3,\n Vec4,\n vec4,\n};"],"names":["lerp","VecType","setDefaultType","create","fromValues","set","ceil","floor","round","clamp","add","addScaled","angle","dot","subtract","sub","equalsApproximately","utils.EPSILON","equals","lerpV","max","min","mulScalar","scale","divScalar","inverse","invert","cross","Vec3Type","length","len","lengthSq","lenSq","distance","dist","distanceSq","distSq","normalize","negate","copy","clone","multiply","mul","divide","div","random","zero","transformMat4","transformMat3","rotate","setLength","truncate","midpoint","MatType","fromQuat","identity","transpose","determinant","setTranslation","getTranslation","vec2.create","getAxis","setAxis","getScaling","translation","translate","rotation","scaling","uniformScaling","uniformScale","rotateX","rotateY","rotateZ","vec3.create","vec3.normalize","vec3.subtract","vec3.cross","vec3.dot","vec3.len","mat3.setDefaultType","mat4.setDefaultType","quat.setDefaultType","vec2.setDefaultType","vec3.setDefaultType","vec4.setDefaultType"],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;AAoBG;AAEI,IAAI,OAAO,GAAG,QAAQ,CAAC;AAE9B;;;;AAIG;AACG,SAAU,UAAU,CAAC,CAAS,EAAA;IAClC,MAAM,GAAG,GAAG,OAAO,CAAC;IACpB,OAAO,GAAG,CAAC,CAAC;AACZ,IAAA,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;AAI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CAAC,IAAI,CAAC,CAAC;AAC1B,IAAAC,gBAAmB,CAAC,IAAI,CAAC,CAAC;AAC1B,IAAAC,gBAAmB,CAAC,IAAI,CAAC,CAAC;AAC1B,IAAAC,gBAAmB,CAAC,IAAI,CAAC,CAAC;AAC5B;;;;"} \ No newline at end of file diff --git a/dist/2.x/wgpu-matrix.module.min.js b/dist/2.x/wgpu-matrix.module.min.js new file mode 100644 index 0000000..6ff2975 --- /dev/null +++ b/dist/2.x/wgpu-matrix.module.min.js @@ -0,0 +1,2 @@ +let n=1e-6;var t={__proto__:null,get EPSILON(){return n},degToRad:function(n){return n*Math.PI/180},euclideanModulo:function(n,t){return(n%t+t)%t},inverseLerp:function(t,r,e){const o=r-t;return Math.abs(r-t)1e-5?(t[0]=e/u,t[1]=o/u):(t[0]=0,t[1]=0),t}function p(n,t){return(t=t||new r(2))[0]=n[0],t[1]=n[1],t}function q(n,t,e){return(e=e||new r(2))[0]=n[0]*t[0],e[1]=n[1]*t[1],e}function b(n,t,e){return(e=e||new r(2))[0]=n[0]/t[0],e[1]=n[1]/t[1],e}function y(n,t,e){return v(n,e=e||new r(2)),f(e,t,e)}var x={__proto__:null,add:function(n,t,e){return(e=e||new r(2))[0]=n[0]+t[0],e[1]=n[1]+t[1],e},addScaled:function(n,t,e,o){return(o=o||new r(2))[0]=n[0]+t[0]*e,o[1]=n[1]+t[1]*e,o},angle:function(n,t){const r=n[0],e=n[1],o=t[0],u=t[1],a=Math.sqrt(r*r+e*e)*Math.sqrt(o*o+u*u),c=a&&M(n,t)/a;return Math.acos(c)},ceil:function(n,t){return(t=t||new r(2))[0]=Math.ceil(n[0]),t[1]=Math.ceil(n[1]),t},clamp:function(n,t=0,e=1,o){return(o=o||new r(2))[0]=Math.min(e,Math.max(t,n[0])),o[1]=Math.min(e,Math.max(t,n[1])),o},clone:p,copy:p,create:o,cross:function(n,t,r){r=r||new u(3);const e=n[0]*t[1]-n[1]*t[0];return r[0]=0,r[1]=0,r[2]=e,r},dist:d,distSq:m,distance:d,distanceSq:m,div:b,divScalar:function(n,t,e){return(e=e||new r(2))[0]=n[0]/t,e[1]=n[1]/t,e},divide:b,dot:M,equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]},equalsApproximately:function(t,r){return Math.abs(t[0]-r[0])t?y(n,t,e):p(n,e)},zero:function(n){return(n=n||new r(2))[0]=0,n[1]=0,n}};let g=Float32Array;const S=new Map([[Float32Array,()=>new Float32Array(12)],[Float64Array,()=>new Float64Array(12)],[Array,()=>new Array(12).fill(0)]]);let A=S.get(Float32Array);function _(n){const t=g;return g=n,A=S.get(n),t}function T(n,t){return(t=t||A())[0]=n[0],t[1]=n[1],t[2]=n[2],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[8]=n[8],t[9]=n[9],t[10]=n[10],t}function z(n){return(n=n||A())[0]=1,n[1]=0,n[2]=0,n[4]=0,n[5]=1,n[6]=0,n[8]=0,n[9]=0,n[10]=1,n}function F(n,t){t=t||A();const r=n[0],e=n[1],o=n[2],u=n[4],a=n[5],c=n[6],i=n[8],s=n[9],f=n[10],h=f*a-c*s,M=-f*u+c*i,l=s*u-a*i,w=1/(r*h+e*M+o*l);return t[0]=h*w,t[1]=(-f*e+o*s)*w,t[2]=(c*e-o*a)*w,t[4]=M*w,t[5]=(f*r-o*i)*w,t[6]=(-c*r+o*u)*w,t[8]=l*w,t[9]=(-s*r+e*i)*w,t[10]=(a*r-e*u)*w,t}function k(n,t,r){r=r||A();const e=n[0],o=n[1],u=n[2],a=n[4],c=n[5],i=n[6],s=n[8],f=n[9],h=n[10],M=t[0],l=t[1],w=t[2],d=t[4],m=t[5],v=t[6],p=t[8],q=t[9],b=t[10];return r[0]=e*M+a*l+s*w,r[1]=o*M+c*l+f*w,r[2]=u*M+i*l+h*w,r[4]=e*d+a*m+s*v,r[5]=o*d+c*m+f*v,r[6]=u*d+i*m+h*v,r[8]=e*p+a*q+s*b,r[9]=o*p+c*q+f*b,r[10]=u*p+i*q+h*b,r}var D={__proto__:null,clone:T,copy:T,create:function(n,t,r,e,o,u,a,c,i){const s=A();return s[3]=0,s[7]=0,s[11]=0,void 0!==n&&(s[0]=n,void 0!==t&&(s[1]=t,void 0!==r&&(s[2]=r,void 0!==e&&(s[4]=e,void 0!==o&&(s[5]=o,void 0!==u&&(s[6]=u,void 0!==a&&(s[8]=a,void 0!==c&&(s[9]=c,void 0!==i&&(s[10]=i))))))))),s},determinant:function(n){const t=n[0],r=n[1],e=n[2],o=n[4],u=n[5],a=n[6],c=n[8],i=n[9],s=n[10];return t*(u*s-i*a)-o*(r*s-i*e)+c*(r*a-u*e)},equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[4]===t[4]&&n[5]===t[5]&&n[6]===t[6]&&n[8]===t[8]&&n[9]===t[9]&&n[10]===t[10]},equalsApproximately:function(t,r){return Math.abs(t[0]-r[0])1e-5?(t[0]=r/a,t[1]=e/a,t[2]=o/a):(t[0]=0,t[1]=0,t[2]=0),t}function j(n,t){return(t=t||new u(3))[0]=n[0],t[1]=n[1],t[2]=n[2],t}function O(n,t,r){return(r=r||new u(3))[0]=n[0]*t[0],r[1]=n[1]*t[1],r[2]=n[2]*t[2],r}function $(n,t,r){return(r=r||new u(3))[0]=n[0]/t[0],r[1]=n[1]/t[1],r[2]=n[2]/t[2],r}function B(n,t,r){return U(n,r=r||new u(3)),V(r,t,r)}var C={__proto__:null,add:function(n,t,r){return(r=r||new u(3))[0]=n[0]+t[0],r[1]=n[1]+t[1],r[2]=n[2]+t[2],r},addScaled:function(n,t,r,e){return(e=e||new u(3))[0]=n[0]+t[0]*r,e[1]=n[1]+t[1]*r,e[2]=n[2]+t[2]*r,e},angle:function(n,t){const r=n[0],e=n[1],o=n[2],u=t[0],a=t[1],c=t[2],i=Math.sqrt(r*r+e*e+o*o)*Math.sqrt(u*u+a*a+c*c),s=i&&R(n,t)/i;return Math.acos(s)},ceil:function(n,t){return(t=t||new u(3))[0]=Math.ceil(n[0]),t[1]=Math.ceil(n[1]),t[2]=Math.ceil(n[2]),t},clamp:function(n,t=0,r=1,e){return(e=e||new u(3))[0]=Math.min(r,Math.max(t,n[0])),e[1]=Math.min(r,Math.max(t,n[1])),e[2]=Math.min(r,Math.max(t,n[2])),e},clone:j,copy:j,create:c,cross:L,dist:Q,distSq:N,distance:Q,distanceSq:N,div:$,divScalar:function(n,t,r){return(r=r||new u(3))[0]=n[0]/t,r[1]=n[1]/t,r[2]=n[2]/t,r},divide:$,dot:R,equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]},equalsApproximately:function(t,r){return Math.abs(t[0]-r[0])t?B(n,t,r):j(n,r)},zero:function(n){return(n=n||new u(3))[0]=0,n[1]=0,n[2]=0,n}};let G=Float32Array;function H(n){const t=G;return G=n,t}function J(n,t){return(t=t||new G(16))[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],t}function K(n){return(n=n||new G(16))[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function W(n,t){t=t||new G(16);const r=n[0],e=n[1],o=n[2],u=n[3],a=n[4],c=n[5],i=n[6],s=n[7],f=n[8],h=n[9],M=n[10],l=n[11],w=n[12],d=n[13],m=n[14],v=n[15],p=M*v,q=m*l,b=i*v,y=m*s,x=i*l,g=M*s,S=o*v,A=m*u,_=o*l,T=M*u,z=o*s,F=i*u,k=f*d,D=w*h,I=a*d,P=w*c,V=a*h,Z=f*c,L=r*d,R=w*e,E=r*h,X=f*e,Y=r*c,Q=a*e,N=p*c+y*h+x*d-(q*c+b*h+g*d),U=q*e+S*h+T*d-(p*e+A*h+_*d),j=b*e+A*c+z*d-(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V,r[14]=u*D+s*I+l*P+v*V,r[15]=a*D+f*I+w*P+p*V,r}let tn,rn,en;function on(n,t,r){r=r||new G(16);let e=n[0],o=n[1],u=n[2];const a=Math.sqrt(e*e+o*o+u*u);e/=a,o/=a,u/=a;const c=e*e,i=o*o,s=u*u,f=Math.cos(t),h=Math.sin(t),M=1-f;return r[0]=c+(1-c)*f,r[1]=e*o*M+u*h,r[2]=e*u*M-o*h,r[3]=0,r[4]=e*o*M-u*h,r[5]=i+(1-i)*f,r[6]=o*u*M+e*h,r[7]=0,r[8]=e*u*M+o*h,r[9]=o*u*M-e*h,r[10]=s+(1-s)*f,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function un(n,t,r,e){e=e||new G(16);let o=t[0],u=t[1],a=t[2];const c=Math.sqrt(o*o+u*u+a*a);o/=c,u/=c,a/=c;const i=o*o,s=u*u,f=a*a,h=Math.cos(r),M=Math.sin(r),l=1-h,w=i+(1-i)*h,d=o*u*l+a*M,m=o*a*l-u*M,v=o*u*l-a*M,p=s+(1-s)*h,q=u*a*l+o*M,b=o*a*l+u*M,y=u*a*l-o*M,x=f+(1-f)*h,g=n[0],S=n[1],A=n[2],_=n[3],T=n[4],z=n[5],F=n[6],k=n[7],D=n[8],I=n[9],P=n[10],V=n[11];return e[0]=w*g+d*T+m*D,e[1]=w*S+d*z+m*I,e[2]=w*A+d*F+m*P,e[3]=w*_+d*k+m*V,e[4]=v*g+p*T+q*D,e[5]=v*S+p*z+q*I,e[6]=v*A+p*F+q*P,e[7]=v*_+p*k+q*V,e[8]=b*g+y*T+x*D,e[9]=b*S+y*z+x*I,e[10]=b*A+y*F+x*P,e[11]=b*_+y*k+x*V,n!==e&&(e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15]),e}var an={__proto__:null,aim:function(n,t,r,e){return e=e||new G(16),tn=tn||c(),rn=rn||c(),en=en||c(),U(I(t,n,en),en),U(L(r,en,tn),tn),U(L(en,tn,rn),rn),e[0]=tn[0],e[1]=tn[1],e[2]=tn[2],e[3]=0,e[4]=rn[0],e[5]=rn[1],e[6]=rn[2],e[7]=0,e[8]=en[0],e[9]=en[1],e[10]=en[2],e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},axisRotate:un,axisRotation:on,cameraAim:function(n,t,r,e){return e=e||new G(16),tn=tn||c(),rn=rn||c(),en=en||c(),U(I(n,t,en),en),U(L(r,en,tn),tn),U(L(en,tn,rn),rn),e[0]=tn[0],e[1]=tn[1],e[2]=tn[2],e[3]=0,e[4]=rn[0],e[5]=rn[1],e[6]=rn[2],e[7]=0,e[8]=en[0],e[9]=en[1],e[10]=en[2],e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},clone:J,copy:J,create:function(n,t,r,e,o,u,a,c,i,s,f,h,M,l,w,d){const m=new G(16);return void 0!==n&&(m[0]=n,void 0!==t&&(m[1]=t,void 0!==r&&(m[2]=r,void 0!==e&&(m[3]=e,void 0!==o&&(m[4]=o,void 0!==u&&(m[5]=u,void 0!==a&&(m[6]=a,void 0!==c&&(m[7]=c,void 0!==i&&(m[8]=i,void 0!==s&&(m[9]=s,void 0!==f&&(m[10]=f,void 0!==h&&(m[11]=h,void 0!==M&&(m[12]=M,void 0!==l&&(m[13]=l,void 0!==w&&(m[14]=w,void 0!==d&&(m[15]=d)))))))))))))))),m},determinant:function(n){const t=n[0],r=n[1],e=n[2],o=n[3],u=n[4],a=n[5],c=n[6],i=n[7],s=n[8],f=n[9],h=n[10],M=n[11],l=n[12],w=n[13],d=n[14],m=n[15],v=h*m,p=d*M,q=c*m,b=d*i,y=c*M,x=h*i,g=e*m,S=d*o,A=e*M,_=h*o,T=e*i,z=c*o;return t*(v*a+b*f+y*w-(p*a+q*f+x*w))+u*(p*r+g*f+_*w-(v*r+S*f+A*w))+s*(q*r+S*a+T*w-(b*r+g*a+z*w))+l*(x*r+A*a+z*f-(y*r+_*a+T*f))},equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]&&n[4]===t[4]&&n[5]===t[5]&&n[6]===t[6]&&n[7]===t[7]&&n[8]===t[8]&&n[9]===t[9]&&n[10]===t[10]&&n[11]===t[11]&&n[12]===t[12]&&n[13]===t[13]&&n[14]===t[14]&&n[15]===t[15]},equalsApproximately:function(t,r){return Math.abs(t[0]-r[0])n){const n=Math.acos(d),t=Math.sin(n);s=Math.sin((1-e)*n)/t,f=Math.sin(e*n)/t}else s=1-e,f=e;return o[0]=s*u+f*h,o[1]=s*a+f*M,o[2]=s*c+f*l,o[3]=s*i+f*w,o}function wn(n,t){return(t=t||new cn(4))[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t}function dn(n,t,r){return(r=r||new cn(4))[0]=n[0]-t[0],r[1]=n[1]-t[1],r[2]=n[2]-t[2],r[3]=n[3]-t[3],r}function mn(n,t,r){return(r=r||new cn(4))[0]=n[0]*t,r[1]=n[1]*t,r[2]=n[2]*t,r[3]=n[3]*t,r}function vn(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]}function pn(n){const t=n[0],r=n[1],e=n[2],o=n[3];return Math.sqrt(t*t+r*r+e*e+o*o)}function qn(n){const t=n[0],r=n[1],e=n[2],o=n[3];return t*t+r*r+e*e+o*o}function bn(n,t){t=t||new cn(4);const r=n[0],e=n[1],o=n[2],u=n[3],a=Math.sqrt(r*r+e*e+o*o+u*u);return a>1e-5?(t[0]=r/a,t[1]=e/a,t[2]=o/a,t[3]=u/a):(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}let yn,xn,gn,Sn,An;var _n={__proto__:null,add:function(n,t,r){return(r=r||new cn(4))[0]=n[0]+t[0],r[1]=n[1]+t[1],r[2]=n[2]+t[2],r[3]=n[3]+t[3],r},angle:function(n,t){const r=vn(n,t);return Math.acos(2*r*r-1)},clone:wn,conjugate:function(n,t){return(t=t||new cn(4))[0]=-n[0],t[1]=-n[1],t[2]=-n[2],t[3]=n[3],t},copy:wn,create:fn,divScalar:function(n,t,r){return(r=r||new cn(4))[0]=n[0]/t,r[1]=n[1]/t,r[2]=n[2]/t,r[3]=n[3]/t,r},dot:vn,equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]},equalsApproximately:function(t,r){return Math.abs(t[0]-r[0])0){const e=Math.sqrt(r+1);t[3]=.5*e;const o=.5/e;t[0]=(n[6]-n[9])*o,t[1]=(n[8]-n[2])*o,t[2]=(n[1]-n[4])*o}else{let r=0;n[5]>n[0]&&(r=1),n[10]>n[4*r+r]&&(r=2);const e=(r+1)%3,o=(r+2)%3,u=Math.sqrt(n[4*r+r]-n[4*e+e]-n[4*o+o]+1);t[r]=.5*u;const a=.5/u;t[3]=(n[4*e+o]-n[4*o+e])*a,t[e]=(n[4*e+r]+n[4*r+e])*a,t[o]=(n[4*o+r]+n[4*r+o])*a}return t},fromValues:fn,identity:function(n){return(n=n||new cn(4))[0]=0,n[1]=0,n[2]=0,n[3]=1,n},inverse:function(n,t){t=t||new cn(4);const r=n[0],e=n[1],o=n[2],u=n[3],a=r*r+e*e+o*o+u*u,c=a?1/a:0;return t[0]=-r*c,t[1]=-e*c,t[2]=-o*c,t[3]=u*c,t},len:pn,lenSq:qn,length:pn,lengthSq:qn,lerp:function(n,t,r,e){return(e=e||new cn(4))[0]=n[0]+r*(t[0]-n[0]),e[1]=n[1]+r*(t[1]-n[1]),e[2]=n[2]+r*(t[2]-n[2]),e[3]=n[3]+r*(t[3]-n[3]),e},mul:Mn,mulScalar:mn,multiply:Mn,normalize:bn,rotateX:function(n,t,r){r=r||new cn(4);const e=.5*t,o=n[0],u=n[1],a=n[2],c=n[3],i=Math.sin(e),s=Math.cos(e);return r[0]=o*s+c*i,r[1]=u*s+a*i,r[2]=a*s-u*i,r[3]=c*s-o*i,r},rotateY:function(n,t,r){r=r||new cn(4);const e=.5*t,o=n[0],u=n[1],a=n[2],c=n[3],i=Math.sin(e),s=Math.cos(e);return r[0]=o*s-a*i,r[1]=u*s+c*i,r[2]=a*s+o*i,r[3]=c*s-u*i,r},rotateZ:function(n,t,r){r=r||new cn(4);const e=.5*t,o=n[0],u=n[1],a=n[2],c=n[3],i=Math.sin(e),s=Math.cos(e);return r[0]=o*s+u*i,r[1]=u*s-o*i,r[2]=a*s+c*i,r[3]=c*s-a*i,r},rotationTo:function(n,t,r){r=r||new cn(4),yn=yn||c(),xn=xn||c(1,0,0),gn=gn||c(0,1,0);const e=R(n,t);return e<-.999999?(L(xn,n,yn),X(yn)<1e-6&&L(gn,n,yn),U(yn,yn),hn(yn,Math.PI,r),r):e>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(L(n,t,yn),r[0]=yn[0],r[1]=yn[1],r[2]=yn[2],r[3]=1+e,bn(r,r))},scale:mn,set:function(n,t,r,e,o){return(o=o||new cn(4))[0]=n,o[1]=t,o[2]=r,o[3]=e,o},setDefaultType:sn,slerp:ln,sqlerp:function(n,t,r,e,o,u){return u=u||new cn(4),Sn=Sn||new cn(4),An=An||new cn(4),ln(n,e,o,Sn),ln(t,r,o,An),ln(Sn,An,2*o*(1-o),u),u},sub:dn,subtract:dn,toAxisAngle:function(t,r){r=r||c(4);const e=2*Math.acos(t[3]),o=Math.sin(.5*e);return o>n?(r[0]=t[0]/o,r[1]=t[1]/o,r[2]=t[2]/o):(r[0]=1,r[1]=0,r[2]=0),{angle:e,axis:r}}};let Tn=Float32Array;function zn(n){const t=Tn;return Tn=n,t}function Fn(n,t,r,e){const o=new Tn(4);return void 0!==n&&(o[0]=n,void 0!==t&&(o[1]=t,void 0!==r&&(o[2]=r,void 0!==e&&(o[3]=e)))),o}function kn(n,t,r){return(r=r||new Tn(4))[0]=n[0]-t[0],r[1]=n[1]-t[1],r[2]=n[2]-t[2],r[3]=n[3]-t[3],r}function Dn(n,t,r,e){return(e=e||new Tn(4))[0]=n[0]+r*(t[0]-n[0]),e[1]=n[1]+r*(t[1]-n[1]),e[2]=n[2]+r*(t[2]-n[2]),e[3]=n[3]+r*(t[3]-n[3]),e}function In(n,t,r){return(r=r||new Tn(4))[0]=n[0]*t,r[1]=n[1]*t,r[2]=n[2]*t,r[3]=n[3]*t,r}function Pn(n,t){return(t=t||new Tn(4))[0]=1/n[0],t[1]=1/n[1],t[2]=1/n[2],t[3]=1/n[3],t}function Vn(n){const t=n[0],r=n[1],e=n[2],o=n[3];return Math.sqrt(t*t+r*r+e*e+o*o)}function Zn(n){const t=n[0],r=n[1],e=n[2],o=n[3];return t*t+r*r+e*e+o*o}function Ln(n,t){const r=n[0]-t[0],e=n[1]-t[1],o=n[2]-t[2],u=n[3]-t[3];return Math.sqrt(r*r+e*e+o*o+u*u)}function Rn(n,t){const r=n[0]-t[0],e=n[1]-t[1],o=n[2]-t[2],u=n[3]-t[3];return r*r+e*e+o*o+u*u}function En(n,t){t=t||new Tn(4);const r=n[0],e=n[1],o=n[2],u=n[3],a=Math.sqrt(r*r+e*e+o*o+u*u);return a>1e-5?(t[0]=r/a,t[1]=e/a,t[2]=o/a,t[3]=u/a):(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function Xn(n,t){return(t=t||new Tn(4))[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t}function Yn(n,t,r){return(r=r||new Tn(4))[0]=n[0]*t[0],r[1]=n[1]*t[1],r[2]=n[2]*t[2],r[3]=n[3]*t[3],r}function Qn(n,t,r){return(r=r||new Tn(4))[0]=n[0]/t[0],r[1]=n[1]/t[1],r[2]=n[2]/t[2],r[3]=n[3]/t[3],r}function Nn(n,t,r){return En(n,r=r||new Tn(4)),In(r,t,r)}var Un={__proto__:null,add:function(n,t,r){return(r=r||new Tn(4))[0]=n[0]+t[0],r[1]=n[1]+t[1],r[2]=n[2]+t[2],r[3]=n[3]+t[3],r},addScaled:function(n,t,r,e){return(e=e||new Tn(4))[0]=n[0]+t[0]*r,e[1]=n[1]+t[1]*r,e[2]=n[2]+t[2]*r,e[3]=n[3]+t[3]*r,e},ceil:function(n,t){return(t=t||new Tn(4))[0]=Math.ceil(n[0]),t[1]=Math.ceil(n[1]),t[2]=Math.ceil(n[2]),t[3]=Math.ceil(n[3]),t},clamp:function(n,t=0,r=1,e){return(e=e||new Tn(4))[0]=Math.min(r,Math.max(t,n[0])),e[1]=Math.min(r,Math.max(t,n[1])),e[2]=Math.min(r,Math.max(t,n[2])),e[3]=Math.min(r,Math.max(t,n[3])),e},clone:Xn,copy:Xn,create:Fn,dist:Ln,distSq:Rn,distance:Ln,distanceSq:Rn,div:Qn,divScalar:function(n,t,r){return(r=r||new Tn(4))[0]=n[0]/t,r[1]=n[1]/t,r[2]=n[2]/t,r[3]=n[3]/t,r},divide:Qn,dot:function(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]},equals:function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]},equalsApproximately:function(t,r){return Math.abs(t[0]-r[0])t?Nn(n,t,r):Xn(n,r)},zero:function(n){return(n=n||new Tn(4))[0]=0,n[1]=0,n[2]=0,n[3]=0,n}};function jn(n){_(n),H(n),sn(n),e(n),a(n),zn(n)}export{D as mat3,an as mat4,_n as quat,jn as setDefaultType,t as utils,x as vec2,C as vec3,Un as vec4}; +//# sourceMappingURL=wgpu-matrix.module.min.js.map diff --git a/dist/2.x/wgpu-matrix.module.min.js.map b/dist/2.x/wgpu-matrix.module.min.js.map new file mode 100644 index 0000000..972811d --- /dev/null +++ b/dist/2.x/wgpu-matrix.module.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wgpu-matrix.module.min.js","sources":["../../../src/utils.ts","../../../src/vec2.ts","../../../src/vec3.ts","../../../src/vec2-impl.ts","../../../src/mat3-impl.ts","../../../src/vec3-impl.ts","../../../src/mat4-impl.ts","../../../src/quat.ts","../../../src/quat-impl.ts","../../../src/vec4.ts","../../../src/vec4-impl.ts","../../../src/wgpu-matrix.ts"],"sourcesContent":["/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nexport let EPSILON = 0.000001;\n\n/**\n * Set the value for EPSILON for various checks\n * @param v - Value to use for EPSILON.\n * @returns previous value of EPSILON;\n */\nexport function setEpsilon(v: number): number {\n const old = EPSILON;\n EPSILON = v;\n return old;\n}\n\n/**\n * Convert degrees to radians\n * @param degrees - Angle in degrees\n * @returns angle converted to radians\n */\nexport function degToRad(degrees: number): number {\n return degrees * Math.PI / 180;\n}\n\n/**\n * Convert radians to degrees\n * @param radians - Angle in radians\n * @returns angle converted to degrees\n */\nexport function radToDeg(radians: number): number {\n return radians * 180 / Math.PI;\n}\n\n/**\n * Lerps between a and b via t\n * @param a - starting value\n * @param b - ending value\n * @param t - value where 0 = a and 1 = b\n * @returns a + (b - a) * t\n */\nexport function lerp(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\n/**\n * Compute the opposite of lerp. Given a and b and a value between\n * a and b returns a value between 0 and 1. 0 if a, 1 if b.\n * Note: no clamping is done.\n * @param a - start value\n * @param b - end value\n * @param v - value between a and b\n * @returns (v - a) / (b - a)\n */\nexport function inverseLerp(a: number, b: number, v: number): number {\n const d = b - a;\n return (Math.abs(b - a) < EPSILON)\n ? a\n : (v - a) / d;\n}\n\n/**\n * Compute the euclidean modulo\n *\n * ```\n * // table for n / 3\n * -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 <- n\n * ------------------------------------\n * -2 -1 -0 -2 -1 0, 1, 2, 0, 1, 2 <- n % 3\n * 1 2 0 1 2 0, 1, 2, 0, 1, 2 <- euclideanModule(n, 3)\n * ```\n *\n * @param n - dividend\n * @param m - divisor\n * @returns the euclidean modulo of n / m\n */\nexport function euclideanModulo(n: number, m: number) {\n return ((n % m) + m) % m;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 2 values, Float32Array with 2 values, or a Float64Array with 2 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec2.setDefaultType}.\n */\nexport type Vec2 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec2 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new Vec2. In other words you can do this\n *\n * const v = vec2.cross(v1, v2); // Creates a new Vec2 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec2.create();\n * vec2.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec2.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec2 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec2\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec2\n */\nexport function setDefaultType(ctor: new (n: number) => Vec2) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a Vec2; may be called with x, y, z to set initial values.\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Vec2's specified type\n * it would be faster to use\n *\n * ```\n * const v = vec2.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Vec2Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `vec2.create` is usually used\n * to create a Vec2 to be filled out as in\n *\n * ```\n * const sum = vec2.create();\n * vec2.add(v1, v2, sum);\n * ```\n *\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @returns the created vector\n */\nexport function create(x = 0, y = 0): Vec2 {\n const dst = new VecType(2);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n }\n }\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 3 values, Float32Array with 3 values, or a Float64Array with 3 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec3.setDefaultType}.\n */\nexport type Vec3 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec3 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Vec3`. In other words you can do this\n *\n * const v = vec3.cross(v1, v2); // Creates a new Vec3 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec3.create();\n * vec3.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec3.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec3 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec3\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec3\n */\nexport function setDefaultType(ctor: new (n: number) => Vec3) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a vec3; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number): Vec3 {\n const dst = new VecType(3);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Vec2, create, setDefaultType, VecType } from './vec2';\nimport { Vec3, VecType as Vec3Type } from './vec3';\n\nexport default Vec2;\nexport { create, setDefaultType };\n\n/**\n * Creates a Vec2; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec2\n * Also see {@link vec2.create} and {@link vec2.copy}\n *\n * @param x first value\n * @param y second value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = x;\n dst[1] = y;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec2, min = 0, max = 1, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec2, b: Vec2, scale: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n\n return dst;\n}\n\n/**\n * Returns the angle in radians between two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns The angle in radians between the 2 vectors.\n */\nexport function angle(a: Vec2, b: Vec2): number {\n const ax = a[0];\n const ay = a[1];\n const bx = b[0];\n const by = b[1];\n const mag1 = Math.sqrt(ax * ax + ay * ay);\n const mag2 = Math.sqrt(bx * bx + by * by);\n const mag = mag1 * mag2;\n const cosine = mag && dot(a, b) / mag;\n return Math.acos(cosine);\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec2, b: Vec2): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec2, b: Vec2): boolean {\n return a[0] === b[0] && a[1] === b[1];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec2, b: Vec2, t: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec2, b: Vec2, t: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec2, k: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec2, k: number, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the cross product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of a cross b.\n */\nexport function cross(a: Vec2, b: Vec2, dst?: Vec3): Vec3 {\n dst = dst || new Vec3Type(3);\n const z = a[0] * b[1] - a[1] * b[0];\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = z;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec2, b: Vec2): number {\n return a[0] * b[0] + a[1] * b[1];\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec2): number {\n const v0 = v[0];\n const v1 = v[1];\n return Math.sqrt(v0 * v0 + v1 * v1);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec2): number {\n const v0 = v[0];\n const v1 = v[1];\n return v0 * v0 + v1 * v1;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec2, b: Vec2): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n return Math.sqrt(dx * dx + dy * dy);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec2, b: Vec2): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n return dx * dx + dy * dy;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const v0 = v[0];\n const v1 = v[1];\n const len = Math.sqrt(v0 * v0 + v1 * v1);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n }\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec2.clone})\n * Also see {@link vec2.create} and {@link vec2.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = v[0];\n dst[1] = v[1];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec2.copy})\n * Also see {@link vec2.create} and {@link vec2.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec2, b: Vec2, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec2, b: Vec2, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Creates a random unit vector * scale\n * @param scale - Default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The random vector.\n */\nexport function random(scale = 1, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const angle = Math.random() * 2 * Math.PI;\n dst[0] = Math.cos(angle) * scale;\n dst[1] = Math.sin(angle) * scale;\n\n return dst;\n}\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n dst[0] = 0;\n dst[1] = 0;\n\n return dst;\n}\n\n\n/**\n * transform Vec2 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional Vec2 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec2, m: Mat4, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const x = v[0];\n const y = v[1];\n\n dst[0] = x * m[0] + y * m[4] + m[12];\n dst[1] = x * m[1] + y * m[5] + m[13];\n\n return dst;\n}\n\n/**\n * Transforms vec4 by 3x3 matrix\n *\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional Vec2 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat3(v: Vec2, m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || new VecType(2);\n\n const x = v[0];\n const y = v[1];\n\n dst[0] = m[0] * x + m[4] * y + m[8];\n dst[1] = m[1] * x + m[5] * y + m[9];\n\n return dst;\n}\n\n/**\n * Rotate a 2D vector\n *\n * @param a The vec2 point to rotate\n * @param b The origin of the rotation\n * @param rad The angle of rotation in radians\n * @returns the rotated vector\n */\nexport function rotate(a: Vec2, b: Vec2, rad: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n // Translate point to the origin\n const p0 = a[0] - b[0];\n const p1 = a[1] - b[1];\n const sinC = Math.sin(rad);\n const cosC = Math.cos(rad);\n\n //perform rotation and translate to correct position\n dst[0] = p0 * cosC - p1 * sinC + b[0];\n dst[1] = p0 * sinC + p1 * cosC + b[1];\n\n return dst;\n}\n\n/**\n * Treat a 2D vector as a direction and set it's length\n *\n * @param a The vec2 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec2, len: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec2 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec2, maxLen: number, dst?: Vec2) {\n dst = dst || new VecType(2);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec2, b: Vec2, dst?: Vec2) {\n dst = dst || new VecType(2);\n return lerp(a, b, 0.5, dst);\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nimport * as utils from './utils.js';\nimport { Quat } from './quat';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport Vec2, * as vec2 from './vec2-impl';\n\nexport default Mat3;\n\nexport type Mat3LikeCtor = new (n: number) => Mat3;\n\n/**\n * 3x3 Matrix math math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new matrix. In other words you can do this\n *\n * const mat = mat3.translation([1, 2, 3]); // Creates a new translation matrix\n *\n * or\n *\n * const mat = mat3.create();\n * mat3.translation([1, 2, 3], mat); // Puts translation matrix in mat.\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always save to pass any matrix as the destination. So for example\n *\n * const mat = mat3.identity();\n * const trans = mat3.translation([1, 2, 3]);\n * mat3.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat.\n *\n */\nlet MatType: Mat3LikeCtor = Float32Array;\n\n// This mess is because with Mat3 we have 3 unused elements.\n// For Float32Array and Float64Array that's not an issue\n// but for Array it's troublesome\nconst ctorMap = new Map Mat3>([\n [Float32Array, () => new Float32Array(12)],\n [Float64Array, () => new Float64Array(12)],\n [Array, () => new Array(12).fill(0)],\n]);\nlet newMat3: () => Mat3 = ctorMap.get(Float32Array)!;\n\n/**\n * Sets the type this library creates for a Mat3\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Mat3\n */\nexport function setDefaultType(ctor: new (n: number) => Mat3) {\n const oldType = MatType;\n MatType = ctor;\n newMat3 = ctorMap.get(ctor)!;\n return oldType;\n}\n\n/**\n * Create a Mat3 from values\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Mat3's specified type\n * it would be faster to use\n *\n * ```\n * const m = mat3.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Mat3Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `mat3.create` is usually used\n * to create a Mat3 to be filled out as in\n *\n * ```\n * const m = mat3.create();\n * mat3.perspective(fov, aspect, near, far, m);\n * ```\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @returns matrix created from values.\n */\nexport function create(\n v0?: number, v1?: number, v2?: number,\n v3?: number, v4?: number, v5?: number,\n v6?: number, v7?: number, v8?: number): Mat3 {\n const dst = newMat3();\n // to make the array homogenous\n dst[3] = 0;\n dst[7] = 0;\n dst[11] = 0;\n\n if (v0 !== undefined) {\n dst[0] = v0;\n if (v1 !== undefined) {\n dst[1] = v1;\n if (v2 !== undefined) {\n dst[2] = v2;\n if (v3 !== undefined) {\n dst[4] = v3;\n if (v4 !== undefined) {\n dst[5] = v4;\n if (v5 !== undefined) {\n dst[6] = v5;\n if (v6 !== undefined) {\n dst[8] = v6;\n if (v7 !== undefined) {\n dst[9] = v7;\n if (v8 !== undefined) {\n dst[10] = v8;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n return dst;\n}\n\n/**\n * Sets the values of a Mat3\n * Also see {@link mat3.create} and {@link mat3.copy}\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 set from values.\n */\nexport function set(\n v0: number, v1: number, v2: number,\n v3: number, v4: number, v5: number,\n v6: number, v7: number, v8: number, dst?: Mat3) {\n dst = dst || newMat3();\n\n dst[0] = v0; dst[1] = v1; dst[ 2] = v2; dst[ 3] = 0;\n dst[4] = v3; dst[5] = v4; dst[ 6] = v5; dst[ 7] = 0;\n dst[8] = v6; dst[9] = v7; dst[10] = v8; dst[11] = 0;\n\n return dst;\n}\n\n/**\n * Creates a Mat3 from the upper left 3x3 part of a Mat4\n * @param m4 - source matrix\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 made from m4\n */\nexport function fromMat4(m4: Mat4, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n dst[0] = m4[0]; dst[1] = m4[1]; dst[ 2] = m4[ 2]; dst[ 3] = 0;\n dst[4] = m4[4]; dst[5] = m4[5]; dst[ 6] = m4[ 6]; dst[ 7] = 0;\n dst[8] = m4[8]; dst[9] = m4[9]; dst[10] = m4[10]; dst[11] = 0;\n return dst;\n}\n\n/**\n * Creates a Mat3 rotation matrix from a quaternion\n * @param q - quaternion to create matrix from\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat3 made from q\n */\nexport function fromQuat(q: Quat, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3];\n const x2 = x + x; const y2 = y + y; const z2 = z + z;\n\n const xx = x * x2;\n const yx = y * x2;\n const yy = y * y2;\n const zx = z * x2;\n const zy = z * y2;\n const zz = z * z2;\n const wx = w * x2;\n const wy = w * y2;\n const wz = w * z2;\n\n dst[ 0] = 1 - yy - zz; dst[ 1] = yx + wz; dst[ 2] = zx - wy; dst[ 3] = 0;\n dst[ 4] = yx - wz; dst[ 5] = 1 - xx - zz; dst[ 6] = zy + wx; dst[ 7] = 0;\n dst[ 8] = zx + wy; dst[ 9] = zy - wx; dst[10] = 1 - xx - yy; dst[11] = 0;\n\n return dst;\n}\n\n/**\n * Negates a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns -m.\n */\nexport function negate(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = -m[ 0]; dst[ 1] = -m[ 1]; dst[ 2] = -m[ 2];\n dst[ 4] = -m[ 4]; dst[ 5] = -m[ 5]; dst[ 6] = -m[ 6];\n dst[ 8] = -m[ 8]; dst[ 9] = -m[ 9]; dst[10] = -m[10];\n\n return dst;\n}\n\n/**\n * Copies a matrix. (same as {@link mat3.clone})\n * Also see {@link mat3.create} and {@link mat3.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport function copy(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = m[ 0]; dst[ 1] = m[ 1]; dst[ 2] = m[ 2];\n dst[ 4] = m[ 4]; dst[ 5] = m[ 5]; dst[ 6] = m[ 6];\n dst[ 8] = m[ 8]; dst[ 9] = m[ 9]; dst[10] = m[10];\n\n return dst;\n}\n\n/**\n * Copies a matrix (same as {@link mat3.copy})\n * Also see {@link mat3.create} and {@link mat3.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport const clone = copy;\n\n/**\n * Check if 2 matrices are approximately equal\n * @param a Operand matrix.\n * @param b Operand matrix.\n * @returns true if matrices are approximately equal\n */\nexport function equalsApproximately(a: Mat3, b: Mat3): boolean {\n return Math.abs(a[ 0] - b[ 0]) < utils.EPSILON &&\n Math.abs(a[ 1] - b[ 1]) < utils.EPSILON &&\n Math.abs(a[ 2] - b[ 2]) < utils.EPSILON &&\n Math.abs(a[ 4] - b[ 4]) < utils.EPSILON &&\n Math.abs(a[ 5] - b[ 5]) < utils.EPSILON &&\n Math.abs(a[ 6] - b[ 6]) < utils.EPSILON &&\n Math.abs(a[ 8] - b[ 8]) < utils.EPSILON &&\n Math.abs(a[ 9] - b[ 9]) < utils.EPSILON &&\n Math.abs(a[10] - b[10]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 matrices are exactly equal\n * @param a Operand matrix.\n * @param b Operand matrix.\n * @returns true if matrices are exactly equal\n */\nexport function equals(a: Mat3, b: Mat3): boolean {\n return a[ 0] === b[ 0] &&\n a[ 1] === b[ 1] &&\n a[ 2] === b[ 2] &&\n a[ 4] === b[ 4] &&\n a[ 5] === b[ 5] &&\n a[ 6] === b[ 6] &&\n a[ 8] === b[ 8] &&\n a[ 9] === b[ 9] &&\n a[10] === b[10];\n}\n\n/**\n * Creates a 3-by-3 identity matrix.\n *\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A 3-by-3 identity matrix.\n */\nexport function identity(dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Takes the transpose of a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The transpose of m.\n */\nexport function transpose(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n if (dst === m) {\n let t: number;\n\n // 0 1 2\n // 4 5 6\n // 8 9 10\n\n t = m[1];\n m[1] = m[4];\n m[4] = t;\n\n t = m[2];\n m[2] = m[8];\n m[8] = t;\n\n t = m[6];\n m[6] = m[9];\n m[9] = t;\n\n return dst;\n }\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n dst[ 0] = m00; dst[ 1] = m10; dst[ 2] = m20;\n dst[ 4] = m01; dst[ 5] = m11; dst[ 6] = m21;\n dst[ 8] = m02; dst[ 9] = m12; dst[10] = m22;\n\n return dst;\n}\n\n/**\n * Computes the inverse of a 3-by-3 matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport function inverse(m: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n const b01 = m22 * m11 - m12 * m21;\n const b11 = -m22 * m10 + m12 * m20;\n const b21 = m21 * m10 - m11 * m20;\n\n const invDet = 1 / (m00 * b01 + m01 * b11 + m02 * b21);\n\n dst[ 0] = b01 * invDet;\n dst[ 1] = (-m22 * m01 + m02 * m21) * invDet;\n dst[ 2] = ( m12 * m01 - m02 * m11) * invDet;\n dst[ 4] = b11 * invDet;\n dst[ 5] = ( m22 * m00 - m02 * m20) * invDet;\n dst[ 6] = (-m12 * m00 + m02 * m10) * invDet;\n dst[ 8] = b21 * invDet;\n dst[ 9] = (-m21 * m00 + m01 * m20) * invDet;\n dst[10] = ( m11 * m00 - m01 * m10) * invDet;\n\n return dst;\n}\n\n/**\n * Compute the determinant of a matrix\n * @param m - the matrix\n * @returns the determinant\n */\nexport function determinant(m: Mat3): number {\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n return m00 * (m11 * m22 - m21 * m12) -\n m10 * (m01 * m22 - m21 * m02) +\n m20 * (m01 * m12 - m11 * m02);\n}\n\n/**\n * Computes the inverse of a 3-by-3 matrix. (same as inverse)\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport const invert = inverse;\n\n/**\n * Multiplies two 3-by-3 matrices with a on the left and b on the right\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport function multiply(a: Mat3, b: Mat3, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const a00 = a[0];\n const a01 = a[1];\n const a02 = a[2];\n const a10 = a[ 4 + 0];\n const a11 = a[ 4 + 1];\n const a12 = a[ 4 + 2];\n const a20 = a[ 8 + 0];\n const a21 = a[ 8 + 1];\n const a22 = a[ 8 + 2];\n const b00 = b[0];\n const b01 = b[1];\n const b02 = b[2];\n const b10 = b[ 4 + 0];\n const b11 = b[ 4 + 1];\n const b12 = b[ 4 + 2];\n const b20 = b[ 8 + 0];\n const b21 = b[ 8 + 1];\n const b22 = b[ 8 + 2];\n\n dst[ 0] = a00 * b00 + a10 * b01 + a20 * b02;\n dst[ 1] = a01 * b00 + a11 * b01 + a21 * b02;\n dst[ 2] = a02 * b00 + a12 * b01 + a22 * b02;\n dst[ 4] = a00 * b10 + a10 * b11 + a20 * b12;\n dst[ 5] = a01 * b10 + a11 * b11 + a21 * b12;\n dst[ 6] = a02 * b10 + a12 * b11 + a22 * b12;\n dst[ 8] = a00 * b20 + a10 * b21 + a20 * b22;\n dst[ 9] = a01 * b20 + a11 * b21 + a21 * b22;\n dst[10] = a02 * b20 + a12 * b21 + a22 * b22;\n\n return dst;\n}\n\n/**\n * Multiplies two 3-by-3 matrices with a on the left and b on the right (same as multiply)\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Sets the translation component of a 3-by-3 matrix to the given\n * vector.\n * @param a - The matrix.\n * @param v - The vector.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix with translation set.\n */\nexport function setTranslation(a: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || identity();\n if (a !== dst) {\n dst[ 0] = a[ 0];\n dst[ 1] = a[ 1];\n dst[ 2] = a[ 2];\n dst[ 4] = a[ 4];\n dst[ 5] = a[ 5];\n dst[ 6] = a[ 6];\n }\n dst[ 8] = v[0];\n dst[ 9] = v[1];\n dst[10] = 1;\n return dst;\n}\n\n/**\n * Returns the translation component of a 3-by-3 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n dst[0] = m[8];\n dst[1] = m[9];\n return dst;\n}\n\n/**\n * Returns an axis of a 3x3 matrix as a vector with 2 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y,\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat3, axis: number, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n return dst;\n}\n\n/**\n * Sets an axis of a 3x3 matrix as a vector with 2 entries\n * @param m - The matrix.\n * @param v - the axis vector\n * @param axis - The axis 0 = x, 1 = y;\n * @param dst - The matrix to set. If not passed a new one is created.\n * @returns The matrix with axis set.\n */\nexport function setAxis(m: Mat3, v: Vec2, axis: number, dst?: Mat3): Mat3 {\n if (dst !== m) {\n dst = copy(m, dst);\n }\n const off = axis * 4;\n dst[off + 0] = v[0];\n dst[off + 1] = v[1];\n return dst;\n}\n\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat3, dst?: Vec2): Vec2 {\n dst = dst || vec2.create();\n\n const xx = m[0];\n const xy = m[1];\n const yx = m[4];\n const yy = m[5];\n\n dst[0] = Math.sqrt(xx * xx + xy * xy);\n dst[1] = Math.sqrt(yx * yx + yy * yy);\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which translates by the given vector v.\n * @param v - The vector by which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translation matrix.\n */\nexport function translation(v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0;\n dst[ 8] = v[0]; dst[ 9] = v[1]; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Translates the given 3-by-3 matrix by the given vector v.\n * @param m - The matrix.\n * @param v - The vector by which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translated matrix.\n */\nexport function translate(m: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const v0 = v[0];\n const v1 = v[1];\n\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n\n if (m !== dst) {\n dst[ 0] = m00;\n dst[ 1] = m01;\n dst[ 2] = m02;\n dst[ 4] = m10;\n dst[ 5] = m11;\n dst[ 6] = m12;\n }\n\n dst[ 8] = m00 * v0 + m10 * v1 + m20;\n dst[ 9] = m01 * v0 + m11 * v1 + m21;\n dst[10] = m02 * v0 + m12 * v1 + m22;\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which rotates by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotation(angleInRadians: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = s; dst[ 2] = 0;\n dst[ 4] = -s; dst[ 5] = c; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 3-by-3 matrix by the given angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotate(m: Mat3, angleInRadians: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 + s * m10;\n dst[ 1] = c * m01 + s * m11;\n dst[ 2] = c * m02 + s * m12;\n\n dst[ 4] = c * m10 - s * m00;\n dst[ 5] = c * m11 - s * m01;\n dst[ 6] = c * m12 - s * m02;\n\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which scales in each dimension by an amount given by\n * the corresponding entry in the given vector; assumes the vector has three\n * entries.\n * @param v - A vector of\n * 2 entries specifying the factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function scaling(v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = v[0]; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = v[1]; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 3-by-3 matrix in each dimension by an amount\n * given by the corresponding entry in the given vector; assumes the vector has\n * three entries.\n * @param m - The matrix to be modified.\n * @param v - A vector of 2 entries specifying the\n * factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function scale(m: Mat3, v: Vec2, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n const v0 = v[0];\n const v1 = v[1];\n\n dst[ 0] = v0 * m[0 * 4 + 0];\n dst[ 1] = v0 * m[0 * 4 + 1];\n dst[ 2] = v0 * m[0 * 4 + 2];\n\n dst[ 4] = v1 * m[1 * 4 + 0];\n dst[ 5] = v1 * m[1 * 4 + 1];\n dst[ 6] = v1 * m[1 * 4 + 2];\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n\n/**\n * Creates a 3-by-3 matrix which scales uniformly in each dimension\n * @param s - Amount to scale\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function uniformScaling(s: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = s; dst[ 1] = 0; dst[ 2] = 0;\n dst[ 4] = 0; dst[ 5] = s; dst[ 6] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 3-by-3 matrix in each dimension by an amount\n * given.\n * @param m - The matrix to be modified.\n * @param s - Amount to scale.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function uniformScale(m: Mat3, s: number, dst?: Mat3): Mat3 {\n dst = dst || newMat3();\n\n dst[ 0] = s * m[0 * 4 + 0];\n dst[ 1] = s * m[0 * 4 + 1];\n dst[ 2] = s * m[0 * 4 + 2];\n\n dst[ 4] = s * m[1 * 4 + 0];\n dst[ 5] = s * m[1 * 4 + 1];\n dst[ 6] = s * m[1 * 4 + 2];\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n }\n\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Vec3, create, setDefaultType, VecType } from './vec3';\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Quat } from './quat';\n\nexport default Vec3;\nexport { create, setDefaultType };\n\n/**\n * Creates a vec3; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec3\n * Also see {@link vec3.create} and {@link vec3.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n dst[2] = Math.ceil(v[2]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n dst[2] = Math.floor(v[2]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n dst[2] = Math.round(v[2]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec3, min = 0, max = 1, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n dst[2] = Math.min(max, Math.max(min, v[2]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec3, b: Vec3, scale: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n dst[2] = a[2] + b[2] * scale;\n\n return dst;\n}\n\n/**\n * Returns the angle in radians between two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns The angle in radians between the 2 vectors.\n */\nexport function angle(a: Vec3, b: Vec3): number {\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const bx = b[0];\n const by = b[1];\n const bz = b[2];\n const mag1 = Math.sqrt(ax * ax + ay * ay + az * az);\n const mag2 = Math.sqrt(bx * bx + by * by + bz * bz);\n const mag = mag1 * mag2;\n const cosine = mag && dot(a, b) / mag;\n return Math.acos(cosine);\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec3, b: Vec3): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec3, b: Vec3): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec3, b: Vec3, t: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec3, b: Vec3, t: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n dst[2] = a[2] + t[2] * (b[2] - a[2]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n dst[2] = Math.max(a[2], b[2]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n dst[2] = Math.min(a[2], b[2]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec3, k: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec3, k: number, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n dst[2] = 1 / v[2];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the cross product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of a cross b.\n */\nexport function cross(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const t1 = a[2] * b[0] - a[0] * b[2];\n const t2 = a[0] * b[1] - a[1] * b[0];\n dst[0] = a[1] * b[2] - a[2] * b[1];\n dst[1] = t1;\n dst[2] = t2;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two vectors; assumes both vectors have\n * three entries.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec3, b: Vec3): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]);\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec3): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec3): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n return v0 * v0 + v1 * v1 + v2 * v2;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec3, b: Vec3): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n return Math.sqrt(dx * dx + dy * dy + dz * dz);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec3, b: Vec3): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n return dx * dx + dy * dy + dz * dz;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n }\n\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n dst[2] = -v[2];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec3.clone})\n * Also see {@link vec3.create} and {@link vec3.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = v[0];\n dst[1] = v[1];\n dst[2] = v[2];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec3.copy})\n * Also see {@link vec3.create} and {@link vec3.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec3, b: Vec3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n dst[2] = a[2] * b[2];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n dst[2] = a[2] / b[2];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Creates a random vector\n * @param scale - Default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The random vector.\n */\nexport function random(scale = 1, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const angle = Math.random() * 2 * Math.PI;\n const z = Math.random() * 2 - 1;\n const zScale = Math.sqrt(1 - z * z) * scale;\n dst[0] = Math.cos(angle) * zScale;\n dst[1] = Math.sin(angle) * zScale;\n dst[2] = z * scale;\n\n return dst;\n}\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n\n return dst;\n}\n\n\n/**\n * transform vec3 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec3, m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n const w = (m[3] * x + m[7] * y + m[11] * z + m[15]) || 1;\n\n dst[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n dst[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n dst[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n\n return dst;\n}\n\n/**\n * Transform vec4 by upper 3x3 matrix inside 4x4 matrix.\n * @param v - The direction.\n * @param m - The matrix.\n * @param dst - optional Vec3 to store result. If not passed a new one is created.\n * @returns The transformed vector.\n */\nexport function transformMat4Upper3x3(v: Vec3, m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n\n dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0];\n dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1];\n dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v2 * m[2 * 4 + 2];\n\n return dst;\n}\n\n/**\n * Transforms vec3 by 3x3 matrix\n *\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat3(v: Vec3, m: Mat3, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n\n dst[0] = x * m[0] + y * m[4] + z * m[8];\n dst[1] = x * m[1] + y * m[5] + z * m[9];\n dst[2] = x * m[2] + y * m[6] + z * m[10];\n\n return dst;\n}\n\n/**\n * Transforms vec3 by Quaternion\n * @param v - the vector to transform\n * @param q - the quaternion to transform by\n * @param dst - optional vec3 to store result. If not passed a new one is created.\n * @returns the transformed\n */\nexport function transformQuat(v: Vec3, q: Quat, dst?: Vec3): Vec3 {\n dst = dst || new VecType(3);\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const w2 = q[3] * 2;\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n\n const uvX = qy * z - qz * y;\n const uvY = qz * x - qx * z;\n const uvZ = qx * y - qy * x;\n\n dst[0] = x + uvX * w2 + (qy * uvZ - qz * uvY) * 2;\n dst[1] = y + uvY * w2 + (qz * uvX - qx * uvZ) * 2;\n dst[2] = z + uvZ * w2 + (qx * uvY - qy * uvX) * 2;\n\n return dst;\n}\n\n/**\n * Returns the translation component of a 4-by-4 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat3, dst?: Vec3) {\n dst = dst || new VecType(3);\n dst[0] = m[12];\n dst[1] = m[13];\n dst[2] = m[14];\n return dst;\n}\n/**\n * Returns an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat4, axis: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n dst[2] = m[off + 2];\n return dst;\n}\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat4, dst: Vec3) {\n dst = dst || new VecType(3);\n const xx = m[0];\n const xy = m[1];\n const xz = m[2];\n const yx = m[4];\n const yy = m[5];\n const yz = m[6];\n const zx = m[8];\n const zy = m[9];\n const zz = m[10];\n dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz);\n dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz);\n dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz);\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the x-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns the rotated vector\n */\nexport function rotateX(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n //Translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n //perform rotation\n r[0] = p[0];\n r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);\n r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad);\n\n //translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the y-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns the rotated vector\n */\nexport function rotateY(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n // translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n // perform rotation\n r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);\n r[1] = p[1];\n r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad);\n\n // translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Rotate a 3D vector around the z-axis\n *\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @param dst - The vector to set. If not passed a new one is created.\n * @returns {vec3} out\n */\nexport function rotateZ(a: Vec3, b: Vec3, rad: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n const p = [];\n const r = [];\n\n // translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n // perform rotation\n r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);\n r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);\n r[2] = p[2];\n\n // translate to correct position\n dst[0] = r[0] + b[0];\n dst[1] = r[1] + b[1];\n dst[2] = r[2] + b[2];\n\n return dst;\n}\n\n/**\n * Treat a 3D vector as a direction and set it's length\n *\n * @param a The vec3 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec3, len: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec3 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec3, maxLen: number, dst?: Vec3) {\n dst = dst || new VecType(3);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec3, b: Vec3, dst?: Vec3) {\n dst = dst || new VecType(3);\n return lerp(a, b, 0.5, dst);\n}\n","\nimport { Mat3 } from './mat3';\nimport { Mat4 } from './mat4';\nimport { Quat } from './quat';\nimport Vec3, * as vec3 from './vec3-impl';\nimport * as utils from './utils';\n\nexport default Mat4;\n\nexport type Mat4LikeCtor = new (n: number) => Mat4;\n\n/**\n * 4x4 Matrix math math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new matrix. In other words you can do this\n *\n * const mat = mat4.translation([1, 2, 3]); // Creates a new translation matrix\n *\n * or\n *\n * const mat = mat4.create();\n * mat4.translation([1, 2, 3], mat); // Puts translation matrix in mat.\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always save to pass any matrix as the destination. So for example\n *\n * const mat = mat4.identity();\n * const trans = mat4.translation([1, 2, 3]);\n * mat4.multiply(mat, trans, mat); // Multiplies mat * trans and puts result in mat.\n *\n */\nlet MatType: Mat4LikeCtor = Float32Array;\n\n/**\n * Sets the type this library creates for a Mat4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Mat4\n */\nexport function setDefaultType(ctor: new (n: number) => Mat4) {\n const oldType = MatType;\n MatType = ctor;\n return oldType;\n}\n\n/**\n * Create a Mat4 from values\n *\n * Note: Since passing in a raw JavaScript array\n * is valid in all circumstances, if you want to\n * force a JavaScript array into a Mat4's specified type\n * it would be faster to use\n *\n * ```\n * const m = mat4.clone(someJSArray);\n * ```\n *\n * Note: a consequence of the implementation is if your Mat4Type = `Array`\n * instead of `Float32Array` or `Float64Array` then any values you\n * don't pass in will be undefined. Usually this is not an issue since\n * (a) using `Array` is rare and (b) using `mat4.create` is usually used\n * to create a Mat4 to be filled out as in\n *\n * ```\n * const m = mat4.create();\n * mat4.perspective(fov, aspect, near, far, m);\n * ```\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param v9 - value for element 9\n * @param v10 - value for element 10\n * @param v11 - value for element 11\n * @param v12 - value for element 12\n * @param v13 - value for element 13\n * @param v14 - value for element 14\n * @param v15 - value for element 15\n * @returns created from values.\n */\nexport function create(\n v0?: number, v1?: number, v2?: number, v3?: number,\n v4?: number, v5?: number, v6?: number, v7?: number,\n v8?: number, v9?: number, v10?: number, v11?: number,\n v12?: number, v13?: number, v14?: number, v15?: number): Mat4 {\n const dst = new MatType(16);\n if (v0 !== undefined) {\n dst[0] = v0;\n if (v1 !== undefined) {\n dst[1] = v1;\n if (v2 !== undefined) {\n dst[2] = v2;\n if (v3 !== undefined) {\n dst[3] = v3;\n if (v4 !== undefined) {\n dst[4] = v4;\n if (v5 !== undefined) {\n dst[5] = v5;\n if (v6 !== undefined) {\n dst[6] = v6;\n if (v7 !== undefined) {\n dst[7] = v7;\n if (v8 !== undefined) {\n dst[8] = v8;\n if (v9 !== undefined) {\n dst[9] = v9;\n if (v10 !== undefined) {\n dst[10] = v10;\n if (v11 !== undefined) {\n dst[11] = v11;\n if (v12 !== undefined) {\n dst[12] = v12;\n if (v13 !== undefined) {\n dst[13] = v13;\n if (v14 !== undefined) {\n dst[14] = v14;\n if (v15 !== undefined) {\n dst[15] = v15;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n return dst;\n}\n\n/**\n * Sets the values of a Mat4\n * Also see {@link mat4.create} and {@link mat4.copy}\n *\n * @param v0 - value for element 0\n * @param v1 - value for element 1\n * @param v2 - value for element 2\n * @param v3 - value for element 3\n * @param v4 - value for element 4\n * @param v5 - value for element 5\n * @param v6 - value for element 6\n * @param v7 - value for element 7\n * @param v8 - value for element 8\n * @param v9 - value for element 9\n * @param v10 - value for element 10\n * @param v11 - value for element 11\n * @param v12 - value for element 12\n * @param v13 - value for element 13\n * @param v14 - value for element 14\n * @param v15 - value for element 15\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 created from values.\n */\nexport function set(\n v0: number, v1: number, v2: number, v3: number,\n v4: number, v5: number, v6: number, v7: number,\n v8: number, v9: number, v10: number, v11: number,\n v12: number, v13: number, v14: number, v15: number,\n dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = v0; dst[ 1] = v1; dst[ 2] = v2; dst[ 3] = v3;\n dst[ 4] = v4; dst[ 5] = v5; dst[ 6] = v6; dst[ 7] = v7;\n dst[ 8] = v8; dst[ 9] = v9; dst[10] = v10; dst[11] = v11;\n dst[12] = v12; dst[13] = v13; dst[14] = v14; dst[15] = v15;\n\n return dst;\n}\n\n/**\n * Creates a Mat4 from a Mat3\n * @param m3 - source matrix\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 made from m3\n */\nexport function fromMat3(m3: Mat3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = m3[0]; dst[ 1] = m3[1]; dst[ 2] = m3[ 2]; dst[ 3] = 0;\n dst[ 4] = m3[4]; dst[ 5] = m3[5]; dst[ 6] = m3[ 6]; dst[ 7] = 0;\n dst[ 8] = m3[8]; dst[ 9] = m3[9]; dst[10] = m3[10]; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a Mat4 rotation matrix from a quaternion\n * @param q - quaternion to create matrix from\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns Mat4 made from q\n */\nexport function fromQuat(q: Quat, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3];\n const x2 = x + x; const y2 = y + y; const z2 = z + z;\n\n const xx = x * x2;\n const yx = y * x2;\n const yy = y * y2;\n const zx = z * x2;\n const zy = z * y2;\n const zz = z * z2;\n const wx = w * x2;\n const wy = w * y2;\n const wz = w * z2;\n\n dst[ 0] = 1 - yy - zz; dst[ 1] = yx + wz; dst[ 2] = zx - wy; dst[ 3] = 0;\n dst[ 4] = yx - wz; dst[ 5] = 1 - xx - zz; dst[ 6] = zy + wx; dst[ 7] = 0;\n dst[ 8] = zx + wy; dst[ 9] = zy - wx; dst[10] = 1 - xx - yy; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Negates a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns -m.\n */\nexport function negate(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = -m[ 0]; dst[ 1] = -m[ 1]; dst[ 2] = -m[ 2]; dst[ 3] = -m[ 3];\n dst[ 4] = -m[ 4]; dst[ 5] = -m[ 5]; dst[ 6] = -m[ 6]; dst[ 7] = -m[ 7];\n dst[ 8] = -m[ 8]; dst[ 9] = -m[ 9]; dst[10] = -m[10]; dst[11] = -m[11];\n dst[12] = -m[12]; dst[13] = -m[13]; dst[14] = -m[14]; dst[15] = -m[15];\n\n return dst;\n}\n\n/**\n * Copies a matrix. (same as {@link mat4.clone})\n * Also see {@link mat4.create} and {@link mat4.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport function copy(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = m[ 0]; dst[ 1] = m[ 1]; dst[ 2] = m[ 2]; dst[ 3] = m[ 3];\n dst[ 4] = m[ 4]; dst[ 5] = m[ 5]; dst[ 6] = m[ 6]; dst[ 7] = m[ 7];\n dst[ 8] = m[ 8]; dst[ 9] = m[ 9]; dst[10] = m[10]; dst[11] = m[11];\n dst[12] = m[12]; dst[13] = m[13]; dst[14] = m[14]; dst[15] = m[15];\n\n return dst;\n}\n\n/**\n * Copies a matrix (same as {@link mat4.copy})\n * Also see {@link mat4.create} and {@link mat4.set}\n * @param m - The matrix.\n * @param dst - The matrix. If not passed a new one is created.\n * @returns A copy of m.\n */\nexport const clone = copy;\n\n/**\n * Check if 2 matrices are approximately equal\n * @param a - Operand matrix.\n * @param b - Operand matrix.\n * @returns true if matrices are approximately equal\n */\nexport function equalsApproximately(a: Mat4, b: Mat4): boolean {\n return Math.abs(a[ 0] - b[ 0]) < utils.EPSILON &&\n Math.abs(a[ 1] - b[ 1]) < utils.EPSILON &&\n Math.abs(a[ 2] - b[ 2]) < utils.EPSILON &&\n Math.abs(a[ 3] - b[ 3]) < utils.EPSILON &&\n Math.abs(a[ 4] - b[ 4]) < utils.EPSILON &&\n Math.abs(a[ 5] - b[ 5]) < utils.EPSILON &&\n Math.abs(a[ 6] - b[ 6]) < utils.EPSILON &&\n Math.abs(a[ 7] - b[ 7]) < utils.EPSILON &&\n Math.abs(a[ 8] - b[ 8]) < utils.EPSILON &&\n Math.abs(a[ 9] - b[ 9]) < utils.EPSILON &&\n Math.abs(a[10] - b[10]) < utils.EPSILON &&\n Math.abs(a[11] - b[11]) < utils.EPSILON &&\n Math.abs(a[12] - b[12]) < utils.EPSILON &&\n Math.abs(a[13] - b[13]) < utils.EPSILON &&\n Math.abs(a[14] - b[14]) < utils.EPSILON &&\n Math.abs(a[15] - b[15]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 matrices are exactly equal\n * @param a - Operand matrix.\n * @param b - Operand matrix.\n * @returns true if matrices are exactly equal\n */\nexport function equals(a: Mat4, b: Mat4): boolean {\n return a[ 0] === b[ 0] &&\n a[ 1] === b[ 1] &&\n a[ 2] === b[ 2] &&\n a[ 3] === b[ 3] &&\n a[ 4] === b[ 4] &&\n a[ 5] === b[ 5] &&\n a[ 6] === b[ 6] &&\n a[ 7] === b[ 7] &&\n a[ 8] === b[ 8] &&\n a[ 9] === b[ 9] &&\n a[10] === b[10] &&\n a[11] === b[11] &&\n a[12] === b[12] &&\n a[13] === b[13] &&\n a[14] === b[14] &&\n a[15] === b[15];\n}\n\n/**\n * Creates a 4-by-4 identity matrix.\n *\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A 4-by-4 identity matrix.\n */\nexport function identity(dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Takes the transpose of a matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The transpose of m.\n */\nexport function transpose(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n if (dst === m) {\n let t;\n\n t = m[1];\n m[1] = m[4];\n m[4] = t;\n\n t = m[2];\n m[2] = m[8];\n m[8] = t;\n\n t = m[3];\n m[3] = m[12];\n m[12] = t;\n\n t = m[6];\n m[6] = m[9];\n m[9] = t;\n\n t = m[7];\n m[7] = m[13];\n m[13] = t;\n\n t = m[11];\n m[11] = m[14];\n m[14] = t;\n return dst;\n }\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n dst[ 0] = m00; dst[ 1] = m10; dst[ 2] = m20; dst[ 3] = m30;\n dst[ 4] = m01; dst[ 5] = m11; dst[ 6] = m21; dst[ 7] = m31;\n dst[ 8] = m02; dst[ 9] = m12; dst[10] = m22; dst[11] = m32;\n dst[12] = m03; dst[13] = m13; dst[14] = m23; dst[15] = m33;\n\n return dst;\n}\n\n/**\n * Computes the inverse of a 4-by-4 matrix.\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport function inverse(m: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n const tmp0 = m22 * m33;\n const tmp1 = m32 * m23;\n const tmp2 = m12 * m33;\n const tmp3 = m32 * m13;\n const tmp4 = m12 * m23;\n const tmp5 = m22 * m13;\n const tmp6 = m02 * m33;\n const tmp7 = m32 * m03;\n const tmp8 = m02 * m23;\n const tmp9 = m22 * m03;\n const tmp10 = m02 * m13;\n const tmp11 = m12 * m03;\n const tmp12 = m20 * m31;\n const tmp13 = m30 * m21;\n const tmp14 = m10 * m31;\n const tmp15 = m30 * m11;\n const tmp16 = m10 * m21;\n const tmp17 = m20 * m11;\n const tmp18 = m00 * m31;\n const tmp19 = m30 * m01;\n const tmp20 = m00 * m21;\n const tmp21 = m20 * m01;\n const tmp22 = m00 * m11;\n const tmp23 = m10 * m01;\n\n const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) -\n (tmp1 * m11 + tmp2 * m21 + tmp5 * m31);\n const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) -\n (tmp0 * m01 + tmp7 * m21 + tmp8 * m31);\n const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) -\n (tmp3 * m01 + tmp6 * m11 + tmp11 * m31);\n const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) -\n (tmp4 * m01 + tmp9 * m11 + tmp10 * m21);\n\n const d = 1 / (m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3);\n\n dst[ 0] = d * t0;\n dst[ 1] = d * t1;\n dst[ 2] = d * t2;\n dst[ 3] = d * t3;\n dst[ 4] = d * ((tmp1 * m10 + tmp2 * m20 + tmp5 * m30) -\n (tmp0 * m10 + tmp3 * m20 + tmp4 * m30));\n dst[ 5] = d * ((tmp0 * m00 + tmp7 * m20 + tmp8 * m30) -\n (tmp1 * m00 + tmp6 * m20 + tmp9 * m30));\n dst[ 6] = d * ((tmp3 * m00 + tmp6 * m10 + tmp11 * m30) -\n (tmp2 * m00 + tmp7 * m10 + tmp10 * m30));\n dst[ 7] = d * ((tmp4 * m00 + tmp9 * m10 + tmp10 * m20) -\n (tmp5 * m00 + tmp8 * m10 + tmp11 * m20));\n dst[ 8] = d * ((tmp12 * m13 + tmp15 * m23 + tmp16 * m33) -\n (tmp13 * m13 + tmp14 * m23 + tmp17 * m33));\n dst[ 9] = d * ((tmp13 * m03 + tmp18 * m23 + tmp21 * m33) -\n (tmp12 * m03 + tmp19 * m23 + tmp20 * m33));\n dst[10] = d * ((tmp14 * m03 + tmp19 * m13 + tmp22 * m33) -\n (tmp15 * m03 + tmp18 * m13 + tmp23 * m33));\n dst[11] = d * ((tmp17 * m03 + tmp20 * m13 + tmp23 * m23) -\n (tmp16 * m03 + tmp21 * m13 + tmp22 * m23));\n dst[12] = d * ((tmp14 * m22 + tmp17 * m32 + tmp13 * m12) -\n (tmp16 * m32 + tmp12 * m12 + tmp15 * m22));\n dst[13] = d * ((tmp20 * m32 + tmp12 * m02 + tmp19 * m22) -\n (tmp18 * m22 + tmp21 * m32 + tmp13 * m02));\n dst[14] = d * ((tmp18 * m12 + tmp23 * m32 + tmp15 * m02) -\n (tmp22 * m32 + tmp14 * m02 + tmp19 * m12));\n dst[15] = d * ((tmp22 * m22 + tmp16 * m02 + tmp21 * m12) -\n (tmp20 * m12 + tmp23 * m22 + tmp17 * m02));\n\n return dst;\n}\n\n/**\n * Compute the determinant of a matrix\n * @param m - the matrix\n * @returns the determinant\n */\nexport function determinant(m: Mat4): number {\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n const tmp0 = m22 * m33;\n const tmp1 = m32 * m23;\n const tmp2 = m12 * m33;\n const tmp3 = m32 * m13;\n const tmp4 = m12 * m23;\n const tmp5 = m22 * m13;\n const tmp6 = m02 * m33;\n const tmp7 = m32 * m03;\n const tmp8 = m02 * m23;\n const tmp9 = m22 * m03;\n const tmp10 = m02 * m13;\n const tmp11 = m12 * m03;\n\n const t0 = (tmp0 * m11 + tmp3 * m21 + tmp4 * m31) -\n (tmp1 * m11 + tmp2 * m21 + tmp5 * m31);\n const t1 = (tmp1 * m01 + tmp6 * m21 + tmp9 * m31) -\n (tmp0 * m01 + tmp7 * m21 + tmp8 * m31);\n const t2 = (tmp2 * m01 + tmp7 * m11 + tmp10 * m31) -\n (tmp3 * m01 + tmp6 * m11 + tmp11 * m31);\n const t3 = (tmp5 * m01 + tmp8 * m11 + tmp11 * m21) -\n (tmp4 * m01 + tmp9 * m11 + tmp10 * m21);\n\n return m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3;\n}\n\n/**\n * Computes the inverse of a 4-by-4 matrix. (same as inverse)\n * @param m - The matrix.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The inverse of m.\n */\nexport const invert = inverse;\n\n/**\n * Multiplies two 4-by-4 matrices with a on the left and b on the right\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport function multiply(a: Mat4, b: Mat4, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const a00 = a[0];\n const a01 = a[1];\n const a02 = a[2];\n const a03 = a[3];\n const a10 = a[ 4 + 0];\n const a11 = a[ 4 + 1];\n const a12 = a[ 4 + 2];\n const a13 = a[ 4 + 3];\n const a20 = a[ 8 + 0];\n const a21 = a[ 8 + 1];\n const a22 = a[ 8 + 2];\n const a23 = a[ 8 + 3];\n const a30 = a[12 + 0];\n const a31 = a[12 + 1];\n const a32 = a[12 + 2];\n const a33 = a[12 + 3];\n const b00 = b[0];\n const b01 = b[1];\n const b02 = b[2];\n const b03 = b[3];\n const b10 = b[ 4 + 0];\n const b11 = b[ 4 + 1];\n const b12 = b[ 4 + 2];\n const b13 = b[ 4 + 3];\n const b20 = b[ 8 + 0];\n const b21 = b[ 8 + 1];\n const b22 = b[ 8 + 2];\n const b23 = b[ 8 + 3];\n const b30 = b[12 + 0];\n const b31 = b[12 + 1];\n const b32 = b[12 + 2];\n const b33 = b[12 + 3];\n\n dst[ 0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03;\n dst[ 1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03;\n dst[ 2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03;\n dst[ 3] = a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03;\n dst[ 4] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13;\n dst[ 5] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13;\n dst[ 6] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13;\n dst[ 7] = a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13;\n dst[ 8] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23;\n dst[ 9] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23;\n dst[10] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23;\n dst[11] = a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23;\n dst[12] = a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33;\n dst[13] = a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33;\n dst[14] = a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33;\n dst[15] = a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33;\n\n return dst;\n}\n\n/**\n * Multiplies two 4-by-4 matrices with a on the left and b on the right (same as multiply)\n * @param a - The matrix on the left.\n * @param b - The matrix on the right.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix product of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Sets the translation component of a 4-by-4 matrix to the given\n * vector.\n * @param a - The matrix.\n * @param v - The vector.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The matrix with translation set.\n */\nexport function setTranslation(a: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || identity();\n if (a !== dst) {\n dst[ 0] = a[ 0];\n dst[ 1] = a[ 1];\n dst[ 2] = a[ 2];\n dst[ 3] = a[ 3];\n dst[ 4] = a[ 4];\n dst[ 5] = a[ 5];\n dst[ 6] = a[ 6];\n dst[ 7] = a[ 7];\n dst[ 8] = a[ 8];\n dst[ 9] = a[ 9];\n dst[10] = a[10];\n dst[11] = a[11];\n }\n dst[12] = v[0];\n dst[13] = v[1];\n dst[14] = v[2];\n dst[15] = 1;\n return dst;\n}\n\n/**\n * Returns the translation component of a 4-by-4 matrix as a vector with 3\n * entries.\n * @param m - The matrix.\n * @param dst - vector to hold result. If not passed a new one is created.\n * @returns The translation component of m.\n */\nexport function getTranslation(m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n dst[0] = m[12];\n dst[1] = m[13];\n dst[2] = m[14];\n return dst;\n}\n\n/**\n * Returns an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @returns The axis component of m.\n */\nexport function getAxis(m: Mat4, axis: number, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n const off = axis * 4;\n dst[0] = m[off + 0];\n dst[1] = m[off + 1];\n dst[2] = m[off + 2];\n return dst;\n}\n\n/**\n * Sets an axis of a 4x4 matrix as a vector with 3 entries\n * @param m - The matrix.\n * @param v - the axis vector\n * @param axis - The axis 0 = x, 1 = y, 2 = z;\n * @param dst - The matrix to set. If not passed a new one is created.\n * @returns The matrix with axis set.\n */\nexport function setAxis(m: Mat4, v: Vec3, axis: number, dst: Mat4): Mat4 {\n if (dst !== m) {\n dst = copy(m, dst);\n }\n const off = axis * 4;\n dst[off + 0] = v[0];\n dst[off + 1] = v[1];\n dst[off + 2] = v[2];\n return dst;\n}\n\n/**\n * Returns the scaling component of the matrix\n * @param m - The Matrix\n * @param dst - The vector to set. If not passed a new one is created.\n */\nexport function getScaling(m: Mat4, dst?: Vec3): Vec3 {\n dst = dst || vec3.create();\n\n const xx = m[0];\n const xy = m[1];\n const xz = m[2];\n const yx = m[4];\n const yy = m[5];\n const yz = m[6];\n const zx = m[8];\n const zy = m[9];\n const zz = m[10];\n\n dst[0] = Math.sqrt(xx * xx + xy * xy + xz * xz);\n dst[1] = Math.sqrt(yx * yx + yy * yy + yz * yz);\n dst[2] = Math.sqrt(zx * zx + zy * zy + zz * zz);\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 perspective transformation matrix given the angular height\n * of the frustum, the aspect ratio, and the near and far clipping planes. The\n * arguments define a frustum extending in the negative z direction. The given\n * angle is the vertical angle of the frustum, and the horizontal angle is\n * determined to produce the given aspect ratio. The arguments near and far are\n * the distances to the near and far clipping planes. Note that near and far\n * are not z coordinates, but rather they are distances along the negative\n * z-axis. The matrix generated sends the viewing frustum to the unit box.\n * We assume a unit box extending from -1 to 1 in the x and y dimensions and\n * from 0 to 1 in the z dimension.\n *\n * Note: If you pass `Infinity` for zFar then it will produce a projection matrix\n * returns -Infinity for Z when transforming coordinates with Z <= 0 and +Infinity for Z\n * otherwise.\n *\n * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians).\n * @param aspect - The aspect ratio width / height.\n * @param zNear - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param zFar - The depth (negative z coordinate)\n * of the far clipping plane.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The perspective matrix.\n */\nexport function perspective(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians);\n\n dst[0] = f / aspect;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n dst[4] = 0;\n dst[5] = f;\n dst[6] = 0;\n dst[7] = 0;\n\n dst[8] = 0;\n dst[9] = 0;\n dst[11] = -1;\n\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (Number.isFinite(zFar)) {\n const rangeInv = 1 / (zNear - zFar);\n dst[10] = zFar * rangeInv;\n dst[14] = zFar * zNear * rangeInv;\n } else {\n dst[10] = -1;\n dst[14] = -zNear;\n }\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 reverse-z perspective transformation matrix given the angular height\n * of the frustum, the aspect ratio, and the near and far clipping planes. The\n * arguments define a frustum extending in the negative z direction. The given\n * angle is the vertical angle of the frustum, and the horizontal angle is\n * determined to produce the given aspect ratio. The arguments near and far are\n * the distances to the near and far clipping planes. Note that near and far\n * are not z coordinates, but rather they are distances along the negative\n * z-axis. The matrix generated sends the viewing frustum to the unit box.\n * We assume a unit box extending from -1 to 1 in the x and y dimensions and\n * from 1 (at -zNear) to 0 (at -zFar) in the z dimension.\n *\n * @param fieldOfViewYInRadians - The camera angle from top to bottom (in radians).\n * @param aspect - The aspect ratio width / height.\n * @param zNear - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param zFar - The depth (negative z coordinate)\n * of the far clipping plane. (default = Infinity)\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The perspective matrix.\n */export function perspectiveReverseZ(fieldOfViewYInRadians: number, aspect: number, zNear: number, zFar = Infinity, dst?: Mat4) {\n dst = dst || new MatType(16);\n\n const f = 1 / Math.tan(fieldOfViewYInRadians * 0.5);\n\n dst[ 0] = f / aspect;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n\n dst[ 4] = 0;\n dst[ 5] = f;\n dst[ 6] = 0;\n dst[ 7] = 0;\n\n dst[ 8] = 0;\n dst[ 9] = 0;\n dst[11] = -1;\n\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (zFar === Infinity) {\n dst[10] = 0;\n dst[14] = zNear;\n } else {\n const rangeInv = 1 / (zFar - zNear);\n dst[10] = zNear * rangeInv;\n dst[14] = zFar * zNear * rangeInv;\n }\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 orthogonal transformation matrix that transforms from\n * the given the left, right, bottom, and top dimensions to -1 +1 in x, and y\n * and 0 to +1 in z.\n * @param left - Left side of the near clipping plane viewport.\n * @param right - Right side of the near clipping plane viewport.\n * @param bottom - Bottom of the near clipping plane viewport.\n * @param top - Top of the near clipping plane viewport.\n * @param near - The depth (negative z coordinate)\n * of the near clipping plane.\n * @param far - The depth (negative z coordinate)\n * of the far clipping plane.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The orthographic projection matrix.\n */\nexport function ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[0] = 2 / (right - left);\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n dst[4] = 0;\n dst[5] = 2 / (top - bottom);\n dst[6] = 0;\n dst[7] = 0;\n\n dst[8] = 0;\n dst[9] = 0;\n dst[10] = 1 / (near - far);\n dst[11] = 0;\n\n dst[12] = (right + left) / (left - right);\n dst[13] = (top + bottom) / (bottom - top);\n dst[14] = near / (near - far);\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 perspective transformation matrix given the left, right,\n * top, bottom, near and far clipping planes. The arguments define a frustum\n * extending in the negative z direction. The arguments near and far are the\n * distances to the near and far clipping planes. Note that near and far are not\n * z coordinates, but rather they are distances along the negative z-axis. The\n * matrix generated sends the viewing frustum to the unit box. We assume a unit\n * box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z\n * dimension.\n * @param left - The x coordinate of the left plane of the box.\n * @param right - The x coordinate of the right plane of the box.\n * @param bottom - The y coordinate of the bottom plane of the box.\n * @param top - The y coordinate of the right plane of the box.\n * @param near - The negative z coordinate of the near plane of the box.\n * @param far - The negative z coordinate of the far plane of the box.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The perspective projection matrix.\n */\nexport function frustum(left: number, right: number, bottom: number, top: number, near: number, far: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const dx = (right - left);\n const dy = (top - bottom);\n const dz = (near - far);\n\n dst[ 0] = 2 * near / dx;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 2 * near / dy;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = (left + right) / dx;\n dst[ 9] = (top + bottom) / dy;\n dst[10] = far / dz;\n dst[11] = -1;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = near * far / dz;\n dst[15] = 0;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 reverse-z perspective transformation matrix given the left, right,\n * top, bottom, near and far clipping planes. The arguments define a frustum\n * extending in the negative z direction. The arguments near and far are the\n * distances to the near and far clipping planes. Note that near and far are not\n * z coordinates, but rather they are distances along the negative z-axis. The\n * matrix generated sends the viewing frustum to the unit box. We assume a unit\n * box extending from -1 to 1 in the x and y dimensions and from 1 (-near) to 0 (-far) in the z\n * dimension.\n * @param left - The x coordinate of the left plane of the box.\n * @param right - The x coordinate of the right plane of the box.\n * @param bottom - The y coordinate of the bottom plane of the box.\n * @param top - The y coordinate of the right plane of the box.\n * @param near - The negative z coordinate of the near plane of the box.\n * @param far - The negative z coordinate of the far plane of the box.\n * @param dst - Output matrix. If not passed a new one is created.\n * @returns The perspective projection matrix.\n */\nexport function frustumReverseZ(left: number, right: number, bottom: number, top: number, near: number, far = Infinity, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const dx = (right - left);\n const dy = (top - bottom);\n\n dst[ 0] = 2 * near / dx;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 2 * near / dy;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = (left + right) / dx;\n dst[ 9] = (top + bottom) / dy;\n dst[11] = -1;\n dst[12] = 0;\n dst[13] = 0;\n dst[15] = 0;\n\n if (far === Infinity) {\n dst[10] = 0;\n dst[14] = near;\n } else {\n const rangeInv = 1 / (far - near);\n dst[10] = near * rangeInv;\n dst[14] = far * near * rangeInv;\n }\n\n return dst;\n}\n\nlet xAxis: Vec3;\nlet yAxis: Vec3;\nlet zAxis: Vec3;\n\n/**\n * Computes a 4-by-4 aim transformation.\n *\n * This is a matrix which positions an object aiming down positive Z.\n * toward the target.\n *\n * Note: this is **NOT** the inverse of lookAt as lookAt looks at negative Z.\n *\n * @param position - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The aim matrix.\n */\nexport function aim(position: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(target, position, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = xAxis[1]; dst[ 2] = xAxis[2]; dst[ 3] = 0;\n dst[ 4] = yAxis[0]; dst[ 5] = yAxis[1]; dst[ 6] = yAxis[2]; dst[ 7] = 0;\n dst[ 8] = zAxis[0]; dst[ 9] = zAxis[1]; dst[10] = zAxis[2]; dst[11] = 0;\n dst[12] = position[0]; dst[13] = position[1]; dst[14] = position[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 camera aim transformation.\n *\n * This is a matrix which positions an object aiming down negative Z.\n * toward the target.\n *\n * Note: this is the inverse of `lookAt`\n *\n * @param eye - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The aim matrix.\n */\nexport function cameraAim(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = xAxis[1]; dst[ 2] = xAxis[2]; dst[ 3] = 0;\n dst[ 4] = yAxis[0]; dst[ 5] = yAxis[1]; dst[ 6] = yAxis[2]; dst[ 7] = 0;\n dst[ 8] = zAxis[0]; dst[ 9] = zAxis[1]; dst[10] = zAxis[2]; dst[11] = 0;\n dst[12] = eye[0]; dst[13] = eye[1]; dst[14] = eye[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Computes a 4-by-4 view transformation.\n *\n * This is a view matrix which transforms all other objects\n * to be in the space of the view defined by the parameters.\n *\n * @param eye - The position of the object.\n * @param target - The position meant to be aimed at.\n * @param up - A vector pointing up.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The look-at matrix.\n */\nexport function lookAt(eye: Vec3, target: Vec3, up: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n xAxis = xAxis || vec3.create();\n yAxis = yAxis || vec3.create();\n zAxis = zAxis || vec3.create();\n\n vec3.normalize(vec3.subtract(eye, target, zAxis), zAxis);\n vec3.normalize(vec3.cross(up, zAxis, xAxis), xAxis);\n vec3.normalize(vec3.cross(zAxis, xAxis, yAxis), yAxis);\n\n dst[ 0] = xAxis[0]; dst[ 1] = yAxis[0]; dst[ 2] = zAxis[0]; dst[ 3] = 0;\n dst[ 4] = xAxis[1]; dst[ 5] = yAxis[1]; dst[ 6] = zAxis[1]; dst[ 7] = 0;\n dst[ 8] = xAxis[2]; dst[ 9] = yAxis[2]; dst[10] = zAxis[2]; dst[11] = 0;\n\n dst[12] = -(xAxis[0] * eye[0] + xAxis[1] * eye[1] + xAxis[2] * eye[2]);\n dst[13] = -(yAxis[0] * eye[0] + yAxis[1] * eye[1] + yAxis[2] * eye[2]);\n dst[14] = -(zAxis[0] * eye[0] + zAxis[1] * eye[1] + zAxis[2] * eye[2]);\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which translates by the given vector v.\n * @param v - The vector by\n * which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translation matrix.\n */\nexport function translation(v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = v[0]; dst[13] = v[1]; dst[14] = v[2]; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Translates the given 4-by-4 matrix by the given vector v.\n * @param m - The matrix.\n * @param v - The vector by\n * which to translate.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The translated matrix.\n */\nexport function translate(m: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m03 = m[3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const m30 = m[3 * 4 + 0];\n const m31 = m[3 * 4 + 1];\n const m32 = m[3 * 4 + 2];\n const m33 = m[3 * 4 + 3];\n\n if (m !== dst) {\n dst[ 0] = m00;\n dst[ 1] = m01;\n dst[ 2] = m02;\n dst[ 3] = m03;\n dst[ 4] = m10;\n dst[ 5] = m11;\n dst[ 6] = m12;\n dst[ 7] = m13;\n dst[ 8] = m20;\n dst[ 9] = m21;\n dst[10] = m22;\n dst[11] = m23;\n }\n\n dst[12] = m00 * v0 + m10 * v1 + m20 * v2 + m30;\n dst[13] = m01 * v0 + m11 * v1 + m21 * v2 + m31;\n dst[14] = m02 * v0 + m12 * v1 + m22 * v2 + m32;\n dst[15] = m03 * v0 + m13 * v1 + m23 * v2 + m33;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationX(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = 1; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = c; dst[ 6] = s; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = -s; dst[10] = c; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateX(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m10 = m[4];\n const m11 = m[5];\n const m12 = m[6];\n const m13 = m[7];\n const m20 = m[8];\n const m21 = m[9];\n const m22 = m[10];\n const m23 = m[11];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[4] = c * m10 + s * m20;\n dst[5] = c * m11 + s * m21;\n dst[6] = c * m12 + s * m22;\n dst[7] = c * m13 + s * m23;\n dst[8] = c * m20 - s * m10;\n dst[9] = c * m21 - s * m11;\n dst[10] = c * m22 - s * m12;\n dst[11] = c * m23 - s * m13;\n\n if (m !== dst) {\n dst[ 0] = m[ 0];\n dst[ 1] = m[ 1];\n dst[ 2] = m[ 2];\n dst[ 3] = m[ 3];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationY(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = 0; dst[ 2] = -s; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = 1; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = s; dst[ 9] = 0; dst[10] = c; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateY(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m20 = m[2 * 4 + 0];\n const m21 = m[2 * 4 + 1];\n const m22 = m[2 * 4 + 2];\n const m23 = m[2 * 4 + 3];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 - s * m20;\n dst[ 1] = c * m01 - s * m21;\n dst[ 2] = c * m02 - s * m22;\n dst[ 3] = c * m03 - s * m23;\n dst[ 8] = c * m20 + s * m00;\n dst[ 9] = c * m21 + s * m01;\n dst[10] = c * m22 + s * m02;\n dst[11] = c * m23 + s * m03;\n\n if (m !== dst) {\n dst[ 4] = m[ 4];\n dst[ 5] = m[ 5];\n dst[ 6] = m[ 6];\n dst[ 7] = m[ 7];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotation matrix.\n */\nexport function rotationZ(angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c; dst[ 1] = s; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = -s; dst[ 5] = c; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = 1; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given\n * angle.\n * @param m - The matrix.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function rotateZ(m: Mat4, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const m00 = m[0 * 4 + 0];\n const m01 = m[0 * 4 + 1];\n const m02 = m[0 * 4 + 2];\n const m03 = m[0 * 4 + 3];\n const m10 = m[1 * 4 + 0];\n const m11 = m[1 * 4 + 1];\n const m12 = m[1 * 4 + 2];\n const m13 = m[1 * 4 + 3];\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n\n dst[ 0] = c * m00 + s * m10;\n dst[ 1] = c * m01 + s * m11;\n dst[ 2] = c * m02 + s * m12;\n dst[ 3] = c * m03 + s * m13;\n dst[ 4] = c * m10 - s * m00;\n dst[ 5] = c * m11 - s * m01;\n dst[ 6] = c * m12 - s * m02;\n dst[ 7] = c * m13 - s * m03;\n\n if (m !== dst) {\n dst[ 8] = m[ 8];\n dst[ 9] = m[ 9];\n dst[10] = m[10];\n dst[11] = m[11];\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the given axis by the given\n * angle.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A matrix which rotates angle radians\n * around the axis.\n */\nexport function axisRotation(axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n let x = axis[0];\n let y = axis[1];\n let z = axis[2];\n const n = Math.sqrt(x * x + y * y + z * z);\n x /= n;\n y /= n;\n z /= n;\n const xx = x * x;\n const yy = y * y;\n const zz = z * z;\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n const oneMinusCosine = 1 - c;\n\n dst[ 0] = xx + (1 - xx) * c;\n dst[ 1] = x * y * oneMinusCosine + z * s;\n dst[ 2] = x * z * oneMinusCosine - y * s;\n dst[ 3] = 0;\n dst[ 4] = x * y * oneMinusCosine - z * s;\n dst[ 5] = yy + (1 - yy) * c;\n dst[ 6] = y * z * oneMinusCosine + x * s;\n dst[ 7] = 0;\n dst[ 8] = x * z * oneMinusCosine + y * s;\n dst[ 9] = y * z * oneMinusCosine - x * s;\n dst[10] = zz + (1 - zz) * c;\n dst[11] = 0;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = 0;\n dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which rotates around the given axis by the given\n * angle. (same as axisRotation)\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns A matrix which rotates angle radians\n * around the axis.\n */\nexport const rotation = axisRotation;\n\n/**\n * Rotates the given 4-by-4 matrix around the given axis by the\n * given angle.\n * @param m - The matrix.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport function axisRotate(m: Mat4, axis: Vec3, angleInRadians: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n let x = axis[0];\n let y = axis[1];\n let z = axis[2];\n const n = Math.sqrt(x * x + y * y + z * z);\n x /= n;\n y /= n;\n z /= n;\n const xx = x * x;\n const yy = y * y;\n const zz = z * z;\n const c = Math.cos(angleInRadians);\n const s = Math.sin(angleInRadians);\n const oneMinusCosine = 1 - c;\n\n const r00 = xx + (1 - xx) * c;\n const r01 = x * y * oneMinusCosine + z * s;\n const r02 = x * z * oneMinusCosine - y * s;\n const r10 = x * y * oneMinusCosine - z * s;\n const r11 = yy + (1 - yy) * c;\n const r12 = y * z * oneMinusCosine + x * s;\n const r20 = x * z * oneMinusCosine + y * s;\n const r21 = y * z * oneMinusCosine - x * s;\n const r22 = zz + (1 - zz) * c;\n\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m03 = m[3];\n const m10 = m[4];\n const m11 = m[5];\n const m12 = m[6];\n const m13 = m[7];\n const m20 = m[8];\n const m21 = m[9];\n const m22 = m[10];\n const m23 = m[11];\n\n dst[ 0] = r00 * m00 + r01 * m10 + r02 * m20;\n dst[ 1] = r00 * m01 + r01 * m11 + r02 * m21;\n dst[ 2] = r00 * m02 + r01 * m12 + r02 * m22;\n dst[ 3] = r00 * m03 + r01 * m13 + r02 * m23;\n dst[ 4] = r10 * m00 + r11 * m10 + r12 * m20;\n dst[ 5] = r10 * m01 + r11 * m11 + r12 * m21;\n dst[ 6] = r10 * m02 + r11 * m12 + r12 * m22;\n dst[ 7] = r10 * m03 + r11 * m13 + r12 * m23;\n dst[ 8] = r20 * m00 + r21 * m10 + r22 * m20;\n dst[ 9] = r20 * m01 + r21 * m11 + r22 * m21;\n dst[10] = r20 * m02 + r21 * m12 + r22 * m22;\n dst[11] = r20 * m03 + r21 * m13 + r22 * m23;\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Rotates the given 4-by-4 matrix around the given axis by the\n * given angle. (same as rotate)\n * @param m - The matrix.\n * @param axis - The axis\n * about which to rotate.\n * @param angleInRadians - The angle by which to rotate (in radians).\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The rotated matrix.\n */\nexport const rotate = axisRotate;\n\n/**\n * Creates a 4-by-4 matrix which scales in each dimension by an amount given by\n * the corresponding entry in the given vector; assumes the vector has three\n * entries.\n * @param v - A vector of\n * three entries specifying the factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function scaling(v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = v[0]; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = v[1]; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = v[2]; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount\n * given by the corresponding entry in the given vector; assumes the vector has\n * three entries.\n * @param m - The matrix to be modified.\n * @param v - A vector of three entries specifying the\n * factor by which to scale in each dimension.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function scale(m: Mat4, v: Vec3, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n\n dst[ 0] = v0 * m[0 * 4 + 0];\n dst[ 1] = v0 * m[0 * 4 + 1];\n dst[ 2] = v0 * m[0 * 4 + 2];\n dst[ 3] = v0 * m[0 * 4 + 3];\n dst[ 4] = v1 * m[1 * 4 + 0];\n dst[ 5] = v1 * m[1 * 4 + 1];\n dst[ 6] = v1 * m[1 * 4 + 2];\n dst[ 7] = v1 * m[1 * 4 + 3];\n dst[ 8] = v2 * m[2 * 4 + 0];\n dst[ 9] = v2 * m[2 * 4 + 1];\n dst[10] = v2 * m[2 * 4 + 2];\n dst[11] = v2 * m[2 * 4 + 3];\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}\n\n/**\n * Creates a 4-by-4 matrix which scales a uniform amount in each dimension.\n * @param s - the amount to scale\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaling matrix.\n */\nexport function uniformScaling(s: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = s; dst[ 1] = 0; dst[ 2] = 0; dst[ 3] = 0;\n dst[ 4] = 0; dst[ 5] = s; dst[ 6] = 0; dst[ 7] = 0;\n dst[ 8] = 0; dst[ 9] = 0; dst[10] = s; dst[11] = 0;\n dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1;\n\n return dst;\n}\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by a uniform scale.\n * @param m - The matrix to be modified.\n * @param s - The amount to scale.\n * @param dst - matrix to hold result. If not passed a new one is created.\n * @returns The scaled matrix.\n */\nexport function uniformScale(m: Mat4, s: number, dst?: Mat4): Mat4 {\n dst = dst || new MatType(16);\n\n dst[ 0] = s * m[0 * 4 + 0];\n dst[ 1] = s * m[0 * 4 + 1];\n dst[ 2] = s * m[0 * 4 + 2];\n dst[ 3] = s * m[0 * 4 + 3];\n dst[ 4] = s * m[1 * 4 + 0];\n dst[ 5] = s * m[1 * 4 + 1];\n dst[ 6] = s * m[1 * 4 + 2];\n dst[ 7] = s * m[1 * 4 + 3];\n dst[ 8] = s * m[2 * 4 + 0];\n dst[ 9] = s * m[2 * 4 + 1];\n dst[10] = s * m[2 * 4 + 2];\n dst[11] = s * m[2 * 4 + 3];\n\n if (m !== dst) {\n dst[12] = m[12];\n dst[13] = m[13];\n dst[14] = m[14];\n dst[15] = m[15];\n }\n\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link quat.setDefaultType}.\n */\nexport type Quat = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Quat4 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Quat4`. In other words you can do this\n *\n * const v = quat4.cross(v1, v2); // Creates a new Quat4 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = quat4.create();\n * quat4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * quat4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let QuatType: new (n: number) => Quat = Float32Array;\n\n/**\n * Sets the type this library creates for a Quat4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Quat4\n */\nexport function setDefaultType(ctor: new (n: number) => Quat) {\n const oldType = QuatType;\n QuatType = ctor;\n return oldType;\n}\n\n/**\n * Creates a quat4; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param w - Initial w value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number, w?: number): Quat {\n const dst = new QuatType(4);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n if (w !== undefined) {\n dst[3] = w;\n }\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Quat, create, setDefaultType, QuatType } from './quat';\nimport { Mat3 } from './mat3.js';\nimport { Mat4 } from './mat4.js';\nimport { Vec3 } from './vec3.js';\nimport * as vec3 from './vec3-impl.js';\n\nexport type RotationOrder = 'xyz' | 'xzy' | 'yxz' | 'yzx' | 'zxy' | 'zyx';\n\nexport default Quat;\nexport { create, setDefaultType };\n\n/**\n * Creates a Quat; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param z - Initial w value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Quat\n * Also see {@link quat.create} and {@link quat.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param w fourth value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, w: number, dst?: Quat) {\n dst = dst || new QuatType(4);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n dst[3] = w;\n\n return dst;\n}\n\n/**\n * Sets a quaternion from the given angle and axis,\n * then returns it.\n *\n * @param axis - the axis to rotate around\n * @param angleInRadians - the angle\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The quaternion that represents the given axis and angle\n **/\nexport function fromAxisAngle(axis: Vec3, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n const s = Math.sin(halfAngle);\n\n dst[0] = s * axis[0];\n dst[1] = s * axis[1];\n dst[2] = s * axis[2];\n dst[3] = Math.cos(halfAngle);\n\n return dst;\n}\n\n/**\n * Gets the rotation axis and angle\n * @param q - quaternion to compute from\n * @param dst - Vec3 to hold result. If not passed in a new one is created.\n * @return angle and axis\n */\nexport function toAxisAngle(q: Quat, dst?: Vec3): { angle: number, axis: Vec3 } {\n dst = dst || vec3.create(4);\n\n const angle = Math.acos(q[3]) * 2;\n const s = Math.sin(angle * 0.5);\n if (s > utils.EPSILON) {\n dst[0] = q[0] / s;\n dst[1] = q[1] / s;\n dst[2] = q[2] / s;\n } else {\n dst[0] = 1;\n dst[1] = 0;\n dst[2] = 0;\n }\n\n return { angle, axis: dst };\n}\n\n/**\n * Returns the angle in degrees between two rotations a and b.\n * @param a - quaternion a\n * @param b - quaternion b\n * @return angle in radians between the two quaternions\n */\nexport function angle(a: Quat, b: Quat) {\n const d = dot(a, b);\n return Math.acos(2 * d * d - 1);\n}\n\n/**\n * Multiplies two quaternions\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function multiply(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const aw = a[3];\n\n const bx = b[0];\n const by = b[1];\n const bz = b[2];\n const bw = b[3];\n\n dst[0] = ax * bw + aw * bx + ay * bz - az * by;\n dst[1] = ay * bw + aw * by + az * bx - ax * bz;\n dst[2] = az * bw + aw * bz + ax * by - ay * bx;\n dst[3] = aw * bw - ax * bx - ay * by - az * bz;\n\n return dst;\n}\n\n/**\n * Multiplies two quaternions\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport const mul = multiply;\n\n/**\n * Rotates the given quaternion around the X axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateX(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const bx = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw + qw * bx;\n dst[1] = qy * bw + qz * bx;\n dst[2] = qz * bw - qy * bx;\n dst[3] = qw * bw - qx * bx;\n\n return dst;\n}\n\n/**\n * Rotates the given quaternion around the Y axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateY(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const by = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw - qz * by;\n dst[1] = qy * bw + qw * by;\n dst[2] = qz * bw + qx * by;\n dst[3] = qw * bw - qy * by;\n\n return dst;\n}\n\n/**\n * Rotates the given quaternion around the Z axis by the given angle.\n * @param q - quaternion to rotate\n * @param angleInRadians - The angle by which to rotate\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function rotateZ(q: Quat, angleInRadians: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const halfAngle = angleInRadians * 0.5;\n\n const qx = q[0];\n const qy = q[1];\n const qz = q[2];\n const qw = q[3];\n\n const bz = Math.sin(halfAngle);\n const bw = Math.cos(halfAngle);\n\n dst[0] = qx * bw + qy * bz;\n dst[1] = qy * bw - qx * bz;\n dst[2] = qz * bw + qw * bz;\n dst[3] = qw * bw - qz * bz;\n\n return dst;\n}\n\n/**\n * Spherically linear interpolate between two quaternions\n *\n * @param a - starting value\n * @param b - ending value\n * @param t - value where 0 = a and 1 = b\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the result of a * b\n */\nexport function slerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const ax = a[0];\n const ay = a[1];\n const az = a[2];\n const aw = a[3];\n\n let bx = b[0];\n let by = b[1];\n let bz = b[2];\n let bw = b[3];\n\n let cosOmega = ax * bx + ay * by + az * bz + aw * bw;\n\n if (cosOmega < 0) {\n cosOmega = -cosOmega;\n bx = -bx;\n by = -by;\n bz = -bz;\n bw = -bw;\n }\n\n let scale0;\n let scale1;\n\n if (1.0 - cosOmega > utils.EPSILON) {\n const omega = Math.acos(cosOmega);\n const sinOmega = Math.sin(omega);\n scale0 = Math.sin((1 - t) * omega) / sinOmega;\n scale1 = Math.sin(t * omega) / sinOmega;\n } else {\n scale0 = 1.0 - t;\n scale1 = t;\n }\n\n dst[0] = scale0 * ax + scale1 * bx;\n dst[1] = scale0 * ay + scale1 * by;\n dst[2] = scale0 * az + scale1 * bz;\n dst[3] = scale0 * aw + scale1 * bw;\n\n return dst;\n}\n\n/**\n * Compute the inverse of a quaternion\n *\n * @param q - quaternion to compute the inverse of\n * @returns A quaternion that is the result of a * b\n */\nexport function inverse(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const a0 = q[0];\n const a1 = q[1];\n const a2 = q[2];\n const a3 = q[3];\n\n const dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;\n const invDot = dot ? 1 / dot : 0;\n\n dst[0] = -a0 * invDot;\n dst[1] = -a1 * invDot;\n dst[2] = -a2 * invDot;\n dst[3] = a3 * invDot;\n\n return dst;\n}\n\n/**\n * Compute the conjugate of a quaternion\n * For quaternions with a magnitude of 1 (a unit quaternion)\n * this returns the same as the inverse but is faster to calculate.\n *\n * @param q - quaternion to compute the conjugate of.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The conjugate of q\n */\nexport function conjugate(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = -q[0];\n dst[1] = -q[1];\n dst[2] = -q[2];\n dst[3] = q[3];\n\n return dst;\n}\n\n/**\n * Creates a quaternion from the given rotation matrix.\n *\n * The created quaternion is not normalized.\n *\n * @param m - rotation matrix\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns the result\n */\nexport function fromMat(m: Mat3 | Mat4, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n /*\n 0 1 2\n 3 4 5\n 6 7 8\n\n 0 1 2\n 4 5 6\n 8 9 10\n */\n\n // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes\n // article \"Quaternion Calculus and Fast Animation\".\n const trace = m[0] + m[5] + m[10];\n\n if (trace > 0.0) {\n // |w| > 1/2, may as well choose w > 1/2\n const root = Math.sqrt(trace + 1); // 2w\n dst[3] = 0.5 * root;\n const invRoot = 0.5 / root; // 1/(4w)\n\n dst[0] = (m[6] - m[9]) * invRoot;\n dst[1] = (m[8] - m[2]) * invRoot;\n dst[2] = (m[1] - m[4]) * invRoot;\n } else {\n // |w| <= 1/2\n let i = 0;\n\n if (m[5] > m[0]) {\n i = 1;\n }\n if (m[10] > m[i * 4 + i]) {\n i = 2;\n }\n\n const j = (i + 1) % 3;\n const k = (i + 2) % 3;\n\n const root = Math.sqrt(m[i * 4 + i] - m[j * 4 + j] - m[k * 4 + k] + 1.0);\n dst[i] = 0.5 * root;\n\n const invRoot = 0.5 / root;\n\n dst[3] = (m[j * 4 + k] - m[k * 4 + j]) * invRoot;\n dst[j] = (m[j * 4 + i] + m[i * 4 + j]) * invRoot;\n dst[k] = (m[k * 4 + i] + m[i * 4 + k]) * invRoot;\n }\n\n return dst;\n}\n\n/**\n * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion.\n *\n * @param xAngleInRadians - angle to rotate around X axis in radians.\n * @param yAngleInRadians - angle to rotate around Y axis in radians.\n * @param zAngleInRadians - angle to rotate around Z axis in radians.\n * @param order - order to apply euler angles\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion representing the same rotation as the euler angles applied in the given order\n */\nexport function fromEuler(\n xAngleInRadians: number,\n yAngleInRadians: number,\n zAngleInRadians: number,\n order: RotationOrder,\n dst?: Quat) {\n dst = dst || new QuatType(4);\n\n const xHalfAngle = xAngleInRadians * 0.5;\n const yHalfAngle = yAngleInRadians * 0.5;\n const zHalfAngle = zAngleInRadians * 0.5;\n\n const sx = Math.sin(xHalfAngle);\n const cx = Math.cos(xHalfAngle);\n const sy = Math.sin(yHalfAngle);\n const cy = Math.cos(yHalfAngle);\n const sz = Math.sin(zHalfAngle);\n const cz = Math.cos(zHalfAngle);\n\n switch (order) {\n case 'xyz':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'xzy':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n case 'yxz':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz - sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n case 'yzx':\n dst[0] = sx * cy * cz + cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'zxy':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz + sx * sy * cz;\n dst[3] = cx * cy * cz - sx * sy * sz;\n break;\n\n case 'zyx':\n dst[0] = sx * cy * cz - cx * sy * sz;\n dst[1] = cx * sy * cz + sx * cy * sz;\n dst[2] = cx * cy * sz - sx * sy * cz;\n dst[3] = cx * cy * cz + sx * sy * sz;\n break;\n\n default:\n throw new Error(`Unknown rotation order: ${order}`);\n }\n\n return dst;\n}\n\n/**\n * Copies a quaternion. (same as {@link quat.clone})\n * Also see {@link quat.create} and {@link quat.set}\n * @param q - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is a copy of q\n */\nexport function copy(q: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = q[0];\n dst[1] = q[1];\n dst[2] = q[2];\n dst[3] = q[3];\n\n return dst;\n}\n\n/**\n * Clones a quaternion. (same as {@link quat.copy})\n * Also see {@link quat.create} and {@link quat.set}\n * @param q - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A copy of q.\n */\nexport const clone = copy;\n\n/**\n * Adds two quaternions; assumes a and b have the same dimension.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the sum of a and b.\n */\nexport function add(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n dst[3] = a[3] + b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two quaternions.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the difference of a and b.\n */\nexport function subtract(a: Quat, b: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n dst[3] = a[3] - b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two quaternions.\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns A quaternion that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Multiplies a quaternion by a scalar.\n * @param v - The quaternion.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport function mulScalar(v: Quat, k: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n dst[3] = v[3] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a quaternion by a scalar. (same as mulScalar)\n * @param v - The quaternion.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The scaled quaternion.\n */\nexport function divScalar(v: Quat, k: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n dst[3] = v[3] / k;\n\n return dst;\n}\n\n/**\n * Computes the dot product of two quaternions\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns dot product\n */\nexport function dot(a: Quat, b: Quat): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]);\n}\n\n/**\n * Performs linear interpolation on two quaternions.\n * Given quaternions a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @param t - Interpolation coefficient.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Quat, b: Quat, t: number, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n dst[3] = a[3] + t * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Computes the length of quaternion\n * @param v - quaternion.\n * @returns length of quaternion.\n */\nexport function length(v: Quat): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n}\n\n/**\n * Computes the length of quaternion (same as length)\n * @param v - quaternion.\n * @returns length of quaternion.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of quaternion\n * @param v - quaternion.\n * @returns square of the length of quaternion.\n */\nexport function lengthSq(v: Quat): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3;\n}\n\n/**\n * Computes the square of the length of quaternion (same as lengthSq)\n * @param v - quaternion.\n * @returns square of the length of quaternion.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Divides a quaternion by its Euclidean length and returns the quotient.\n * @param v - The quaternion.\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns The normalized quaternion.\n */\nexport function normalize(v: Quat, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n dst[3] = v3 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n }\n\n return dst;\n}\n\n/**\n * Check if 2 quaternions are approximately equal\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns true if quaternions are approximately equal\n */\nexport function equalsApproximately(a: Quat, b: Quat): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON &&\n Math.abs(a[3] - b[3]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 quaternions are exactly equal\n * @param a - Operand quaternion.\n * @param b - Operand quaternion.\n * @returns true if quaternions are exactly equal\n */\nexport function equals(a: Quat, b: Quat): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Creates an identity quaternion\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns an identity quaternion\n */\nexport function identity(dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 1;\n\n return dst;\n}\n\nlet tempVec3: Vec3;\nlet xUnitVec3: Vec3;\nlet yUnitVec3: Vec3;\n\n/**\n * Computes a quaternion to represent the shortest rotation from one vector to another.\n *\n * @param aUnit - the start vector\n * @param bUnit - the end vector\n * @param dst - quaternion to hold result. If not passed in a new one is created.\n * @returns the result\n */\nexport function rotationTo(aUnit: Vec3, bUnit: Vec3, dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n tempVec3 = tempVec3 || vec3.create();\n xUnitVec3 = xUnitVec3 || vec3.create(1, 0, 0);\n yUnitVec3 = yUnitVec3 || vec3.create(0, 1, 0);\n\n const dot = vec3.dot(aUnit, bUnit);\n if (dot < -0.999999) {\n vec3.cross(xUnitVec3, aUnit, tempVec3);\n if (vec3.len(tempVec3) < 0.000001) {\n vec3.cross(yUnitVec3, aUnit, tempVec3);\n }\n\n vec3.normalize(tempVec3, tempVec3);\n fromAxisAngle(tempVec3, Math.PI, dst);\n\n return dst;\n } else if (dot > 0.999999) {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 1;\n\n return dst;\n } else {\n vec3.cross(aUnit, bUnit, tempVec3);\n\n dst[0] = tempVec3[0];\n dst[1] = tempVec3[1];\n dst[2] = tempVec3[2];\n dst[3] = 1 + dot;\n\n return normalize(dst, dst);\n }\n}\n\nlet tempQuat1: Quat;\nlet tempQuat2: Quat;\n\n/**\n * Performs a spherical linear interpolation with two control points\n *\n * @param a - the first quaternion\n * @param b - the second quaternion\n * @param c - the third quaternion\n * @param d - the fourth quaternion\n * @param t - Interpolation coefficient 0 to 1\n * @returns result\n */\nexport function sqlerp(\n a: Quat,\n b: Quat,\n c: Quat,\n d: Quat,\n t: number,\n dst?: Quat): Quat {\n dst = dst || new QuatType(4);\n\n tempQuat1 = tempQuat1 || new QuatType(4);\n tempQuat2 = tempQuat2 || new QuatType(4);\n\n slerp(a, d, t, tempQuat1);\n slerp(b, c, t, tempQuat2);\n slerp(tempQuat1, tempQuat2, 2 * t * (1 - t), dst);\n\n return dst;\n}\n","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * A JavaScript array with 4 values, Float32Array with 4 values, or a Float64Array with 4 values.\n * When created by the library will create the default type which is `Float32Array`\n * but can be set by calling {@link vec4.setDefaultType}.\n */\nexport type Vec4 = number[] | Float32Array | Float64Array;\n\n/**\n *\n * Vec4 math functions.\n *\n * Almost all functions take an optional `dst` argument. If it is not passed in the\n * functions will create a new `Vec4`. In other words you can do this\n *\n * const v = vec4.cross(v1, v2); // Creates a new Vec4 with the cross product of v1 x v2.\n *\n * or\n *\n * const v = vec4.create();\n * vec4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v\n *\n * The first style is often easier but depending on where it's used it generates garbage where\n * as there is almost never allocation with the second style.\n *\n * It is always safe to pass any vector as the destination. So for example\n *\n * vec4.cross(v1, v2, v1); // Puts the cross product of v1 x v2 in v1\n *\n */\n\nexport let VecType: new (n: number) => Vec4 = Float32Array;\n\n/**\n * Sets the type this library creates for a Vec4\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n * @returns previous constructor for Vec4\n */\nexport function setDefaultType(ctor: new (n: number) => Vec4) {\n const oldType = VecType;\n VecType = ctor;\n return oldType;\n}\n\n/**\n * Creates a vec4; may be called with x, y, z to set initial values.\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param w - Initial w value.\n * @returns the created vector\n */\nexport function create(x?: number, y?: number, z?: number, w?: number): Vec4 {\n const dst = new VecType(4);\n if (x !== undefined) {\n dst[0] = x;\n if (y !== undefined) {\n dst[1] = y;\n if (z !== undefined) {\n dst[2] = z;\n if (w !== undefined) {\n dst[3] = w;\n }\n }\n }\n }\n return dst;\n}","/*\n * Copyright 2022 Gregg Tavares\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nimport * as utils from './utils.js';\nimport { Vec4, create, setDefaultType, VecType } from './vec4';\nimport { Mat4 } from './mat4';\n\nexport default Vec4;\nexport { create, setDefaultType };\n\n/**\n * Creates a vec4; may be called with x, y, z to set initial values. (same as create)\n * @param x - Initial x value.\n * @param y - Initial y value.\n * @param z - Initial z value.\n * @param z - Initial w value.\n * @returns the created vector\n */\nexport const fromValues = create;\n\n/**\n * Sets the values of a Vec4\n * Also see {@link vec4.create} and {@link vec4.copy}\n *\n * @param x first value\n * @param y second value\n * @param z third value\n * @param w fourth value\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector with its elements set.\n */\nexport function set(x: number, y: number, z: number, w: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n dst[0] = x;\n dst[1] = y;\n dst[2] = z;\n dst[3] = w;\n\n return dst;\n}\n\n/**\n * Applies Math.ceil to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the ceil of each element of v.\n */\nexport function ceil(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.ceil(v[0]);\n dst[1] = Math.ceil(v[1]);\n dst[2] = Math.ceil(v[2]);\n dst[3] = Math.ceil(v[3]);\n\n return dst;\n}\n\n/**\n * Applies Math.floor to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the floor of each element of v.\n */\nexport function floor(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.floor(v[0]);\n dst[1] = Math.floor(v[1]);\n dst[2] = Math.floor(v[2]);\n dst[3] = Math.floor(v[3]);\n\n return dst;\n}\n\n/**\n * Applies Math.round to each element of vector\n * @param v - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the round of each element of v.\n */\nexport function round(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.round(v[0]);\n dst[1] = Math.round(v[1]);\n dst[2] = Math.round(v[2]);\n dst[3] = Math.round(v[3]);\n\n return dst;\n}\n\n/**\n * Clamp each element of vector between min and max\n * @param v - Operand vector.\n * @param max - Min value, default 0\n * @param min - Max value, default 1\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that the clamped value of each element of v.\n */\nexport function clamp(v: Vec4, min = 0, max = 1, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.min(max, Math.max(min, v[0]));\n dst[1] = Math.min(max, Math.max(min, v[1]));\n dst[2] = Math.min(max, Math.max(min, v[2]));\n dst[3] = Math.min(max, Math.max(min, v[3]));\n\n return dst;\n}\n\n/**\n * Adds two vectors; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a and b.\n */\nexport function add(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + b[0];\n dst[1] = a[1] + b[1];\n dst[2] = a[2] + b[2];\n dst[3] = a[3] + b[3];\n\n return dst;\n}\n\n/**\n * Adds two vectors, scaling the 2nd; assumes a and b have the same dimension.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param scale - Amount to scale b\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the sum of a + b * scale.\n */\nexport function addScaled(a: Vec4, b: Vec4, scale: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + b[0] * scale;\n dst[1] = a[1] + b[1] * scale;\n dst[2] = a[2] + b[2] * scale;\n dst[3] = a[3] + b[3] * scale;\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport function subtract(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] - b[0];\n dst[1] = a[1] - b[1];\n dst[2] = a[2] - b[2];\n dst[3] = a[3] - b[3];\n\n return dst;\n}\n\n/**\n * Subtracts two vectors.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A vector that is the difference of a and b.\n */\nexport const sub = subtract;\n\n/**\n * Check if 2 vectors are approximately equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are approximately equal\n */\nexport function equalsApproximately(a: Vec4, b: Vec4): boolean {\n return Math.abs(a[0] - b[0]) < utils.EPSILON &&\n Math.abs(a[1] - b[1]) < utils.EPSILON &&\n Math.abs(a[2] - b[2]) < utils.EPSILON &&\n Math.abs(a[3] - b[3]) < utils.EPSILON;\n}\n\n/**\n * Check if 2 vectors are exactly equal\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns true if vectors are exactly equal\n */\nexport function equals(a: Vec4, b: Vec4): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficient.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The linear interpolated result.\n */\nexport function lerp(a: Vec4, b: Vec4, t: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + t * (b[0] - a[0]);\n dst[1] = a[1] + t * (b[1] - a[1]);\n dst[2] = a[2] + t * (b[2] - a[2]);\n dst[3] = a[3] + t * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Performs linear interpolation on two vectors.\n * Given vectors a and b and interpolation coefficient vector t, returns\n * a + t * (b - a).\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param t - Interpolation coefficients vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns the linear interpolated result.\n */\nexport function lerpV(a: Vec4, b: Vec4, t: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] + t[0] * (b[0] - a[0]);\n dst[1] = a[1] + t[1] * (b[1] - a[1]);\n dst[2] = a[2] + t[2] * (b[2] - a[2]);\n dst[3] = a[3] + t[3] * (b[3] - a[3]);\n\n return dst;\n}\n\n/**\n * Return max values of two vectors.\n * Given vectors a and b returns\n * [max(a[0], b[0]), max(a[1], b[1]), max(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The max components vector.\n */\nexport function max(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.max(a[0], b[0]);\n dst[1] = Math.max(a[1], b[1]);\n dst[2] = Math.max(a[2], b[2]);\n dst[3] = Math.max(a[3], b[3]);\n\n return dst;\n}\n\n/**\n * Return min values of two vectors.\n * Given vectors a and b returns\n * [min(a[0], b[0]), min(a[1], b[1]), min(a[2], b[2])].\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The min components vector.\n */\nexport function min(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = Math.min(a[0], b[0]);\n dst[1] = Math.min(a[1], b[1]);\n dst[2] = Math.min(a[2], b[2]);\n dst[3] = Math.min(a[3], b[3]);\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function mulScalar(v: Vec4, k: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0] * k;\n dst[1] = v[1] * k;\n dst[2] = v[2] * k;\n dst[3] = v[3] * k;\n\n return dst;\n}\n\n/**\n * Multiplies a vector by a scalar. (same as mulScalar)\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport const scale = mulScalar;\n\n/**\n * Divides a vector by a scalar.\n * @param v - The vector.\n * @param k - The scalar.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The scaled vector.\n */\nexport function divScalar(v: Vec4, k: number, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0] / k;\n dst[1] = v[1] / k;\n dst[2] = v[2] / k;\n dst[3] = v[3] / k;\n\n return dst;\n}\n\n/**\n * Inverse a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport function inverse(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = 1 / v[0];\n dst[1] = 1 / v[1];\n dst[2] = 1 / v[2];\n dst[3] = 1 / v[3];\n\n return dst;\n}\n\n/**\n * Invert a vector. (same as inverse)\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The inverted vector.\n */\nexport const invert = inverse;\n\n/**\n * Computes the dot product of two vectors\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @returns dot product\n */\nexport function dot(a: Vec4, b: Vec4): number {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]);\n}\n\n/**\n * Computes the length of vector\n * @param v - vector.\n * @returns length of vector.\n */\nexport function length(v: Vec4): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n}\n\n/**\n * Computes the length of vector (same as length)\n * @param v - vector.\n * @returns length of vector.\n */\nexport const len = length;\n\n/**\n * Computes the square of the length of vector\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport function lengthSq(v: Vec4): number {\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n return v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3;\n}\n\n/**\n * Computes the square of the length of vector (same as lengthSq)\n * @param v - vector.\n * @returns square of the length of vector.\n */\nexport const lenSq = lengthSq;\n\n/**\n * Computes the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport function distance(a: Vec4, b: Vec4): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n const dw = a[3] - b[3];\n return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw);\n}\n\n/**\n * Computes the distance between 2 points (same as distance)\n * @param a - vector.\n * @param b - vector.\n * @returns distance between a and b\n */\nexport const dist = distance;\n\n/**\n * Computes the square of the distance between 2 points\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport function distanceSq(a: Vec4, b: Vec4): number {\n const dx = a[0] - b[0];\n const dy = a[1] - b[1];\n const dz = a[2] - b[2];\n const dw = a[3] - b[3];\n return dx * dx + dy * dy + dz * dz + dw * dw;\n}\n\n/**\n * Computes the square of the distance between 2 points (same as distanceSq)\n * @param a - vector.\n * @param b - vector.\n * @returns square of the distance between a and b\n */\nexport const distSq = distanceSq;\n\n/**\n * Divides a vector by its Euclidean length and returns the quotient.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The normalized vector.\n */\nexport function normalize(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n const v0 = v[0];\n const v1 = v[1];\n const v2 = v[2];\n const v3 = v[3];\n const len = Math.sqrt(v0 * v0 + v1 * v1 + v2 * v2 + v3 * v3);\n\n if (len > 0.00001) {\n dst[0] = v0 / len;\n dst[1] = v1 / len;\n dst[2] = v2 / len;\n dst[3] = v3 / len;\n } else {\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n }\n\n return dst;\n}\n\n/**\n * Negates a vector.\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns -v.\n */\nexport function negate(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = -v[0];\n dst[1] = -v[1];\n dst[2] = -v[2];\n dst[3] = -v[3];\n\n return dst;\n}\n\n/**\n * Copies a vector. (same as {@link vec4.clone})\n * Also see {@link vec4.create} and {@link vec4.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport function copy(v: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = v[0];\n dst[1] = v[1];\n dst[2] = v[2];\n dst[3] = v[3];\n\n return dst;\n}\n\n/**\n * Clones a vector. (same as {@link vec4.copy})\n * Also see {@link vec4.create} and {@link vec4.set}\n * @param v - The vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns A copy of v.\n */\nexport const clone = copy;\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport function multiply(a: Vec4, b: Vec4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] * b[0];\n dst[1] = a[1] * b[1];\n dst[2] = a[2] * b[2];\n dst[3] = a[3] * b[3];\n\n return dst;\n}\n\n/**\n * Multiplies a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as mul)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of products of entries of a and b.\n */\nexport const mul = multiply;\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length.\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport function divide(a: Vec4, b: Vec4, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n dst[0] = a[0] / b[0];\n dst[1] = a[1] / b[1];\n dst[2] = a[2] / b[2];\n dst[3] = a[3] / b[3];\n\n return dst;\n}\n\n/**\n * Divides a vector by another vector (component-wise); assumes a and\n * b have the same length. (same as divide)\n * @param a - Operand vector.\n * @param b - Operand vector.\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The vector of quotients of entries of a and b.\n */\nexport const div = divide;\n\n/**\n * Zero's a vector\n * @param dst - vector to hold result. If not passed in a new one is created.\n * @returns The zeroed vector.\n */\nexport function zero(dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n dst[0] = 0;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n return dst;\n}\n\n\n/**\n * transform vec4 by 4x4 matrix\n * @param v - the vector\n * @param m - The matrix.\n * @param dst - optional vec4 to store result. If not passed a new one is created.\n * @returns the transformed vector\n */\nexport function transformMat4(v: Vec4, m: Mat4, dst?: Vec4): Vec4 {\n dst = dst || new VecType(4);\n\n const x = v[0];\n const y = v[1];\n const z = v[2];\n const w = v[3];\n\n dst[0] = m[0] * x + m[4] * y + m[ 8] * z + m[12] * w;\n dst[1] = m[1] * x + m[5] * y + m[ 9] * z + m[13] * w;\n dst[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n dst[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n\n return dst;\n}\n\n\n/**\n * Treat a 4D vector as a direction and set it's length\n *\n * @param a The vec4 to lengthen\n * @param len The length of the resulting vector\n * @returns The lengthened vector\n */\nexport function setLength(a: Vec4, len: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n normalize(a, dst);\n return mulScalar(dst, len, dst);\n}\n\n/**\n * Ensure a vector is not longer than a max length\n *\n * @param a The vec4 to limit\n * @param maxLen The longest length of the resulting vector\n * @returns The vector, shortened to maxLen if it's too long\n */\nexport function truncate(a: Vec4, maxLen: number, dst?: Vec4) {\n dst = dst || new VecType(4);\n\n if (length(a) > maxLen) {\n return setLength(a, maxLen, dst);\n }\n\n return copy(a, dst);\n}\n\n/**\n * Return the vector exactly between 2 endpoint vectors\n *\n * @param a Endpoint 1\n * @param b Endpoint 2\n * @returns The vector exactly residing between endpoints 1 and 2\n */\nexport function midpoint(a: Vec4, b: Vec4, dst?: Vec4) {\n dst = dst || new VecType(4);\n return lerp(a, b, 0.5, dst);\n}\n","import Mat3, * as mat3 from './mat3-impl';\nimport Mat4, * as mat4 from './mat4-impl';\nimport Quat, * as quat from './quat-impl';\nimport Vec2, * as vec2 from './vec2-impl';\nimport Vec3, * as vec3 from './vec3-impl';\nimport Vec4, * as vec4 from './vec4-impl';\nimport * as utils from './utils';\n\n/**\n * Sets the type this library creates for all types\n *\n * example:\n *\n * ```\n * setDefaultType(Float64Array);\n * ```\n *\n * @param ctor - the constructor for the type. Either `Float32Array`, `Float64Array`, or `Array`\n */\nexport function setDefaultType(ctor: new (n: number) => Float32Array | Float64Array | number[]) {\n mat3.setDefaultType(ctor);\n mat4.setDefaultType(ctor);\n quat.setDefaultType(ctor);\n vec2.setDefaultType(ctor);\n vec3.setDefaultType(ctor);\n vec4.setDefaultType(ctor);\n}\n\nexport {\n Mat3,\n mat3,\n Mat4,\n mat4,\n Quat,\n quat,\n utils,\n Vec2,\n vec2,\n Vec3,\n vec3,\n Vec4,\n vec4,\n};"],"names":["EPSILON","degrees","Math","PI","n","m","a","b","v","d","abs","t","radians","old","VecType","Float32Array","setDefaultType","ctor","oldType","create","x","y","dst","undefined","z","subtract","lerp","mulScalar","k","inverse","dot","length","v0","v1","sqrt","lengthSq","distance","dx","dy","distanceSq","normalize","len","copy","multiply","divide","setLength","scale","ax","ay","bx","by","mag","cosine","acos","ceil","min","max","Vec3Type","utils.EPSILON","floor","angle","random","cos","sin","rad","p0","p1","sinC","cosC","round","maxLen","MatType","ctorMap","Map","Float64Array","Array","fill","newMat3","get","identity","m00","m01","m02","m10","m11","m12","m20","m21","m22","b01","b11","b21","invDet","a00","a01","a02","a10","a11","a12","a20","a21","a22","b00","b02","b10","b12","b20","b22","v2","v3","v4","v5","v6","v7","v8","m4","q","w","x2","y2","z2","xx","yx","yy","zx","zy","zz","wx","wy","wz","axis","off","vec2.create","xy","angleInRadians","c","s","cross","t1","t2","dz","az","bz","xz","yz","zScale","p","r","qx","qy","qz","w2","uvX","uvY","uvZ","m03","m13","m23","m30","m31","m32","m33","tmp0","tmp1","tmp2","tmp3","tmp4","tmp5","tmp6","tmp7","tmp8","tmp9","tmp10","tmp11","tmp12","tmp13","tmp14","tmp15","tmp16","tmp17","tmp18","tmp19","tmp20","tmp21","tmp22","tmp23","t0","t3","a03","a13","a23","a30","a31","a32","a33","b03","b13","b23","b30","b31","b32","b33","xAxis","yAxis","zAxis","axisRotation","oneMinusCosine","axisRotate","r00","r01","r02","r10","r11","r12","r20","r21","r22","position","target","up","vec3.create","vec3.normalize","vec3.subtract","vec3.cross","eye","v9","v10","v11","v12","v13","v14","v15","m3","left","right","bottom","top","near","far","Infinity","rangeInv","fieldOfViewYInRadians","aspect","zNear","zFar","f","tan","Number","isFinite","QuatType","fromAxisAngle","halfAngle","aw","bw","slerp","scale0","scale1","cosOmega","omega","sinOmega","tempVec3","xUnitVec3","yUnitVec3","tempQuat1","tempQuat2","xAngleInRadians","yAngleInRadians","zAngleInRadians","order","xHalfAngle","yHalfAngle","zHalfAngle","sx","cx","sy","cy","sz","cz","Error","trace","root","invRoot","i","j","a0","a1","a2","a3","invDot","qw","aUnit","bUnit","vec3.dot","vec3.len","dw","mat3.setDefaultType","mat4.setDefaultType","quat.setDefaultType","vec2.setDefaultType","vec3.setDefaultType","vec4.setDefaultType"],"mappings":"AAsBO,IAAIA,EAAU,4DAkBf,SAAmBC,GACvB,OAAOA,EAAUC,KAAKC,GAAK,GAC7B,kBAqDgB,SAAgBC,EAAWC,GACzC,OAASD,EAAIC,EAAKA,GAAKA,CACzB,uBAxB4BC,EAAWC,EAAWC,GAChD,MAAMC,EAAIF,EAAID,EACd,OAAQJ,KAAKQ,IAAIH,EAAID,GAAKN,EACrBM,GACCE,EAAIF,GAAKG,CACjB,gBAlBqBH,EAAWC,EAAWI,GACzC,OAAOL,GAAKC,EAAID,GAAKK,CACvB,WAbM,SAAmBC,GACvB,OAAiB,IAAVA,EAAgBV,KAAKC,EAC9B,aAtBM,SAAqBK,GACzB,MAAMK,EAAMb,EAEZ,OADAA,EAAUQ,EACHK,CACT,GCmBO,IAAIC,EAAmCC,aAOxC,SAAUC,EAAeC,GAC7B,MAAMC,EAAUJ,EAEhB,OADAA,EAAUG,EACHC,C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zR,GACpB0R,EAAoB1R,GACpB2R,GAAoB3R,EACtB"} \ No newline at end of file diff --git a/dist/3.x/wgpu-matrix.js b/dist/3.x/wgpu-matrix.js index 4ba6c47..4218068 100644 --- a/dist/3.x/wgpu-matrix.js +++ b/dist/3.x/wgpu-matrix.js @@ -1,4 +1,4 @@ -/* wgpu-matrix@3.0.0, license MIT */ +/* wgpu-matrix@3.0.1, license MIT */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : diff --git a/dist/3.x/wgpu-matrix.module.js b/dist/3.x/wgpu-matrix.module.js index 61025da..8bf8de6 100644 --- a/dist/3.x/wgpu-matrix.module.js +++ b/dist/3.x/wgpu-matrix.module.js @@ -1,4 +1,4 @@ -/* wgpu-matrix@3.0.0, license MIT */ +/* wgpu-matrix@3.0.1, license MIT */ function wrapConstructor(OriginalConstructor, modifier) { return class extends OriginalConstructor { constructor(...args) { diff --git a/package-lock.json b/package-lock.json index 1e97202..41f7f10 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wgpu-matrix", - "version": "3.0.0", + "version": "3.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wgpu-matrix", - "version": "3.0.0", + "version": "3.0.1", "license": "MIT", "devDependencies": { "@rollup/plugin-terser": "^0.4.4", diff --git a/package.json b/package.json index 403f54e..78b570c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wgpu-matrix", - "version": "3.0.0", + "version": "3.0.1", "description": "fast matrix math library for WebGPU", "main": "dist/3.x/wgpu-matrix.module.js", "module": "dist/3.x/wgpu-matrix.module.js",