diff --git a/.gitignore b/.gitignore index 665fe595..4d4a77b9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,3 @@ tmp node_modules npm-debug.log -dist -!dist/gl-matrix.js -!dist/gl-matrix.min.js diff --git a/.size-snapshot.json b/.size-snapshot.json index dc939dfa..fc738cf5 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -10,8 +10,8 @@ "gzipped": 12913 }, "gl-matrix-min.js": { - "bundled": 207220, + "bundled": 214853, "minified": 52740, - "gzipped": 13405 + "gzipped": 13516 } } diff --git a/dist/LICENSE.md b/dist/LICENSE.md new file mode 100644 index 00000000..be8c473a --- /dev/null +++ b/dist/LICENSE.md @@ -0,0 +1,19 @@ +Copyright (c) 2015-2025, Brandon Jones, Colin MacKenzie IV. + +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. \ No newline at end of file diff --git a/dist/README.md b/dist/README.md new file mode 100644 index 00000000..f457e112 --- /dev/null +++ b/dist/README.md @@ -0,0 +1,33 @@ +glMatrix +======================= +[![NPM Version](https://img.shields.io/npm/v/gl-matrix.svg)](https://www.npmjs.com/package/gl-matrix) +[![Build Status](https://travis-ci.org/toji/gl-matrix.svg)](https://travis-ci.org/toji/gl-matrix) + +JavaScript has evolved into a language capable of handling realtime 3D graphics, +via WebGL, and computationally intensive tasks such as physics simulations. +These types of applications demand high performance vector and matrix math, +which is something that JavaScript doesn't provide by default. +glMatrix to the rescue! + +glMatrix is designed to perform vector and matrix operations stupidly fast! By +hand-tuning each function for maximum performance and encouraging efficient +usage patterns through API conventions, glMatrix will help you get the most out +of your browser's JavaScript engine. + +Learn More +---------------------- +For documentation and news, visit the [glMatrix Homepage](http://glmatrix.net/) + +For a tutorial, see [the "Introducing glMatrix" section of _Introduction to Computer Graphics_ by David J. Eck](http://math.hws.edu/graphicsbook/c7/s1.html#webgl3d.1.2) + +For a babel plugin to make writing the API nicer, see [babel-plugin-transform-gl-matrix](https://github.com/akira-cn/babel-plugin-transform-gl-matrix) + +Regarding the current performance in modern web browsers, calling `glMatrix.setMatrixArrayType(Array)` to use normal arrays instead of Float32Arrays can greatly increase the performance. + +Contributing Guidelines +---------------------- +See [CONTRIBUTING.md](./CONTRIBUTING.md) + +Building +---------------------- +See [BUILDING.md](./BUILDING.md) diff --git a/dist/esm/mat2.js b/dist/esm/mat2.js index f51bfec0..f2cb0bf0 100644 --- a/dist/esm/mat2.js +++ b/dist/esm/mat2.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new identity mat2 * - * @returns {mat2} a new 2x2 matrix + * @returns {ArrayType} a new 2x2 matrix */ export function create() { var out = new glMatrix.ARRAY_TYPE(4); @@ -25,7 +25,7 @@ export function create() { * Creates a new mat2 initialized with values from an existing matrix * * @param {ReadonlyMat2} a matrix to clone - * @returns {mat2} a new 2x2 matrix + * @returns {ArrayType} a new 2x2 matrix */ export function clone(a) { var out = new glMatrix.ARRAY_TYPE(4); @@ -39,9 +39,10 @@ export function clone(a) { /** * Copy the values from one mat2 to another * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function copy(out, a) { out[0] = a[0]; @@ -54,8 +55,9 @@ export function copy(out, a) { /** * Set a mat2 to the identity matrix * - * @param {mat2} out the receiving matrix - * @returns {mat2} out + * @template {mat2} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat2} out */ export function identity(out) { out[0] = 1; @@ -72,7 +74,7 @@ export function identity(out) { * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m10 Component in column 1, row 0 position (index 2) * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out A new 2x2 matrix + * @returns {ArrayType} out A new 2x2 matrix */ export function fromValues(m00, m01, m10, m11) { var out = new glMatrix.ARRAY_TYPE(4); @@ -86,12 +88,13 @@ export function fromValues(m00, m01, m10, m11) { /** * Set the components of a mat2 to the given values * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m10 Component in column 1, row 0 position (index 2) * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function set(out, m00, m01, m10, m11) { out[0] = m00; @@ -104,9 +107,10 @@ export function set(out, m00, m01, m10, m11) { /** * Transpose the values of a mat2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache @@ -127,9 +131,10 @@ export function transpose(out, a) { /** * Inverts a mat2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2 | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat2 | null} out, or null if source matrix is not invertible */ export function invert(out, a) { var a0 = a[0], @@ -153,9 +158,10 @@ export function invert(out, a) { /** * Calculates the adjugate of a mat2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function adjoint(out, a) { // Caching this value is necessary if out == a @@ -180,10 +186,11 @@ export function determinant(a) { /** * Multiplies two mat2's * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function multiply(out, a, b) { var a0 = a[0], @@ -204,10 +211,11 @@ export function multiply(out, a, b) { /** * Rotates a mat2 by the given angle * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function rotate(out, a, rad) { var a0 = a[0], @@ -226,10 +234,11 @@ export function rotate(out, a, rad) { /** * Scales the mat2 by the dimensions in the given vec2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the matrix to rotate * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out **/ export function scale(out, a, v) { var a0 = a[0], @@ -252,9 +261,10 @@ export function scale(out, a, v) { * mat2.identity(dest); * mat2.rotate(dest, dest, rad); * - * @param {mat2} out mat2 receiving operation result + * @template {mat2} T + * @param {T} out mat2 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function fromRotation(out, rad) { var s = Math.sin(rad); @@ -273,9 +283,10 @@ export function fromRotation(out, rad) { * mat2.identity(dest); * mat2.scale(dest, dest, vec); * - * @param {mat2} out mat2 receiving operation result + * @template {mat2} T + * @param {T} out mat2 receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function fromScaling(out, v) { out[0] = v[0]; @@ -324,10 +335,11 @@ export function LDU(L, D, U, a) { /** * Adds two mat2's * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -340,10 +352,11 @@ export function add(out, a, b) { /** * Subtracts matrix b from matrix a * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -386,10 +399,11 @@ export function equals(a, b) { /** * Multiply each element of the matrix by a scalar. * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -402,11 +416,12 @@ export function multiplyScalar(out, a, b) { /** * Adds two mat2's after multiplying each element of the second operand by a scalar value. * - * @param {mat2} out the receiving vector + * @template {mat2} T + * @param {T} out the receiving vector * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; diff --git a/dist/esm/mat2d.js b/dist/esm/mat2d.js index 16e60541..2c8f2324 100644 --- a/dist/esm/mat2d.js +++ b/dist/esm/mat2d.js @@ -22,7 +22,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new identity mat2d * - * @returns {mat2d} a new 2x3 matrix + * @returns {ArrayType} a new 2x3 matrix */ export function create() { var out = new glMatrix.ARRAY_TYPE(6); @@ -41,7 +41,7 @@ export function create() { * Creates a new mat2d initialized with values from an existing matrix * * @param {ReadonlyMat2d} a matrix to clone - * @returns {mat2d} a new 2x3 matrix + * @returns {ArrayType} a new 2x3 matrix */ export function clone(a) { var out = new glMatrix.ARRAY_TYPE(6); @@ -57,9 +57,10 @@ export function clone(a) { /** * Copy the values from one mat2d to another * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the source matrix - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function copy(out, a) { out[0] = a[0]; @@ -74,8 +75,9 @@ export function copy(out, a) { /** * Set a mat2d to the identity matrix * - * @param {mat2d} out the receiving matrix - * @returns {mat2d} out + * @template {mat2d} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat2d} out */ export function identity(out) { out[0] = 1; @@ -96,7 +98,7 @@ export function identity(out) { * @param {Number} d Component D (index 3) * @param {Number} tx Component TX (index 4) * @param {Number} ty Component TY (index 5) - * @returns {mat2d} A new mat2d + * @returns {ArrayType} A new mat2d */ export function fromValues(a, b, c, d, tx, ty) { var out = new glMatrix.ARRAY_TYPE(6); @@ -112,14 +114,15 @@ export function fromValues(a, b, c, d, tx, ty) { /** * Set the components of a mat2d to the given values * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {Number} a Component A (index 0) * @param {Number} b Component B (index 1) * @param {Number} c Component C (index 2) * @param {Number} d Component D (index 3) * @param {Number} tx Component TX (index 4) * @param {Number} ty Component TY (index 5) - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function set(out, a, b, c, d, tx, ty) { out[0] = a; @@ -134,9 +137,10 @@ export function set(out, a, b, c, d, tx, ty) { /** * Inverts a mat2d * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the source matrix - * @returns {mat2d | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat2d | null} out, or null if source matrix is not invertible */ export function invert(out, a) { var aa = a[0], @@ -172,10 +176,11 @@ export function determinant(a) { /** * Multiplies two mat2d's * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function multiply(out, a, b) { var a0 = a[0], @@ -202,10 +207,11 @@ export function multiply(out, a, b) { /** * Rotates a mat2d by the given angle * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function rotate(out, a, rad) { var a0 = a[0], @@ -228,10 +234,11 @@ export function rotate(out, a, rad) { /** * Scales the mat2d by the dimensions in the given vec2 * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to translate * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out **/ export function scale(out, a, v) { var a0 = a[0], @@ -254,10 +261,11 @@ export function scale(out, a, v) { /** * Translates the mat2d by the dimensions in the given vec2 * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to translate * @param {ReadonlyVec2} v the vec2 to translate the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out **/ export function translate(out, a, v) { var a0 = a[0], @@ -284,9 +292,10 @@ export function translate(out, a, v) { * mat2d.identity(dest); * mat2d.rotate(dest, dest, rad); * - * @param {mat2d} out mat2d receiving operation result + * @template {mat2d} T + * @param {T} out mat2d receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function fromRotation(out, rad) { var s = Math.sin(rad), @@ -307,9 +316,10 @@ export function fromRotation(out, rad) { * mat2d.identity(dest); * mat2d.scale(dest, dest, vec); * - * @param {mat2d} out mat2d receiving operation result + * @template {mat2d} T + * @param {T} out mat2d receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function fromScaling(out, v) { out[0] = v[0]; @@ -328,9 +338,10 @@ export function fromScaling(out, v) { * mat2d.identity(dest); * mat2d.translate(dest, dest, vec); * - * @param {mat2d} out mat2d receiving operation result + * @template {mat2d} T + * @param {T} out mat2d receiving operation result * @param {ReadonlyVec2} v Translation vector - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function fromTranslation(out, v) { out[0] = 1; @@ -365,10 +376,11 @@ export function frob(a) { /** * Adds two mat2d's * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -383,10 +395,11 @@ export function add(out, a, b) { /** * Subtracts matrix b from matrix a * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -401,10 +414,11 @@ export function subtract(out, a, b) { /** * Multiply each element of the matrix by a scalar. * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -419,11 +433,12 @@ export function multiplyScalar(out, a, b) { /** * Adds two mat2d's after multiplying each element of the second operand by a scalar value. * - * @param {mat2d} out the receiving vector + * @template {mat2d} T + * @param {T} out the receiving vector * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; diff --git a/dist/esm/mat3.js b/dist/esm/mat3.js index 66df4510..32e99581 100644 --- a/dist/esm/mat3.js +++ b/dist/esm/mat3.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new identity mat3 * - * @returns {mat3} a new 3x3 matrix + * @returns {ArrayType} a new 3x3 matrix */ export function create() { var out = new glMatrix.ARRAY_TYPE(9); @@ -29,9 +29,10 @@ export function create() { /** * Copies the upper-left 3x3 values into the given mat3. * - * @param {mat3} out the receiving 3x3 matrix + * @template {mat3} T + * @param {T} out the receiving 3x3 matrix * @param {ReadonlyMat4} a the source 4x4 matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromMat4(out, a) { out[0] = a[0]; @@ -50,7 +51,7 @@ export function fromMat4(out, a) { * Creates a new mat3 initialized with values from an existing matrix * * @param {ReadonlyMat3} a matrix to clone - * @returns {mat3} a new 3x3 matrix + * @returns {ArrayType} a new 3x3 matrix */ export function clone(a) { var out = new glMatrix.ARRAY_TYPE(9); @@ -69,9 +70,10 @@ export function clone(a) { /** * Copy the values from one mat3 to another * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function copy(out, a) { out[0] = a[0]; @@ -98,7 +100,7 @@ export function copy(out, a) { * @param {Number} m20 Component in column 2, row 0 position (index 6) * @param {Number} m21 Component in column 2, row 1 position (index 7) * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} A new mat3 + * @returns {ArrayType} A new mat3 */ export function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { var out = new glMatrix.ARRAY_TYPE(9); @@ -117,7 +119,8 @@ export function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { /** * Set the components of a mat3 to the given values * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) @@ -127,7 +130,7 @@ export function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { * @param {Number} m20 Component in column 2, row 0 position (index 6) * @param {Number} m21 Component in column 2, row 1 position (index 7) * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { out[0] = m00; @@ -145,8 +148,9 @@ export function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { /** * Set a mat3 to the identity matrix * - * @param {mat3} out the receiving matrix - * @returns {mat3} out + * @template {mat3} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat3} out */ export function identity(out) { out[0] = 1; @@ -164,9 +168,10 @@ export function identity(out) { /** * Transpose the values of a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -197,9 +202,10 @@ export function transpose(out, a) { /** * Inverts a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3 | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat3 | null} out, or null if source matrix is not invertible */ export function invert(out, a) { var a00 = a[0], @@ -236,9 +242,10 @@ export function invert(out, a) { /** * Calculates the adjugate of a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function adjoint(out, a) { var a00 = a[0], @@ -284,10 +291,11 @@ export function determinant(a) { /** * Multiplies two mat3's * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function multiply(out, a, b) { var a00 = a[0], @@ -323,10 +331,11 @@ export function multiply(out, a, b) { /** * Translate a mat3 by the given vector * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to translate * @param {ReadonlyVec2} v vector to translate by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function translate(out, a, v) { var a00 = a[0], @@ -355,10 +364,11 @@ export function translate(out, a, v) { /** * Rotates a mat3 by the given angle * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function rotate(out, a, rad) { var a00 = a[0], @@ -387,10 +397,11 @@ export function rotate(out, a, rad) { /** * Scales the mat3 by the dimensions in the given vec2 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to scale * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out **/ export function scale(out, a, v) { var x = v[0], @@ -414,9 +425,10 @@ export function scale(out, a, v) { * mat3.identity(dest); * mat3.translate(dest, dest, vec); * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyVec2} v Translation vector - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromTranslation(out, v) { out[0] = 1; @@ -438,9 +450,10 @@ export function fromTranslation(out, v) { * mat3.identity(dest); * mat3.rotate(dest, dest, rad); * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromRotation(out, rad) { var s = Math.sin(rad), @@ -464,9 +477,10 @@ export function fromRotation(out, rad) { * mat3.identity(dest); * mat3.scale(dest, dest, vec); * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromScaling(out, v) { out[0] = v[0]; @@ -484,9 +498,10 @@ export function fromScaling(out, v) { /** * Copies the values from a mat2d into a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to copy - * @returns {mat3} out + * @returns {ReturnType.Mat3} out **/ export function fromMat2d(out, a) { out[0] = a[0]; @@ -504,10 +519,11 @@ export function fromMat2d(out, a) { /** * Calculates a 3x3 matrix from the given quaternion * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyQuat} q Quaternion to create matrix from * - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromQuat(out, q) { var x = q[0], @@ -541,10 +557,11 @@ export function fromQuat(out, q) { /** * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from * - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function normalFromMat4(out, a) { var a00 = a[0], @@ -597,10 +614,11 @@ export function normalFromMat4(out, a) { /** * Generates a 2D projection matrix with the given bounds * - * @param {mat3} out mat3 frustum matrix will be written into + * @template {mat3} T + * @param {T} out mat3 frustum matrix will be written into * @param {number} width Width of your gl context * @param {number} height Height of gl context - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function projection(out, width, height) { out[0] = 2 / width; @@ -638,10 +656,11 @@ export function frob(a) { /** * Adds two mat3's * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -659,10 +678,11 @@ export function add(out, a, b) { /** * Subtracts matrix b from matrix a * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -680,10 +700,11 @@ export function subtract(out, a, b) { /** * Multiply each element of the matrix by a scalar. * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -701,11 +722,12 @@ export function multiplyScalar(out, a, b) { /** * Adds two mat3's after multiplying each element of the second operand by a scalar value. * - * @param {mat3} out the receiving vector + * @template {mat3} T + * @param {T} out the receiving vector * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; diff --git a/dist/esm/mat4.js b/dist/esm/mat4.js index 184b4d53..a305b508 100644 --- a/dist/esm/mat4.js +++ b/dist/esm/mat4.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new identity mat4 * - * @returns {mat4} a new 4x4 matrix + * @returns {ArrayType} a new 4x4 matrix */ export function create() { var out = new glMatrix.ARRAY_TYPE(16); @@ -37,7 +37,7 @@ export function create() { * Creates a new mat4 initialized with values from an existing matrix * * @param {ReadonlyMat4} a matrix to clone - * @returns {mat4} a new 4x4 matrix + * @returns {ArrayType} a new 4x4 matrix */ export function clone(a) { var out = new glMatrix.ARRAY_TYPE(16); @@ -63,9 +63,10 @@ export function clone(a) { /** * Copy the values from one mat4 to another * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function copy(out, a) { out[0] = a[0]; @@ -106,7 +107,7 @@ export function copy(out, a) { * @param {Number} m31 Component in column 3, row 1 position (index 13) * @param {Number} m32 Component in column 3, row 2 position (index 14) * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} A new mat4 + * @returns {ArrayType} A new mat4 */ export function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { var out = new glMatrix.ARRAY_TYPE(16); @@ -132,7 +133,8 @@ export function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22 /** * Set the components of a mat4 to the given values * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) @@ -149,7 +151,7 @@ export function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22 * @param {Number} m31 Component in column 3, row 1 position (index 13) * @param {Number} m32 Component in column 3, row 2 position (index 14) * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { out[0] = m00; @@ -174,8 +176,9 @@ export function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, /** * Set a mat4 to the identity matrix * - * @param {mat4} out the receiving matrix - * @returns {mat4} out + * @template {mat4} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat4} out */ export function identity(out) { out[0] = 1; @@ -200,9 +203,10 @@ export function identity(out) { /** * Transpose the values of a mat4 * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -249,9 +253,10 @@ export function transpose(out, a) { /** * Inverts a mat4 * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4 | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat4 | null} out, or null if source matrix is not invertible */ export function invert(out, a) { var a00 = a[0], @@ -311,9 +316,10 @@ export function invert(out, a) { /** * Calculates the adjugate of a mat4 * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function adjoint(out, a) { var a00 = a[0], @@ -404,10 +410,11 @@ export function determinant(a) { /** * Multiplies two mat4s * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function multiply(out, a, b) { var a00 = a[0], @@ -466,10 +473,11 @@ export function multiply(out, a, b) { /** * Translate a mat4 by the given vector * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to translate * @param {ReadonlyVec3} v vector to translate by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function translate(out, a, v) { var x = v[0], @@ -519,10 +527,11 @@ export function translate(out, a, v) { /** * Scales the mat4 by the dimensions in the given vec3 not using vectorization * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to scale * @param {ReadonlyVec3} v the vec3 to scale the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out **/ export function scale(out, a, v) { var x = v[0], @@ -550,11 +559,12 @@ export function scale(out, a, v) { /** * Rotates a mat4 by the given angle around the given axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by * @param {ReadonlyVec3} axis the axis to rotate around - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function rotate(out, a, rad, axis) { var x = axis[0], @@ -628,10 +638,11 @@ export function rotate(out, a, rad, axis) { /** * Rotates a matrix by the given angle around the X axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function rotateX(out, a, rad) { var s = Math.sin(rad); @@ -671,10 +682,11 @@ export function rotateX(out, a, rad) { /** * Rotates a matrix by the given angle around the Y axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function rotateY(out, a, rad) { var s = Math.sin(rad); @@ -714,10 +726,11 @@ export function rotateY(out, a, rad) { /** * Rotates a matrix by the given angle around the Z axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function rotateZ(out, a, rad) { var s = Math.sin(rad); @@ -761,9 +774,10 @@ export function rotateZ(out, a, rad) { * mat4.identity(dest); * mat4.translate(dest, dest, vec); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {ReadonlyVec3} v Translation vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromTranslation(out, v) { out[0] = 1; @@ -792,9 +806,10 @@ export function fromTranslation(out, v) { * mat4.identity(dest); * mat4.scale(dest, dest, vec); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {ReadonlyVec3} v Scaling vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromScaling(out, v) { out[0] = v[0]; @@ -823,10 +838,11 @@ export function fromScaling(out, v) { * mat4.identity(dest); * mat4.rotate(dest, dest, rad, axis); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by * @param {ReadonlyVec3} axis the axis to rotate around - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromRotation(out, rad, axis) { var x = axis[0], @@ -872,9 +888,10 @@ export function fromRotation(out, rad, axis) { * mat4.identity(dest); * mat4.rotateX(dest, dest, rad); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromXRotation(out, rad) { var s = Math.sin(rad); @@ -907,9 +924,10 @@ export function fromXRotation(out, rad) { * mat4.identity(dest); * mat4.rotateY(dest, dest, rad); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromYRotation(out, rad) { var s = Math.sin(rad); @@ -942,9 +960,10 @@ export function fromYRotation(out, rad) { * mat4.identity(dest); * mat4.rotateZ(dest, dest, rad); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromZRotation(out, rad) { var s = Math.sin(rad); @@ -980,10 +999,11 @@ export function fromZRotation(out, rad) { * mat4.fromQuat(quatMat, quat); * mat4.multiply(dest, dest, quatMat); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {quat} q Rotation quaternion * @param {ReadonlyVec3} v Translation vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromRotationTranslation(out, q, v) { // Quaternion math @@ -1027,7 +1047,7 @@ export function fromRotationTranslation(out, q, v) { * * @param {mat4} out Matrix * @param {ReadonlyQuat2} a Dual Quaternion - * @returns {mat4} mat4 receiving operation result + * @returns {ArrayType} mat4 receiving operation result */ export function fromQuat2(out, a) { var translation = new glMatrix.ARRAY_TYPE(3); @@ -1153,11 +1173,12 @@ export function getRotation(out, mat) { /** * Decomposes a transformation matrix into its rotation, translation * and scale components. Returns only the rotation component + * * @param {quat} out_r Quaternion to receive the rotation component * @param {vec3} out_t Vector to receive the translation vector * @param {vec3} out_s Vector to receive the scaling factor * @param {ReadonlyMat4} mat Matrix to be decomposed (input) - * @returns {quat} out_r + * @returns {ArrayType} out_r */ export function decompose(out_r, out_t, out_s, mat) { out_t[0] = mat[12]; @@ -1228,11 +1249,12 @@ export function decompose(out_r, out_t, out_s, mat) { * mat4.multiply(dest, dest, quatMat); * mat4.scale(dest, dest, scale) * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {quat} q Rotation quaternion * @param {ReadonlyVec3} v Translation vector * @param {ReadonlyVec3} s Scaling vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromRotationTranslationScale(out, q, v, s) { // Quaternion math @@ -1287,12 +1309,13 @@ export function fromRotationTranslationScale(out, q, v, s) { * mat4.scale(dest, dest, scale) * mat4.translate(dest, dest, negativeOrigin); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {quat} q Rotation quaternion * @param {ReadonlyVec3} v Translation vector * @param {ReadonlyVec3} s Scaling vector * @param {ReadonlyVec3} o The origin vector around which to scale and rotate - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromRotationTranslationScaleOrigin(out, q, v, s, o) { // Quaternion math @@ -1349,10 +1372,11 @@ export function fromRotationTranslationScaleOrigin(out, q, v, s, o) { /** * Calculates a 4x4 matrix from the given quaternion * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {ReadonlyQuat} q Quaternion to create matrix from * - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromQuat(out, q) { var x = q[0], @@ -1393,6 +1417,7 @@ export function fromQuat(out, q) { /** * Generates a frustum matrix with the given bounds * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {Number} left Left bound of the frustum * @param {Number} right Right bound of the frustum @@ -1400,7 +1425,7 @@ export function fromQuat(out, q) { * @param {Number} top Top bound of the frustum * @param {Number} near Near bound of the frustum * @param {Number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function frustum(out, left, right, bottom, top, near, far) { var rl = 1 / (right - left); @@ -1431,12 +1456,13 @@ export function frustum(out, left, right, bottom, top, near, far) { * which matches WebGL/OpenGL's clip volume. * Passing null/undefined/no value for far will generate infinite projection matrix. * - * @param {mat4} out mat4 frustum matrix will be written into + * @template {mat4} T + * @param {T} out mat4 frustum matrix will be written into * @param {number} fovy Vertical field of view in radians * @param {number} aspect Aspect ratio. typically viewport width/height * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum, can be null or Infinity - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function perspectiveNO(out, fovy, aspect, near, far) { var f = 1.0 / Math.tan(fovy / 2); @@ -1477,12 +1503,13 @@ export var perspective = perspectiveNO; * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. * Passing null/undefined/no value for far will generate infinite projection matrix. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {number} fovy Vertical field of view in radians * @param {number} aspect Aspect ratio. typically viewport width/height * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum, can be null or Infinity - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function perspectiveZO(out, fovy, aspect, near, far) { var f = 1.0 / Math.tan(fovy / 2); @@ -1516,11 +1543,12 @@ export function perspectiveZO(out, fovy, aspect, near, far) { * This is primarily useful for generating projection matrices to be used * with the still experiemental WebVR API. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function perspectiveFromFieldOfView(out, fov, near, far) { var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0); @@ -1553,6 +1581,7 @@ export function perspectiveFromFieldOfView(out, fov, near, far) { * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], * which matches WebGL/OpenGL's clip volume. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {number} left Left bound of the frustum * @param {number} right Right bound of the frustum @@ -1560,7 +1589,7 @@ export function perspectiveFromFieldOfView(out, fov, near, far) { * @param {number} top Top bound of the frustum * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function orthoNO(out, left, right, bottom, top, near, far) { var lr = 1 / (left - right); @@ -1596,6 +1625,7 @@ export var ortho = orthoNO; * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {number} left Left bound of the frustum * @param {number} right Right bound of the frustum @@ -1603,7 +1633,7 @@ export var ortho = orthoNO; * @param {number} top Top bound of the frustum * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function orthoZO(out, left, right, bottom, top, near, far) { var lr = 1 / (left - right); @@ -1632,11 +1662,12 @@ export function orthoZO(out, left, right, bottom, top, near, far) { * Generates a look-at matrix with the given eye position, focal point, and up axis. * If you want a matrix that actually makes an object look at another object, you should use targetTo instead. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {ReadonlyVec3} eye Position of the viewer * @param {ReadonlyVec3} center Point the viewer is looking at * @param {ReadonlyVec3} up vec3 pointing up - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function lookAt(out, eye, center, up) { var x0, x1, x2, y0, y1, y2, z0, z1, z2, len; @@ -1709,11 +1740,12 @@ export function lookAt(out, eye, center, up) { /** * Generates a matrix that makes something look at something else. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {ReadonlyVec3} eye Position of the viewer * @param {ReadonlyVec3} target Point the viewer is looking at * @param {ReadonlyVec3} up vec3 pointing up - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function targetTo(out, eye, target, up) { var eyex = eye[0], @@ -1784,10 +1816,11 @@ export function frob(a) { /** * Adds two mat4's * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -1812,10 +1845,11 @@ export function add(out, a, b) { /** * Subtracts matrix b from matrix a * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -1840,10 +1874,11 @@ export function subtract(out, a, b) { /** * Multiply each element of the matrix by a scalar. * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -1868,11 +1903,12 @@ export function multiplyScalar(out, a, b) { /** * Adds two mat4's after multiplying each element of the second operand by a scalar value. * - * @param {mat4} out the receiving vector + * @template {mat4} T + * @param {T} out the receiving vector * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; diff --git a/dist/esm/quat.js b/dist/esm/quat.js index 646525ad..d4983861 100644 --- a/dist/esm/quat.js +++ b/dist/esm/quat.js @@ -11,7 +11,7 @@ import * as vec4 from "./vec4.js"; /** * Creates a new identity quat * - * @returns {quat} a new quaternion + * @returns {ReturnType.Quat} a new quaternion */ export function create() { var out = new glMatrix.ARRAY_TYPE(4); @@ -27,8 +27,9 @@ export function create() { /** * Set a quat to the identity quaternion * - * @param {quat} out the receiving quaternion - * @returns {quat} out + * @template {quat} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat} out */ export function identity(out) { out[0] = 0; @@ -42,10 +43,11 @@ export function identity(out) { * Sets a quat from the given angle and rotation axis, * then returns it. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyVec3} axis the axis around which to rotate * @param {Number} rad the angle in radians - * @returns {quat} out + * @returns {ReturnType.Quat} out **/ export function setAxisAngle(out, axis, rad) { rad = rad * 0.5; @@ -101,10 +103,11 @@ export function getAngle(a, b) { /** * Multiplies two quat's * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function multiply(out, a, b) { var ax = a[0], @@ -125,10 +128,11 @@ export function multiply(out, a, b) { /** * Rotates a quaternion by the given angle about the X axis * - * @param {quat} out quat receiving operation result + * @template {quat} T + * @param {T} out quat receiving operation result * @param {ReadonlyQuat} a quat to rotate * @param {number} rad angle (in radians) to rotate - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function rotateX(out, a, rad) { rad *= 0.5; @@ -148,10 +152,11 @@ export function rotateX(out, a, rad) { /** * Rotates a quaternion by the given angle about the Y axis * - * @param {quat} out quat receiving operation result + * @template {quat} T + * @param {T} out quat receiving operation result * @param {ReadonlyQuat} a quat to rotate * @param {number} rad angle (in radians) to rotate - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function rotateY(out, a, rad) { rad *= 0.5; @@ -171,10 +176,11 @@ export function rotateY(out, a, rad) { /** * Rotates a quaternion by the given angle about the Z axis * - * @param {quat} out quat receiving operation result + * @template {quat} T + * @param {T} out quat receiving operation result * @param {ReadonlyQuat} a quat to rotate * @param {number} rad angle (in radians) to rotate - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function rotateZ(out, a, rad) { rad *= 0.5; @@ -196,9 +202,10 @@ export function rotateZ(out, a, rad) { * Assumes that quaternion is 1 unit in length. * Any existing W component will be ignored. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate W component of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function calculateW(out, a) { var x = a[0], @@ -214,9 +221,10 @@ export function calculateW(out, a) { /** * Calculate the exponential of a unit quaternion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate the exponential of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function exp(out, a) { var x = a[0], @@ -236,9 +244,10 @@ export function exp(out, a) { /** * Calculate the natural logarithm of a unit quaternion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate the exponential of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function ln(out, a) { var x = a[0], @@ -257,10 +266,11 @@ export function ln(out, a) { /** * Calculate the scalar power of a unit quaternion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate the exponential of * @param {Number} b amount to scale the quaternion by - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function pow(out, a, b) { ln(out, a); @@ -272,11 +282,12 @@ export function pow(out, a, b) { /** * Performs a spherical linear interpolation between two quat * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function slerp(out, a, b, t) { // benchmarks: @@ -325,8 +336,9 @@ export function slerp(out, a, b, t) { /** * Generates a random unit quaternion * - * @param {quat} out the receiving quaternion - * @returns {quat} out + * @template {quat} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat} out */ export function random(out) { // Implementation of http://planning.cs.uiuc.edu/node198.html @@ -346,9 +358,10 @@ export function random(out) { /** * Calculates the inverse of a quat * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate inverse of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function invert(out, a) { var a0 = a[0], @@ -371,9 +384,10 @@ export function invert(out, a) { * Calculates the conjugate of a quat * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate conjugate of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function conjugate(out, a) { out[0] = -a[0]; @@ -389,9 +403,10 @@ export function conjugate(out, a) { * NOTE: The resultant quaternion is not normalized, so you should be sure * to renormalize the quaternion yourself where necessary. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyMat3} m rotation matrix - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export function fromMat3(out, m) { @@ -427,12 +442,13 @@ export function fromMat3(out, m) { /** * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {Number} x Angle to rotate around X axis in degrees. * @param {Number} y Angle to rotate around Y axis in degrees. * @param {Number} z Angle to rotate around Z axis in degrees. * @param {'xyz'|'xzy'|'yxz'|'yzx'|'zxy'|'zyx'} order Intrinsic order for conversion, default is zyx. - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export function fromEuler(out, x, y, z) { @@ -504,7 +520,7 @@ export function str(a) { * Creates a new quat initialized with values from an existing quaternion * * @param {ReadonlyQuat} a quaternion to clone - * @returns {quat} a new quaternion + * @returns {ReturnType.Quat} a new quaternion * @function */ export var clone = vec4.clone; @@ -516,7 +532,7 @@ export var clone = vec4.clone; * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {quat} a new quaternion + * @returns {ReturnType.Quat} a new quaternion * @function */ export var fromValues = vec4.fromValues; @@ -524,9 +540,10 @@ export var fromValues = vec4.fromValues; /** * Copy the values from one quat to another * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the source quaternion - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export var copy = vec4.copy; @@ -534,12 +551,13 @@ export var copy = vec4.copy; /** * Set the components of a quat to the given values * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export var set = vec4.set; @@ -547,10 +565,11 @@ export var set = vec4.set; /** * Adds two quat's * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export var add = vec4.add; @@ -564,10 +583,11 @@ export var mul = multiply; /** * Scales a quat by a scalar number * - * @param {quat} out the receiving vector + * @template {quat} T + * @param {T} out the receiving vector * @param {ReadonlyQuat} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export var scale = vec4.scale; @@ -585,11 +605,12 @@ export var dot = vec4.dot; /** * Performs a linear interpolation between two quat's * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export var lerp = vec4.lerp; @@ -626,9 +647,10 @@ export var sqrLen = squaredLength; /** * Normalize a quat * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quaternion to normalize - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export var normalize = vec4.normalize; @@ -661,10 +683,11 @@ export function equals(a, b) { * * Both vectors are assumed to be unit length. * - * @param {quat} out the receiving quaternion. + * @template {quat} T + * @param {T} out the receiving quaternion. * @param {ReadonlyVec3} a the initial vector * @param {ReadonlyVec3} b the destination vector - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export var rotationTo = function () { var tmpvec3 = vec3.create(); @@ -698,13 +721,14 @@ export var rotationTo = function () { /** * Performs a spherical linear interpolation with two control points * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand * @param {ReadonlyQuat} c the third operand * @param {ReadonlyQuat} d the fourth operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export var sqlerp = function () { var temp1 = create(); @@ -722,10 +746,12 @@ export var sqlerp = function () { * axes. Each axis is a vec3 and is expected to be unit length and * perpendicular to all other specified axes. * + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyVec3} view the vector representing the viewing direction * @param {ReadonlyVec3} right the vector representing the local "right" direction * @param {ReadonlyVec3} up the vector representing the local "up" direction - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export var setAxes = function () { var matr = mat3.create(); diff --git a/dist/esm/quat2.js b/dist/esm/quat2.js index c7a84da2..77afa1c6 100644 --- a/dist/esm/quat2.js +++ b/dist/esm/quat2.js @@ -1,6 +1,6 @@ import * as glMatrix from "./common.js"; -import * as quat from "./quat.js"; import * as mat4 from "./mat4.js"; +import * as quat from "./quat.js"; /** * Dual Quaternion
@@ -13,7 +13,7 @@ import * as mat4 from "./mat4.js"; /** * Creates a new identity dual quat * - * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation] + * @returns {ArrayType} a new dual quaternion [real -> rotation, dual -> translation] */ export function create() { var dq = new glMatrix.ARRAY_TYPE(8); @@ -34,7 +34,7 @@ export function create() { * Creates a new quat initialized with values from an existing quaternion * * @param {ReadonlyQuat2} a dual quaternion to clone - * @returns {quat2} new dual quaternion + * @returns {ArrayType} new dual quaternion * @function */ export function clone(a) { @@ -61,7 +61,7 @@ export function clone(a) { * @param {Number} y2 Y component * @param {Number} z2 Z component * @param {Number} w2 W component - * @returns {quat2} new dual quaternion + * @returns {ArrayType} new dual quaternion * @function */ export function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) { @@ -87,7 +87,7 @@ export function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) { * @param {Number} x2 X component (translation) * @param {Number} y2 Y component (translation) * @param {Number} z2 Z component (translation) - * @returns {quat2} new dual quaternion + * @returns {ArrayType} new dual quaternion * @function */ export function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) { @@ -109,10 +109,11 @@ export function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) { /** * Creates a dual quat from a quaternion and a translation * - * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result * @param {ReadonlyQuat} q a normalized quaternion * @param {ReadonlyVec3} t translation vector - * @returns {quat2} dual quaternion receiving operation result + * @returns {ReturnType.Quat2} dual quaternion receiving operation result * @function */ export function fromRotationTranslation(out, q, t) { @@ -137,9 +138,10 @@ export function fromRotationTranslation(out, q, t) { /** * Creates a dual quat from a translation * - * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result * @param {ReadonlyVec3} t translation vector - * @returns {quat2} dual quaternion receiving operation result + * @returns {ReturnType.Quat2} dual quaternion receiving operation result * @function */ export function fromTranslation(out, t) { @@ -157,9 +159,10 @@ export function fromTranslation(out, t) { /** * Creates a dual quat from a quaternion * - * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result * @param {ReadonlyQuat} q the quaternion - * @returns {quat2} dual quaternion receiving operation result + * @returns {ReturnType.Quat2} dual quaternion receiving operation result * @function */ export function fromRotation(out, q) { @@ -177,9 +180,10 @@ export function fromRotation(out, q) { /** * Creates a new dual quat from a matrix (4x4) * - * @param {quat2} out the dual quaternion + * @template {quat2} T + * @param {T} out the dual quaternion * @param {ReadonlyMat4} a the matrix - * @returns {quat2} dual quat receiving operation result + * @returns {ReturnType.Quat2} dual quat receiving operation result * @function */ export function fromMat4(out, a) { @@ -195,9 +199,10 @@ export function fromMat4(out, a) { /** * Copy the values from one dual quat to another * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the source dual quaternion - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function copy(out, a) { @@ -215,8 +220,9 @@ export function copy(out, a) { /** * Set a dual quat to the identity dual quaternion * - * @param {quat2} out the receiving quaternion - * @returns {quat2} out + * @template {quat2} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat2} out */ export function identity(out) { out[0] = 0; @@ -233,7 +239,8 @@ export function identity(out) { /** * Set the components of a dual quat to the given values * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {Number} x1 X component * @param {Number} y1 Y component * @param {Number} z1 Z component @@ -242,7 +249,7 @@ export function identity(out) { * @param {Number} y2 Y component * @param {Number} z2 Z component * @param {Number} w2 W component - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function set(out, x1, y1, z1, w1, x2, y2, z2, w2) { @@ -282,9 +289,10 @@ export function getDual(out, a) { /** * Set the real component of a dual quat to the given quaternion * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} q a quaternion representing the real part - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export var setReal = quat.copy; @@ -292,9 +300,10 @@ export var setReal = quat.copy; /** * Set the dual component of a dual quat to the given quaternion * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} q a quaternion representing the dual part - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function setDual(out, q) { @@ -329,10 +338,11 @@ export function getTranslation(out, a) { /** * Translates a dual quat by the given vector * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to translate * @param {ReadonlyVec3} v vector to translate by - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function translate(out, a, v) { var ax1 = a[0], @@ -360,10 +370,11 @@ export function translate(out, a, v) { /** * Rotates a dual quat around the X axis * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {number} rad how far should the rotation be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateX(out, a, rad) { var bx = -a[0], @@ -393,10 +404,11 @@ export function rotateX(out, a, rad) { /** * Rotates a dual quat around the Y axis * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {number} rad how far should the rotation be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateY(out, a, rad) { var bx = -a[0], @@ -426,10 +438,11 @@ export function rotateY(out, a, rad) { /** * Rotates a dual quat around the Z axis * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {number} rad how far should the rotation be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateZ(out, a, rad) { var bx = -a[0], @@ -459,10 +472,11 @@ export function rotateZ(out, a, rad) { /** * Rotates a dual quat by a given quaternion (a * q) * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {ReadonlyQuat} q quaternion to rotate by - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateByQuatAppend(out, a, q) { var qx = q[0], @@ -491,10 +505,11 @@ export function rotateByQuatAppend(out, a, q) { /** * Rotates a dual quat by a given quaternion (q * a) * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat} q quaternion to rotate by * @param {ReadonlyQuat2} a the dual quaternion to rotate - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateByQuatPrepend(out, q, a) { var qx = q[0], @@ -523,11 +538,12 @@ export function rotateByQuatPrepend(out, q, a) { /** * Rotates a dual quat around a given axis. Does the normalisation automatically * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {ReadonlyVec3} axis the axis to rotate around * @param {Number} rad how far the rotation should be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateAroundAxis(out, a, axis, rad) { //Special case for rad = 0 @@ -563,10 +579,11 @@ export function rotateAroundAxis(out, a, axis, rad) { /** * Adds two dual quat's * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the first operand * @param {ReadonlyQuat2} b the second operand - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function add(out, a, b) { @@ -584,10 +601,11 @@ export function add(out, a, b) { /** * Multiplies two dual quat's * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the first operand * @param {ReadonlyQuat2} b the second operand - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function multiply(out, a, b) { var ax0 = a[0], @@ -626,10 +644,11 @@ export var mul = multiply; /** * Scales a dual quat by a scalar number * - * @param {quat2} out the receiving dual quat + * @template {quat2} T + * @param {T} out the receiving dual quat * @param {ReadonlyQuat2} a the dual quat to scale * @param {Number} b amount to scale the dual quat by - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function scale(out, a, b) { @@ -658,11 +677,12 @@ export var dot = quat.dot; * Performs a linear interpolation between two dual quats's * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5) * - * @param {quat2} out the receiving dual quat + * @template {quat2} T + * @param {T} out the receiving dual quat * @param {ReadonlyQuat2} a the first operand * @param {ReadonlyQuat2} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function lerp(out, a, b, t) { var mt = 1 - t; @@ -681,9 +701,10 @@ export function lerp(out, a, b, t) { /** * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a dual quat to calculate inverse of - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function invert(out, a) { var sqlen = squaredLength(a); @@ -702,9 +723,10 @@ export function invert(out, a) { * Calculates the conjugate of a dual quat * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result. * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat2} a quat to calculate conjugate of - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function conjugate(out, a) { out[0] = -a[0]; @@ -751,9 +773,10 @@ export var sqrLen = squaredLength; /** * Normalize a dual quat * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a dual quaternion to normalize - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function normalize(out, a) { diff --git a/dist/esm/vec2.js b/dist/esm/vec2.js index 263e14a8..ce7e4a98 100644 --- a/dist/esm/vec2.js +++ b/dist/esm/vec2.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new, empty vec2 * - * @returns {vec2} a new 2D vector + * @returns {ArrayType} a new 2D vector */ export function create() { var out = new glMatrix.ARRAY_TYPE(2); @@ -23,7 +23,7 @@ export function create() { * Creates a new vec2 initialized with values from an existing vector * * @param {ReadonlyVec2} a vector to clone - * @returns {vec2} a new 2D vector + * @returns {ArrayType} a new 2D vector */ export function clone(a) { var out = new glMatrix.ARRAY_TYPE(2); @@ -37,7 +37,7 @@ export function clone(a) { * * @param {Number} x X component * @param {Number} y Y component - * @returns {vec2} a new 2D vector + * @returns {ArrayType} a new 2D vector */ export function fromValues(x, y) { var out = new glMatrix.ARRAY_TYPE(2); @@ -49,9 +49,10 @@ export function fromValues(x, y) { /** * Copy the values from one vec2 to another * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the source vector - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function copy(out, a) { out[0] = a[0]; @@ -62,10 +63,11 @@ export function copy(out, a) { /** * Set the components of a vec2 to the given values * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {Number} x X component * @param {Number} y Y component - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function set(out, x, y) { out[0] = x; @@ -76,10 +78,11 @@ export function set(out, x, y) { /** * Adds two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -90,10 +93,11 @@ export function add(out, a, b) { /** * Subtracts vector b from vector a * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -104,10 +108,11 @@ export function subtract(out, a, b) { /** * Multiplies two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function multiply(out, a, b) { out[0] = a[0] * b[0]; @@ -118,10 +123,11 @@ export function multiply(out, a, b) { /** * Divides two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function divide(out, a, b) { out[0] = a[0] / b[0]; @@ -132,9 +138,10 @@ export function divide(out, a, b) { /** * Math.ceil the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to ceil - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function ceil(out, a) { out[0] = Math.ceil(a[0]); @@ -145,9 +152,10 @@ export function ceil(out, a) { /** * Math.floor the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to floor - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function floor(out, a) { out[0] = Math.floor(a[0]); @@ -158,10 +166,11 @@ export function floor(out, a) { /** * Returns the minimum of two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function min(out, a, b) { out[0] = Math.min(a[0], b[0]); @@ -172,10 +181,11 @@ export function min(out, a, b) { /** * Returns the maximum of two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function max(out, a, b) { out[0] = Math.max(a[0], b[0]); @@ -186,9 +196,10 @@ export function max(out, a, b) { /** * symmetric round the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to round - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function round(out, a) { out[0] = glMatrix.round(a[0]); @@ -199,10 +210,11 @@ export function round(out, a) { /** * Scales a vec2 by a scalar number * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function scale(out, a, b) { out[0] = a[0] * b; @@ -213,11 +225,12 @@ export function scale(out, a, b) { /** * Adds two vec2's after scaling the second operand by a scalar value * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -278,9 +291,10 @@ export function squaredLength(a) { /** * Negates the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to negate - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function negate(out, a) { out[0] = -a[0]; @@ -291,9 +305,10 @@ export function negate(out, a) { /** * Returns the inverse of the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to invert - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function inverse(out, a) { out[0] = 1.0 / a[0]; @@ -304,9 +319,10 @@ export function inverse(out, a) { /** * Normalize a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to normalize - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function normalize(out, a) { var x = a[0], @@ -336,10 +352,11 @@ export function dot(a, b) { * Computes the cross product of two vec2's * Note that the cross product must by definition produce a 3D vector * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec2} out */ export function cross(out, a, b) { var z = a[0] * b[1] - a[1] * b[0]; @@ -351,11 +368,12 @@ export function cross(out, a, b) { /** * Performs a linear interpolation between two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function lerp(out, a, b, t) { var ax = a[0], @@ -368,9 +386,10 @@ export function lerp(out, a, b, t) { /** * Generates a random vector with the given scale * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function random(out, scale) { scale = scale === undefined ? 1.0 : scale; @@ -383,10 +402,11 @@ export function random(out, scale) { /** * Transforms the vec2 with a mat2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat2} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function transformMat2(out, a, m) { var x = a[0], @@ -399,10 +419,11 @@ export function transformMat2(out, a, m) { /** * Transforms the vec2 with a mat2d * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat2d} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function transformMat2d(out, a, m) { var x = a[0], @@ -416,10 +437,11 @@ export function transformMat2d(out, a, m) { * Transforms the vec2 with a mat3 * 3rd vector component is implicitly '1' * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat3} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function transformMat3(out, a, m) { var x = a[0], @@ -434,10 +456,11 @@ export function transformMat3(out, a, m) { * 3rd vector component is implicitly '0' * 4th vector component is implicitly '1' * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function transformMat4(out, a, m) { var x = a[0]; @@ -449,11 +472,12 @@ export function transformMat4(out, a, m) { /** * Rotate a 2D vector - * @param {vec2} out The receiving vec2 + * @template {vec2} T + * @param {T} out The receiving vec2 * @param {ReadonlyVec2} a The vec2 point to rotate * @param {ReadonlyVec2} b The origin of the rotation * @param {Number} rad The angle of rotation in radians - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function rotate(out, a, b, rad) { //Translate point to the origin @@ -500,8 +524,9 @@ export function signedAngle(a, b) { /** * Set the components of a vec2 to zero * - * @param {vec2} out the receiving vector - * @returns {vec2} out + * @template {vec2} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec2} out */ export function zero(out) { out[0] = 0.0; diff --git a/dist/esm/vec3.js b/dist/esm/vec3.js index caf84a5f..11e1705e 100644 --- a/dist/esm/vec3.js +++ b/dist/esm/vec3.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new, empty vec3 * - * @returns {vec3} a new 3D vector + * @returns {ArrayType} a new 3D vector */ export function create() { var out = new glMatrix.ARRAY_TYPE(3); @@ -24,7 +24,7 @@ export function create() { * Creates a new vec3 initialized with values from an existing vector * * @param {ReadonlyVec3} a vector to clone - * @returns {vec3} a new 3D vector + * @returns {ArrayType} a new 3D vector */ export function clone(a) { var out = new glMatrix.ARRAY_TYPE(3); @@ -53,7 +53,7 @@ export function length(a) { * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component - * @returns {vec3} a new 3D vector + * @returns {ArrayType} a new 3D vector */ export function fromValues(x, y, z) { var out = new glMatrix.ARRAY_TYPE(3); @@ -66,9 +66,10 @@ export function fromValues(x, y, z) { /** * Copy the values from one vec3 to another * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the source vector - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function copy(out, a) { out[0] = a[0]; @@ -80,11 +81,12 @@ export function copy(out, a) { /** * Set the components of a vec3 to the given values * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function set(out, x, y, z) { out[0] = x; @@ -96,10 +98,11 @@ export function set(out, x, y, z) { /** * Adds two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -111,10 +114,11 @@ export function add(out, a, b) { /** * Subtracts vector b from vector a * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -126,10 +130,11 @@ export function subtract(out, a, b) { /** * Multiplies two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function multiply(out, a, b) { out[0] = a[0] * b[0]; @@ -141,10 +146,11 @@ export function multiply(out, a, b) { /** * Divides two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function divide(out, a, b) { out[0] = a[0] / b[0]; @@ -156,9 +162,10 @@ export function divide(out, a, b) { /** * Math.ceil the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to ceil - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function ceil(out, a) { out[0] = Math.ceil(a[0]); @@ -170,9 +177,10 @@ export function ceil(out, a) { /** * Math.floor the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to floor - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function floor(out, a) { out[0] = Math.floor(a[0]); @@ -184,10 +192,11 @@ export function floor(out, a) { /** * Returns the minimum of two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function min(out, a, b) { out[0] = Math.min(a[0], b[0]); @@ -199,10 +208,11 @@ export function min(out, a, b) { /** * Returns the maximum of two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function max(out, a, b) { out[0] = Math.max(a[0], b[0]); @@ -214,9 +224,10 @@ export function max(out, a, b) { /** * symmetric round the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to round - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function round(out, a) { out[0] = glMatrix.round(a[0]); @@ -228,10 +239,11 @@ export function round(out, a) { /** * Scales a vec3 by a scalar number * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function scale(out, a, b) { out[0] = a[0] * b; @@ -243,11 +255,12 @@ export function scale(out, a, b) { /** * Adds two vec3's after scaling the second operand by a scalar value * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -300,9 +313,10 @@ export function squaredLength(a) { /** * Negates the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to negate - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function negate(out, a) { out[0] = -a[0]; @@ -314,9 +328,10 @@ export function negate(out, a) { /** * Returns the inverse of the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to invert - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function inverse(out, a) { out[0] = 1.0 / a[0]; @@ -328,9 +343,10 @@ export function inverse(out, a) { /** * Normalize a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to normalize - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function normalize(out, a) { var x = a[0]; @@ -361,10 +377,11 @@ export function dot(a, b) { /** * Computes the cross product of two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function cross(out, a, b) { var ax = a[0], @@ -382,11 +399,12 @@ export function cross(out, a, b) { /** * Performs a linear interpolation between two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function lerp(out, a, b, t) { var ax = a[0]; @@ -401,11 +419,12 @@ export function lerp(out, a, b, t) { /** * Performs a spherical linear interpolation between two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function slerp(out, a, b, t) { var angle = Math.acos(Math.min(Math.max(dot(a, b), -1), 1)); @@ -421,13 +440,14 @@ export function slerp(out, a, b, t) { /** * Performs a hermite interpolation with two control points * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {ReadonlyVec3} c the third operand * @param {ReadonlyVec3} d the fourth operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function hermite(out, a, b, c, d, t) { var factorTimes2 = t * t; @@ -444,13 +464,14 @@ export function hermite(out, a, b, c, d, t) { /** * Performs a bezier interpolation with two control points * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {ReadonlyVec3} c the third operand * @param {ReadonlyVec3} d the fourth operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function bezier(out, a, b, c, d, t) { var inverseFactor = 1 - t; @@ -469,9 +490,10 @@ export function bezier(out, a, b, c, d, t) { /** * Generates a random vector with the given scale * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function random(out, scale) { scale = scale === undefined ? 1.0 : scale; @@ -488,10 +510,11 @@ export function random(out, scale) { * Transforms the vec3 with a mat4. * 4th vector component is implicitly '1' * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function transformMat4(out, a, m) { var x = a[0], @@ -508,10 +531,11 @@ export function transformMat4(out, a, m) { /** * Transforms the vec3 with a mat3. * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to transform * @param {ReadonlyMat3} m the 3x3 matrix to transform with - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function transformMat3(out, a, m) { var x = a[0], @@ -527,10 +551,11 @@ export function transformMat3(out, a, m) { * Transforms the vec3 with a quat * Can also be used for dual quaternions. (Multiply it with the real part) * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to transform * @param {ReadonlyQuat} q normalized quaternion to transform with - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function transformQuat(out, a, q) { // Fast Vector Rotation using Quaternions by Robert Eisele @@ -563,11 +588,12 @@ export function transformQuat(out, a, q) { /** * Rotate a 3D vector around the x-axis - * @param {vec3} out The receiving vec3 + * @template {vec3} T + * @param {T} out The receiving vec3 * @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 - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function rotateX(out, a, b, rad) { var p = [], @@ -591,11 +617,12 @@ export function rotateX(out, a, b, rad) { /** * Rotate a 3D vector around the y-axis - * @param {vec3} out The receiving vec3 + * @template {vec3} T + * @param {T} out The receiving vec3 * @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 - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function rotateY(out, a, b, rad) { var p = [], @@ -619,11 +646,12 @@ export function rotateY(out, a, b, rad) { /** * Rotate a 3D vector around the z-axis - * @param {vec3} out The receiving vec3 + * @template {vec3} T + * @param {T} out The receiving vec3 * @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 - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function rotateZ(out, a, b, rad) { var p = [], @@ -666,8 +694,9 @@ export function angle(a, b) { /** * Set the components of a vec3 to zero * - * @param {vec3} out the receiving vector - * @returns {vec3} out + * @template {vec3} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec3} out */ export function zero(out) { out[0] = 0.0; diff --git a/dist/esm/vec4.js b/dist/esm/vec4.js index a52b5bfc..56f0d589 100644 --- a/dist/esm/vec4.js +++ b/dist/esm/vec4.js @@ -3,12 +3,12 @@ import * as glMatrix from "./common.js"; /** * 4 Dimensional Vector * @module vec4 - */ +*/ /** * Creates a new, empty vec4 * - * @returns {vec4} a new 4D vector + * @returns {ArrayType} a new 4D vector */ export function create() { var out = new glMatrix.ARRAY_TYPE(4); @@ -25,7 +25,7 @@ export function create() { * Creates a new vec4 initialized with values from an existing vector * * @param {ReadonlyVec4} a vector to clone - * @returns {vec4} a new 4D vector + * @returns {ArrayType} a new 4D vector */ export function clone(a) { var out = new glMatrix.ARRAY_TYPE(4); @@ -43,7 +43,7 @@ export function clone(a) { * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {vec4} a new 4D vector + * @returns {ArrayType} a new 4D vector */ export function fromValues(x, y, z, w) { var out = new glMatrix.ARRAY_TYPE(4); @@ -57,9 +57,10 @@ export function fromValues(x, y, z, w) { /** * Copy the values from one vec4 to another * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the source vector - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function copy(out, a) { out[0] = a[0]; @@ -72,12 +73,13 @@ export function copy(out, a) { /** * Set the components of a vec4 to the given values * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function set(out, x, y, z, w) { out[0] = x; @@ -90,10 +92,11 @@ export function set(out, x, y, z, w) { /** * Adds two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -106,10 +109,11 @@ export function add(out, a, b) { /** * Subtracts vector b from vector a * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -122,10 +126,11 @@ export function subtract(out, a, b) { /** * Multiplies two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function multiply(out, a, b) { out[0] = a[0] * b[0]; @@ -138,10 +143,11 @@ export function multiply(out, a, b) { /** * Divides two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function divide(out, a, b) { out[0] = a[0] / b[0]; @@ -154,9 +160,10 @@ export function divide(out, a, b) { /** * Math.ceil the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to ceil - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function ceil(out, a) { out[0] = Math.ceil(a[0]); @@ -169,9 +176,10 @@ export function ceil(out, a) { /** * Math.floor the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to floor - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function floor(out, a) { out[0] = Math.floor(a[0]); @@ -184,10 +192,11 @@ export function floor(out, a) { /** * Returns the minimum of two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function min(out, a, b) { out[0] = Math.min(a[0], b[0]); @@ -200,10 +209,11 @@ export function min(out, a, b) { /** * Returns the maximum of two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function max(out, a, b) { out[0] = Math.max(a[0], b[0]); @@ -216,9 +226,10 @@ export function max(out, a, b) { /** * symmetric round the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to round - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function round(out, a) { out[0] = glMatrix.round(a[0]); @@ -231,10 +242,11 @@ export function round(out, a) { /** * Scales a vec4 by a scalar number * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function scale(out, a, b) { out[0] = a[0] * b; @@ -247,11 +259,12 @@ export function scale(out, a, b) { /** * Adds two vec4's after scaling the second operand by a scalar value * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -322,9 +335,10 @@ export function squaredLength(a) { /** * Negates the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to negate - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function negate(out, a) { out[0] = -a[0]; @@ -337,9 +351,10 @@ export function negate(out, a) { /** * Returns the inverse of the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to invert - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function inverse(out, a) { out[0] = 1.0 / a[0]; @@ -352,9 +367,10 @@ export function inverse(out, a) { /** * Normalize a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to normalize - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function normalize(out, a) { var x = a[0]; @@ -386,11 +402,12 @@ export function dot(a, b) { /** * Returns the cross-product of three vectors in a 4-dimensional space * - * @param {ReadonlyVec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} u the first vector * @param {ReadonlyVec4} v the second vector * @param {ReadonlyVec4} w the third vector - * @returns {vec4} result + * @returns {ReturnType.Vec4} result */ export function cross(out, u, v, w) { var A = v[0] * w[1] - v[1] * w[0], @@ -413,11 +430,12 @@ export function cross(out, u, v, w) { /** * Performs a linear interpolation between two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function lerp(out, a, b, t) { var ax = a[0]; @@ -434,9 +452,10 @@ export function lerp(out, a, b, t) { /** * Generates a random vector with the given scale * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function random(out, scale) { scale = scale === undefined ? 1.0 : scale; @@ -466,10 +485,11 @@ export function random(out, scale) { /** * Transforms the vec4 with a mat4. * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function transformMat4(out, a, m) { var x = a[0], @@ -486,10 +506,11 @@ export function transformMat4(out, a, m) { /** * Transforms the vec4 with a quat * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the vector to transform * @param {ReadonlyQuat} q normalized quaternion to transform with - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function transformQuat(out, a, q) { // Fast Vector Rotation using Quaternions by Robert Eisele @@ -524,8 +545,9 @@ export function transformQuat(out, a, q) { /** * Set the components of a vec4 to zero * - * @param {vec4} out the receiving vector - * @returns {vec4} out + * @template {vec4} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec4} out */ export function zero(out) { out[0] = 0.0; diff --git a/dist/gl-matrix.js b/dist/gl-matrix.js index 100b7b37..33a58317 100644 --- a/dist/gl-matrix.js +++ b/dist/gl-matrix.js @@ -119,7 +119,7 @@ THE SOFTWARE. /** * Creates a new identity mat2 * - * @returns {mat2} a new 2x2 matrix + * @returns {ArrayType} a new 2x2 matrix */ function create$8() { var out = new ARRAY_TYPE(4); @@ -136,7 +136,7 @@ THE SOFTWARE. * Creates a new mat2 initialized with values from an existing matrix * * @param {ReadonlyMat2} a matrix to clone - * @returns {mat2} a new 2x2 matrix + * @returns {ArrayType} a new 2x2 matrix */ function clone$8(a) { var out = new ARRAY_TYPE(4); @@ -150,9 +150,10 @@ THE SOFTWARE. /** * Copy the values from one mat2 to another * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function copy$8(out, a) { out[0] = a[0]; @@ -165,8 +166,9 @@ THE SOFTWARE. /** * Set a mat2 to the identity matrix * - * @param {mat2} out the receiving matrix - * @returns {mat2} out + * @template {mat2} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat2} out */ function identity$5(out) { out[0] = 1; @@ -183,7 +185,7 @@ THE SOFTWARE. * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m10 Component in column 1, row 0 position (index 2) * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out A new 2x2 matrix + * @returns {ArrayType} out A new 2x2 matrix */ function fromValues$8(m00, m01, m10, m11) { var out = new ARRAY_TYPE(4); @@ -197,12 +199,13 @@ THE SOFTWARE. /** * Set the components of a mat2 to the given values * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m10 Component in column 1, row 0 position (index 2) * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function set$8(out, m00, m01, m10, m11) { out[0] = m00; @@ -215,9 +218,10 @@ THE SOFTWARE. /** * Transpose the values of a mat2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function transpose$2(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache @@ -238,9 +242,10 @@ THE SOFTWARE. /** * Inverts a mat2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2 | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat2 | null} out, or null if source matrix is not invertible */ function invert$5(out, a) { var a0 = a[0], @@ -264,9 +269,10 @@ THE SOFTWARE. /** * Calculates the adjugate of a mat2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function adjoint$2(out, a) { // Caching this value is necessary if out == a @@ -291,10 +297,11 @@ THE SOFTWARE. /** * Multiplies two mat2's * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function multiply$8(out, a, b) { var a0 = a[0], @@ -315,10 +322,11 @@ THE SOFTWARE. /** * Rotates a mat2 by the given angle * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function rotate$4(out, a, rad) { var a0 = a[0], @@ -337,10 +345,11 @@ THE SOFTWARE. /** * Scales the mat2 by the dimensions in the given vec2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the matrix to rotate * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out **/ function scale$8(out, a, v) { var a0 = a[0], @@ -363,9 +372,10 @@ THE SOFTWARE. * mat2.identity(dest); * mat2.rotate(dest, dest, rad); * - * @param {mat2} out mat2 receiving operation result + * @template {mat2} T + * @param {T} out mat2 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function fromRotation$4(out, rad) { var s = Math.sin(rad); @@ -384,9 +394,10 @@ THE SOFTWARE. * mat2.identity(dest); * mat2.scale(dest, dest, vec); * - * @param {mat2} out mat2 receiving operation result + * @template {mat2} T + * @param {T} out mat2 receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function fromScaling$3(out, v) { out[0] = v[0]; @@ -435,10 +446,11 @@ THE SOFTWARE. /** * Adds two mat2's * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function add$8(out, a, b) { out[0] = a[0] + b[0]; @@ -451,10 +463,11 @@ THE SOFTWARE. /** * Subtracts matrix b from matrix a * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function subtract$6(out, a, b) { out[0] = a[0] - b[0]; @@ -497,10 +510,11 @@ THE SOFTWARE. /** * Multiply each element of the matrix by a scalar. * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function multiplyScalar$3(out, a, b) { out[0] = a[0] * b; @@ -513,11 +527,12 @@ THE SOFTWARE. /** * Adds two mat2's after multiplying each element of the second operand by a scalar value. * - * @param {mat2} out the receiving vector + * @template {mat2} T + * @param {T} out the receiving vector * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ function multiplyScalarAndAdd$3(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -591,7 +606,7 @@ THE SOFTWARE. /** * Creates a new identity mat2d * - * @returns {mat2d} a new 2x3 matrix + * @returns {ArrayType} a new 2x3 matrix */ function create$7() { var out = new ARRAY_TYPE(6); @@ -610,7 +625,7 @@ THE SOFTWARE. * Creates a new mat2d initialized with values from an existing matrix * * @param {ReadonlyMat2d} a matrix to clone - * @returns {mat2d} a new 2x3 matrix + * @returns {ArrayType} a new 2x3 matrix */ function clone$7(a) { var out = new ARRAY_TYPE(6); @@ -626,9 +641,10 @@ THE SOFTWARE. /** * Copy the values from one mat2d to another * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the source matrix - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function copy$7(out, a) { out[0] = a[0]; @@ -643,8 +659,9 @@ THE SOFTWARE. /** * Set a mat2d to the identity matrix * - * @param {mat2d} out the receiving matrix - * @returns {mat2d} out + * @template {mat2d} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat2d} out */ function identity$4(out) { out[0] = 1; @@ -665,7 +682,7 @@ THE SOFTWARE. * @param {Number} d Component D (index 3) * @param {Number} tx Component TX (index 4) * @param {Number} ty Component TY (index 5) - * @returns {mat2d} A new mat2d + * @returns {ArrayType} A new mat2d */ function fromValues$7(a, b, c, d, tx, ty) { var out = new ARRAY_TYPE(6); @@ -681,14 +698,15 @@ THE SOFTWARE. /** * Set the components of a mat2d to the given values * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {Number} a Component A (index 0) * @param {Number} b Component B (index 1) * @param {Number} c Component C (index 2) * @param {Number} d Component D (index 3) * @param {Number} tx Component TX (index 4) * @param {Number} ty Component TY (index 5) - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function set$7(out, a, b, c, d, tx, ty) { out[0] = a; @@ -703,9 +721,10 @@ THE SOFTWARE. /** * Inverts a mat2d * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the source matrix - * @returns {mat2d | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat2d | null} out, or null if source matrix is not invertible */ function invert$4(out, a) { var aa = a[0], @@ -741,10 +760,11 @@ THE SOFTWARE. /** * Multiplies two mat2d's * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function multiply$7(out, a, b) { var a0 = a[0], @@ -771,10 +791,11 @@ THE SOFTWARE. /** * Rotates a mat2d by the given angle * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function rotate$3(out, a, rad) { var a0 = a[0], @@ -797,10 +818,11 @@ THE SOFTWARE. /** * Scales the mat2d by the dimensions in the given vec2 * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to translate * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out **/ function scale$7(out, a, v) { var a0 = a[0], @@ -823,10 +845,11 @@ THE SOFTWARE. /** * Translates the mat2d by the dimensions in the given vec2 * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to translate * @param {ReadonlyVec2} v the vec2 to translate the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out **/ function translate$3(out, a, v) { var a0 = a[0], @@ -853,9 +876,10 @@ THE SOFTWARE. * mat2d.identity(dest); * mat2d.rotate(dest, dest, rad); * - * @param {mat2d} out mat2d receiving operation result + * @template {mat2d} T + * @param {T} out mat2d receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function fromRotation$3(out, rad) { var s = Math.sin(rad), @@ -876,9 +900,10 @@ THE SOFTWARE. * mat2d.identity(dest); * mat2d.scale(dest, dest, vec); * - * @param {mat2d} out mat2d receiving operation result + * @template {mat2d} T + * @param {T} out mat2d receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function fromScaling$2(out, v) { out[0] = v[0]; @@ -897,9 +922,10 @@ THE SOFTWARE. * mat2d.identity(dest); * mat2d.translate(dest, dest, vec); * - * @param {mat2d} out mat2d receiving operation result + * @template {mat2d} T + * @param {T} out mat2d receiving operation result * @param {ReadonlyVec2} v Translation vector - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function fromTranslation$3(out, v) { out[0] = 1; @@ -934,10 +960,11 @@ THE SOFTWARE. /** * Adds two mat2d's * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function add$7(out, a, b) { out[0] = a[0] + b[0]; @@ -952,10 +979,11 @@ THE SOFTWARE. /** * Subtracts matrix b from matrix a * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function subtract$5(out, a, b) { out[0] = a[0] - b[0]; @@ -970,10 +998,11 @@ THE SOFTWARE. /** * Multiply each element of the matrix by a scalar. * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function multiplyScalar$2(out, a, b) { out[0] = a[0] * b; @@ -988,11 +1017,12 @@ THE SOFTWARE. /** * Adds two mat2d's after multiplying each element of the second operand by a scalar value. * - * @param {mat2d} out the receiving vector + * @template {mat2d} T + * @param {T} out the receiving vector * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ function multiplyScalarAndAdd$2(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -1087,7 +1117,7 @@ THE SOFTWARE. /** * Creates a new identity mat3 * - * @returns {mat3} a new 3x3 matrix + * @returns {ArrayType} a new 3x3 matrix */ function create$6() { var out = new ARRAY_TYPE(9); @@ -1108,9 +1138,10 @@ THE SOFTWARE. /** * Copies the upper-left 3x3 values into the given mat3. * - * @param {mat3} out the receiving 3x3 matrix + * @template {mat3} T + * @param {T} out the receiving 3x3 matrix * @param {ReadonlyMat4} a the source 4x4 matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function fromMat4$1(out, a) { out[0] = a[0]; @@ -1129,7 +1160,7 @@ THE SOFTWARE. * Creates a new mat3 initialized with values from an existing matrix * * @param {ReadonlyMat3} a matrix to clone - * @returns {mat3} a new 3x3 matrix + * @returns {ArrayType} a new 3x3 matrix */ function clone$6(a) { var out = new ARRAY_TYPE(9); @@ -1148,9 +1179,10 @@ THE SOFTWARE. /** * Copy the values from one mat3 to another * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function copy$6(out, a) { out[0] = a[0]; @@ -1177,7 +1209,7 @@ THE SOFTWARE. * @param {Number} m20 Component in column 2, row 0 position (index 6) * @param {Number} m21 Component in column 2, row 1 position (index 7) * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} A new mat3 + * @returns {ArrayType} A new mat3 */ function fromValues$6(m00, m01, m02, m10, m11, m12, m20, m21, m22) { var out = new ARRAY_TYPE(9); @@ -1196,7 +1228,8 @@ THE SOFTWARE. /** * Set the components of a mat3 to the given values * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) @@ -1206,7 +1239,7 @@ THE SOFTWARE. * @param {Number} m20 Component in column 2, row 0 position (index 6) * @param {Number} m21 Component in column 2, row 1 position (index 7) * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function set$6(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { out[0] = m00; @@ -1224,8 +1257,9 @@ THE SOFTWARE. /** * Set a mat3 to the identity matrix * - * @param {mat3} out the receiving matrix - * @returns {mat3} out + * @template {mat3} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat3} out */ function identity$3(out) { out[0] = 1; @@ -1243,9 +1277,10 @@ THE SOFTWARE. /** * Transpose the values of a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function transpose$1(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -1276,9 +1311,10 @@ THE SOFTWARE. /** * Inverts a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3 | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat3 | null} out, or null if source matrix is not invertible */ function invert$3(out, a) { var a00 = a[0], @@ -1315,9 +1351,10 @@ THE SOFTWARE. /** * Calculates the adjugate of a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function adjoint$1(out, a) { var a00 = a[0], @@ -1363,10 +1400,11 @@ THE SOFTWARE. /** * Multiplies two mat3's * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function multiply$6(out, a, b) { var a00 = a[0], @@ -1402,10 +1440,11 @@ THE SOFTWARE. /** * Translate a mat3 by the given vector * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to translate * @param {ReadonlyVec2} v vector to translate by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function translate$2(out, a, v) { var a00 = a[0], @@ -1434,10 +1473,11 @@ THE SOFTWARE. /** * Rotates a mat3 by the given angle * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function rotate$2(out, a, rad) { var a00 = a[0], @@ -1466,10 +1506,11 @@ THE SOFTWARE. /** * Scales the mat3 by the dimensions in the given vec2 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to scale * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out **/ function scale$6(out, a, v) { var x = v[0], @@ -1493,9 +1534,10 @@ THE SOFTWARE. * mat3.identity(dest); * mat3.translate(dest, dest, vec); * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyVec2} v Translation vector - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function fromTranslation$2(out, v) { out[0] = 1; @@ -1517,9 +1559,10 @@ THE SOFTWARE. * mat3.identity(dest); * mat3.rotate(dest, dest, rad); * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function fromRotation$2(out, rad) { var s = Math.sin(rad), @@ -1543,9 +1586,10 @@ THE SOFTWARE. * mat3.identity(dest); * mat3.scale(dest, dest, vec); * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function fromScaling$1(out, v) { out[0] = v[0]; @@ -1563,9 +1607,10 @@ THE SOFTWARE. /** * Copies the values from a mat2d into a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to copy - * @returns {mat3} out + * @returns {ReturnType.Mat3} out **/ function fromMat2d(out, a) { out[0] = a[0]; @@ -1583,10 +1628,11 @@ THE SOFTWARE. /** * Calculates a 3x3 matrix from the given quaternion * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyQuat} q Quaternion to create matrix from * - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function fromQuat$1(out, q) { var x = q[0], @@ -1620,10 +1666,11 @@ THE SOFTWARE. /** * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from * - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function normalFromMat4(out, a) { var a00 = a[0], @@ -1676,10 +1723,11 @@ THE SOFTWARE. /** * Generates a 2D projection matrix with the given bounds * - * @param {mat3} out mat3 frustum matrix will be written into + * @template {mat3} T + * @param {T} out mat3 frustum matrix will be written into * @param {number} width Width of your gl context * @param {number} height Height of gl context - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function projection(out, width, height) { out[0] = 2 / width; @@ -1717,10 +1765,11 @@ THE SOFTWARE. /** * Adds two mat3's * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function add$6(out, a, b) { out[0] = a[0] + b[0]; @@ -1738,10 +1787,11 @@ THE SOFTWARE. /** * Subtracts matrix b from matrix a * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function subtract$4(out, a, b) { out[0] = a[0] - b[0]; @@ -1759,10 +1809,11 @@ THE SOFTWARE. /** * Multiply each element of the matrix by a scalar. * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function multiplyScalar$1(out, a, b) { out[0] = a[0] * b; @@ -1780,11 +1831,12 @@ THE SOFTWARE. /** * Adds two mat3's after multiplying each element of the second operand by a scalar value. * - * @param {mat3} out the receiving vector + * @template {mat3} T + * @param {T} out the receiving vector * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ function multiplyScalarAndAdd$1(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -1895,7 +1947,7 @@ THE SOFTWARE. /** * Creates a new identity mat4 * - * @returns {mat4} a new 4x4 matrix + * @returns {ArrayType} a new 4x4 matrix */ function create$5() { var out = new ARRAY_TYPE(16); @@ -1924,7 +1976,7 @@ THE SOFTWARE. * Creates a new mat4 initialized with values from an existing matrix * * @param {ReadonlyMat4} a matrix to clone - * @returns {mat4} a new 4x4 matrix + * @returns {ArrayType} a new 4x4 matrix */ function clone$5(a) { var out = new ARRAY_TYPE(16); @@ -1950,9 +2002,10 @@ THE SOFTWARE. /** * Copy the values from one mat4 to another * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function copy$5(out, a) { out[0] = a[0]; @@ -1993,7 +2046,7 @@ THE SOFTWARE. * @param {Number} m31 Component in column 3, row 1 position (index 13) * @param {Number} m32 Component in column 3, row 2 position (index 14) * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} A new mat4 + * @returns {ArrayType} A new mat4 */ function fromValues$5(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { var out = new ARRAY_TYPE(16); @@ -2019,7 +2072,8 @@ THE SOFTWARE. /** * Set the components of a mat4 to the given values * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) @@ -2036,7 +2090,7 @@ THE SOFTWARE. * @param {Number} m31 Component in column 3, row 1 position (index 13) * @param {Number} m32 Component in column 3, row 2 position (index 14) * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function set$5(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { out[0] = m00; @@ -2061,8 +2115,9 @@ THE SOFTWARE. /** * Set a mat4 to the identity matrix * - * @param {mat4} out the receiving matrix - * @returns {mat4} out + * @template {mat4} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat4} out */ function identity$2(out) { out[0] = 1; @@ -2087,9 +2142,10 @@ THE SOFTWARE. /** * Transpose the values of a mat4 * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -2136,9 +2192,10 @@ THE SOFTWARE. /** * Inverts a mat4 * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4 | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat4 | null} out, or null if source matrix is not invertible */ function invert$2(out, a) { var a00 = a[0], @@ -2198,9 +2255,10 @@ THE SOFTWARE. /** * Calculates the adjugate of a mat4 * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function adjoint(out, a) { var a00 = a[0], @@ -2291,10 +2349,11 @@ THE SOFTWARE. /** * Multiplies two mat4s * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function multiply$5(out, a, b) { var a00 = a[0], @@ -2353,10 +2412,11 @@ THE SOFTWARE. /** * Translate a mat4 by the given vector * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to translate * @param {ReadonlyVec3} v vector to translate by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function translate$1(out, a, v) { var x = v[0], @@ -2406,10 +2466,11 @@ THE SOFTWARE. /** * Scales the mat4 by the dimensions in the given vec3 not using vectorization * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to scale * @param {ReadonlyVec3} v the vec3 to scale the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out **/ function scale$5(out, a, v) { var x = v[0], @@ -2437,11 +2498,12 @@ THE SOFTWARE. /** * Rotates a mat4 by the given angle around the given axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by * @param {ReadonlyVec3} axis the axis to rotate around - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function rotate$1(out, a, rad, axis) { var x = axis[0], @@ -2515,10 +2577,11 @@ THE SOFTWARE. /** * Rotates a matrix by the given angle around the X axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function rotateX$3(out, a, rad) { var s = Math.sin(rad); @@ -2558,10 +2621,11 @@ THE SOFTWARE. /** * Rotates a matrix by the given angle around the Y axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function rotateY$3(out, a, rad) { var s = Math.sin(rad); @@ -2601,10 +2665,11 @@ THE SOFTWARE. /** * Rotates a matrix by the given angle around the Z axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function rotateZ$3(out, a, rad) { var s = Math.sin(rad); @@ -2648,9 +2713,10 @@ THE SOFTWARE. * mat4.identity(dest); * mat4.translate(dest, dest, vec); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {ReadonlyVec3} v Translation vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromTranslation$1(out, v) { out[0] = 1; @@ -2679,9 +2745,10 @@ THE SOFTWARE. * mat4.identity(dest); * mat4.scale(dest, dest, vec); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {ReadonlyVec3} v Scaling vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromScaling(out, v) { out[0] = v[0]; @@ -2710,10 +2777,11 @@ THE SOFTWARE. * mat4.identity(dest); * mat4.rotate(dest, dest, rad, axis); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by * @param {ReadonlyVec3} axis the axis to rotate around - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromRotation$1(out, rad, axis) { var x = axis[0], @@ -2759,9 +2827,10 @@ THE SOFTWARE. * mat4.identity(dest); * mat4.rotateX(dest, dest, rad); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromXRotation(out, rad) { var s = Math.sin(rad); @@ -2794,9 +2863,10 @@ THE SOFTWARE. * mat4.identity(dest); * mat4.rotateY(dest, dest, rad); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromYRotation(out, rad) { var s = Math.sin(rad); @@ -2829,9 +2899,10 @@ THE SOFTWARE. * mat4.identity(dest); * mat4.rotateZ(dest, dest, rad); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromZRotation(out, rad) { var s = Math.sin(rad); @@ -2867,10 +2938,11 @@ THE SOFTWARE. * mat4.fromQuat(quatMat, quat); * mat4.multiply(dest, dest, quatMat); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {quat} q Rotation quaternion * @param {ReadonlyVec3} v Translation vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromRotationTranslation$1(out, q, v) { // Quaternion math @@ -2914,7 +2986,7 @@ THE SOFTWARE. * * @param {mat4} out Matrix * @param {ReadonlyQuat2} a Dual Quaternion - * @returns {mat4} mat4 receiving operation result + * @returns {ArrayType} mat4 receiving operation result */ function fromQuat2(out, a) { var translation = new ARRAY_TYPE(3); @@ -3040,11 +3112,12 @@ THE SOFTWARE. /** * Decomposes a transformation matrix into its rotation, translation * and scale components. Returns only the rotation component + * * @param {quat} out_r Quaternion to receive the rotation component * @param {vec3} out_t Vector to receive the translation vector * @param {vec3} out_s Vector to receive the scaling factor * @param {ReadonlyMat4} mat Matrix to be decomposed (input) - * @returns {quat} out_r + * @returns {ArrayType} out_r */ function decompose(out_r, out_t, out_s, mat) { out_t[0] = mat[12]; @@ -3115,11 +3188,12 @@ THE SOFTWARE. * mat4.multiply(dest, dest, quatMat); * mat4.scale(dest, dest, scale) * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {quat} q Rotation quaternion * @param {ReadonlyVec3} v Translation vector * @param {ReadonlyVec3} s Scaling vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromRotationTranslationScale(out, q, v, s) { // Quaternion math @@ -3174,12 +3248,13 @@ THE SOFTWARE. * mat4.scale(dest, dest, scale) * mat4.translate(dest, dest, negativeOrigin); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {quat} q Rotation quaternion * @param {ReadonlyVec3} v Translation vector * @param {ReadonlyVec3} s Scaling vector * @param {ReadonlyVec3} o The origin vector around which to scale and rotate - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromRotationTranslationScaleOrigin(out, q, v, s, o) { // Quaternion math @@ -3236,10 +3311,11 @@ THE SOFTWARE. /** * Calculates a 4x4 matrix from the given quaternion * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {ReadonlyQuat} q Quaternion to create matrix from * - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function fromQuat(out, q) { var x = q[0], @@ -3280,6 +3356,7 @@ THE SOFTWARE. /** * Generates a frustum matrix with the given bounds * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {Number} left Left bound of the frustum * @param {Number} right Right bound of the frustum @@ -3287,7 +3364,7 @@ THE SOFTWARE. * @param {Number} top Top bound of the frustum * @param {Number} near Near bound of the frustum * @param {Number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function frustum(out, left, right, bottom, top, near, far) { var rl = 1 / (right - left); @@ -3318,12 +3395,13 @@ THE SOFTWARE. * which matches WebGL/OpenGL's clip volume. * Passing null/undefined/no value for far will generate infinite projection matrix. * - * @param {mat4} out mat4 frustum matrix will be written into + * @template {mat4} T + * @param {T} out mat4 frustum matrix will be written into * @param {number} fovy Vertical field of view in radians * @param {number} aspect Aspect ratio. typically viewport width/height * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum, can be null or Infinity - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function perspectiveNO(out, fovy, aspect, near, far) { var f = 1.0 / Math.tan(fovy / 2); @@ -3364,12 +3442,13 @@ THE SOFTWARE. * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. * Passing null/undefined/no value for far will generate infinite projection matrix. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {number} fovy Vertical field of view in radians * @param {number} aspect Aspect ratio. typically viewport width/height * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum, can be null or Infinity - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function perspectiveZO(out, fovy, aspect, near, far) { var f = 1.0 / Math.tan(fovy / 2); @@ -3403,11 +3482,12 @@ THE SOFTWARE. * This is primarily useful for generating projection matrices to be used * with the still experiemental WebVR API. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function perspectiveFromFieldOfView(out, fov, near, far) { var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0); @@ -3440,6 +3520,7 @@ THE SOFTWARE. * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], * which matches WebGL/OpenGL's clip volume. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {number} left Left bound of the frustum * @param {number} right Right bound of the frustum @@ -3447,7 +3528,7 @@ THE SOFTWARE. * @param {number} top Top bound of the frustum * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function orthoNO(out, left, right, bottom, top, near, far) { var lr = 1 / (left - right); @@ -3483,6 +3564,7 @@ THE SOFTWARE. * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {number} left Left bound of the frustum * @param {number} right Right bound of the frustum @@ -3490,7 +3572,7 @@ THE SOFTWARE. * @param {number} top Top bound of the frustum * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function orthoZO(out, left, right, bottom, top, near, far) { var lr = 1 / (left - right); @@ -3519,11 +3601,12 @@ THE SOFTWARE. * Generates a look-at matrix with the given eye position, focal point, and up axis. * If you want a matrix that actually makes an object look at another object, you should use targetTo instead. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {ReadonlyVec3} eye Position of the viewer * @param {ReadonlyVec3} center Point the viewer is looking at * @param {ReadonlyVec3} up vec3 pointing up - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function lookAt(out, eye, center, up) { var x0, x1, x2, y0, y1, y2, z0, z1, z2, len; @@ -3596,11 +3679,12 @@ THE SOFTWARE. /** * Generates a matrix that makes something look at something else. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {ReadonlyVec3} eye Position of the viewer * @param {ReadonlyVec3} target Point the viewer is looking at * @param {ReadonlyVec3} up vec3 pointing up - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function targetTo(out, eye, target, up) { var eyex = eye[0], @@ -3671,10 +3755,11 @@ THE SOFTWARE. /** * Adds two mat4's * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function add$5(out, a, b) { out[0] = a[0] + b[0]; @@ -3699,10 +3784,11 @@ THE SOFTWARE. /** * Subtracts matrix b from matrix a * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function subtract$3(out, a, b) { out[0] = a[0] - b[0]; @@ -3727,10 +3813,11 @@ THE SOFTWARE. /** * Multiply each element of the matrix by a scalar. * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -3755,11 +3842,12 @@ THE SOFTWARE. /** * Adds two mat4's after multiplying each element of the second operand by a scalar value. * - * @param {mat4} out the receiving vector + * @template {mat4} T + * @param {T} out the receiving vector * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -3911,7 +3999,7 @@ THE SOFTWARE. /** * Creates a new, empty vec3 * - * @returns {vec3} a new 3D vector + * @returns {ArrayType} a new 3D vector */ function create$4() { var out = new ARRAY_TYPE(3); @@ -3927,7 +4015,7 @@ THE SOFTWARE. * Creates a new vec3 initialized with values from an existing vector * * @param {ReadonlyVec3} a vector to clone - * @returns {vec3} a new 3D vector + * @returns {ArrayType} a new 3D vector */ function clone$4(a) { var out = new ARRAY_TYPE(3); @@ -3956,7 +4044,7 @@ THE SOFTWARE. * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component - * @returns {vec3} a new 3D vector + * @returns {ArrayType} a new 3D vector */ function fromValues$4(x, y, z) { var out = new ARRAY_TYPE(3); @@ -3969,9 +4057,10 @@ THE SOFTWARE. /** * Copy the values from one vec3 to another * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the source vector - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function copy$4(out, a) { out[0] = a[0]; @@ -3983,11 +4072,12 @@ THE SOFTWARE. /** * Set the components of a vec3 to the given values * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function set$4(out, x, y, z) { out[0] = x; @@ -3999,10 +4089,11 @@ THE SOFTWARE. /** * Adds two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function add$4(out, a, b) { out[0] = a[0] + b[0]; @@ -4014,10 +4105,11 @@ THE SOFTWARE. /** * Subtracts vector b from vector a * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function subtract$2(out, a, b) { out[0] = a[0] - b[0]; @@ -4029,10 +4121,11 @@ THE SOFTWARE. /** * Multiplies two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function multiply$4(out, a, b) { out[0] = a[0] * b[0]; @@ -4044,10 +4137,11 @@ THE SOFTWARE. /** * Divides two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function divide$2(out, a, b) { out[0] = a[0] / b[0]; @@ -4059,9 +4153,10 @@ THE SOFTWARE. /** * Math.ceil the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to ceil - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function ceil$2(out, a) { out[0] = Math.ceil(a[0]); @@ -4073,9 +4168,10 @@ THE SOFTWARE. /** * Math.floor the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to floor - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function floor$2(out, a) { out[0] = Math.floor(a[0]); @@ -4087,10 +4183,11 @@ THE SOFTWARE. /** * Returns the minimum of two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function min$2(out, a, b) { out[0] = Math.min(a[0], b[0]); @@ -4102,10 +4199,11 @@ THE SOFTWARE. /** * Returns the maximum of two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function max$2(out, a, b) { out[0] = Math.max(a[0], b[0]); @@ -4117,9 +4215,10 @@ THE SOFTWARE. /** * symmetric round the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to round - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function round$2(out, a) { out[0] = round$3(a[0]); @@ -4131,10 +4230,11 @@ THE SOFTWARE. /** * Scales a vec3 by a scalar number * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function scale$4(out, a, b) { out[0] = a[0] * b; @@ -4146,11 +4246,12 @@ THE SOFTWARE. /** * Adds two vec3's after scaling the second operand by a scalar value * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function scaleAndAdd$2(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -4203,9 +4304,10 @@ THE SOFTWARE. /** * Negates the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to negate - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function negate$2(out, a) { out[0] = -a[0]; @@ -4217,9 +4319,10 @@ THE SOFTWARE. /** * Returns the inverse of the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to invert - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function inverse$2(out, a) { out[0] = 1.0 / a[0]; @@ -4231,9 +4334,10 @@ THE SOFTWARE. /** * Normalize a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to normalize - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function normalize$4(out, a) { var x = a[0]; @@ -4264,10 +4368,11 @@ THE SOFTWARE. /** * Computes the cross product of two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function cross$2(out, a, b) { var ax = a[0], @@ -4285,11 +4390,12 @@ THE SOFTWARE. /** * Performs a linear interpolation between two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function lerp$4(out, a, b, t) { var ax = a[0]; @@ -4304,11 +4410,12 @@ THE SOFTWARE. /** * Performs a spherical linear interpolation between two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function slerp$1(out, a, b, t) { var angle = Math.acos(Math.min(Math.max(dot$4(a, b), -1), 1)); @@ -4324,13 +4431,14 @@ THE SOFTWARE. /** * Performs a hermite interpolation with two control points * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {ReadonlyVec3} c the third operand * @param {ReadonlyVec3} d the fourth operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function hermite(out, a, b, c, d, t) { var factorTimes2 = t * t; @@ -4347,13 +4455,14 @@ THE SOFTWARE. /** * Performs a bezier interpolation with two control points * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {ReadonlyVec3} c the third operand * @param {ReadonlyVec3} d the fourth operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function bezier(out, a, b, c, d, t) { var inverseFactor = 1 - t; @@ -4372,9 +4481,10 @@ THE SOFTWARE. /** * Generates a random vector with the given scale * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function random$3(out, scale) { scale = scale === undefined ? 1.0 : scale; @@ -4391,10 +4501,11 @@ THE SOFTWARE. * Transforms the vec3 with a mat4. * 4th vector component is implicitly '1' * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function transformMat4$2(out, a, m) { var x = a[0], @@ -4411,10 +4522,11 @@ THE SOFTWARE. /** * Transforms the vec3 with a mat3. * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to transform * @param {ReadonlyMat3} m the 3x3 matrix to transform with - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function transformMat3$1(out, a, m) { var x = a[0], @@ -4430,10 +4542,11 @@ THE SOFTWARE. * Transforms the vec3 with a quat * Can also be used for dual quaternions. (Multiply it with the real part) * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to transform * @param {ReadonlyQuat} q normalized quaternion to transform with - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function transformQuat$1(out, a, q) { // Fast Vector Rotation using Quaternions by Robert Eisele @@ -4466,11 +4579,12 @@ THE SOFTWARE. /** * Rotate a 3D vector around the x-axis - * @param {vec3} out The receiving vec3 + * @template {vec3} T + * @param {T} out The receiving vec3 * @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 - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function rotateX$2(out, a, b, rad) { var p = [], @@ -4494,11 +4608,12 @@ THE SOFTWARE. /** * Rotate a 3D vector around the y-axis - * @param {vec3} out The receiving vec3 + * @template {vec3} T + * @param {T} out The receiving vec3 * @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 - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function rotateY$2(out, a, b, rad) { var p = [], @@ -4522,11 +4637,12 @@ THE SOFTWARE. /** * Rotate a 3D vector around the z-axis - * @param {vec3} out The receiving vec3 + * @template {vec3} T + * @param {T} out The receiving vec3 * @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 - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ function rotateZ$2(out, a, b, rad) { var p = [], @@ -4569,8 +4685,9 @@ THE SOFTWARE. /** * Set the components of a vec3 to zero * - * @param {vec3} out the receiving vector - * @returns {vec3} out + * @template {vec3} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec3} out */ function zero$2(out) { out[0] = 0.0; @@ -4755,12 +4872,12 @@ THE SOFTWARE. /** * 4 Dimensional Vector * @module vec4 - */ + */ /** * Creates a new, empty vec4 * - * @returns {vec4} a new 4D vector + * @returns {ArrayType} a new 4D vector */ function create$3() { var out = new ARRAY_TYPE(4); @@ -4777,7 +4894,7 @@ THE SOFTWARE. * Creates a new vec4 initialized with values from an existing vector * * @param {ReadonlyVec4} a vector to clone - * @returns {vec4} a new 4D vector + * @returns {ArrayType} a new 4D vector */ function clone$3(a) { var out = new ARRAY_TYPE(4); @@ -4795,7 +4912,7 @@ THE SOFTWARE. * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {vec4} a new 4D vector + * @returns {ArrayType} a new 4D vector */ function fromValues$3(x, y, z, w) { var out = new ARRAY_TYPE(4); @@ -4809,9 +4926,10 @@ THE SOFTWARE. /** * Copy the values from one vec4 to another * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the source vector - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function copy$3(out, a) { out[0] = a[0]; @@ -4824,12 +4942,13 @@ THE SOFTWARE. /** * Set the components of a vec4 to the given values * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function set$3(out, x, y, z, w) { out[0] = x; @@ -4842,10 +4961,11 @@ THE SOFTWARE. /** * Adds two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function add$3(out, a, b) { out[0] = a[0] + b[0]; @@ -4858,10 +4978,11 @@ THE SOFTWARE. /** * Subtracts vector b from vector a * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function subtract$1(out, a, b) { out[0] = a[0] - b[0]; @@ -4874,10 +4995,11 @@ THE SOFTWARE. /** * Multiplies two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function multiply$3(out, a, b) { out[0] = a[0] * b[0]; @@ -4890,10 +5012,11 @@ THE SOFTWARE. /** * Divides two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function divide$1(out, a, b) { out[0] = a[0] / b[0]; @@ -4906,9 +5029,10 @@ THE SOFTWARE. /** * Math.ceil the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to ceil - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function ceil$1(out, a) { out[0] = Math.ceil(a[0]); @@ -4921,9 +5045,10 @@ THE SOFTWARE. /** * Math.floor the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to floor - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function floor$1(out, a) { out[0] = Math.floor(a[0]); @@ -4936,10 +5061,11 @@ THE SOFTWARE. /** * Returns the minimum of two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function min$1(out, a, b) { out[0] = Math.min(a[0], b[0]); @@ -4952,10 +5078,11 @@ THE SOFTWARE. /** * Returns the maximum of two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function max$1(out, a, b) { out[0] = Math.max(a[0], b[0]); @@ -4968,9 +5095,10 @@ THE SOFTWARE. /** * symmetric round the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to round - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function round$1(out, a) { out[0] = round$3(a[0]); @@ -4983,10 +5111,11 @@ THE SOFTWARE. /** * Scales a vec4 by a scalar number * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function scale$3(out, a, b) { out[0] = a[0] * b; @@ -4999,11 +5128,12 @@ THE SOFTWARE. /** * Adds two vec4's after scaling the second operand by a scalar value * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function scaleAndAdd$1(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -5074,9 +5204,10 @@ THE SOFTWARE. /** * Negates the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to negate - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function negate$1(out, a) { out[0] = -a[0]; @@ -5089,9 +5220,10 @@ THE SOFTWARE. /** * Returns the inverse of the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to invert - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function inverse$1(out, a) { out[0] = 1.0 / a[0]; @@ -5104,9 +5236,10 @@ THE SOFTWARE. /** * Normalize a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to normalize - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function normalize$3(out, a) { var x = a[0]; @@ -5138,11 +5271,12 @@ THE SOFTWARE. /** * Returns the cross-product of three vectors in a 4-dimensional space * - * @param {ReadonlyVec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} u the first vector * @param {ReadonlyVec4} v the second vector * @param {ReadonlyVec4} w the third vector - * @returns {vec4} result + * @returns {ReturnType.Vec4} result */ function cross$1(out, u, v, w) { var A = v[0] * w[1] - v[1] * w[0], @@ -5165,11 +5299,12 @@ THE SOFTWARE. /** * Performs a linear interpolation between two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function lerp$3(out, a, b, t) { var ax = a[0]; @@ -5186,9 +5321,10 @@ THE SOFTWARE. /** * Generates a random vector with the given scale * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function random$2(out, scale) { scale = scale === undefined ? 1.0 : scale; @@ -5218,10 +5354,11 @@ THE SOFTWARE. /** * Transforms the vec4 with a mat4. * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function transformMat4$1(out, a, m) { var x = a[0], @@ -5238,10 +5375,11 @@ THE SOFTWARE. /** * Transforms the vec4 with a quat * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the vector to transform * @param {ReadonlyQuat} q normalized quaternion to transform with - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ function transformQuat(out, a, q) { // Fast Vector Rotation using Quaternions by Robert Eisele @@ -5276,8 +5414,9 @@ THE SOFTWARE. /** * Set the components of a vec4 to zero * - * @param {vec4} out the receiving vector - * @returns {vec4} out + * @template {vec4} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec4} out */ function zero$1(out) { out[0] = 0.0; @@ -5464,7 +5603,7 @@ THE SOFTWARE. /** * Creates a new identity quat * - * @returns {quat} a new quaternion + * @returns {ReturnType.Quat} a new quaternion */ function create$2() { var out = new ARRAY_TYPE(4); @@ -5480,8 +5619,9 @@ THE SOFTWARE. /** * Set a quat to the identity quaternion * - * @param {quat} out the receiving quaternion - * @returns {quat} out + * @template {quat} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat} out */ function identity$1(out) { out[0] = 0; @@ -5495,10 +5635,11 @@ THE SOFTWARE. * Sets a quat from the given angle and rotation axis, * then returns it. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyVec3} axis the axis around which to rotate * @param {Number} rad the angle in radians - * @returns {quat} out + * @returns {ReturnType.Quat} out **/ function setAxisAngle(out, axis, rad) { rad = rad * 0.5; @@ -5554,10 +5695,11 @@ THE SOFTWARE. /** * Multiplies two quat's * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function multiply$2(out, a, b) { var ax = a[0], @@ -5578,10 +5720,11 @@ THE SOFTWARE. /** * Rotates a quaternion by the given angle about the X axis * - * @param {quat} out quat receiving operation result + * @template {quat} T + * @param {T} out quat receiving operation result * @param {ReadonlyQuat} a quat to rotate * @param {number} rad angle (in radians) to rotate - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function rotateX$1(out, a, rad) { rad *= 0.5; @@ -5601,10 +5744,11 @@ THE SOFTWARE. /** * Rotates a quaternion by the given angle about the Y axis * - * @param {quat} out quat receiving operation result + * @template {quat} T + * @param {T} out quat receiving operation result * @param {ReadonlyQuat} a quat to rotate * @param {number} rad angle (in radians) to rotate - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function rotateY$1(out, a, rad) { rad *= 0.5; @@ -5624,10 +5768,11 @@ THE SOFTWARE. /** * Rotates a quaternion by the given angle about the Z axis * - * @param {quat} out quat receiving operation result + * @template {quat} T + * @param {T} out quat receiving operation result * @param {ReadonlyQuat} a quat to rotate * @param {number} rad angle (in radians) to rotate - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function rotateZ$1(out, a, rad) { rad *= 0.5; @@ -5649,9 +5794,10 @@ THE SOFTWARE. * Assumes that quaternion is 1 unit in length. * Any existing W component will be ignored. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate W component of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function calculateW(out, a) { var x = a[0], @@ -5667,9 +5813,10 @@ THE SOFTWARE. /** * Calculate the exponential of a unit quaternion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate the exponential of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function exp(out, a) { var x = a[0], @@ -5689,9 +5836,10 @@ THE SOFTWARE. /** * Calculate the natural logarithm of a unit quaternion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate the exponential of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function ln(out, a) { var x = a[0], @@ -5710,10 +5858,11 @@ THE SOFTWARE. /** * Calculate the scalar power of a unit quaternion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate the exponential of * @param {Number} b amount to scale the quaternion by - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function pow(out, a, b) { ln(out, a); @@ -5725,11 +5874,12 @@ THE SOFTWARE. /** * Performs a spherical linear interpolation between two quat * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function slerp(out, a, b, t) { // benchmarks: @@ -5778,8 +5928,9 @@ THE SOFTWARE. /** * Generates a random unit quaternion * - * @param {quat} out the receiving quaternion - * @returns {quat} out + * @template {quat} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat} out */ function random$1(out) { // Implementation of http://planning.cs.uiuc.edu/node198.html @@ -5799,9 +5950,10 @@ THE SOFTWARE. /** * Calculates the inverse of a quat * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate inverse of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function invert$1(out, a) { var a0 = a[0], @@ -5824,9 +5976,10 @@ THE SOFTWARE. * Calculates the conjugate of a quat * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate conjugate of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ function conjugate$1(out, a) { out[0] = -a[0]; @@ -5842,9 +5995,10 @@ THE SOFTWARE. * NOTE: The resultant quaternion is not normalized, so you should be sure * to renormalize the quaternion yourself where necessary. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyMat3} m rotation matrix - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ function fromMat3(out, m) { @@ -5880,12 +6034,13 @@ THE SOFTWARE. /** * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {Number} x Angle to rotate around X axis in degrees. * @param {Number} y Angle to rotate around Y axis in degrees. * @param {Number} z Angle to rotate around Z axis in degrees. * @param {'xyz'|'xzy'|'yxz'|'yzx'|'zxy'|'zyx'} order Intrinsic order for conversion, default is zyx. - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ function fromEuler(out, x, y, z) { @@ -5957,7 +6112,7 @@ THE SOFTWARE. * Creates a new quat initialized with values from an existing quaternion * * @param {ReadonlyQuat} a quaternion to clone - * @returns {quat} a new quaternion + * @returns {ReturnType.Quat} a new quaternion * @function */ var clone$2 = clone$3; @@ -5969,7 +6124,7 @@ THE SOFTWARE. * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {quat} a new quaternion + * @returns {ReturnType.Quat} a new quaternion * @function */ var fromValues$2 = fromValues$3; @@ -5977,9 +6132,10 @@ THE SOFTWARE. /** * Copy the values from one quat to another * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the source quaternion - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ var copy$2 = copy$3; @@ -5987,12 +6143,13 @@ THE SOFTWARE. /** * Set the components of a quat to the given values * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ var set$2 = set$3; @@ -6000,10 +6157,11 @@ THE SOFTWARE. /** * Adds two quat's * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ var add$2 = add$3; @@ -6017,10 +6175,11 @@ THE SOFTWARE. /** * Scales a quat by a scalar number * - * @param {quat} out the receiving vector + * @template {quat} T + * @param {T} out the receiving vector * @param {ReadonlyQuat} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ var scale$2 = scale$3; @@ -6038,11 +6197,12 @@ THE SOFTWARE. /** * Performs a linear interpolation between two quat's * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ var lerp$2 = lerp$3; @@ -6079,9 +6239,10 @@ THE SOFTWARE. /** * Normalize a quat * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quaternion to normalize - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ var normalize$2 = normalize$3; @@ -6114,10 +6275,11 @@ THE SOFTWARE. * * Both vectors are assumed to be unit length. * - * @param {quat} out the receiving quaternion. + * @template {quat} T + * @param {T} out the receiving quaternion. * @param {ReadonlyVec3} a the initial vector * @param {ReadonlyVec3} b the destination vector - * @returns {quat} out + * @returns {ReturnType.Quat} out */ var rotationTo = function () { var tmpvec3 = create$4(); @@ -6151,13 +6313,14 @@ THE SOFTWARE. /** * Performs a spherical linear interpolation with two control points * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand * @param {ReadonlyQuat} c the third operand * @param {ReadonlyQuat} d the fourth operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out + * @returns {ReturnType.Quat} out */ var sqlerp = function () { var temp1 = create$2(); @@ -6175,10 +6338,12 @@ THE SOFTWARE. * axes. Each axis is a vec3 and is expected to be unit length and * perpendicular to all other specified axes. * + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyVec3} view the vector representing the viewing direction * @param {ReadonlyVec3} right the vector representing the local "right" direction * @param {ReadonlyVec3} up the vector representing the local "up" direction - * @returns {quat} out + * @returns {ReturnType.Quat} out */ var setAxes = function () { var matr = create$6(); @@ -6250,7 +6415,7 @@ THE SOFTWARE. /** * Creates a new identity dual quat * - * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation] + * @returns {ArrayType} a new dual quaternion [real -> rotation, dual -> translation] */ function create$1() { var dq = new ARRAY_TYPE(8); @@ -6271,7 +6436,7 @@ THE SOFTWARE. * Creates a new quat initialized with values from an existing quaternion * * @param {ReadonlyQuat2} a dual quaternion to clone - * @returns {quat2} new dual quaternion + * @returns {ArrayType} new dual quaternion * @function */ function clone$1(a) { @@ -6298,7 +6463,7 @@ THE SOFTWARE. * @param {Number} y2 Y component * @param {Number} z2 Z component * @param {Number} w2 W component - * @returns {quat2} new dual quaternion + * @returns {ArrayType} new dual quaternion * @function */ function fromValues$1(x1, y1, z1, w1, x2, y2, z2, w2) { @@ -6324,7 +6489,7 @@ THE SOFTWARE. * @param {Number} x2 X component (translation) * @param {Number} y2 Y component (translation) * @param {Number} z2 Z component (translation) - * @returns {quat2} new dual quaternion + * @returns {ArrayType} new dual quaternion * @function */ function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) { @@ -6346,10 +6511,11 @@ THE SOFTWARE. /** * Creates a dual quat from a quaternion and a translation * - * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result * @param {ReadonlyQuat} q a normalized quaternion * @param {ReadonlyVec3} t translation vector - * @returns {quat2} dual quaternion receiving operation result + * @returns {ReturnType.Quat2} dual quaternion receiving operation result * @function */ function fromRotationTranslation(out, q, t) { @@ -6374,9 +6540,10 @@ THE SOFTWARE. /** * Creates a dual quat from a translation * - * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result * @param {ReadonlyVec3} t translation vector - * @returns {quat2} dual quaternion receiving operation result + * @returns {ReturnType.Quat2} dual quaternion receiving operation result * @function */ function fromTranslation(out, t) { @@ -6394,9 +6561,10 @@ THE SOFTWARE. /** * Creates a dual quat from a quaternion * - * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result * @param {ReadonlyQuat} q the quaternion - * @returns {quat2} dual quaternion receiving operation result + * @returns {ReturnType.Quat2} dual quaternion receiving operation result * @function */ function fromRotation(out, q) { @@ -6414,9 +6582,10 @@ THE SOFTWARE. /** * Creates a new dual quat from a matrix (4x4) * - * @param {quat2} out the dual quaternion + * @template {quat2} T + * @param {T} out the dual quaternion * @param {ReadonlyMat4} a the matrix - * @returns {quat2} dual quat receiving operation result + * @returns {ReturnType.Quat2} dual quat receiving operation result * @function */ function fromMat4(out, a) { @@ -6432,9 +6601,10 @@ THE SOFTWARE. /** * Copy the values from one dual quat to another * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the source dual quaternion - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ function copy$1(out, a) { @@ -6452,8 +6622,9 @@ THE SOFTWARE. /** * Set a dual quat to the identity dual quaternion * - * @param {quat2} out the receiving quaternion - * @returns {quat2} out + * @template {quat2} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat2} out */ function identity(out) { out[0] = 0; @@ -6470,7 +6641,8 @@ THE SOFTWARE. /** * Set the components of a dual quat to the given values * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {Number} x1 X component * @param {Number} y1 Y component * @param {Number} z1 Z component @@ -6479,7 +6651,7 @@ THE SOFTWARE. * @param {Number} y2 Y component * @param {Number} z2 Z component * @param {Number} w2 W component - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ function set$1(out, x1, y1, z1, w1, x2, y2, z2, w2) { @@ -6519,9 +6691,10 @@ THE SOFTWARE. /** * Set the real component of a dual quat to the given quaternion * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} q a quaternion representing the real part - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ var setReal = copy$2; @@ -6529,9 +6702,10 @@ THE SOFTWARE. /** * Set the dual component of a dual quat to the given quaternion * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} q a quaternion representing the dual part - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ function setDual(out, q) { @@ -6566,10 +6740,11 @@ THE SOFTWARE. /** * Translates a dual quat by the given vector * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to translate * @param {ReadonlyVec3} v vector to translate by - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function translate(out, a, v) { var ax1 = a[0], @@ -6597,10 +6772,11 @@ THE SOFTWARE. /** * Rotates a dual quat around the X axis * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {number} rad how far should the rotation be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function rotateX(out, a, rad) { var bx = -a[0], @@ -6630,10 +6806,11 @@ THE SOFTWARE. /** * Rotates a dual quat around the Y axis * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {number} rad how far should the rotation be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function rotateY(out, a, rad) { var bx = -a[0], @@ -6663,10 +6840,11 @@ THE SOFTWARE. /** * Rotates a dual quat around the Z axis * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {number} rad how far should the rotation be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function rotateZ(out, a, rad) { var bx = -a[0], @@ -6696,10 +6874,11 @@ THE SOFTWARE. /** * Rotates a dual quat by a given quaternion (a * q) * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {ReadonlyQuat} q quaternion to rotate by - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function rotateByQuatAppend(out, a, q) { var qx = q[0], @@ -6728,10 +6907,11 @@ THE SOFTWARE. /** * Rotates a dual quat by a given quaternion (q * a) * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat} q quaternion to rotate by * @param {ReadonlyQuat2} a the dual quaternion to rotate - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function rotateByQuatPrepend(out, q, a) { var qx = q[0], @@ -6760,11 +6940,12 @@ THE SOFTWARE. /** * Rotates a dual quat around a given axis. Does the normalisation automatically * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {ReadonlyVec3} axis the axis to rotate around * @param {Number} rad how far the rotation should be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function rotateAroundAxis(out, a, axis, rad) { //Special case for rad = 0 @@ -6800,10 +6981,11 @@ THE SOFTWARE. /** * Adds two dual quat's * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the first operand * @param {ReadonlyQuat2} b the second operand - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ function add$1(out, a, b) { @@ -6821,10 +7003,11 @@ THE SOFTWARE. /** * Multiplies two dual quat's * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the first operand * @param {ReadonlyQuat2} b the second operand - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function multiply$1(out, a, b) { var ax0 = a[0], @@ -6863,10 +7046,11 @@ THE SOFTWARE. /** * Scales a dual quat by a scalar number * - * @param {quat2} out the receiving dual quat + * @template {quat2} T + * @param {T} out the receiving dual quat * @param {ReadonlyQuat2} a the dual quat to scale * @param {Number} b amount to scale the dual quat by - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ function scale$1(out, a, b) { @@ -6895,11 +7079,12 @@ THE SOFTWARE. * Performs a linear interpolation between two dual quats's * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5) * - * @param {quat2} out the receiving dual quat + * @template {quat2} T + * @param {T} out the receiving dual quat * @param {ReadonlyQuat2} a the first operand * @param {ReadonlyQuat2} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function lerp$1(out, a, b, t) { var mt = 1 - t; @@ -6918,9 +7103,10 @@ THE SOFTWARE. /** * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a dual quat to calculate inverse of - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function invert(out, a) { var sqlen = squaredLength$1(a); @@ -6939,9 +7125,10 @@ THE SOFTWARE. * Calculates the conjugate of a dual quat * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result. * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat2} a quat to calculate conjugate of - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ function conjugate(out, a) { out[0] = -a[0]; @@ -6988,9 +7175,10 @@ THE SOFTWARE. /** * Normalize a dual quat * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a dual quaternion to normalize - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ function normalize$1(out, a) { @@ -7117,7 +7305,7 @@ THE SOFTWARE. /** * Creates a new, empty vec2 * - * @returns {vec2} a new 2D vector + * @returns {ArrayType} a new 2D vector */ function create() { var out = new ARRAY_TYPE(2); @@ -7132,7 +7320,7 @@ THE SOFTWARE. * Creates a new vec2 initialized with values from an existing vector * * @param {ReadonlyVec2} a vector to clone - * @returns {vec2} a new 2D vector + * @returns {ArrayType} a new 2D vector */ function clone(a) { var out = new ARRAY_TYPE(2); @@ -7146,7 +7334,7 @@ THE SOFTWARE. * * @param {Number} x X component * @param {Number} y Y component - * @returns {vec2} a new 2D vector + * @returns {ArrayType} a new 2D vector */ function fromValues(x, y) { var out = new ARRAY_TYPE(2); @@ -7158,9 +7346,10 @@ THE SOFTWARE. /** * Copy the values from one vec2 to another * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the source vector - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function copy(out, a) { out[0] = a[0]; @@ -7171,10 +7360,11 @@ THE SOFTWARE. /** * Set the components of a vec2 to the given values * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {Number} x X component * @param {Number} y Y component - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function set(out, x, y) { out[0] = x; @@ -7185,10 +7375,11 @@ THE SOFTWARE. /** * Adds two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function add(out, a, b) { out[0] = a[0] + b[0]; @@ -7199,10 +7390,11 @@ THE SOFTWARE. /** * Subtracts vector b from vector a * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -7213,10 +7405,11 @@ THE SOFTWARE. /** * Multiplies two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function multiply(out, a, b) { out[0] = a[0] * b[0]; @@ -7227,10 +7420,11 @@ THE SOFTWARE. /** * Divides two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function divide(out, a, b) { out[0] = a[0] / b[0]; @@ -7241,9 +7435,10 @@ THE SOFTWARE. /** * Math.ceil the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to ceil - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function ceil(out, a) { out[0] = Math.ceil(a[0]); @@ -7254,9 +7449,10 @@ THE SOFTWARE. /** * Math.floor the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to floor - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function floor(out, a) { out[0] = Math.floor(a[0]); @@ -7267,10 +7463,11 @@ THE SOFTWARE. /** * Returns the minimum of two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function min(out, a, b) { out[0] = Math.min(a[0], b[0]); @@ -7281,10 +7478,11 @@ THE SOFTWARE. /** * Returns the maximum of two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function max(out, a, b) { out[0] = Math.max(a[0], b[0]); @@ -7295,9 +7493,10 @@ THE SOFTWARE. /** * symmetric round the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to round - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function round(out, a) { out[0] = round$3(a[0]); @@ -7308,10 +7507,11 @@ THE SOFTWARE. /** * Scales a vec2 by a scalar number * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function scale(out, a, b) { out[0] = a[0] * b; @@ -7322,11 +7522,12 @@ THE SOFTWARE. /** * Adds two vec2's after scaling the second operand by a scalar value * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -7387,9 +7588,10 @@ THE SOFTWARE. /** * Negates the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to negate - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function negate(out, a) { out[0] = -a[0]; @@ -7400,9 +7602,10 @@ THE SOFTWARE. /** * Returns the inverse of the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to invert - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function inverse(out, a) { out[0] = 1.0 / a[0]; @@ -7413,9 +7616,10 @@ THE SOFTWARE. /** * Normalize a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to normalize - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function normalize(out, a) { var x = a[0], @@ -7445,10 +7649,11 @@ THE SOFTWARE. * Computes the cross product of two vec2's * Note that the cross product must by definition produce a 3D vector * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec2} out */ function cross(out, a, b) { var z = a[0] * b[1] - a[1] * b[0]; @@ -7460,11 +7665,12 @@ THE SOFTWARE. /** * Performs a linear interpolation between two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function lerp(out, a, b, t) { var ax = a[0], @@ -7477,9 +7683,10 @@ THE SOFTWARE. /** * Generates a random vector with the given scale * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function random(out, scale) { scale = scale === undefined ? 1.0 : scale; @@ -7492,10 +7699,11 @@ THE SOFTWARE. /** * Transforms the vec2 with a mat2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat2} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function transformMat2(out, a, m) { var x = a[0], @@ -7508,10 +7716,11 @@ THE SOFTWARE. /** * Transforms the vec2 with a mat2d * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat2d} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function transformMat2d(out, a, m) { var x = a[0], @@ -7525,10 +7734,11 @@ THE SOFTWARE. * Transforms the vec2 with a mat3 * 3rd vector component is implicitly '1' * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat3} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function transformMat3(out, a, m) { var x = a[0], @@ -7543,10 +7753,11 @@ THE SOFTWARE. * 3rd vector component is implicitly '0' * 4th vector component is implicitly '1' * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function transformMat4(out, a, m) { var x = a[0]; @@ -7558,11 +7769,12 @@ THE SOFTWARE. /** * Rotate a 2D vector - * @param {vec2} out The receiving vec2 + * @template {vec2} T + * @param {T} out The receiving vec2 * @param {ReadonlyVec2} a The vec2 point to rotate * @param {ReadonlyVec2} b The origin of the rotation * @param {Number} rad The angle of rotation in radians - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ function rotate(out, a, b, rad) { //Translate point to the origin @@ -7609,8 +7821,9 @@ THE SOFTWARE. /** * Set the components of a vec2 to zero * - * @param {vec2} out the receiving vector - * @returns {vec2} out + * @template {vec2} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec2} out */ function zero(out) { out[0] = 0.0; diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 00000000..3e53ea44 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,3597 @@ +declare module "gl-matrix" { + +/** + * Users can augment this interface to override the default array type + * + * @example + * export module "gl-matrix" { + * interface Overrides { + * ArrayType: Float64Array + * } + * } + */ +interface Overrides { } + +/** + * Users can override `ArrayType` by augmenting `gl-matrix` module + * + * @example + * export module "gl-matrix" { + * interface Overrides { + * ArrayType: Float64Array + * } + * } + */ +export type ArrayType = Overrides extends { ArrayType: infer T } ? T : Float32Array + +interface IndexedCollection extends Iterable { + readonly length: number; + [index: number]: number; +} + +export namespace Tuple { + // prettier-ignore + export type Mat2 = [ + number, number, + number, number + ] + // prettier-ignore + export type Mat2d = [ + number, number, + number, number, + number, number + ] + // prettier-ignore + export type Mat3 = [ + number, number, number, + number, number, number, + number, number, number + ] + // prettier-ignore + export type Mat4 = [ + number, number, number, number, + number, number, number, number, + number, number, number, number, + number, number, number, number + ] + export type Quat = [number, number, number, number] + // prettier-ignore + export type Quat2 = [ + number, number, number, number, + number, number, number, number + ] + export type Vec2 = [number, number] + export type Vec3 = [number, number, number] + export type Vec4 = [number, number, number, number] + + // prettier-ignore + export type ReadonlyMat2 = readonly [ + number, number, + number, number + ] + // prettier-ignore + export type ReadonlyMat2d = readonly [ + number, number, + number, number, + number, number + ] + // prettier-ignore + export type ReadonlyMat3 = readonly [ + number, number, number, + number, number, number, + number, number, number + ] + // prettier-ignore + export type ReadonlyMat4 = readonly [ + number, number, number, number, + number, number, number, number, + number, number, number, number, + number, number, number, number + ] + export type ReadonlyQuat = readonly [number, number, number, number] + // prettier-ignore + export type ReadonlyQuat2 = readonly [ + number, number, number, number, + number, number, number, number + ] + export type ReadonlyVec2 = readonly [number, number] + export type ReadonlyVec3 = readonly [number, number, number]; + export type ReadonlyVec4 = readonly [number, number, number, number]; +} + +/** + * Return type utilities. Narrows Array to Tuple types, preserves other types. + * + * @example + * const result = mat4.copy([], mat4.create()); // Tuple.Mat4 + * const result2 = mat4.copy(new Float32Array(16), mat4.create()); // Float32Array + */ +export namespace ReturnType { + export type Mat2 = T extends Array ? Tuple.Mat2 : T + export type Mat2d = T extends Array ? Tuple.Mat2d : T + export type Mat3 = T extends Array ? Tuple.Mat3 : T + export type Mat4 = T extends Array ? Tuple.Mat4 : T + export type Quat = T extends Array ? Tuple.Quat : T + export type Quat2 = T extends Array ? Tuple.Quat2 : T + export type Vec2 = T extends Array ? Tuple.Vec2 : T + export type Vec3 = T extends Array ? Tuple.Vec3 : T + export type Vec4 = T extends Array ? Tuple.Vec4 : T +} + +export type mat2 = IndexedCollection | Tuple.Mat2; +export type mat2d = IndexedCollection | Tuple.Mat2d; +export type mat3 = IndexedCollection | Tuple.Mat3; +export type mat4 = IndexedCollection | Tuple.Mat4; +export type quat = IndexedCollection | Tuple.Quat; +export type quat2 = IndexedCollection | Tuple.Quat2; +export type vec2 = IndexedCollection | Tuple.Vec2; +export type vec3 = IndexedCollection | Tuple.Vec3; +export type vec4 = IndexedCollection | Tuple.Vec4; + +export type ReadonlyMat2 = IndexedCollection | Tuple.ReadonlyMat2; +export type ReadonlyMat2d = IndexedCollection | Tuple.ReadonlyMat2d; +export type ReadonlyMat3 = IndexedCollection | Tuple.ReadonlyMat3; +export type ReadonlyMat4 = IndexedCollection | Tuple.ReadonlyMat4; +export type ReadonlyQuat = IndexedCollection | Tuple.ReadonlyQuat; +export type ReadonlyQuat2 = IndexedCollection | Tuple.ReadonlyQuat2; +export type ReadonlyVec2 = IndexedCollection | Tuple.ReadonlyVec2; +export type ReadonlyVec3 = IndexedCollection | Tuple.ReadonlyVec3; +export type ReadonlyVec4 = IndexedCollection | Tuple.ReadonlyVec4; + +export namespace glMatrix { + /** + * Symmetric round + * see https://www.npmjs.com/package/round-half-up-symmetric#user-content-detailed-background + * + * @param {Number} a value to round + */ + export function round(a: number): number; + /** + * Sets the type of array used when creating new vectors and matrices + * + * @param {Float32ArrayConstructor | ArrayConstructor} type Array type, such as Float32Array or Array + */ + export function setMatrixArrayType(type: Float32ArrayConstructor | ArrayConstructor): void; + /** + * Convert Degree To Radian + * + * @param {Number} a Angle in Degrees + */ + export function toRadian(a: number): number; + /** + * Convert Radian To Degree + * + * @param {Number} a Angle in Radians + */ + export function toDegree(a: number): number; + /** + * Tests whether or not the arguments have approximately the same value, within an absolute + * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less + * than or equal to 1.0, and a relative tolerance is used for larger values) + * + * @param {Number} a The first number to test. + * @param {Number} b The second number to test. + * @param {Number} tolerance Absolute or relative tolerance (default glMatrix.EPSILON) + * @returns {Boolean} True if the numbers are approximately equal, false otherwise. + */ + export function equals(a: number, b: number, tolerance?: number): boolean; + /** + * Common utilities + * @module glMatrix + */ + export const EPSILON: 0.000001; + export let ARRAY_TYPE: ArrayConstructor | Float32ArrayConstructor; + export let RANDOM: () => number; + export let ANGLE_ORDER: string; +} +export namespace mat2 { + /** + * 2x2 Matrix + * @module mat2 + */ + /** + * Creates a new identity mat2 + * + * @returns {ArrayType} a new 2x2 matrix + */ + export function create(): ArrayType; + /** + * Creates a new mat2 initialized with values from an existing matrix + * + * @param {ReadonlyMat2} a matrix to clone + * @returns {ArrayType} a new 2x2 matrix + */ + export function clone(a: ReadonlyMat2): ArrayType; + /** + * Copy the values from one mat2 to another + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the source matrix + * @returns {ReturnType.Mat2} out + */ + export function copy(out: T, a: ReadonlyMat2): ReturnType.Mat2; + /** + * Set a mat2 to the identity matrix + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat2} out + */ + export function identity(out: T): ReturnType.Mat2; + /** + * Create a new mat2 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m10 Component in column 1, row 0 position (index 2) + * @param {Number} m11 Component in column 1, row 1 position (index 3) + * @returns {ArrayType} out A new 2x2 matrix + */ + export function fromValues(m00: number, m01: number, m10: number, m11: number): ArrayType; + /** + * Set the components of a mat2 to the given values + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m10 Component in column 1, row 0 position (index 2) + * @param {Number} m11 Component in column 1, row 1 position (index 3) + * @returns {ReturnType.Mat2} out + */ + export function set(out: T, m00: number, m01: number, m10: number, m11: number): ReturnType.Mat2; + /** + * Transpose the values of a mat2 + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the source matrix + * @returns {ReturnType.Mat2} out + */ + export function transpose(out: T, a: ReadonlyMat2): ReturnType.Mat2; + /** + * Inverts a mat2 + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the source matrix + * @returns {ReturnType.Mat2 | null} out, or null if source matrix is not invertible + */ + export function invert(out: T, a: ReadonlyMat2): ReturnType.Mat2 | null; + /** + * Calculates the adjugate of a mat2 + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the source matrix + * @returns {ReturnType.Mat2} out + */ + export function adjoint(out: T, a: ReadonlyMat2): ReturnType.Mat2; + /** + * Calculates the determinant of a mat2 + * + * @param {ReadonlyMat2} a the source matrix + * @returns {Number} determinant of a + */ + export function determinant(a: ReadonlyMat2): number; + /** + * Multiplies two mat2's + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @returns {ReturnType.Mat2} out + */ + export function multiply(out: T, a: ReadonlyMat2, b: ReadonlyMat2): ReturnType.Mat2; + /** + * Rotates a mat2 by the given angle + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat2} out + */ + export function rotate(out: T, a: ReadonlyMat2, rad: number): ReturnType.Mat2; + /** + * Scales the mat2 by the dimensions in the given vec2 + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the matrix to rotate + * @param {ReadonlyVec2} v the vec2 to scale the matrix by + * @returns {ReturnType.Mat2} out + **/ + export function scale(out: T, a: ReadonlyMat2, v: ReadonlyVec2): ReturnType.Mat2; + /** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.rotate(dest, dest, rad); + * + * @template {mat2} T + * @param {T} out mat2 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat2} out + */ + export function fromRotation(out: T, rad: number): ReturnType.Mat2; + /** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.scale(dest, dest, vec); + * + * @template {mat2} T + * @param {T} out mat2 receiving operation result + * @param {ReadonlyVec2} v Scaling vector + * @returns {ReturnType.Mat2} out + */ + export function fromScaling(out: T, v: ReadonlyVec2): ReturnType.Mat2; + /** + * Returns a string representation of a mat2 + * + * @param {ReadonlyMat2} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ + export function str(a: ReadonlyMat2): string; + /** + * Returns Frobenius norm of a mat2 + * + * @param {ReadonlyMat2} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ + export function frob(a: ReadonlyMat2): number; + /** + * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix + * @param {ReadonlyMat2} L the lower triangular matrix + * @param {ReadonlyMat2} D the diagonal matrix + * @param {ReadonlyMat2} U the upper triangular matrix + * @param {ReadonlyMat2} a the input matrix to factorize + */ + export function LDU(L: ReadonlyMat2, D: ReadonlyMat2, U: ReadonlyMat2, a: ReadonlyMat2): ReadonlyMat2[]; + /** + * Adds two mat2's + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @returns {ReturnType.Mat2} out + */ + export function add(out: T, a: ReadonlyMat2, b: ReadonlyMat2): ReturnType.Mat2; + /** + * Subtracts matrix b from matrix a + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @returns {ReturnType.Mat2} out + */ + export function subtract(out: T, a: ReadonlyMat2, b: ReadonlyMat2): ReturnType.Mat2; + /** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyMat2} a The first matrix. + * @param {ReadonlyMat2} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + export function exactEquals(a: ReadonlyMat2, b: ReadonlyMat2): boolean; + /** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {ReadonlyMat2} a The first matrix. + * @param {ReadonlyMat2} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + export function equals(a: ReadonlyMat2, b: ReadonlyMat2): boolean; + /** + * Multiply each element of the matrix by a scalar. + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {ReturnType.Mat2} out + */ + export function multiplyScalar(out: T, a: ReadonlyMat2, b: number): ReturnType.Mat2; + /** + * Adds two mat2's after multiplying each element of the second operand by a scalar value. + * + * @template {mat2} T + * @param {T} out the receiving vector + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {ReturnType.Mat2} out + */ + export function multiplyScalarAndAdd(out: T, a: ReadonlyMat2, b: ReadonlyMat2, scale: number): ReturnType.Mat2; + /** + * Multiplies two mat2's + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @returns {ReturnType.Mat2} out + */ + export function mul(out: T, a: ReadonlyMat2, b: ReadonlyMat2): ReturnType.Mat2; + /** + * Subtracts matrix b from matrix a + * + * @template {mat2} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @returns {ReturnType.Mat2} out + */ + export function sub(out: T, a: ReadonlyMat2, b: ReadonlyMat2): ReturnType.Mat2; +} +export namespace mat2d { + /** + * 2x3 Matrix + * @module mat2d + * @description + * A mat2d contains six elements defined as: + *
+     * [a, b,
+     *  c, d,
+     *  tx, ty]
+     * 
+ * This is a short form for the 3x3 matrix: + *
+     * [a, b, 0,
+     *  c, d, 0,
+     *  tx, ty, 1]
+     * 
+ * The last column is ignored so the array is shorter and operations are faster. + */ + /** + * Creates a new identity mat2d + * + * @returns {ArrayType} a new 2x3 matrix + */ + export function create(): ArrayType; + /** + * Creates a new mat2d initialized with values from an existing matrix + * + * @param {ReadonlyMat2d} a matrix to clone + * @returns {ArrayType} a new 2x3 matrix + */ + export function clone(a: ReadonlyMat2d): ArrayType; + /** + * Copy the values from one mat2d to another + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the source matrix + * @returns {ReturnType.Mat2d} out + */ + export function copy(out: T, a: ReadonlyMat2d): ReturnType.Mat2d; + /** + * Set a mat2d to the identity matrix + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat2d} out + */ + export function identity(out: T): ReturnType.Mat2d; + /** + * Create a new mat2d with the given values + * + * @param {Number} a Component A (index 0) + * @param {Number} b Component B (index 1) + * @param {Number} c Component C (index 2) + * @param {Number} d Component D (index 3) + * @param {Number} tx Component TX (index 4) + * @param {Number} ty Component TY (index 5) + * @returns {ArrayType} A new mat2d + */ + export function fromValues(a: number, b: number, c: number, d: number, tx: number, ty: number): ArrayType; + /** + * Set the components of a mat2d to the given values + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {Number} a Component A (index 0) + * @param {Number} b Component B (index 1) + * @param {Number} c Component C (index 2) + * @param {Number} d Component D (index 3) + * @param {Number} tx Component TX (index 4) + * @param {Number} ty Component TY (index 5) + * @returns {ReturnType.Mat2d} out + */ + export function set(out: T, a: number, b: number, c: number, d: number, tx: number, ty: number): ReturnType.Mat2d; + /** + * Inverts a mat2d + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the source matrix + * @returns {ReturnType.Mat2d | null} out, or null if source matrix is not invertible + */ + export function invert(out: T, a: ReadonlyMat2d): ReturnType.Mat2d | null; + /** + * Calculates the determinant of a mat2d + * + * @param {ReadonlyMat2d} a the source matrix + * @returns {Number} determinant of a + */ + export function determinant(a: ReadonlyMat2d): number; + /** + * Multiplies two mat2d's + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @returns {ReturnType.Mat2d} out + */ + export function multiply(out: T, a: ReadonlyMat2d, b: ReadonlyMat2d): ReturnType.Mat2d; + /** + * Rotates a mat2d by the given angle + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat2d} out + */ + export function rotate(out: T, a: ReadonlyMat2d, rad: number): ReturnType.Mat2d; + /** + * Scales the mat2d by the dimensions in the given vec2 + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to translate + * @param {ReadonlyVec2} v the vec2 to scale the matrix by + * @returns {ReturnType.Mat2d} out + **/ + export function scale(out: T, a: ReadonlyMat2d, v: ReadonlyVec2): ReturnType.Mat2d; + /** + * Translates the mat2d by the dimensions in the given vec2 + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to translate + * @param {ReadonlyVec2} v the vec2 to translate the matrix by + * @returns {ReturnType.Mat2d} out + **/ + export function translate(out: T, a: ReadonlyMat2d, v: ReadonlyVec2): ReturnType.Mat2d; + /** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.rotate(dest, dest, rad); + * + * @template {mat2d} T + * @param {T} out mat2d receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat2d} out + */ + export function fromRotation(out: T, rad: number): ReturnType.Mat2d; + /** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.scale(dest, dest, vec); + * + * @template {mat2d} T + * @param {T} out mat2d receiving operation result + * @param {ReadonlyVec2} v Scaling vector + * @returns {ReturnType.Mat2d} out + */ + export function fromScaling(out: T, v: ReadonlyVec2): ReturnType.Mat2d; + /** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.translate(dest, dest, vec); + * + * @template {mat2d} T + * @param {T} out mat2d receiving operation result + * @param {ReadonlyVec2} v Translation vector + * @returns {ReturnType.Mat2d} out + */ + export function fromTranslation(out: T, v: ReadonlyVec2): ReturnType.Mat2d; + /** + * Returns a string representation of a mat2d + * + * @param {ReadonlyMat2d} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ + export function str(a: ReadonlyMat2d): string; + /** + * Returns Frobenius norm of a mat2d + * + * @param {ReadonlyMat2d} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ + export function frob(a: ReadonlyMat2d): number; + /** + * Adds two mat2d's + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @returns {ReturnType.Mat2d} out + */ + export function add(out: T, a: ReadonlyMat2d, b: ReadonlyMat2d): ReturnType.Mat2d; + /** + * Subtracts matrix b from matrix a + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @returns {ReturnType.Mat2d} out + */ + export function subtract(out: T, a: ReadonlyMat2d, b: ReadonlyMat2d): ReturnType.Mat2d; + /** + * Multiply each element of the matrix by a scalar. + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {ReturnType.Mat2d} out + */ + export function multiplyScalar(out: T, a: ReadonlyMat2d, b: number): ReturnType.Mat2d; + /** + * Adds two mat2d's after multiplying each element of the second operand by a scalar value. + * + * @template {mat2d} T + * @param {T} out the receiving vector + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {ReturnType.Mat2d} out + */ + export function multiplyScalarAndAdd(out: T, a: ReadonlyMat2d, b: ReadonlyMat2d, scale: number): ReturnType.Mat2d; + /** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyMat2d} a The first matrix. + * @param {ReadonlyMat2d} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + export function exactEquals(a: ReadonlyMat2d, b: ReadonlyMat2d): boolean; + /** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {ReadonlyMat2d} a The first matrix. + * @param {ReadonlyMat2d} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + export function equals(a: ReadonlyMat2d, b: ReadonlyMat2d): boolean; + /** + * Multiplies two mat2d's + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @returns {ReturnType.Mat2d} out + */ + export function mul(out: T, a: ReadonlyMat2d, b: ReadonlyMat2d): ReturnType.Mat2d; + /** + * Subtracts matrix b from matrix a + * + * @template {mat2d} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @returns {ReturnType.Mat2d} out + */ + export function sub(out: T, a: ReadonlyMat2d, b: ReadonlyMat2d): ReturnType.Mat2d; +} +export namespace mat3 { + /** + * 3x3 Matrix + * @module mat3 + */ + /** + * Creates a new identity mat3 + * + * @returns {ArrayType} a new 3x3 matrix + */ + export function create(): ArrayType; + /** + * Copies the upper-left 3x3 values into the given mat3. + * + * @template {mat3} T + * @param {T} out the receiving 3x3 matrix + * @param {ReadonlyMat4} a the source 4x4 matrix + * @returns {ReturnType.Mat3} out + */ + export function fromMat4(out: T, a: ReadonlyMat4): ReturnType.Mat3; + /** + * Creates a new mat3 initialized with values from an existing matrix + * + * @param {ReadonlyMat3} a matrix to clone + * @returns {ArrayType} a new 3x3 matrix + */ + export function clone(a: ReadonlyMat3): ArrayType; + /** + * Copy the values from one mat3 to another + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {ReturnType.Mat3} out + */ + export function copy(out: T, a: ReadonlyMat3): ReturnType.Mat3; + /** + * Create a new mat3 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {ArrayType} A new mat3 + */ + export function fromValues(m00: number, m01: number, m02: number, m10: number, m11: number, m12: number, m20: number, m21: number, m22: number): ArrayType; + /** + * Set the components of a mat3 to the given values + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {ReturnType.Mat3} out + */ + export function set(out: T, m00: number, m01: number, m02: number, m10: number, m11: number, m12: number, m20: number, m21: number, m22: number): ReturnType.Mat3; + /** + * Set a mat3 to the identity matrix + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat3} out + */ + export function identity(out: T): ReturnType.Mat3; + /** + * Transpose the values of a mat3 + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {ReturnType.Mat3} out + */ + export function transpose(out: T, a: ReadonlyMat3): ReturnType.Mat3; + /** + * Inverts a mat3 + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {ReturnType.Mat3 | null} out, or null if source matrix is not invertible + */ + export function invert(out: T, a: ReadonlyMat3): ReturnType.Mat3 | null; + /** + * Calculates the adjugate of a mat3 + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {ReturnType.Mat3} out + */ + export function adjoint(out: T, a: ReadonlyMat3): ReturnType.Mat3; + /** + * Calculates the determinant of a mat3 + * + * @param {ReadonlyMat3} a the source matrix + * @returns {Number} determinant of a + */ + export function determinant(a: ReadonlyMat3): number; + /** + * Multiplies two mat3's + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {ReturnType.Mat3} out + */ + export function multiply(out: T, a: ReadonlyMat3, b: ReadonlyMat3): ReturnType.Mat3; + /** + * Translate a mat3 by the given vector + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to translate + * @param {ReadonlyVec2} v vector to translate by + * @returns {ReturnType.Mat3} out + */ + export function translate(out: T, a: ReadonlyMat3, v: ReadonlyVec2): ReturnType.Mat3; + /** + * Rotates a mat3 by the given angle + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat3} out + */ + export function rotate(out: T, a: ReadonlyMat3, rad: number): ReturnType.Mat3; + /** + * Scales the mat3 by the dimensions in the given vec2 + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to scale + * @param {ReadonlyVec2} v the vec2 to scale the matrix by + * @returns {ReturnType.Mat3} out + **/ + export function scale(out: T, a: ReadonlyMat3, v: ReadonlyVec2): ReturnType.Mat3; + /** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.translate(dest, dest, vec); + * + * @template {mat3} T + * @param {T} out mat3 receiving operation result + * @param {ReadonlyVec2} v Translation vector + * @returns {ReturnType.Mat3} out + */ + export function fromTranslation(out: T, v: ReadonlyVec2): ReturnType.Mat3; + /** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.rotate(dest, dest, rad); + * + * @template {mat3} T + * @param {T} out mat3 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat3} out + */ + export function fromRotation(out: T, rad: number): ReturnType.Mat3; + /** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.scale(dest, dest, vec); + * + * @template {mat3} T + * @param {T} out mat3 receiving operation result + * @param {ReadonlyVec2} v Scaling vector + * @returns {ReturnType.Mat3} out + */ + export function fromScaling(out: T, v: ReadonlyVec2): ReturnType.Mat3; + /** + * Copies the values from a mat2d into a mat3 + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to copy + * @returns {ReturnType.Mat3} out + **/ + export function fromMat2d(out: T, a: ReadonlyMat2d): ReturnType.Mat3; + /** + * Calculates a 3x3 matrix from the given quaternion + * + * @template {mat3} T + * @param {T} out mat3 receiving operation result + * @param {ReadonlyQuat} q Quaternion to create matrix from + * + * @returns {ReturnType.Mat3} out + */ + export function fromQuat(out: T, q: ReadonlyQuat): ReturnType.Mat3; + /** + * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix + * + * @template {mat3} T + * @param {T} out mat3 receiving operation result + * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from + * + * @returns {ReturnType.Mat3} out + */ + export function normalFromMat4(out: T, a: ReadonlyMat4): ReturnType.Mat3; + /** + * Generates a 2D projection matrix with the given bounds + * + * @template {mat3} T + * @param {T} out mat3 frustum matrix will be written into + * @param {number} width Width of your gl context + * @param {number} height Height of gl context + * @returns {ReturnType.Mat3} out + */ + export function projection(out: T, width: number, height: number): ReturnType.Mat3; + /** + * Returns a string representation of a mat3 + * + * @param {ReadonlyMat3} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ + export function str(a: ReadonlyMat3): string; + /** + * Returns Frobenius norm of a mat3 + * + * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ + export function frob(a: ReadonlyMat3): number; + /** + * Adds two mat3's + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {ReturnType.Mat3} out + */ + export function add(out: T, a: ReadonlyMat3, b: ReadonlyMat3): ReturnType.Mat3; + /** + * Subtracts matrix b from matrix a + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {ReturnType.Mat3} out + */ + export function subtract(out: T, a: ReadonlyMat3, b: ReadonlyMat3): ReturnType.Mat3; + /** + * Multiply each element of the matrix by a scalar. + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {ReturnType.Mat3} out + */ + export function multiplyScalar(out: T, a: ReadonlyMat3, b: number): ReturnType.Mat3; + /** + * Adds two mat3's after multiplying each element of the second operand by a scalar value. + * + * @template {mat3} T + * @param {T} out the receiving vector + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {ReturnType.Mat3} out + */ + export function multiplyScalarAndAdd(out: T, a: ReadonlyMat3, b: ReadonlyMat3, scale: number): ReturnType.Mat3; + /** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyMat3} a The first matrix. + * @param {ReadonlyMat3} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + export function exactEquals(a: ReadonlyMat3, b: ReadonlyMat3): boolean; + /** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {ReadonlyMat3} a The first matrix. + * @param {ReadonlyMat3} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + export function equals(a: ReadonlyMat3, b: ReadonlyMat3): boolean; + /** + * Multiplies two mat3's + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {ReturnType.Mat3} out + */ + export function mul(out: T, a: ReadonlyMat3, b: ReadonlyMat3): ReturnType.Mat3; + /** + * Subtracts matrix b from matrix a + * + * @template {mat3} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {ReturnType.Mat3} out + */ + export function sub(out: T, a: ReadonlyMat3, b: ReadonlyMat3): ReturnType.Mat3; +} +export namespace mat4 { + /** + * 4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied. + * @module mat4 + */ + /** + * Creates a new identity mat4 + * + * @returns {ArrayType} a new 4x4 matrix + */ + export function create(): ArrayType; + /** + * Creates a new mat4 initialized with values from an existing matrix + * + * @param {ReadonlyMat4} a matrix to clone + * @returns {ArrayType} a new 4x4 matrix + */ + export function clone(a: ReadonlyMat4): ArrayType; + /** + * Copy the values from one mat4 to another + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {ReturnType.Mat4} out + */ + export function copy(out: T, a: ReadonlyMat4): ReturnType.Mat4; + /** + * Create a new mat4 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {ArrayType} A new mat4 + */ + export function fromValues(m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): ArrayType; + /** + * Set the components of a mat4 to the given values + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {ReturnType.Mat4} out + */ + export function set(out: T, m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): ReturnType.Mat4; + /** + * Set a mat4 to the identity matrix + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat4} out + */ + export function identity(out: T): ReturnType.Mat4; + /** + * Transpose the values of a mat4 + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {ReturnType.Mat4} out + */ + export function transpose(out: T, a: ReadonlyMat4): ReturnType.Mat4; + /** + * Inverts a mat4 + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {ReturnType.Mat4 | null} out, or null if source matrix is not invertible + */ + export function invert(out: T, a: ReadonlyMat4): ReturnType.Mat4 | null; + /** + * Calculates the adjugate of a mat4 + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {ReturnType.Mat4} out + */ + export function adjoint(out: T, a: ReadonlyMat4): ReturnType.Mat4; + /** + * Calculates the determinant of a mat4 + * + * @param {ReadonlyMat4} a the source matrix + * @returns {Number} determinant of a + */ + export function determinant(a: ReadonlyMat4): number; + /** + * Multiplies two mat4s + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {ReturnType.Mat4} out + */ + export function multiply(out: T, a: ReadonlyMat4, b: ReadonlyMat4): ReturnType.Mat4; + /** + * Translate a mat4 by the given vector + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to translate + * @param {ReadonlyVec3} v vector to translate by + * @returns {ReturnType.Mat4} out + */ + export function translate(out: T, a: ReadonlyMat4, v: ReadonlyVec3): ReturnType.Mat4; + /** + * Scales the mat4 by the dimensions in the given vec3 not using vectorization + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to scale + * @param {ReadonlyVec3} v the vec3 to scale the matrix by + * @returns {ReturnType.Mat4} out + **/ + export function scale(out: T, a: ReadonlyMat4, v: ReadonlyVec3): ReturnType.Mat4; + /** + * Rotates a mat4 by the given angle around the given axis + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @param {ReadonlyVec3} axis the axis to rotate around + * @returns {ReturnType.Mat4} out + */ + export function rotate(out: T, a: ReadonlyMat4, rad: number, axis: ReadonlyVec3): ReturnType.Mat4; + /** + * Rotates a matrix by the given angle around the X axis + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat4} out + */ + export function rotateX(out: T, a: ReadonlyMat4, rad: number): ReturnType.Mat4; + /** + * Rotates a matrix by the given angle around the Y axis + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat4} out + */ + export function rotateY(out: T, a: ReadonlyMat4, rad: number): ReturnType.Mat4; + /** + * Rotates a matrix by the given angle around the Z axis + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat4} out + */ + export function rotateZ(out: T, a: ReadonlyMat4, rad: number): ReturnType.Mat4; + /** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, dest, vec); + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {ReadonlyVec3} v Translation vector + * @returns {ReturnType.Mat4} out + */ + export function fromTranslation(out: T, v: ReadonlyVec3): ReturnType.Mat4; + /** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.scale(dest, dest, vec); + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {ReadonlyVec3} v Scaling vector + * @returns {ReturnType.Mat4} out + */ + export function fromScaling(out: T, v: ReadonlyVec3): ReturnType.Mat4; + /** + * Creates a matrix from a given angle around a given axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotate(dest, dest, rad, axis); + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @param {ReadonlyVec3} axis the axis to rotate around + * @returns {ReturnType.Mat4} out + */ + export function fromRotation(out: T, rad: number, axis: ReadonlyVec3): ReturnType.Mat4; + /** + * Creates a matrix from the given angle around the X axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateX(dest, dest, rad); + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat4} out + */ + export function fromXRotation(out: T, rad: number): ReturnType.Mat4; + /** + * Creates a matrix from the given angle around the Y axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateY(dest, dest, rad); + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat4} out + */ + export function fromYRotation(out: T, rad: number): ReturnType.Mat4; + /** + * Creates a matrix from the given angle around the Z axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateZ(dest, dest, rad); + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {ReturnType.Mat4} out + */ + export function fromZRotation(out: T, rad: number): ReturnType.Mat4; + /** + * Creates a matrix from a quaternion rotation and vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, dest, vec); + * let quatMat = mat4.create(); + * mat4.fromQuat(quatMat, quat); + * mat4.multiply(dest, dest, quatMat); + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {quat} q Rotation quaternion + * @param {ReadonlyVec3} v Translation vector + * @returns {ReturnType.Mat4} out + */ + export function fromRotationTranslation(out: T, q: quat, v: ReadonlyVec3): ReturnType.Mat4; + /** + * Creates a new mat4 from a dual quat. + * + * @param {mat4} out Matrix + * @param {ReadonlyQuat2} a Dual Quaternion + * @returns {ArrayType} mat4 receiving operation result + */ + export function fromQuat2(out: mat4, a: ReadonlyQuat2): ArrayType; + /** + * Returns the translation vector component of a transformation + * matrix. If a matrix is built with fromRotationTranslation, + * the returned vector will be the same as the translation vector + * originally supplied. + * @param {vec3} out Vector to receive translation component + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @return {vec3} out + */ + export function getTranslation(out: vec3, mat: ReadonlyMat4): vec3; + /** + * Returns the scaling factor component of a transformation + * matrix. If a matrix is built with fromRotationTranslationScale + * with a normalized Quaternion parameter, the returned vector will be + * the same as the scaling vector + * originally supplied. + * @param {vec3} out Vector to receive scaling factor component + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @return {vec3} out + */ + export function getScaling(out: vec3, mat: ReadonlyMat4): vec3; + /** + * Returns a quaternion representing the rotational component + * of a transformation matrix. If a matrix is built with + * fromRotationTranslation, the returned quaternion will be the + * same as the quaternion originally supplied. + * @param {quat} out Quaternion to receive the rotation component + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @return {quat} out + */ + export function getRotation(out: quat, mat: ReadonlyMat4): quat; + /** + * Decomposes a transformation matrix into its rotation, translation + * and scale components. Returns only the rotation component + * + * @param {quat} out_r Quaternion to receive the rotation component + * @param {vec3} out_t Vector to receive the translation vector + * @param {vec3} out_s Vector to receive the scaling factor + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @returns {ArrayType} out_r + */ + export function decompose(out_r: quat, out_t: vec3, out_s: vec3, mat: ReadonlyMat4): ArrayType; + /** + * Creates a matrix from a quaternion rotation, vector translation and vector scale + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, dest, vec); + * let quatMat = mat4.create(); + * mat4.fromQuat(quatMat, quat); + * mat4.multiply(dest, dest, quatMat); + * mat4.scale(dest, dest, scale) + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {quat} q Rotation quaternion + * @param {ReadonlyVec3} v Translation vector + * @param {ReadonlyVec3} s Scaling vector + * @returns {ReturnType.Mat4} out + */ + export function fromRotationTranslationScale(out: T, q: quat, v: ReadonlyVec3, s: ReadonlyVec3): ReturnType.Mat4; + /** + * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, dest, vec); + * mat4.translate(dest, dest, origin); + * let quatMat = mat4.create(); + * mat4.fromQuat(quatMat, quat); + * mat4.multiply(dest, dest, quatMat); + * mat4.scale(dest, dest, scale) + * mat4.translate(dest, dest, negativeOrigin); + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {quat} q Rotation quaternion + * @param {ReadonlyVec3} v Translation vector + * @param {ReadonlyVec3} s Scaling vector + * @param {ReadonlyVec3} o The origin vector around which to scale and rotate + * @returns {ReturnType.Mat4} out + */ + export function fromRotationTranslationScaleOrigin(out: T, q: quat, v: ReadonlyVec3, s: ReadonlyVec3, o: ReadonlyVec3): ReturnType.Mat4; + /** + * Calculates a 4x4 matrix from the given quaternion + * + * @template {mat4} T + * @param {T} out mat4 receiving operation result + * @param {ReadonlyQuat} q Quaternion to create matrix from + * + * @returns {ReturnType.Mat4} out + */ + export function fromQuat(out: T, q: ReadonlyQuat): ReturnType.Mat4; + /** + * Generates a frustum matrix with the given bounds + * + * @template {mat4} T + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Number} left Left bound of the frustum + * @param {Number} right Right bound of the frustum + * @param {Number} bottom Bottom bound of the frustum + * @param {Number} top Top bound of the frustum + * @param {Number} near Near bound of the frustum + * @param {Number} far Far bound of the frustum + * @returns {ReturnType.Mat4} out + */ + export function frustum(out: mat4, left: number, right: number, bottom: number, top: number, near: number, far: number): ReturnType.Mat4; + /** + * Generates a perspective projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], + * which matches WebGL/OpenGL's clip volume. + * Passing null/undefined/no value for far will generate infinite projection matrix. + * + * @template {mat4} T + * @param {T} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum, can be null or Infinity + * @returns {ReturnType.Mat4} out + */ + export function perspectiveNO(out: T, fovy: number, aspect: number, near: number, far: number): ReturnType.Mat4; + /** + * Generates a perspective projection matrix suitable for WebGPU with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], + * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. + * Passing null/undefined/no value for far will generate infinite projection matrix. + * + * @template {mat4} T + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum, can be null or Infinity + * @returns {ReturnType.Mat4} out + */ + export function perspectiveZO(out: mat4, fovy: number, aspect: number, near: number, far: number): ReturnType.Mat4; + /** + * Generates a perspective projection matrix with the given field of view. + * This is primarily useful for generating projection matrices to be used + * with the still experiemental WebVR API. + * + * @template {mat4} T + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {ReturnType.Mat4} out + */ + export function perspectiveFromFieldOfView(out: mat4, fov: any, near: number, far: number): ReturnType.Mat4; + /** + * Generates a orthogonal projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], + * which matches WebGL/OpenGL's clip volume. + * + * @template {mat4} T + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} left Left bound of the frustum + * @param {number} right Right bound of the frustum + * @param {number} bottom Bottom bound of the frustum + * @param {number} top Top bound of the frustum + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {ReturnType.Mat4} out + */ + export function orthoNO(out: mat4, left: number, right: number, bottom: number, top: number, near: number, far: number): ReturnType.Mat4; + /** + * Generates a orthogonal projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], + * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. + * + * @template {mat4} T + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} left Left bound of the frustum + * @param {number} right Right bound of the frustum + * @param {number} bottom Bottom bound of the frustum + * @param {number} top Top bound of the frustum + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {ReturnType.Mat4} out + */ + export function orthoZO(out: mat4, left: number, right: number, bottom: number, top: number, near: number, far: number): ReturnType.Mat4; + /** + * Generates a look-at matrix with the given eye position, focal point, and up axis. + * If you want a matrix that actually makes an object look at another object, you should use targetTo instead. + * + * @template {mat4} T + * @param {mat4} out mat4 frustum matrix will be written into + * @param {ReadonlyVec3} eye Position of the viewer + * @param {ReadonlyVec3} center Point the viewer is looking at + * @param {ReadonlyVec3} up vec3 pointing up + * @returns {ReturnType.Mat4} out + */ + export function lookAt(out: mat4, eye: ReadonlyVec3, center: ReadonlyVec3, up: ReadonlyVec3): ReturnType.Mat4; + /** + * Generates a matrix that makes something look at something else. + * + * @template {mat4} T + * @param {mat4} out mat4 frustum matrix will be written into + * @param {ReadonlyVec3} eye Position of the viewer + * @param {ReadonlyVec3} target Point the viewer is looking at + * @param {ReadonlyVec3} up vec3 pointing up + * @returns {ReturnType.Mat4} out + */ + export function targetTo(out: mat4, eye: ReadonlyVec3, target: ReadonlyVec3, up: ReadonlyVec3): ReturnType.Mat4; + /** + * Returns a string representation of a mat4 + * + * @param {ReadonlyMat4} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ + export function str(a: ReadonlyMat4): string; + /** + * Returns Frobenius norm of a mat4 + * + * @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ + export function frob(a: ReadonlyMat4): number; + /** + * Adds two mat4's + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {ReturnType.Mat4} out + */ + export function add(out: T, a: ReadonlyMat4, b: ReadonlyMat4): ReturnType.Mat4; + /** + * Subtracts matrix b from matrix a + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {ReturnType.Mat4} out + */ + export function subtract(out: T, a: ReadonlyMat4, b: ReadonlyMat4): ReturnType.Mat4; + /** + * Multiply each element of the matrix by a scalar. + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {ReturnType.Mat4} out + */ + export function multiplyScalar(out: T, a: ReadonlyMat4, b: number): ReturnType.Mat4; + /** + * Adds two mat4's after multiplying each element of the second operand by a scalar value. + * + * @template {mat4} T + * @param {T} out the receiving vector + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {ReturnType.Mat4} out + */ + export function multiplyScalarAndAdd(out: T, a: ReadonlyMat4, b: ReadonlyMat4, scale: number): ReturnType.Mat4; + /** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyMat4} a The first matrix. + * @param {ReadonlyMat4} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + export function exactEquals(a: ReadonlyMat4, b: ReadonlyMat4): boolean; + /** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {ReadonlyMat4} a The first matrix. + * @param {ReadonlyMat4} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + export function equals(a: ReadonlyMat4, b: ReadonlyMat4): boolean; + /** + * Generates a perspective projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], + * which matches WebGL/OpenGL's clip volume. + * Passing null/undefined/no value for far will generate infinite projection matrix. + * + * @template {mat4} T + * @param {T} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum, can be null or Infinity + * @returns {ReturnType.Mat4} out + */ + export function perspective(out: T, fovy: number, aspect: number, near: number, far: number): ReturnType.Mat4; + /** + * Generates a orthogonal projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], + * which matches WebGL/OpenGL's clip volume. + * + * @template {mat4} T + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} left Left bound of the frustum + * @param {number} right Right bound of the frustum + * @param {number} bottom Bottom bound of the frustum + * @param {number} top Top bound of the frustum + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {ReturnType.Mat4} out + */ + export function ortho(out: mat4, left: number, right: number, bottom: number, top: number, near: number, far: number): ReturnType.Mat4; + /** + * Multiplies two mat4s + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {ReturnType.Mat4} out + */ + export function mul(out: T, a: ReadonlyMat4, b: ReadonlyMat4): ReturnType.Mat4; + /** + * Subtracts matrix b from matrix a + * + * @template {mat4} T + * @param {T} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {ReturnType.Mat4} out + */ + export function sub(out: T, a: ReadonlyMat4, b: ReadonlyMat4): ReturnType.Mat4; +} +export namespace vec3 { + /** + * 3 Dimensional Vector + * @module vec3 + */ + /** + * Creates a new, empty vec3 + * + * @returns {ArrayType} a new 3D vector + */ + export function create(): ArrayType; + /** + * Creates a new vec3 initialized with values from an existing vector + * + * @param {ReadonlyVec3} a vector to clone + * @returns {ArrayType} a new 3D vector + */ + export function clone(a: ReadonlyVec3): ArrayType; + /** + * Calculates the length of a vec3 + * + * @param {ReadonlyVec3} a vector to calculate length of + * @returns {Number} length of a + */ + export function length(a: ReadonlyVec3): number; + /** + * Creates a new vec3 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {ArrayType} a new 3D vector + */ + export function fromValues(x: number, y: number, z: number): ArrayType; + /** + * Copy the values from one vec3 to another + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the source vector + * @returns {ReturnType.Vec3} out + */ + export function copy(out: T, a: ReadonlyVec3): ReturnType.Vec3; + /** + * Set the components of a vec3 to the given values + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {ReturnType.Vec3} out + */ + export function set(out: T, x: number, y: number, z: number): ReturnType.Vec3; + /** + * Adds two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function add(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * Subtracts vector b from vector a + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function subtract(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * Multiplies two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function multiply(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * Divides two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function divide(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * Math.ceil the components of a vec3 + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a vector to ceil + * @returns {ReturnType.Vec3} out + */ + export function ceil(out: T, a: ReadonlyVec3): ReturnType.Vec3; + /** + * Math.floor the components of a vec3 + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a vector to floor + * @returns {ReturnType.Vec3} out + */ + export function floor(out: T, a: ReadonlyVec3): ReturnType.Vec3; + /** + * Returns the minimum of two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function min(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * Returns the maximum of two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function max(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * symmetric round the components of a vec3 + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a vector to round + * @returns {ReturnType.Vec3} out + */ + export function round(out: T, a: ReadonlyVec3): ReturnType.Vec3; + /** + * Scales a vec3 by a scalar number + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {ReturnType.Vec3} out + */ + export function scale(out: T, a: ReadonlyVec3, b: number): ReturnType.Vec3; + /** + * Adds two vec3's after scaling the second operand by a scalar value + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {ReturnType.Vec3} out + */ + export function scaleAndAdd(out: T, a: ReadonlyVec3, b: ReadonlyVec3, scale: number): ReturnType.Vec3; + /** + * Calculates the euclidian distance between two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} distance between a and b + */ + export function distance(a: ReadonlyVec3, b: ReadonlyVec3): number; + /** + * Calculates the squared euclidian distance between two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} squared distance between a and b + */ + export function squaredDistance(a: ReadonlyVec3, b: ReadonlyVec3): number; + /** + * Calculates the squared length of a vec3 + * + * @param {ReadonlyVec3} a vector to calculate squared length of + * @returns {Number} squared length of a + */ + export function squaredLength(a: ReadonlyVec3): number; + /** + * Negates the components of a vec3 + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a vector to negate + * @returns {ReturnType.Vec3} out + */ + export function negate(out: T, a: ReadonlyVec3): ReturnType.Vec3; + /** + * Returns the inverse of the components of a vec3 + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a vector to invert + * @returns {ReturnType.Vec3} out + */ + export function inverse(out: T, a: ReadonlyVec3): ReturnType.Vec3; + /** + * Normalize a vec3 + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a vector to normalize + * @returns {ReturnType.Vec3} out + */ + export function normalize(out: T, a: ReadonlyVec3): ReturnType.Vec3; + /** + * Calculates the dot product of two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} dot product of a and b + */ + export function dot(a: ReadonlyVec3, b: ReadonlyVec3): number; + /** + * Computes the cross product of two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function cross(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * Performs a linear interpolation between two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {ReturnType.Vec3} out + */ + export function lerp(out: T, a: ReadonlyVec3, b: ReadonlyVec3, t: number): ReturnType.Vec3; + /** + * Performs a spherical linear interpolation between two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {ReturnType.Vec3} out + */ + export function slerp(out: T, a: ReadonlyVec3, b: ReadonlyVec3, t: number): ReturnType.Vec3; + /** + * Performs a hermite interpolation with two control points + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec3} c the third operand + * @param {ReadonlyVec3} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {ReturnType.Vec3} out + */ + export function hermite(out: T, a: ReadonlyVec3, b: ReadonlyVec3, c: ReadonlyVec3, d: ReadonlyVec3, t: number): ReturnType.Vec3; + /** + * Performs a bezier interpolation with two control points + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec3} c the third operand + * @param {ReadonlyVec3} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {ReturnType.Vec3} out + */ + export function bezier(out: T, a: ReadonlyVec3, b: ReadonlyVec3, c: ReadonlyVec3, d: ReadonlyVec3, t: number): ReturnType.Vec3; + /** + * Generates a random vector with the given scale + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned + * @returns {ReturnType.Vec3} out + */ + export function random(out: T, scale?: number): ReturnType.Vec3; + /** + * Transforms the vec3 with a mat4. + * 4th vector component is implicitly '1' + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the vector to transform + * @param {ReadonlyMat4} m matrix to transform with + * @returns {ReturnType.Vec3} out + */ + export function transformMat4(out: T, a: ReadonlyVec3, m: ReadonlyMat4): ReturnType.Vec3; + /** + * Transforms the vec3 with a mat3. + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the vector to transform + * @param {ReadonlyMat3} m the 3x3 matrix to transform with + * @returns {ReturnType.Vec3} out + */ + export function transformMat3(out: T, a: ReadonlyVec3, m: ReadonlyMat3): ReturnType.Vec3; + /** + * Transforms the vec3 with a quat + * Can also be used for dual quaternions. (Multiply it with the real part) + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the vector to transform + * @param {ReadonlyQuat} q normalized quaternion to transform with + * @returns {ReturnType.Vec3} out + */ + export function transformQuat(out: T, a: ReadonlyVec3, q: ReadonlyQuat): ReturnType.Vec3; + /** + * Rotate a 3D vector around the x-axis + * @template {vec3} T + * @param {T} out The receiving vec3 + * @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 + * @returns {ReturnType.Vec3} out + */ + export function rotateX(out: T, a: ReadonlyVec3, b: ReadonlyVec3, rad: number): ReturnType.Vec3; + /** + * Rotate a 3D vector around the y-axis + * @template {vec3} T + * @param {T} out The receiving vec3 + * @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 + * @returns {ReturnType.Vec3} out + */ + export function rotateY(out: T, a: ReadonlyVec3, b: ReadonlyVec3, rad: number): ReturnType.Vec3; + /** + * Rotate a 3D vector around the z-axis + * @template {vec3} T + * @param {T} out The receiving vec3 + * @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 + * @returns {ReturnType.Vec3} out + */ + export function rotateZ(out: T, a: ReadonlyVec3, b: ReadonlyVec3, rad: number): ReturnType.Vec3; + /** + * Get the angle between two 3D vectors + * @param {ReadonlyVec3} a The first operand + * @param {ReadonlyVec3} b The second operand + * @returns {Number} The angle in radians + */ + export function angle(a: ReadonlyVec3, b: ReadonlyVec3): number; + /** + * Set the components of a vec3 to zero + * + * @template {vec3} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec3} out + */ + export function zero(out: T): ReturnType.Vec3; + /** + * Returns a string representation of a vector + * + * @param {ReadonlyVec3} a vector to represent as a string + * @returns {String} string representation of the vector + */ + export function str(a: ReadonlyVec3): string; + /** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyVec3} a The first vector. + * @param {ReadonlyVec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + export function exactEquals(a: ReadonlyVec3, b: ReadonlyVec3): boolean; + /** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {ReadonlyVec3} a The first vector. + * @param {ReadonlyVec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + export function equals(a: ReadonlyVec3, b: ReadonlyVec3): boolean; + /** + * Subtracts vector b from vector a + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function sub(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * Multiplies two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function mul(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * Divides two vec3's + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {ReturnType.Vec3} out + */ + export function div(out: T, a: ReadonlyVec3, b: ReadonlyVec3): ReturnType.Vec3; + /** + * Calculates the euclidian distance between two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} distance between a and b + */ + export function dist(a: ReadonlyVec3, b: ReadonlyVec3): number; + /** + * Calculates the squared euclidian distance between two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} squared distance between a and b + */ + export function sqrDist(a: ReadonlyVec3, b: ReadonlyVec3): number; + /** + * Calculates the length of a vec3 + * + * @param {ReadonlyVec3} a vector to calculate length of + * @returns {Number} length of a + */ + export function len(a: ReadonlyVec3): number; + /** + * Calculates the squared length of a vec3 + * + * @param {ReadonlyVec3} a vector to calculate squared length of + * @returns {Number} squared length of a + */ + export function sqrLen(a: ReadonlyVec3): number; + export function forEach(a: any, stride: any, offset: any, count: any, fn: any, arg: any): any; +} +export namespace vec4 { + /** + * 4 Dimensional Vector + * @module vec4 + */ + /** + * Creates a new, empty vec4 + * + * @returns {ArrayType} a new 4D vector + */ + export function create(): ArrayType; + /** + * Creates a new vec4 initialized with values from an existing vector + * + * @param {ReadonlyVec4} a vector to clone + * @returns {ArrayType} a new 4D vector + */ + export function clone(a: ReadonlyVec4): ArrayType; + /** + * Creates a new vec4 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {ArrayType} a new 4D vector + */ + export function fromValues(x: number, y: number, z: number, w: number): ArrayType; + /** + * Copy the values from one vec4 to another + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the source vector + * @returns {ReturnType.Vec4} out + */ + export function copy(out: T, a: ReadonlyVec4): ReturnType.Vec4; + /** + * Set the components of a vec4 to the given values + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {ReturnType.Vec4} out + */ + export function set(out: T, x: number, y: number, z: number, w: number): ReturnType.Vec4; + /** + * Adds two vec4's + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {ReturnType.Vec4} out + */ + export function add(out: T, a: ReadonlyVec4, b: ReadonlyVec4): ReturnType.Vec4; + /** + * Subtracts vector b from vector a + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {ReturnType.Vec4} out + */ + export function subtract(out: T, a: ReadonlyVec4, b: ReadonlyVec4): ReturnType.Vec4; + /** + * Multiplies two vec4's + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {ReturnType.Vec4} out + */ + export function multiply(out: T, a: ReadonlyVec4, b: ReadonlyVec4): ReturnType.Vec4; + /** + * Divides two vec4's + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {ReturnType.Vec4} out + */ + export function divide(out: T, a: ReadonlyVec4, b: ReadonlyVec4): ReturnType.Vec4; + /** + * Math.ceil the components of a vec4 + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a vector to ceil + * @returns {ReturnType.Vec4} out + */ + export function ceil(out: T, a: ReadonlyVec4): ReturnType.Vec4; + /** + * Math.floor the components of a vec4 + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a vector to floor + * @returns {ReturnType.Vec4} out + */ + export function floor(out: T, a: ReadonlyVec4): ReturnType.Vec4; + /** + * Returns the minimum of two vec4's + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {ReturnType.Vec4} out + */ + export function min(out: T, a: ReadonlyVec4, b: ReadonlyVec4): ReturnType.Vec4; + /** + * Returns the maximum of two vec4's + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {ReturnType.Vec4} out + */ + export function max(out: T, a: ReadonlyVec4, b: ReadonlyVec4): ReturnType.Vec4; + /** + * symmetric round the components of a vec4 + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a vector to round + * @returns {ReturnType.Vec4} out + */ + export function round(out: T, a: ReadonlyVec4): ReturnType.Vec4; + /** + * Scales a vec4 by a scalar number + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {ReturnType.Vec4} out + */ + export function scale(out: T, a: ReadonlyVec4, b: number): ReturnType.Vec4; + /** + * Adds two vec4's after scaling the second operand by a scalar value + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {ReturnType.Vec4} out + */ + export function scaleAndAdd(out: T, a: ReadonlyVec4, b: ReadonlyVec4, scale: number): ReturnType.Vec4; + /** + * Calculates the euclidian distance between two vec4's + * + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} distance between a and b + */ + export function distance(a: ReadonlyVec4, b: ReadonlyVec4): number; + /** + * Calculates the squared euclidian distance between two vec4's + * + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} squared distance between a and b + */ + export function squaredDistance(a: ReadonlyVec4, b: ReadonlyVec4): number; + /** + * Calculates the length of a vec4 + * + * @param {ReadonlyVec4} a vector to calculate length of + * @returns {Number} length of a + */ + export function length(a: ReadonlyVec4): number; + /** + * Calculates the squared length of a vec4 + * + * @param {ReadonlyVec4} a vector to calculate squared length of + * @returns {Number} squared length of a + */ + export function squaredLength(a: ReadonlyVec4): number; + /** + * Negates the components of a vec4 + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a vector to negate + * @returns {ReturnType.Vec4} out + */ + export function negate(out: T, a: ReadonlyVec4): ReturnType.Vec4; + /** + * Returns the inverse of the components of a vec4 + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a vector to invert + * @returns {ReturnType.Vec4} out + */ + export function inverse(out: T, a: ReadonlyVec4): ReturnType.Vec4; + /** + * Normalize a vec4 + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a vector to normalize + * @returns {ReturnType.Vec4} out + */ + export function normalize(out: T, a: ReadonlyVec4): ReturnType.Vec4; + /** + * Calculates the dot product of two vec4's + * + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} dot product of a and b + */ + export function dot(a: ReadonlyVec4, b: ReadonlyVec4): number; + /** + * Returns the cross-product of three vectors in a 4-dimensional space + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} u the first vector + * @param {ReadonlyVec4} v the second vector + * @param {ReadonlyVec4} w the third vector + * @returns {ReturnType.Vec4} result + */ + export function cross(out: T, u: ReadonlyVec4, v: ReadonlyVec4, w: ReadonlyVec4): ReturnType.Vec4; + /** + * Performs a linear interpolation between two vec4's + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {ReturnType.Vec4} out + */ + export function lerp(out: T, a: ReadonlyVec4, b: ReadonlyVec4, t: number): ReturnType.Vec4; + /** + * Generates a random vector with the given scale + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned + * @returns {ReturnType.Vec4} out + */ + export function random(out: T, scale?: number): ReturnType.Vec4; + /** + * Transforms the vec4 with a mat4. + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the vector to transform + * @param {ReadonlyMat4} m matrix to transform with + * @returns {ReturnType.Vec4} out + */ + export function transformMat4(out: T, a: ReadonlyVec4, m: ReadonlyMat4): ReturnType.Vec4; + /** + * Transforms the vec4 with a quat + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the vector to transform + * @param {ReadonlyQuat} q normalized quaternion to transform with + * @returns {ReturnType.Vec4} out + */ + export function transformQuat(out: T, a: ReadonlyVec4, q: ReadonlyQuat): ReturnType.Vec4; + /** + * Set the components of a vec4 to zero + * + * @template {vec4} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec4} out + */ + export function zero(out: T): ReturnType.Vec4; + /** + * Returns a string representation of a vector + * + * @param {ReadonlyVec4} a vector to represent as a string + * @returns {String} string representation of the vector + */ + export function str(a: ReadonlyVec4): string; + /** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyVec4} a The first vector. + * @param {ReadonlyVec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + export function exactEquals(a: ReadonlyVec4, b: ReadonlyVec4): boolean; + /** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {ReadonlyVec4} a The first vector. + * @param {ReadonlyVec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + export function equals(a: ReadonlyVec4, b: ReadonlyVec4): boolean; + /** + * Subtracts vector b from vector a + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {ReturnType.Vec4} out + */ + export function sub(out: T, a: ReadonlyVec4, b: ReadonlyVec4): ReturnType.Vec4; + /** + * Multiplies two vec4's + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {ReturnType.Vec4} out + */ + export function mul(out: T, a: ReadonlyVec4, b: ReadonlyVec4): ReturnType.Vec4; + /** + * Divides two vec4's + * + * @template {vec4} T + * @param {T} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {ReturnType.Vec4} out + */ + export function div(out: T, a: ReadonlyVec4, b: ReadonlyVec4): ReturnType.Vec4; + /** + * Calculates the euclidian distance between two vec4's + * + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} distance between a and b + */ + export function dist(a: ReadonlyVec4, b: ReadonlyVec4): number; + /** + * Calculates the squared euclidian distance between two vec4's + * + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} squared distance between a and b + */ + export function sqrDist(a: ReadonlyVec4, b: ReadonlyVec4): number; + /** + * Calculates the length of a vec4 + * + * @param {ReadonlyVec4} a vector to calculate length of + * @returns {Number} length of a + */ + export function len(a: ReadonlyVec4): number; + /** + * Calculates the squared length of a vec4 + * + * @param {ReadonlyVec4} a vector to calculate squared length of + * @returns {Number} squared length of a + */ + export function sqrLen(a: ReadonlyVec4): number; + export function forEach(a: any, stride: any, offset: any, count: any, fn: any, arg: any): any; +} +export namespace quat { + /** + * Quaternion in the format XYZW + * @module quat + */ + /** + * Creates a new identity quat + * + * @returns {ReturnType.Quat} a new quaternion + */ + export function create(): ReturnType.Quat; + /** + * Set a quat to the identity quaternion + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat} out + */ + export function identity(out: T_1): ReturnType.Quat; + /** + * Sets a quat from the given angle and rotation axis, + * then returns it. + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyVec3} axis the axis around which to rotate + * @param {Number} rad the angle in radians + * @returns {ReturnType.Quat} out + **/ + export function setAxisAngle(out: T_1, axis: ReadonlyVec3, rad: number): ReturnType.Quat; + /** + * Gets the rotation axis and angle for a given + * quaternion. If a quaternion is created with + * setAxisAngle, this method will return the same + * values as providied in the original parameter list + * OR functionally equivalent values. + * Example: The quaternion formed by axis [0, 0, 1] and + * angle -90 is the same as the quaternion formed by + * [0, 0, 1] and 270. This method favors the latter. + * @param {vec3} out_axis Vector receiving the axis of rotation + * @param {ReadonlyQuat} q Quaternion to be decomposed + * @return {Number} Angle, in radians, of the rotation + */ + export function getAxisAngle(out_axis: vec3, q: ReadonlyQuat): number; + /** + * Gets the angular distance between two unit quaternions + * + * @param {ReadonlyQuat} a Origin unit quaternion + * @param {ReadonlyQuat} b Destination unit quaternion + * @return {Number} Angle, in radians, between the two quaternions + */ + export function getAngle(a: ReadonlyQuat, b: ReadonlyQuat): number; + /** + * Multiplies two quat's + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @returns {ReturnType.Quat} out + */ + export function multiply(out: T_1, a: ReadonlyQuat, b: ReadonlyQuat): ReturnType.Quat; + /** + * Rotates a quaternion by the given angle about the X axis + * + * @template {quat} T + * @param {T} out quat receiving operation result + * @param {ReadonlyQuat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {ReturnType.Quat} out + */ + export function rotateX(out: T_1, a: ReadonlyQuat, rad: number): ReturnType.Quat; + /** + * Rotates a quaternion by the given angle about the Y axis + * + * @template {quat} T + * @param {T} out quat receiving operation result + * @param {ReadonlyQuat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {ReturnType.Quat} out + */ + export function rotateY(out: T_1, a: ReadonlyQuat, rad: number): ReturnType.Quat; + /** + * Rotates a quaternion by the given angle about the Z axis + * + * @template {quat} T + * @param {T} out quat receiving operation result + * @param {ReadonlyQuat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {ReturnType.Quat} out + */ + export function rotateZ(out: T_1, a: ReadonlyQuat, rad: number): ReturnType.Quat; + /** + * Calculates the W component of a quat from the X, Y, and Z components. + * Assumes that quaternion is 1 unit in length. + * Any existing W component will be ignored. + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate W component of + * @returns {ReturnType.Quat} out + */ + export function calculateW(out: T_1, a: ReadonlyQuat): ReturnType.Quat; + /** + * Calculate the exponential of a unit quaternion. + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate the exponential of + * @returns {ReturnType.Quat} out + */ + export function exp(out: T_1, a: ReadonlyQuat): ReturnType.Quat; + /** + * Calculate the natural logarithm of a unit quaternion. + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate the exponential of + * @returns {ReturnType.Quat} out + */ + export function ln(out: T_1, a: ReadonlyQuat): ReturnType.Quat; + /** + * Calculate the scalar power of a unit quaternion. + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate the exponential of + * @param {Number} b amount to scale the quaternion by + * @returns {ReturnType.Quat} out + */ + export function pow(out: T_1, a: ReadonlyQuat, b: number): ReturnType.Quat; + /** + * Performs a spherical linear interpolation between two quat + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {ReturnType.Quat} out + */ + export function slerp(out: T_1, a: ReadonlyQuat, b: ReadonlyQuat, t: number): ReturnType.Quat; + /** + * Generates a random unit quaternion + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat} out + */ + export function random(out: T_1): ReturnType.Quat; + /** + * Calculates the inverse of a quat + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate inverse of + * @returns {ReturnType.Quat} out + */ + export function invert(out: T_1, a: ReadonlyQuat): ReturnType.Quat; + /** + * Calculates the conjugate of a quat + * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate conjugate of + * @returns {ReturnType.Quat} out + */ + export function conjugate(out: T_1, a: ReadonlyQuat): ReturnType.Quat; + /** + * Creates a quaternion from the given 3x3 rotation matrix. + * + * NOTE: The resultant quaternion is not normalized, so you should be sure + * to renormalize the quaternion yourself where necessary. + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyMat3} m rotation matrix + * @returns {ReturnType.Quat} out + * @function + */ + export function fromMat3(out: T_1, m: ReadonlyMat3): ReturnType.Quat; + /** + * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion. + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {Number} x Angle to rotate around X axis in degrees. + * @param {Number} y Angle to rotate around Y axis in degrees. + * @param {Number} z Angle to rotate around Z axis in degrees. + * @param {'xyz'|'xzy'|'yxz'|'yzx'|'zxy'|'zyx'} order Intrinsic order for conversion, default is zyx. + * @returns {ReturnType.Quat} out + * @function + */ + export function fromEuler(out: T_1, x: number, y: number, z: number, order?: "xyz" | "xzy" | "yxz" | "yzx" | "zxy" | "zyx"): ReturnType.Quat; + /** + * Returns a string representation of a quaternion + * + * @param {ReadonlyQuat} a vector to represent as a string + * @returns {String} string representation of the vector + */ + export function str(a: ReadonlyQuat): string; + /** + * Returns whether or not the quaternions point approximately to the same direction. + * + * Both quaternions are assumed to be unit length. + * + * @param {ReadonlyQuat} a The first unit quaternion. + * @param {ReadonlyQuat} b The second unit quaternion. + * @returns {Boolean} True if the quaternions are equal, false otherwise. + */ + export function equals(a: ReadonlyQuat, b: ReadonlyQuat): boolean; + /** + * Creates a new quat initialized with values from an existing quaternion + * + * @param {ReadonlyQuat} a quaternion to clone + * @returns {ReturnType.Quat} a new quaternion + * @function + */ + export const clone: typeof vec4.clone; + /** + * Creates a new quat initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {ReturnType.Quat} a new quaternion + * @function + */ + export const fromValues: typeof vec4.fromValues; + /** + * Copy the values from one quat to another + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a the source quaternion + * @returns {ReturnType.Quat} out + * @function + */ + export const copy: typeof vec4.copy; + /** + * Set the components of a quat to the given values + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {ReturnType.Quat} out + * @function + */ + export const set: typeof vec4.set; + /** + * Adds two quat's + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @returns {ReturnType.Quat} out + * @function + */ + export const add: typeof vec4.add; + /** + * Multiplies two quat's + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @returns {ReturnType.Quat} out + */ + export function mul(out: T_1, a: ReadonlyQuat, b: ReadonlyQuat): ReturnType.Quat; + /** + * Scales a quat by a scalar number + * + * @template {quat} T + * @param {T} out the receiving vector + * @param {ReadonlyQuat} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {ReturnType.Quat} out + * @function + */ + export const scale: typeof vec4.scale; + /** + * Calculates the dot product of two quat's + * + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @returns {Number} dot product of a and b + * @function + */ + export const dot: typeof vec4.dot; + /** + * Performs a linear interpolation between two quat's + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {ReturnType.Quat} out + * @function + */ + export const lerp: typeof vec4.lerp; + /** + * Calculates the length of a quat + * + * @param {ReadonlyQuat} a vector to calculate length of + * @returns {Number} length of a + */ + export const length: typeof vec4.length; + /** + * Alias for {@link quat.length} + * @function + */ + export const len: typeof vec4.length; + /** + * Calculates the squared length of a quat + * + * @param {ReadonlyQuat} a vector to calculate squared length of + * @returns {Number} squared length of a + * @function + */ + export const squaredLength: typeof vec4.squaredLength; + /** + * Alias for {@link quat.squaredLength} + * @function + */ + export const sqrLen: typeof vec4.squaredLength; + /** + * Normalize a quat + * + * @template {quat} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} a quaternion to normalize + * @returns {ReturnType.Quat} out + * @function + */ + export const normalize: typeof vec4.normalize; + /** + * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyQuat} a The first quaternion. + * @param {ReadonlyQuat} b The second quaternion. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + export const exactEquals: typeof vec4.exactEquals; + export function rotationTo(out: any, a: any, b: any): any; + export function sqlerp(out: any, a: any, b: any, c: any, d: any, t: any): any; + export function setAxes(out: any, view: any, right: any, up: any): any; + +} +export namespace quat2 { + /** + * Dual Quaternion
+ * Format: [real, dual]
+ * Quaternion format: XYZW
+ * Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.
+ * @module quat2 + */ + /** + * Creates a new identity dual quat + * + * @returns {ArrayType} a new dual quaternion [real -> rotation, dual -> translation] + */ + export function create(): ArrayType; + /** + * Creates a new quat initialized with values from an existing quaternion + * + * @param {ReadonlyQuat2} a dual quaternion to clone + * @returns {ArrayType} new dual quaternion + * @function + */ + export function clone(a: ReadonlyQuat2): ArrayType; + /** + * Creates a new dual quat initialized with the given values + * + * @param {Number} x1 X component + * @param {Number} y1 Y component + * @param {Number} z1 Z component + * @param {Number} w1 W component + * @param {Number} x2 X component + * @param {Number} y2 Y component + * @param {Number} z2 Z component + * @param {Number} w2 W component + * @returns {ArrayType} new dual quaternion + * @function + */ + export function fromValues(x1: number, y1: number, z1: number, w1: number, x2: number, y2: number, z2: number, w2: number): ArrayType; + /** + * Creates a new dual quat from the given values (quat and translation) + * + * @param {Number} x1 X component + * @param {Number} y1 Y component + * @param {Number} z1 Z component + * @param {Number} w1 W component + * @param {Number} x2 X component (translation) + * @param {Number} y2 Y component (translation) + * @param {Number} z2 Z component (translation) + * @returns {ArrayType} new dual quaternion + * @function + */ + export function fromRotationTranslationValues(x1: number, y1: number, z1: number, w1: number, x2: number, y2: number, z2: number): ArrayType; + /** + * Creates a dual quat from a quaternion and a translation + * + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result + * @param {ReadonlyQuat} q a normalized quaternion + * @param {ReadonlyVec3} t translation vector + * @returns {ReturnType.Quat2} dual quaternion receiving operation result + * @function + */ + export function fromRotationTranslation(out: T_1, q: ReadonlyQuat, t: ReadonlyVec3): ReturnType.Quat2; + /** + * Creates a dual quat from a translation + * + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result + * @param {ReadonlyVec3} t translation vector + * @returns {ReturnType.Quat2} dual quaternion receiving operation result + * @function + */ + export function fromTranslation(out: T_1, t: ReadonlyVec3): ReturnType.Quat2; + /** + * Creates a dual quat from a quaternion + * + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result + * @param {ReadonlyQuat} q the quaternion + * @returns {ReturnType.Quat2} dual quaternion receiving operation result + * @function + */ + export function fromRotation(out: T_1, q: ReadonlyQuat): ReturnType.Quat2; + /** + * Creates a new dual quat from a matrix (4x4) + * + * @template {quat2} T + * @param {T} out the dual quaternion + * @param {ReadonlyMat4} a the matrix + * @returns {ReturnType.Quat2} dual quat receiving operation result + * @function + */ + export function fromMat4(out: T_1, a: ReadonlyMat4): ReturnType.Quat2; + /** + * Copy the values from one dual quat to another + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the source dual quaternion + * @returns {ReturnType.Quat2} out + * @function + */ + export function copy(out: T_1, a: ReadonlyQuat2): ReturnType.Quat2; + /** + * Set a dual quat to the identity dual quaternion + * + * @template {quat2} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat2} out + */ + export function identity(out: T_1): ReturnType.Quat2; + /** + * Set the components of a dual quat to the given values + * + * @template {quat2} T + * @param {T} out the receiving quaternion + * @param {Number} x1 X component + * @param {Number} y1 Y component + * @param {Number} z1 Z component + * @param {Number} w1 W component + * @param {Number} x2 X component + * @param {Number} y2 Y component + * @param {Number} z2 Z component + * @param {Number} w2 W component + * @returns {ReturnType.Quat2} out + * @function + */ + export function set(out: T_1, x1: number, y1: number, z1: number, w1: number, x2: number, y2: number, z2: number, w2: number): ReturnType.Quat2; + /** + * Gets the dual part of a dual quat + * @param {quat} out dual part + * @param {ReadonlyQuat2} a Dual Quaternion + * @return {quat} dual part + */ + export function getDual(out: quat, a: ReadonlyQuat2): quat; + /** + * Set the dual component of a dual quat to the given quaternion + * + * @template {quat2} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} q a quaternion representing the dual part + * @returns {ReturnType.Quat2} out + * @function + */ + export function setDual(out: T_1, q: ReadonlyQuat): ReturnType.Quat2; + /** + * Gets the translation of a normalized dual quat + * @param {vec3} out translation + * @param {ReadonlyQuat2} a Dual Quaternion to be decomposed + * @return {vec3} translation + */ + export function getTranslation(out: vec3, a: ReadonlyQuat2): vec3; + /** + * Translates a dual quat by the given vector + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to translate + * @param {ReadonlyVec3} v vector to translate by + * @returns {ReturnType.Quat2} out + */ + export function translate(out: T_1, a: ReadonlyQuat2, v: ReadonlyVec3): ReturnType.Quat2; + /** + * Rotates a dual quat around the X axis + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {number} rad how far should the rotation be + * @returns {ReturnType.Quat2} out + */ + export function rotateX(out: T_1, a: ReadonlyQuat2, rad: number): ReturnType.Quat2; + /** + * Rotates a dual quat around the Y axis + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {number} rad how far should the rotation be + * @returns {ReturnType.Quat2} out + */ + export function rotateY(out: T_1, a: ReadonlyQuat2, rad: number): ReturnType.Quat2; + /** + * Rotates a dual quat around the Z axis + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {number} rad how far should the rotation be + * @returns {ReturnType.Quat2} out + */ + export function rotateZ(out: T_1, a: ReadonlyQuat2, rad: number): ReturnType.Quat2; + /** + * Rotates a dual quat by a given quaternion (a * q) + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {ReadonlyQuat} q quaternion to rotate by + * @returns {ReturnType.Quat2} out + */ + export function rotateByQuatAppend(out: T_1, a: ReadonlyQuat2, q: ReadonlyQuat): ReturnType.Quat2; + /** + * Rotates a dual quat by a given quaternion (q * a) + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat} q quaternion to rotate by + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @returns {ReturnType.Quat2} out + */ + export function rotateByQuatPrepend(out: T_1, q: ReadonlyQuat, a: ReadonlyQuat2): ReturnType.Quat2; + /** + * Rotates a dual quat around a given axis. Does the normalisation automatically + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {ReadonlyVec3} axis the axis to rotate around + * @param {Number} rad how far the rotation should be + * @returns {ReturnType.Quat2} out + */ + export function rotateAroundAxis(out: T_1, a: ReadonlyQuat2, axis: ReadonlyVec3, rad: number): ReturnType.Quat2; + /** + * Adds two dual quat's + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the first operand + * @param {ReadonlyQuat2} b the second operand + * @returns {ReturnType.Quat2} out + * @function + */ + export function add(out: T_1, a: ReadonlyQuat2, b: ReadonlyQuat2): ReturnType.Quat2; + /** + * Multiplies two dual quat's + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the first operand + * @param {ReadonlyQuat2} b the second operand + * @returns {ReturnType.Quat2} out + */ + export function multiply(out: T_1, a: ReadonlyQuat2, b: ReadonlyQuat2): ReturnType.Quat2; + /** + * Scales a dual quat by a scalar number + * + * @template {quat2} T + * @param {T} out the receiving dual quat + * @param {ReadonlyQuat2} a the dual quat to scale + * @param {Number} b amount to scale the dual quat by + * @returns {ReturnType.Quat2} out + * @function + */ + export function scale(out: T_1, a: ReadonlyQuat2, b: number): ReturnType.Quat2; + /** + * Performs a linear interpolation between two dual quats's + * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5) + * + * @template {quat2} T + * @param {T} out the receiving dual quat + * @param {ReadonlyQuat2} a the first operand + * @param {ReadonlyQuat2} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {ReturnType.Quat2} out + */ + export function lerp(out: T_1, a: ReadonlyQuat2, b: ReadonlyQuat2, t: number): ReturnType.Quat2; + /** + * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a dual quat to calculate inverse of + * @returns {ReturnType.Quat2} out + */ + export function invert(out: T_1, a: ReadonlyQuat2): ReturnType.Quat2; + /** + * Calculates the conjugate of a dual quat + * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result. + * + * @template {quat2} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat2} a quat to calculate conjugate of + * @returns {ReturnType.Quat2} out + */ + export function conjugate(out: T_1, a: ReadonlyQuat2): ReturnType.Quat2; + /** + * Normalize a dual quat + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a dual quaternion to normalize + * @returns {ReturnType.Quat2} out + * @function + */ + export function normalize(out: T_1, a: ReadonlyQuat2): ReturnType.Quat2; + /** + * Returns a string representation of a dual quaternion + * + * @param {ReadonlyQuat2} a dual quaternion to represent as a string + * @returns {String} string representation of the dual quat + */ + export function str(a: ReadonlyQuat2): string; + /** + * Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyQuat2} a the first dual quaternion. + * @param {ReadonlyQuat2} b the second dual quaternion. + * @returns {Boolean} true if the dual quaternions are equal, false otherwise. + */ + export function exactEquals(a: ReadonlyQuat2, b: ReadonlyQuat2): boolean; + /** + * Returns whether or not the dual quaternions have approximately the same elements in the same position. + * + * @param {ReadonlyQuat2} a the first dual quat. + * @param {ReadonlyQuat2} b the second dual quat. + * @returns {Boolean} true if the dual quats are equal, false otherwise. + */ + export function equals(a: ReadonlyQuat2, b: ReadonlyQuat2): boolean; + /** + * Gets the real part of a dual quat + * @param {quat} out real part + * @param {ReadonlyQuat2} a Dual Quaternion + * @return {quat} real part + */ + export const getReal: typeof vec4.copy; + /** + * Set the real component of a dual quat to the given quaternion + * + * @template {quat2} T + * @param {T} out the receiving quaternion + * @param {ReadonlyQuat} q a quaternion representing the real part + * @returns {ReturnType.Quat2} out + * @function + */ + export const setReal: typeof vec4.copy; + /** + * Multiplies two dual quat's + * + * @template {quat2} T + * @param {T} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the first operand + * @param {ReadonlyQuat2} b the second operand + * @returns {ReturnType.Quat2} out + */ + export function mul(out: T_1, a: ReadonlyQuat2, b: ReadonlyQuat2): ReturnType.Quat2; + /** + * Calculates the dot product of two dual quat's (The dot product of the real parts) + * + * @param {ReadonlyQuat2} a the first operand + * @param {ReadonlyQuat2} b the second operand + * @returns {Number} dot product of a and b + * @function + */ + export const dot: typeof vec4.dot; + /** + * Calculates the length of a dual quat + * + * @param {ReadonlyQuat2} a dual quat to calculate length of + * @returns {Number} length of a + * @function + */ + export const length: typeof vec4.length; + /** + * Alias for {@link quat2.length} + * @function + */ + export const len: typeof vec4.length; + /** + * Calculates the squared length of a dual quat + * + * @param {ReadonlyQuat2} a dual quat to calculate squared length of + * @returns {Number} squared length of a + * @function + */ + export const squaredLength: typeof vec4.squaredLength; + /** + * Alias for {@link quat2.squaredLength} + * @function + */ + export const sqrLen: typeof vec4.squaredLength; +} +export namespace vec2 { + /** + * 2 Dimensional Vector + * @module vec2 + */ + /** + * Creates a new, empty vec2 + * + * @returns {ArrayType} a new 2D vector + */ + export function create(): ArrayType; + /** + * Creates a new vec2 initialized with values from an existing vector + * + * @param {ReadonlyVec2} a vector to clone + * @returns {ArrayType} a new 2D vector + */ + export function clone(a: ReadonlyVec2): ArrayType; + /** + * Creates a new vec2 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @returns {ArrayType} a new 2D vector + */ + export function fromValues(x: number, y: number): ArrayType; + /** + * Copy the values from one vec2 to another + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the source vector + * @returns {ReturnType.Vec2} out + */ + export function copy(out: T, a: ReadonlyVec2): ReturnType.Vec2; + /** + * Set the components of a vec2 to the given values + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @returns {ReturnType.Vec2} out + */ + export function set(out: T, x: number, y: number): ReturnType.Vec2; + /** + * Adds two vec2's + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function add(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * Subtracts vector b from vector a + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function subtract(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * Multiplies two vec2's + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function multiply(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * Divides two vec2's + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function divide(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * Math.ceil the components of a vec2 + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a vector to ceil + * @returns {ReturnType.Vec2} out + */ + export function ceil(out: T, a: ReadonlyVec2): ReturnType.Vec2; + /** + * Math.floor the components of a vec2 + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a vector to floor + * @returns {ReturnType.Vec2} out + */ + export function floor(out: T, a: ReadonlyVec2): ReturnType.Vec2; + /** + * Returns the minimum of two vec2's + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function min(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * Returns the maximum of two vec2's + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function max(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * symmetric round the components of a vec2 + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a vector to round + * @returns {ReturnType.Vec2} out + */ + export function round(out: T, a: ReadonlyVec2): ReturnType.Vec2; + /** + * Scales a vec2 by a scalar number + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {ReturnType.Vec2} out + */ + export function scale(out: T, a: ReadonlyVec2, b: number): ReturnType.Vec2; + /** + * Adds two vec2's after scaling the second operand by a scalar value + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {ReturnType.Vec2} out + */ + export function scaleAndAdd(out: T, a: ReadonlyVec2, b: ReadonlyVec2, scale: number): ReturnType.Vec2; + /** + * Calculates the euclidian distance between two vec2's + * + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {Number} distance between a and b + */ + export function distance(a: ReadonlyVec2, b: ReadonlyVec2): number; + /** + * Calculates the squared euclidian distance between two vec2's + * + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {Number} squared distance between a and b + */ + export function squaredDistance(a: ReadonlyVec2, b: ReadonlyVec2): number; + /** + * Calculates the length of a vec2 + * + * @param {ReadonlyVec2} a vector to calculate length of + * @returns {Number} length of a + */ + export function length(a: ReadonlyVec2): number; + /** + * Calculates the squared length of a vec2 + * + * @param {ReadonlyVec2} a vector to calculate squared length of + * @returns {Number} squared length of a + */ + export function squaredLength(a: ReadonlyVec2): number; + /** + * Negates the components of a vec2 + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a vector to negate + * @returns {ReturnType.Vec2} out + */ + export function negate(out: T, a: ReadonlyVec2): ReturnType.Vec2; + /** + * Returns the inverse of the components of a vec2 + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a vector to invert + * @returns {ReturnType.Vec2} out + */ + export function inverse(out: T, a: ReadonlyVec2): ReturnType.Vec2; + /** + * Normalize a vec2 + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a vector to normalize + * @returns {ReturnType.Vec2} out + */ + export function normalize(out: T, a: ReadonlyVec2): ReturnType.Vec2; + /** + * Calculates the dot product of two vec2's + * + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {Number} dot product of a and b + */ + export function dot(a: ReadonlyVec2, b: ReadonlyVec2): number; + /** + * Computes the cross product of two vec2's + * Note that the cross product must by definition produce a 3D vector + * + * @template {vec3} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function cross(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * Performs a linear interpolation between two vec2's + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {ReturnType.Vec2} out + */ + export function lerp(out: T, a: ReadonlyVec2, b: ReadonlyVec2, t: number): ReturnType.Vec2; + /** + * Generates a random vector with the given scale + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned + * @returns {ReturnType.Vec2} out + */ + export function random(out: T, scale?: number): ReturnType.Vec2; + /** + * Transforms the vec2 with a mat2 + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat2} m matrix to transform with + * @returns {ReturnType.Vec2} out + */ + export function transformMat2(out: T, a: ReadonlyVec2, m: ReadonlyMat2): ReturnType.Vec2; + /** + * Transforms the vec2 with a mat2d + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat2d} m matrix to transform with + * @returns {ReturnType.Vec2} out + */ + export function transformMat2d(out: T, a: ReadonlyVec2, m: ReadonlyMat2d): ReturnType.Vec2; + /** + * Transforms the vec2 with a mat3 + * 3rd vector component is implicitly '1' + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat3} m matrix to transform with + * @returns {ReturnType.Vec2} out + */ + export function transformMat3(out: T, a: ReadonlyVec2, m: ReadonlyMat3): ReturnType.Vec2; + /** + * Transforms the vec2 with a mat4 + * 3rd vector component is implicitly '0' + * 4th vector component is implicitly '1' + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat4} m matrix to transform with + * @returns {ReturnType.Vec2} out + */ + export function transformMat4(out: T, a: ReadonlyVec2, m: ReadonlyMat4): ReturnType.Vec2; + /** + * Rotate a 2D vector + * @template {vec2} T + * @param {T} out The receiving vec2 + * @param {ReadonlyVec2} a The vec2 point to rotate + * @param {ReadonlyVec2} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @returns {ReturnType.Vec2} out + */ + export function rotate(out: T, a: ReadonlyVec2, b: ReadonlyVec2, rad: number): ReturnType.Vec2; + /** + * Get the smallest angle between two 2D vectors + * @param {ReadonlyVec2} a The first operand + * @param {ReadonlyVec2} b The second operand + * @returns {Number} The angle in radians + */ + export function angle(a: ReadonlyVec2, b: ReadonlyVec2): number; + /** + * Get the signed angle in the interval [-pi,pi] between two 2D vectors (positive if `a` is to the right of `b`) + * + * @param {ReadonlyVec2} a The first vector + * @param {ReadonlyVec2} b The second vector + * @returns {number} The signed angle in radians + */ + export function signedAngle(a: ReadonlyVec2, b: ReadonlyVec2): number; + /** + * Set the components of a vec2 to zero + * + * @template {vec2} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec2} out + */ + export function zero(out: T): ReturnType.Vec2; + /** + * Returns a string representation of a vector + * + * @param {ReadonlyVec2} a vector to represent as a string + * @returns {String} string representation of the vector + */ + export function str(a: ReadonlyVec2): string; + /** + * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) + * + * @param {ReadonlyVec2} a The first vector. + * @param {ReadonlyVec2} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + export function exactEquals(a: ReadonlyVec2, b: ReadonlyVec2): boolean; + /** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {ReadonlyVec2} a The first vector. + * @param {ReadonlyVec2} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + export function equals(a: ReadonlyVec2, b: ReadonlyVec2): boolean; + /** + * Calculates the length of a vec2 + * + * @param {ReadonlyVec2} a vector to calculate length of + * @returns {Number} length of a + */ + export function len(a: ReadonlyVec2): number; + /** + * Subtracts vector b from vector a + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function sub(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * Multiplies two vec2's + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function mul(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * Divides two vec2's + * + * @template {vec2} T + * @param {T} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {ReturnType.Vec2} out + */ + export function div(out: T, a: ReadonlyVec2, b: ReadonlyVec2): ReturnType.Vec2; + /** + * Calculates the euclidian distance between two vec2's + * + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {Number} distance between a and b + */ + export function dist(a: ReadonlyVec2, b: ReadonlyVec2): number; + /** + * Calculates the squared euclidian distance between two vec2's + * + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {Number} squared distance between a and b + */ + export function sqrDist(a: ReadonlyVec2, b: ReadonlyVec2): number; + /** + * Calculates the squared length of a vec2 + * + * @param {ReadonlyVec2} a vector to calculate squared length of + * @returns {Number} squared length of a + */ + export function sqrLen(a: ReadonlyVec2): number; + export function forEach(a: any, stride: any, offset: any, count: any, fn: any, arg: any): any; +} + + +} \ No newline at end of file diff --git a/dist/package.json b/dist/package.json new file mode 100644 index 00000000..a8aa8014 --- /dev/null +++ b/dist/package.json @@ -0,0 +1,29 @@ +{ + "version": "3.4.4", + "name": "gl-matrix", + "description": "Javascript Matrix and Vector library for High Performance WebGL apps", + "sideEffects": false, + "type": "module", + "main": "./esm/index.js", + "module": "./esm/index.js", + "types": "./index.d.ts", + "homepage": "http://glmatrix.net", + "license": "MIT", + "bugs": { + "url": "https://github.com/toji/gl-matrix/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/toji/gl-matrix.git" + }, + "contributors": [ + { + "name": "Brandon Jones", + "email": "tojiro@gmail.com" + }, + { + "name": "Colin MacKenzie IV", + "email": "sinisterchipmunk@gmail.com" + } + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 8d4437ea..a16bdd7a 100644 --- a/package.json +++ b/package.json @@ -7,19 +7,6 @@ "type": "module", "main": "./dist/esm/index.js", "module": "./dist/esm/index.js", - "exports": { - ".": "./dist/esm/index.js", - "./common": "./dist/esm/common.js", - "./mat2": "./dist/esm/mat2.js", - "./mat2d": "./dist/esm/mat2d.js", - "./mat3": "./dist/esm/mat3.js", - "./mat4": "./dist/esm/mat4.js", - "./quat": "./dist/esm/quat.js", - "./quat2": "./dist/esm/quat2.js", - "./vec2": "./dist/esm/vec2.js", - "./vec3": "./dist/esm/vec3.js", - "./vec4": "./dist/esm/vec4.js" - }, "types": "./dist/index.d.ts", "homepage": "http://glmatrix.net", "license": "MIT", diff --git a/src/mat2.js b/src/mat2.js index 2a8cd39f..d9e1901b 100644 --- a/src/mat2.js +++ b/src/mat2.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new identity mat2 * - * @returns {mat2} a new 2x2 matrix + * @returns {ArrayType} a new 2x2 matrix */ export function create() { let out = new glMatrix.ARRAY_TYPE(4); @@ -25,7 +25,7 @@ export function create() { * Creates a new mat2 initialized with values from an existing matrix * * @param {ReadonlyMat2} a matrix to clone - * @returns {mat2} a new 2x2 matrix + * @returns {ArrayType} a new 2x2 matrix */ export function clone(a) { let out = new glMatrix.ARRAY_TYPE(4); @@ -39,9 +39,10 @@ export function clone(a) { /** * Copy the values from one mat2 to another * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function copy(out, a) { out[0] = a[0]; @@ -54,8 +55,9 @@ export function copy(out, a) { /** * Set a mat2 to the identity matrix * - * @param {mat2} out the receiving matrix - * @returns {mat2} out + * @template {mat2} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat2} out */ export function identity(out) { out[0] = 1; @@ -72,7 +74,7 @@ export function identity(out) { * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m10 Component in column 1, row 0 position (index 2) * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out A new 2x2 matrix + * @returns {ArrayType} out A new 2x2 matrix */ export function fromValues(m00, m01, m10, m11) { let out = new glMatrix.ARRAY_TYPE(4); @@ -86,12 +88,13 @@ export function fromValues(m00, m01, m10, m11) { /** * Set the components of a mat2 to the given values * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m10 Component in column 1, row 0 position (index 2) * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function set(out, m00, m01, m10, m11) { out[0] = m00; @@ -104,9 +107,10 @@ export function set(out, m00, m01, m10, m11) { /** * Transpose the values of a mat2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache @@ -128,9 +132,10 @@ export function transpose(out, a) { /** * Inverts a mat2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2 | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat2 | null} out, or null if source matrix is not invertible */ export function invert(out, a) { let a0 = a[0], @@ -157,9 +162,10 @@ export function invert(out, a) { /** * Calculates the adjugate of a mat2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function adjoint(out, a) { // Caching this value is necessary if out == a @@ -185,10 +191,11 @@ export function determinant(a) { /** * Multiplies two mat2's * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function multiply(out, a, b) { let a0 = a[0], @@ -209,10 +216,11 @@ export function multiply(out, a, b) { /** * Rotates a mat2 by the given angle * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function rotate(out, a, rad) { let a0 = a[0], @@ -231,10 +239,11 @@ export function rotate(out, a, rad) { /** * Scales the mat2 by the dimensions in the given vec2 * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the matrix to rotate * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out **/ export function scale(out, a, v) { let a0 = a[0], @@ -257,9 +266,10 @@ export function scale(out, a, v) { * mat2.identity(dest); * mat2.rotate(dest, dest, rad); * - * @param {mat2} out mat2 receiving operation result + * @template {mat2} T + * @param {T} out mat2 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function fromRotation(out, rad) { let s = Math.sin(rad); @@ -278,9 +288,10 @@ export function fromRotation(out, rad) { * mat2.identity(dest); * mat2.scale(dest, dest, vec); * - * @param {mat2} out mat2 receiving operation result + * @template {mat2} T + * @param {T} out mat2 receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function fromScaling(out, v) { out[0] = v[0]; @@ -329,10 +340,11 @@ export function LDU(L, D, U, a) { /** * Adds two mat2's * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -345,10 +357,11 @@ export function add(out, a, b) { /** * Subtracts matrix b from matrix a * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -400,10 +413,11 @@ export function equals(a, b) { /** * Multiply each element of the matrix by a scalar. * - * @param {mat2} out the receiving matrix + * @template {mat2} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -416,11 +430,12 @@ export function multiplyScalar(out, a, b) { /** * Adds two mat2's after multiplying each element of the second operand by a scalar value. * - * @param {mat2} out the receiving vector + * @template {mat2} T + * @param {T} out the receiving vector * @param {ReadonlyMat2} a the first operand * @param {ReadonlyMat2} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2} out + * @returns {ReturnType.Mat2} out */ export function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; diff --git a/src/mat2d.js b/src/mat2d.js index fce8aabd..f2c1e1d6 100644 --- a/src/mat2d.js +++ b/src/mat2d.js @@ -22,7 +22,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new identity mat2d * - * @returns {mat2d} a new 2x3 matrix + * @returns {ArrayType} a new 2x3 matrix */ export function create() { let out = new glMatrix.ARRAY_TYPE(6); @@ -41,7 +41,7 @@ export function create() { * Creates a new mat2d initialized with values from an existing matrix * * @param {ReadonlyMat2d} a matrix to clone - * @returns {mat2d} a new 2x3 matrix + * @returns {ArrayType} a new 2x3 matrix */ export function clone(a) { let out = new glMatrix.ARRAY_TYPE(6); @@ -57,9 +57,10 @@ export function clone(a) { /** * Copy the values from one mat2d to another * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the source matrix - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function copy(out, a) { out[0] = a[0]; @@ -74,8 +75,9 @@ export function copy(out, a) { /** * Set a mat2d to the identity matrix * - * @param {mat2d} out the receiving matrix - * @returns {mat2d} out + * @template {mat2d} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat2d} out */ export function identity(out) { out[0] = 1; @@ -96,7 +98,7 @@ export function identity(out) { * @param {Number} d Component D (index 3) * @param {Number} tx Component TX (index 4) * @param {Number} ty Component TY (index 5) - * @returns {mat2d} A new mat2d + * @returns {ArrayType} A new mat2d */ export function fromValues(a, b, c, d, tx, ty) { let out = new glMatrix.ARRAY_TYPE(6); @@ -112,14 +114,15 @@ export function fromValues(a, b, c, d, tx, ty) { /** * Set the components of a mat2d to the given values * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {Number} a Component A (index 0) * @param {Number} b Component B (index 1) * @param {Number} c Component C (index 2) * @param {Number} d Component D (index 3) * @param {Number} tx Component TX (index 4) * @param {Number} ty Component TY (index 5) - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function set(out, a, b, c, d, tx, ty) { out[0] = a; @@ -134,9 +137,10 @@ export function set(out, a, b, c, d, tx, ty) { /** * Inverts a mat2d * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the source matrix - * @returns {mat2d | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat2d | null} out, or null if source matrix is not invertible */ export function invert(out, a) { let aa = a[0], @@ -174,10 +178,11 @@ export function determinant(a) { /** * Multiplies two mat2d's * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function multiply(out, a, b) { let a0 = a[0], @@ -204,10 +209,11 @@ export function multiply(out, a, b) { /** * Rotates a mat2d by the given angle * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function rotate(out, a, rad) { let a0 = a[0], @@ -230,10 +236,11 @@ export function rotate(out, a, rad) { /** * Scales the mat2d by the dimensions in the given vec2 * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to translate * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out **/ export function scale(out, a, v) { let a0 = a[0], @@ -256,10 +263,11 @@ export function scale(out, a, v) { /** * Translates the mat2d by the dimensions in the given vec2 * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to translate * @param {ReadonlyVec2} v the vec2 to translate the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out **/ export function translate(out, a, v) { let a0 = a[0], @@ -286,9 +294,10 @@ export function translate(out, a, v) { * mat2d.identity(dest); * mat2d.rotate(dest, dest, rad); * - * @param {mat2d} out mat2d receiving operation result + * @template {mat2d} T + * @param {T} out mat2d receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function fromRotation(out, rad) { let s = Math.sin(rad), @@ -309,9 +318,10 @@ export function fromRotation(out, rad) { * mat2d.identity(dest); * mat2d.scale(dest, dest, vec); * - * @param {mat2d} out mat2d receiving operation result + * @template {mat2d} T + * @param {T} out mat2d receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function fromScaling(out, v) { out[0] = v[0]; @@ -330,9 +340,10 @@ export function fromScaling(out, v) { * mat2d.identity(dest); * mat2d.translate(dest, dest, vec); * - * @param {mat2d} out mat2d receiving operation result + * @template {mat2d} T + * @param {T} out mat2d receiving operation result * @param {ReadonlyVec2} v Translation vector - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function fromTranslation(out, v) { out[0] = 1; @@ -381,10 +392,11 @@ export function frob(a) { /** * Adds two mat2d's * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -399,10 +411,11 @@ export function add(out, a, b) { /** * Subtracts matrix b from matrix a * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -417,10 +430,11 @@ export function subtract(out, a, b) { /** * Multiply each element of the matrix by a scalar. * - * @param {mat2d} out the receiving matrix + * @template {mat2d} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -435,11 +449,12 @@ export function multiplyScalar(out, a, b) { /** * Adds two mat2d's after multiplying each element of the second operand by a scalar value. * - * @param {mat2d} out the receiving vector + * @template {mat2d} T + * @param {T} out the receiving vector * @param {ReadonlyMat2d} a the first operand * @param {ReadonlyMat2d} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2d} out + * @returns {ReturnType.Mat2d} out */ export function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; diff --git a/src/mat3.js b/src/mat3.js index 2a966eaa..de4379d9 100644 --- a/src/mat3.js +++ b/src/mat3.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new identity mat3 * - * @returns {mat3} a new 3x3 matrix + * @returns {ArrayType} a new 3x3 matrix */ export function create() { let out = new glMatrix.ARRAY_TYPE(9); @@ -29,9 +29,10 @@ export function create() { /** * Copies the upper-left 3x3 values into the given mat3. * - * @param {mat3} out the receiving 3x3 matrix + * @template {mat3} T + * @param {T} out the receiving 3x3 matrix * @param {ReadonlyMat4} a the source 4x4 matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromMat4(out, a) { out[0] = a[0]; @@ -50,7 +51,7 @@ export function fromMat4(out, a) { * Creates a new mat3 initialized with values from an existing matrix * * @param {ReadonlyMat3} a matrix to clone - * @returns {mat3} a new 3x3 matrix + * @returns {ArrayType} a new 3x3 matrix */ export function clone(a) { let out = new glMatrix.ARRAY_TYPE(9); @@ -69,9 +70,10 @@ export function clone(a) { /** * Copy the values from one mat3 to another * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function copy(out, a) { out[0] = a[0]; @@ -98,7 +100,7 @@ export function copy(out, a) { * @param {Number} m20 Component in column 2, row 0 position (index 6) * @param {Number} m21 Component in column 2, row 1 position (index 7) * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} A new mat3 + * @returns {ArrayType} A new mat3 */ export function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { let out = new glMatrix.ARRAY_TYPE(9); @@ -117,7 +119,8 @@ export function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { /** * Set the components of a mat3 to the given values * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) @@ -127,7 +130,7 @@ export function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { * @param {Number} m20 Component in column 2, row 0 position (index 6) * @param {Number} m21 Component in column 2, row 1 position (index 7) * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { out[0] = m00; @@ -145,8 +148,9 @@ export function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { /** * Set a mat3 to the identity matrix * - * @param {mat3} out the receiving matrix - * @returns {mat3} out + * @template {mat3} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat3} out */ export function identity(out) { out[0] = 1; @@ -164,9 +168,10 @@ export function identity(out) { /** * Transpose the values of a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -198,9 +203,10 @@ export function transpose(out, a) { /** * Inverts a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3 | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat3 | null} out, or null if source matrix is not invertible */ export function invert(out, a) { let a00 = a[0], @@ -240,9 +246,10 @@ export function invert(out, a) { /** * Calculates the adjugate of a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function adjoint(out, a) { let a00 = a[0], @@ -294,10 +301,11 @@ export function determinant(a) { /** * Multiplies two mat3's * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function multiply(out, a, b) { let a00 = a[0], @@ -337,10 +345,11 @@ export function multiply(out, a, b) { /** * Translate a mat3 by the given vector * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to translate * @param {ReadonlyVec2} v vector to translate by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function translate(out, a, v) { let a00 = a[0], @@ -372,10 +381,11 @@ export function translate(out, a, v) { /** * Rotates a mat3 by the given angle * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function rotate(out, a, rad) { let a00 = a[0], @@ -407,10 +417,11 @@ export function rotate(out, a, rad) { /** * Scales the mat3 by the dimensions in the given vec2 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to scale * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out **/ export function scale(out, a, v) { let x = v[0], @@ -437,9 +448,10 @@ export function scale(out, a, v) { * mat3.identity(dest); * mat3.translate(dest, dest, vec); * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyVec2} v Translation vector - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromTranslation(out, v) { out[0] = 1; @@ -461,9 +473,10 @@ export function fromTranslation(out, v) { * mat3.identity(dest); * mat3.rotate(dest, dest, rad); * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromRotation(out, rad) { let s = Math.sin(rad), @@ -490,9 +503,10 @@ export function fromRotation(out, rad) { * mat3.identity(dest); * mat3.scale(dest, dest, vec); * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromScaling(out, v) { out[0] = v[0]; @@ -512,9 +526,10 @@ export function fromScaling(out, v) { /** * Copies the values from a mat2d into a mat3 * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat2d} a the matrix to copy - * @returns {mat3} out + * @returns {ReturnType.Mat3} out **/ export function fromMat2d(out, a) { out[0] = a[0]; @@ -534,10 +549,11 @@ export function fromMat2d(out, a) { /** * Calculates a 3x3 matrix from the given quaternion * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyQuat} q Quaternion to create matrix from * - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function fromQuat(out, q) { let x = q[0], @@ -576,10 +592,11 @@ export function fromQuat(out, q) { /** * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix * - * @param {mat3} out mat3 receiving operation result + * @template {mat3} T + * @param {T} out mat3 receiving operation result * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from * - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function normalFromMat4(out, a) { let a00 = a[0], @@ -639,10 +656,11 @@ export function normalFromMat4(out, a) { /** * Generates a 2D projection matrix with the given bounds * - * @param {mat3} out mat3 frustum matrix will be written into + * @template {mat3} T + * @param {T} out mat3 frustum matrix will be written into * @param {number} width Width of your gl context * @param {number} height Height of gl context - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function projection(out, width, height) { out[0] = 2 / width; @@ -710,10 +728,11 @@ export function frob(a) { /** * Adds two mat3's * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -731,10 +750,11 @@ export function add(out, a, b) { /** * Subtracts matrix b from matrix a * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -752,10 +772,11 @@ export function subtract(out, a, b) { /** * Multiply each element of the matrix by a scalar. * - * @param {mat3} out the receiving matrix + * @template {mat3} T + * @param {T} out the receiving matrix * @param {ReadonlyMat3} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -773,11 +794,12 @@ export function multiplyScalar(out, a, b) { /** * Adds two mat3's after multiplying each element of the second operand by a scalar value. * - * @param {mat3} out the receiving vector + * @template {mat3} T + * @param {T} out the receiving vector * @param {ReadonlyMat3} a the first operand * @param {ReadonlyMat3} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat3} out + * @returns {ReturnType.Mat3} out */ export function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; diff --git a/src/mat4.js b/src/mat4.js index 206f7680..896ca717 100644 --- a/src/mat4.js +++ b/src/mat4.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new identity mat4 * - * @returns {mat4} a new 4x4 matrix + * @returns {ArrayType} a new 4x4 matrix */ export function create() { let out = new glMatrix.ARRAY_TYPE(16); @@ -37,7 +37,7 @@ export function create() { * Creates a new mat4 initialized with values from an existing matrix * * @param {ReadonlyMat4} a matrix to clone - * @returns {mat4} a new 4x4 matrix + * @returns {ArrayType} a new 4x4 matrix */ export function clone(a) { let out = new glMatrix.ARRAY_TYPE(16); @@ -63,9 +63,10 @@ export function clone(a) { /** * Copy the values from one mat4 to another * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function copy(out, a) { out[0] = a[0]; @@ -106,7 +107,7 @@ export function copy(out, a) { * @param {Number} m31 Component in column 3, row 1 position (index 13) * @param {Number} m32 Component in column 3, row 2 position (index 14) * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} A new mat4 + * @returns {ArrayType} A new mat4 */ export function fromValues( m00, @@ -149,7 +150,8 @@ export function fromValues( /** * Set the components of a mat4 to the given values * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) @@ -166,7 +168,7 @@ export function fromValues( * @param {Number} m31 Component in column 3, row 1 position (index 13) * @param {Number} m32 Component in column 3, row 2 position (index 14) * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function set( out, @@ -209,8 +211,9 @@ export function set( /** * Set a mat4 to the identity matrix * - * @param {mat4} out the receiving matrix - * @returns {mat4} out + * @template {mat4} T + * @param {T} out the receiving matrix + * @returns {ReturnType.Mat4} out */ export function identity(out) { out[0] = 1; @@ -235,9 +238,10 @@ export function identity(out) { /** * Transpose the values of a mat4 * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values @@ -286,9 +290,10 @@ export function transpose(out, a) { /** * Inverts a mat4 * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4 | null} out, or null if source matrix is not invertible + * @returns {ReturnType.Mat4 | null} out, or null if source matrix is not invertible */ export function invert(out, a) { let a00 = a[0], @@ -353,9 +358,10 @@ export function invert(out, a) { /** * Calculates the adjugate of a mat4 * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function adjoint(out, a) { let a00 = a[0], @@ -449,10 +455,11 @@ export function determinant(a) { /** * Multiplies two mat4s * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function multiply(out, a, b) { let a00 = a[0], @@ -514,10 +521,11 @@ export function multiply(out, a, b) { /** * Translate a mat4 by the given vector * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to translate * @param {ReadonlyVec3} v vector to translate by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function translate(out, a, v) { let x = v[0], @@ -571,10 +579,11 @@ export function translate(out, a, v) { /** * Scales the mat4 by the dimensions in the given vec3 not using vectorization * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to scale * @param {ReadonlyVec3} v the vec3 to scale the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out **/ export function scale(out, a, v) { let x = v[0], @@ -603,11 +612,12 @@ export function scale(out, a, v) { /** * Rotates a mat4 by the given angle around the given axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by * @param {ReadonlyVec3} axis the axis to rotate around - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function rotate(out, a, rad, axis) { let x = axis[0], @@ -686,10 +696,11 @@ export function rotate(out, a, rad, axis) { /** * Rotates a matrix by the given angle around the X axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function rotateX(out, a, rad) { let s = Math.sin(rad); @@ -730,10 +741,11 @@ export function rotateX(out, a, rad) { /** * Rotates a matrix by the given angle around the Y axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function rotateY(out, a, rad) { let s = Math.sin(rad); @@ -774,10 +786,11 @@ export function rotateY(out, a, rad) { /** * Rotates a matrix by the given angle around the Z axis * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function rotateZ(out, a, rad) { let s = Math.sin(rad); @@ -822,9 +835,10 @@ export function rotateZ(out, a, rad) { * mat4.identity(dest); * mat4.translate(dest, dest, vec); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {ReadonlyVec3} v Translation vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromTranslation(out, v) { out[0] = 1; @@ -853,9 +867,10 @@ export function fromTranslation(out, v) { * mat4.identity(dest); * mat4.scale(dest, dest, vec); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {ReadonlyVec3} v Scaling vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromScaling(out, v) { out[0] = v[0]; @@ -884,10 +899,11 @@ export function fromScaling(out, v) { * mat4.identity(dest); * mat4.rotate(dest, dest, rad, axis); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by * @param {ReadonlyVec3} axis the axis to rotate around - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromRotation(out, rad, axis) { let x = axis[0], @@ -936,9 +952,10 @@ export function fromRotation(out, rad, axis) { * mat4.identity(dest); * mat4.rotateX(dest, dest, rad); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromXRotation(out, rad) { let s = Math.sin(rad); @@ -971,9 +988,10 @@ export function fromXRotation(out, rad) { * mat4.identity(dest); * mat4.rotateY(dest, dest, rad); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromYRotation(out, rad) { let s = Math.sin(rad); @@ -1006,9 +1024,10 @@ export function fromYRotation(out, rad) { * mat4.identity(dest); * mat4.rotateZ(dest, dest, rad); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromZRotation(out, rad) { let s = Math.sin(rad); @@ -1044,10 +1063,11 @@ export function fromZRotation(out, rad) { * mat4.fromQuat(quatMat, quat); * mat4.multiply(dest, dest, quatMat); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {quat} q Rotation quaternion * @param {ReadonlyVec3} v Translation vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromRotationTranslation(out, q, v) { // Quaternion math @@ -1094,7 +1114,7 @@ export function fromRotationTranslation(out, q, v) { * * @param {mat4} out Matrix * @param {ReadonlyQuat2} a Dual Quaternion - * @returns {mat4} mat4 receiving operation result + * @returns {ArrayType} mat4 receiving operation result */ export function fromQuat2(out, a) { let translation = new glMatrix.ARRAY_TYPE(3); @@ -1229,11 +1249,12 @@ export function getRotation(out, mat) { /** * Decomposes a transformation matrix into its rotation, translation * and scale components. Returns only the rotation component + * * @param {quat} out_r Quaternion to receive the rotation component * @param {vec3} out_t Vector to receive the translation vector * @param {vec3} out_s Vector to receive the scaling factor * @param {ReadonlyMat4} mat Matrix to be decomposed (input) - * @returns {quat} out_r + * @returns {ArrayType} out_r */ export function decompose(out_r, out_t, out_s, mat) { out_t[0] = mat[12]; @@ -1311,11 +1332,12 @@ export function decompose(out_r, out_t, out_s, mat) { * mat4.multiply(dest, dest, quatMat); * mat4.scale(dest, dest, scale) * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {quat} q Rotation quaternion * @param {ReadonlyVec3} v Translation vector * @param {ReadonlyVec3} s Scaling vector - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromRotationTranslationScale(out, q, v, s) { // Quaternion math @@ -1373,12 +1395,13 @@ export function fromRotationTranslationScale(out, q, v, s) { * mat4.scale(dest, dest, scale) * mat4.translate(dest, dest, negativeOrigin); * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {quat} q Rotation quaternion * @param {ReadonlyVec3} v Translation vector * @param {ReadonlyVec3} s Scaling vector * @param {ReadonlyVec3} o The origin vector around which to scale and rotate - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromRotationTranslationScaleOrigin(out, q, v, s, o) { // Quaternion math @@ -1441,10 +1464,11 @@ export function fromRotationTranslationScaleOrigin(out, q, v, s, o) { /** * Calculates a 4x4 matrix from the given quaternion * - * @param {mat4} out mat4 receiving operation result + * @template {mat4} T + * @param {T} out mat4 receiving operation result * @param {ReadonlyQuat} q Quaternion to create matrix from * - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function fromQuat(out, q) { let x = q[0], @@ -1491,6 +1515,7 @@ export function fromQuat(out, q) { /** * Generates a frustum matrix with the given bounds * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {Number} left Left bound of the frustum * @param {Number} right Right bound of the frustum @@ -1498,7 +1523,7 @@ export function fromQuat(out, q) { * @param {Number} top Top bound of the frustum * @param {Number} near Near bound of the frustum * @param {Number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function frustum(out, left, right, bottom, top, near, far) { let rl = 1 / (right - left); @@ -1529,12 +1554,13 @@ export function frustum(out, left, right, bottom, top, near, far) { * which matches WebGL/OpenGL's clip volume. * Passing null/undefined/no value for far will generate infinite projection matrix. * - * @param {mat4} out mat4 frustum matrix will be written into + * @template {mat4} T + * @param {T} out mat4 frustum matrix will be written into * @param {number} fovy Vertical field of view in radians * @param {number} aspect Aspect ratio. typically viewport width/height * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum, can be null or Infinity - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function perspectiveNO(out, fovy, aspect, near, far) { const f = 1.0 / Math.tan(fovy / 2); @@ -1575,12 +1601,13 @@ export const perspective = perspectiveNO; * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. * Passing null/undefined/no value for far will generate infinite projection matrix. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {number} fovy Vertical field of view in radians * @param {number} aspect Aspect ratio. typically viewport width/height * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum, can be null or Infinity - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function perspectiveZO(out, fovy, aspect, near, far) { const f = 1.0 / Math.tan(fovy / 2); @@ -1614,11 +1641,12 @@ export function perspectiveZO(out, fovy, aspect, near, far) { * This is primarily useful for generating projection matrices to be used * with the still experiemental WebVR API. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function perspectiveFromFieldOfView(out, fov, near, far) { let upTan = Math.tan((fov.upDegrees * Math.PI) / 180.0); @@ -1652,6 +1680,7 @@ export function perspectiveFromFieldOfView(out, fov, near, far) { * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], * which matches WebGL/OpenGL's clip volume. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {number} left Left bound of the frustum * @param {number} right Right bound of the frustum @@ -1659,7 +1688,7 @@ export function perspectiveFromFieldOfView(out, fov, near, far) { * @param {number} top Top bound of the frustum * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function orthoNO(out, left, right, bottom, top, near, far) { const lr = 1 / (left - right); @@ -1695,6 +1724,7 @@ export const ortho = orthoNO; * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {number} left Left bound of the frustum * @param {number} right Right bound of the frustum @@ -1702,7 +1732,7 @@ export const ortho = orthoNO; * @param {number} top Top bound of the frustum * @param {number} near Near bound of the frustum * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function orthoZO(out, left, right, bottom, top, near, far) { const lr = 1 / (left - right); @@ -1731,11 +1761,12 @@ export function orthoZO(out, left, right, bottom, top, near, far) { * Generates a look-at matrix with the given eye position, focal point, and up axis. * If you want a matrix that actually makes an object look at another object, you should use targetTo instead. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {ReadonlyVec3} eye Position of the viewer * @param {ReadonlyVec3} center Point the viewer is looking at * @param {ReadonlyVec3} up vec3 pointing up - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function lookAt(out, eye, center, up) { let x0, x1, x2, y0, y1, y2, z0, z1, z2, len; @@ -1820,11 +1851,12 @@ export function lookAt(out, eye, center, up) { /** * Generates a matrix that makes something look at something else. * + * @template {mat4} T * @param {mat4} out mat4 frustum matrix will be written into * @param {ReadonlyVec3} eye Position of the viewer * @param {ReadonlyVec3} target Point the viewer is looking at * @param {ReadonlyVec3} up vec3 pointing up - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function targetTo(out, eye, target, up) { let eyex = eye[0], @@ -1951,10 +1983,11 @@ export function frob(a) { /** * Adds two mat4's * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -1979,10 +2012,11 @@ export function add(out, a, b) { /** * Subtracts matrix b from matrix a * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -2007,10 +2041,11 @@ export function subtract(out, a, b) { /** * Multiply each element of the matrix by a scalar. * - * @param {mat4} out the receiving matrix + * @template {mat4} T + * @param {T} out the receiving matrix * @param {ReadonlyMat4} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -2035,11 +2070,12 @@ export function multiplyScalar(out, a, b) { /** * Adds two mat4's after multiplying each element of the second operand by a scalar value. * - * @param {mat4} out the receiving vector + * @template {mat4} T + * @param {T} out the receiving vector * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat4} out + * @returns {ReturnType.Mat4} out */ export function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; diff --git a/src/quat.js b/src/quat.js index 6f917a1c..b59a2459 100644 --- a/src/quat.js +++ b/src/quat.js @@ -11,7 +11,7 @@ import * as vec4 from "./vec4.js"; /** * Creates a new identity quat * - * @returns {quat} a new quaternion + * @returns {ReturnType.Quat} a new quaternion */ export function create() { let out = new glMatrix.ARRAY_TYPE(4); @@ -27,8 +27,9 @@ export function create() { /** * Set a quat to the identity quaternion * - * @param {quat} out the receiving quaternion - * @returns {quat} out + * @template {quat} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat} out */ export function identity(out) { out[0] = 0; @@ -42,10 +43,11 @@ export function identity(out) { * Sets a quat from the given angle and rotation axis, * then returns it. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyVec3} axis the axis around which to rotate * @param {Number} rad the angle in radians - * @returns {quat} out + * @returns {ReturnType.Quat} out **/ export function setAxisAngle(out, axis, rad) { rad = rad * 0.5; @@ -102,10 +104,11 @@ export function getAngle(a, b) { /** * Multiplies two quat's * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function multiply(out, a, b) { let ax = a[0], @@ -127,10 +130,11 @@ export function multiply(out, a, b) { /** * Rotates a quaternion by the given angle about the X axis * - * @param {quat} out quat receiving operation result + * @template {quat} T + * @param {T} out quat receiving operation result * @param {ReadonlyQuat} a quat to rotate * @param {number} rad angle (in radians) to rotate - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function rotateX(out, a, rad) { rad *= 0.5; @@ -152,10 +156,11 @@ export function rotateX(out, a, rad) { /** * Rotates a quaternion by the given angle about the Y axis * - * @param {quat} out quat receiving operation result + * @template {quat} T + * @param {T} out quat receiving operation result * @param {ReadonlyQuat} a quat to rotate * @param {number} rad angle (in radians) to rotate - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function rotateY(out, a, rad) { rad *= 0.5; @@ -177,10 +182,11 @@ export function rotateY(out, a, rad) { /** * Rotates a quaternion by the given angle about the Z axis * - * @param {quat} out quat receiving operation result + * @template {quat} T + * @param {T} out quat receiving operation result * @param {ReadonlyQuat} a quat to rotate * @param {number} rad angle (in radians) to rotate - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function rotateZ(out, a, rad) { rad *= 0.5; @@ -204,9 +210,10 @@ export function rotateZ(out, a, rad) { * Assumes that quaternion is 1 unit in length. * Any existing W component will be ignored. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate W component of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function calculateW(out, a) { let x = a[0], @@ -223,9 +230,10 @@ export function calculateW(out, a) { /** * Calculate the exponential of a unit quaternion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate the exponential of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function exp(out, a) { let x = a[0], @@ -248,9 +256,10 @@ export function exp(out, a) { /** * Calculate the natural logarithm of a unit quaternion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate the exponential of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function ln(out, a) { let x = a[0], @@ -272,10 +281,11 @@ export function ln(out, a) { /** * Calculate the scalar power of a unit quaternion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate the exponential of * @param {Number} b amount to scale the quaternion by - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function pow(out, a, b) { ln(out, a); @@ -287,11 +297,12 @@ export function pow(out, a, b) { /** * Performs a spherical linear interpolation between two quat * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function slerp(out, a, b, t) { // benchmarks: @@ -342,8 +353,9 @@ export function slerp(out, a, b, t) { /** * Generates a random unit quaternion * - * @param {quat} out the receiving quaternion - * @returns {quat} out + * @template {quat} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat} out */ export function random(out) { // Implementation of http://planning.cs.uiuc.edu/node198.html @@ -365,9 +377,10 @@ export function random(out) { /** * Calculates the inverse of a quat * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate inverse of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function invert(out, a) { let a0 = a[0], @@ -390,9 +403,10 @@ export function invert(out, a) { * Calculates the conjugate of a quat * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quat to calculate conjugate of - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export function conjugate(out, a) { out[0] = -a[0]; @@ -408,9 +422,10 @@ export function conjugate(out, a) { * NOTE: The resultant quaternion is not normalized, so you should be sure * to renormalize the quaternion yourself where necessary. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyMat3} m rotation matrix - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export function fromMat3(out, m) { @@ -449,12 +464,13 @@ export function fromMat3(out, m) { /** * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion. * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {Number} x Angle to rotate around X axis in degrees. * @param {Number} y Angle to rotate around Y axis in degrees. * @param {Number} z Angle to rotate around Z axis in degrees. * @param {'xyz'|'xzy'|'yxz'|'yzx'|'zxy'|'zyx'} order Intrinsic order for conversion, default is zyx. - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export function fromEuler(out, x, y, z, order = glMatrix.ANGLE_ORDER) { @@ -534,7 +550,7 @@ export function str(a) { * Creates a new quat initialized with values from an existing quaternion * * @param {ReadonlyQuat} a quaternion to clone - * @returns {quat} a new quaternion + * @returns {ReturnType.Quat} a new quaternion * @function */ export const clone = vec4.clone; @@ -546,7 +562,7 @@ export const clone = vec4.clone; * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {quat} a new quaternion + * @returns {ReturnType.Quat} a new quaternion * @function */ export const fromValues = vec4.fromValues; @@ -554,9 +570,10 @@ export const fromValues = vec4.fromValues; /** * Copy the values from one quat to another * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the source quaternion - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export const copy = vec4.copy; @@ -564,12 +581,13 @@ export const copy = vec4.copy; /** * Set the components of a quat to the given values * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export const set = vec4.set; @@ -577,10 +595,11 @@ export const set = vec4.set; /** * Adds two quat's * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export const add = vec4.add; @@ -594,10 +613,11 @@ export const mul = multiply; /** * Scales a quat by a scalar number * - * @param {quat} out the receiving vector + * @template {quat} T + * @param {T} out the receiving vector * @param {ReadonlyQuat} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export const scale = vec4.scale; @@ -615,11 +635,12 @@ export const dot = vec4.dot; /** * Performs a linear interpolation between two quat's * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export const lerp = vec4.lerp; @@ -656,9 +677,10 @@ export const sqrLen = squaredLength; /** * Normalize a quat * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a quaternion to normalize - * @returns {quat} out + * @returns {ReturnType.Quat} out * @function */ export const normalize = vec4.normalize; @@ -691,10 +713,11 @@ export function equals(a, b) { * * Both vectors are assumed to be unit length. * - * @param {quat} out the receiving quaternion. + * @template {quat} T + * @param {T} out the receiving quaternion. * @param {ReadonlyVec3} a the initial vector * @param {ReadonlyVec3} b the destination vector - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export const rotationTo = (function () { let tmpvec3 = vec3.create(); @@ -729,13 +752,14 @@ export const rotationTo = (function () { /** * Performs a spherical linear interpolation with two control points * - * @param {quat} out the receiving quaternion + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} a the first operand * @param {ReadonlyQuat} b the second operand * @param {ReadonlyQuat} c the third operand * @param {ReadonlyQuat} d the fourth operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export const sqlerp = (function () { let temp1 = create(); @@ -755,10 +779,12 @@ export const sqlerp = (function () { * axes. Each axis is a vec3 and is expected to be unit length and * perpendicular to all other specified axes. * + * @template {quat} T + * @param {T} out the receiving quaternion * @param {ReadonlyVec3} view the vector representing the viewing direction * @param {ReadonlyVec3} right the vector representing the local "right" direction * @param {ReadonlyVec3} up the vector representing the local "up" direction - * @returns {quat} out + * @returns {ReturnType.Quat} out */ export const setAxes = (function () { let matr = mat3.create(); diff --git a/src/quat2.js b/src/quat2.js index 8774a094..48edb89e 100644 --- a/src/quat2.js +++ b/src/quat2.js @@ -1,6 +1,6 @@ import * as glMatrix from "./common.js"; -import * as quat from "./quat.js"; import * as mat4 from "./mat4.js"; +import * as quat from "./quat.js"; /** * Dual Quaternion
@@ -13,7 +13,7 @@ import * as mat4 from "./mat4.js"; /** * Creates a new identity dual quat * - * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation] + * @returns {ArrayType} a new dual quaternion [real -> rotation, dual -> translation] */ export function create() { let dq = new glMatrix.ARRAY_TYPE(8); @@ -34,7 +34,7 @@ export function create() { * Creates a new quat initialized with values from an existing quaternion * * @param {ReadonlyQuat2} a dual quaternion to clone - * @returns {quat2} new dual quaternion + * @returns {ArrayType} new dual quaternion * @function */ export function clone(a) { @@ -61,7 +61,7 @@ export function clone(a) { * @param {Number} y2 Y component * @param {Number} z2 Z component * @param {Number} w2 W component - * @returns {quat2} new dual quaternion + * @returns {ArrayType} new dual quaternion * @function */ export function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) { @@ -87,7 +87,7 @@ export function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) { * @param {Number} x2 X component (translation) * @param {Number} y2 Y component (translation) * @param {Number} z2 Z component (translation) - * @returns {quat2} new dual quaternion + * @returns {ArrayType} new dual quaternion * @function */ export function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) { @@ -109,10 +109,11 @@ export function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) { /** * Creates a dual quat from a quaternion and a translation * - * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result * @param {ReadonlyQuat} q a normalized quaternion * @param {ReadonlyVec3} t translation vector - * @returns {quat2} dual quaternion receiving operation result + * @returns {ReturnType.Quat2} dual quaternion receiving operation result * @function */ export function fromRotationTranslation(out, q, t) { @@ -137,9 +138,10 @@ export function fromRotationTranslation(out, q, t) { /** * Creates a dual quat from a translation * - * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result * @param {ReadonlyVec3} t translation vector - * @returns {quat2} dual quaternion receiving operation result + * @returns {ReturnType.Quat2} dual quaternion receiving operation result * @function */ export function fromTranslation(out, t) { @@ -157,9 +159,10 @@ export function fromTranslation(out, t) { /** * Creates a dual quat from a quaternion * - * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @template {quat2} T + * @param {T} out dual quaternion receiving operation result * @param {ReadonlyQuat} q the quaternion - * @returns {quat2} dual quaternion receiving operation result + * @returns {ReturnType.Quat2} dual quaternion receiving operation result * @function */ export function fromRotation(out, q) { @@ -177,9 +180,10 @@ export function fromRotation(out, q) { /** * Creates a new dual quat from a matrix (4x4) * - * @param {quat2} out the dual quaternion + * @template {quat2} T + * @param {T} out the dual quaternion * @param {ReadonlyMat4} a the matrix - * @returns {quat2} dual quat receiving operation result + * @returns {ReturnType.Quat2} dual quat receiving operation result * @function */ export function fromMat4(out, a) { @@ -195,9 +199,10 @@ export function fromMat4(out, a) { /** * Copy the values from one dual quat to another * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the source dual quaternion - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function copy(out, a) { @@ -215,8 +220,9 @@ export function copy(out, a) { /** * Set a dual quat to the identity dual quaternion * - * @param {quat2} out the receiving quaternion - * @returns {quat2} out + * @template {quat2} T + * @param {T} out the receiving quaternion + * @returns {ReturnType.Quat2} out */ export function identity(out) { out[0] = 0; @@ -233,7 +239,8 @@ export function identity(out) { /** * Set the components of a dual quat to the given values * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {Number} x1 X component * @param {Number} y1 Y component * @param {Number} z1 Z component @@ -242,7 +249,7 @@ export function identity(out) { * @param {Number} y2 Y component * @param {Number} z2 Z component * @param {Number} w2 W component - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function set(out, x1, y1, z1, w1, x2, y2, z2, w2) { @@ -283,9 +290,10 @@ export function getDual(out, a) { /** * Set the real component of a dual quat to the given quaternion * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} q a quaternion representing the real part - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export const setReal = quat.copy; @@ -293,9 +301,10 @@ export const setReal = quat.copy; /** * Set the dual component of a dual quat to the given quaternion * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat} q a quaternion representing the dual part - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function setDual(out, q) { @@ -330,10 +339,11 @@ export function getTranslation(out, a) { /** * Translates a dual quat by the given vector * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to translate * @param {ReadonlyVec3} v vector to translate by - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function translate(out, a, v) { let ax1 = a[0], @@ -361,10 +371,11 @@ export function translate(out, a, v) { /** * Rotates a dual quat around the X axis * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {number} rad how far should the rotation be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateX(out, a, rad) { let bx = -a[0], @@ -394,10 +405,11 @@ export function rotateX(out, a, rad) { /** * Rotates a dual quat around the Y axis * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {number} rad how far should the rotation be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateY(out, a, rad) { let bx = -a[0], @@ -427,10 +439,11 @@ export function rotateY(out, a, rad) { /** * Rotates a dual quat around the Z axis * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {number} rad how far should the rotation be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateZ(out, a, rad) { let bx = -a[0], @@ -460,10 +473,11 @@ export function rotateZ(out, a, rad) { /** * Rotates a dual quat by a given quaternion (a * q) * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {ReadonlyQuat} q quaternion to rotate by - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateByQuatAppend(out, a, q) { let qx = q[0], @@ -493,10 +507,11 @@ export function rotateByQuatAppend(out, a, q) { /** * Rotates a dual quat by a given quaternion (q * a) * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat} q quaternion to rotate by * @param {ReadonlyQuat2} a the dual quaternion to rotate - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateByQuatPrepend(out, q, a) { let qx = q[0], @@ -526,11 +541,12 @@ export function rotateByQuatPrepend(out, q, a) { /** * Rotates a dual quat around a given axis. Does the normalisation automatically * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the dual quaternion to rotate * @param {ReadonlyVec3} axis the axis to rotate around * @param {Number} rad how far the rotation should be - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function rotateAroundAxis(out, a, axis, rad) { //Special case for rad = 0 @@ -570,10 +586,11 @@ export function rotateAroundAxis(out, a, axis, rad) { /** * Adds two dual quat's * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the first operand * @param {ReadonlyQuat2} b the second operand - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function add(out, a, b) { @@ -591,10 +608,11 @@ export function add(out, a, b) { /** * Multiplies two dual quat's * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a the first operand * @param {ReadonlyQuat2} b the second operand - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function multiply(out, a, b) { let ax0 = a[0], @@ -665,10 +683,11 @@ export const mul = multiply; /** * Scales a dual quat by a scalar number * - * @param {quat2} out the receiving dual quat + * @template {quat2} T + * @param {T} out the receiving dual quat * @param {ReadonlyQuat2} a the dual quat to scale * @param {Number} b amount to scale the dual quat by - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function scale(out, a, b) { @@ -697,11 +716,12 @@ export const dot = quat.dot; * Performs a linear interpolation between two dual quats's * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5) * - * @param {quat2} out the receiving dual quat + * @template {quat2} T + * @param {T} out the receiving dual quat * @param {ReadonlyQuat2} a the first operand * @param {ReadonlyQuat2} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function lerp(out, a, b, t) { let mt = 1 - t; @@ -722,9 +742,10 @@ export function lerp(out, a, b, t) { /** * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a dual quat to calculate inverse of - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function invert(out, a) { let sqlen = squaredLength(a); @@ -743,9 +764,10 @@ export function invert(out, a) { * Calculates the conjugate of a dual quat * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result. * - * @param {quat2} out the receiving quaternion + * @template {quat2} T + * @param {T} out the receiving quaternion * @param {ReadonlyQuat2} a quat to calculate conjugate of - * @returns {quat2} out + * @returns {ReturnType.Quat2} out */ export function conjugate(out, a) { out[0] = -a[0]; @@ -792,9 +814,10 @@ export const sqrLen = squaredLength; /** * Normalize a dual quat * - * @param {quat2} out the receiving dual quaternion + * @template {quat2} T + * @param {T} out the receiving dual quaternion * @param {ReadonlyQuat2} a dual quaternion to normalize - * @returns {quat2} out + * @returns {ReturnType.Quat2} out * @function */ export function normalize(out, a) { diff --git a/src/types.d.ts b/src/types.d.ts index 58237b88..e276e91a 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,94 +1,137 @@ -interface IndexedCollection extends Iterable { - readonly length: number; - [index: number]: number; -} - -// prettier-ignore -declare type mat2 = - | [number, number, - number, number] - | IndexedCollection; - -// prettier-ignore -declare type mat2d = - | [number, number, - number, number, - number, number] - | IndexedCollection; - -// prettier-ignore -declare type mat3 = - | [number, number, number, - number, number, number, - number, number, number] - | IndexedCollection; - -// prettier-ignore -declare type mat4 = - | [number, number, number, number, - number, number, number, number, - number, number, number, number, - number, number, number, number] - | IndexedCollection; - -declare type quat = [number, number, number, number] | IndexedCollection; +/** + * Users can augment this interface to override the default array type + * + * @example + * declare module "gl-matrix" { + * interface Overrides { + * ArrayType: Float64Array + * } + * } + */ +interface Overrides { } -// prettier-ignore -declare type quat2 = - | [number, number, number, number, - number, number, number, number] - | IndexedCollection; +/** + * Users can override `ArrayType` by augmenting `gl-matrix` module + * + * @example + * declare module "gl-matrix" { + * interface Overrides { + * ArrayType: Float64Array + * } + * } + */ +declare type ArrayType = Overrides extends { ArrayType: infer T } ? T : Float32Array -declare type vec2 = [number, number] | IndexedCollection; -declare type vec3 = [number, number, number] | IndexedCollection; -declare type vec4 = [number, number, number, number] | IndexedCollection; - -// prettier-ignore -declare type ReadonlyMat2 = - | readonly [ - number, number, - number, number - ] - | IndexedCollection; - -// prettier-ignore -declare type ReadonlyMat2d = - | readonly [ - number, number, - number, number, - number, number - ] - | IndexedCollection; +interface IndexedCollection extends Iterable { + readonly length: number; + [index: number]: number; +} -// prettier-ignore -declare type ReadonlyMat3 = - | readonly [ - number, number, number, - number, number, number, - number, number, number - ] - | IndexedCollection; +declare namespace Tuple { + // prettier-ignore + export type Mat2 = [ + number, number, + number, number + ] + // prettier-ignore + export type Mat2d = [ + number, number, + number, number, + number, number + ] + // prettier-ignore + export type Mat3 = [ + number, number, number, + number, number, number, + number, number, number + ] + // prettier-ignore + export type Mat4 = [ + number, number, number, number, + number, number, number, number, + number, number, number, number, + number, number, number, number + ] + export type Quat = [number, number, number, number] + // prettier-ignore + export type Quat2 = [ + number, number, number, number, + number, number, number, number + ] + export type Vec2 = [number, number] + export type Vec3 = [number, number, number] + export type Vec4 = [number, number, number, number] -// prettier-ignore -declare type ReadonlyMat4 = - | readonly [ - number, number, number, number, - number, number, number, number, - number, number, number, number, - number, number, number, number - ] - | IndexedCollection; + // prettier-ignore + export type ReadonlyMat2 = readonly [ + number, number, + number, number + ] + // prettier-ignore + export type ReadonlyMat2d = readonly [ + number, number, + number, number, + number, number + ] + // prettier-ignore + export type ReadonlyMat3 = readonly [ + number, number, number, + number, number, number, + number, number, number + ] + // prettier-ignore + export type ReadonlyMat4 = readonly [ + number, number, number, number, + number, number, number, number, + number, number, number, number, + number, number, number, number + ] + export type ReadonlyQuat = readonly [number, number, number, number] + // prettier-ignore + export type ReadonlyQuat2 = readonly [ + number, number, number, number, + number, number, number, number + ] + export type ReadonlyVec2 = readonly [number, number] + export type ReadonlyVec3 = readonly [number, number, number]; + export type ReadonlyVec4 = readonly [number, number, number, number]; +} -declare type ReadonlyQuat = - | readonly [number, number, number, number] - | IndexedCollection; +/** + * Return type utilities. Narrows Array to Tuple types, preserves other types. + * + * @example + * const result = mat4.copy([], mat4.create()); // Tuple.Mat4 + * const result2 = mat4.copy(new Float32Array(16), mat4.create()); // Float32Array + */ +declare namespace ReturnType { + export type Mat2 = T extends Array ? Tuple.Mat2 : T + export type Mat2d = T extends Array ? Tuple.Mat2d : T + export type Mat3 = T extends Array ? Tuple.Mat3 : T + export type Mat4 = T extends Array ? Tuple.Mat4 : T + export type Quat = T extends Array ? Tuple.Quat : T + export type Quat2 = T extends Array ? Tuple.Quat2 : T + export type Vec2 = T extends Array ? Tuple.Vec2 : T + export type Vec3 = T extends Array ? Tuple.Vec3 : T + export type Vec4 = T extends Array ? Tuple.Vec4 : T +} -declare type ReadonlyQuat2 = - | readonly [number, number, number, number, number, number, number, number] - | IndexedCollection; +declare type mat2 = IndexedCollection | Tuple.Mat2; +declare type mat2d = IndexedCollection | Tuple.Mat2d; +declare type mat3 = IndexedCollection | Tuple.Mat3; +declare type mat4 = IndexedCollection | Tuple.Mat4; +declare type quat = IndexedCollection | Tuple.Quat; +declare type quat2 = IndexedCollection | Tuple.Quat2; +declare type vec2 = IndexedCollection | Tuple.Vec2; +declare type vec3 = IndexedCollection | Tuple.Vec3; +declare type vec4 = IndexedCollection | Tuple.Vec4; -declare type ReadonlyVec2 = readonly [number, number] | IndexedCollection; -declare type ReadonlyVec3 = readonly [number, number, number] | IndexedCollection; -declare type ReadonlyVec4 = - | readonly [number, number, number, number] - | IndexedCollection; +declare type ReadonlyMat2 = IndexedCollection | Tuple.ReadonlyMat2; +declare type ReadonlyMat2d = IndexedCollection | Tuple.ReadonlyMat2d; +declare type ReadonlyMat3 = IndexedCollection | Tuple.ReadonlyMat3; +declare type ReadonlyMat4 = IndexedCollection | Tuple.ReadonlyMat4; +declare type ReadonlyQuat = IndexedCollection | Tuple.ReadonlyQuat; +declare type ReadonlyQuat2 = IndexedCollection | Tuple.ReadonlyQuat2; +declare type ReadonlyVec2 = IndexedCollection | Tuple.ReadonlyVec2; +declare type ReadonlyVec3 = IndexedCollection | Tuple.ReadonlyVec3; +declare type ReadonlyVec4 = IndexedCollection | Tuple.ReadonlyVec4; diff --git a/src/vec2.js b/src/vec2.js index 76b851a8..e676c856 100644 --- a/src/vec2.js +++ b/src/vec2.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new, empty vec2 * - * @returns {vec2} a new 2D vector + * @returns {ArrayType} a new 2D vector */ export function create() { let out = new glMatrix.ARRAY_TYPE(2); @@ -23,7 +23,7 @@ export function create() { * Creates a new vec2 initialized with values from an existing vector * * @param {ReadonlyVec2} a vector to clone - * @returns {vec2} a new 2D vector + * @returns {ArrayType} a new 2D vector */ export function clone(a) { let out = new glMatrix.ARRAY_TYPE(2); @@ -37,7 +37,7 @@ export function clone(a) { * * @param {Number} x X component * @param {Number} y Y component - * @returns {vec2} a new 2D vector + * @returns {ArrayType} a new 2D vector */ export function fromValues(x, y) { let out = new glMatrix.ARRAY_TYPE(2); @@ -49,9 +49,10 @@ export function fromValues(x, y) { /** * Copy the values from one vec2 to another * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the source vector - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function copy(out, a) { out[0] = a[0]; @@ -62,10 +63,11 @@ export function copy(out, a) { /** * Set the components of a vec2 to the given values * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {Number} x X component * @param {Number} y Y component - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function set(out, x, y) { out[0] = x; @@ -76,10 +78,11 @@ export function set(out, x, y) { /** * Adds two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -90,10 +93,11 @@ export function add(out, a, b) { /** * Subtracts vector b from vector a * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -104,10 +108,11 @@ export function subtract(out, a, b) { /** * Multiplies two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function multiply(out, a, b) { out[0] = a[0] * b[0]; @@ -118,10 +123,11 @@ export function multiply(out, a, b) { /** * Divides two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function divide(out, a, b) { out[0] = a[0] / b[0]; @@ -132,9 +138,10 @@ export function divide(out, a, b) { /** * Math.ceil the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to ceil - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function ceil(out, a) { out[0] = Math.ceil(a[0]); @@ -145,9 +152,10 @@ export function ceil(out, a) { /** * Math.floor the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to floor - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function floor(out, a) { out[0] = Math.floor(a[0]); @@ -158,10 +166,11 @@ export function floor(out, a) { /** * Returns the minimum of two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function min(out, a, b) { out[0] = Math.min(a[0], b[0]); @@ -172,10 +181,11 @@ export function min(out, a, b) { /** * Returns the maximum of two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function max(out, a, b) { out[0] = Math.max(a[0], b[0]); @@ -186,9 +196,10 @@ export function max(out, a, b) { /** * symmetric round the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to round - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function round(out, a) { out[0] = glMatrix.round(a[0]); @@ -199,10 +210,11 @@ export function round(out, a) { /** * Scales a vec2 by a scalar number * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function scale(out, a, b) { out[0] = a[0] * b; @@ -213,11 +225,12 @@ export function scale(out, a, b) { /** * Adds two vec2's after scaling the second operand by a scalar value * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -278,9 +291,10 @@ export function squaredLength(a) { /** * Negates the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to negate - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function negate(out, a) { out[0] = -a[0]; @@ -291,9 +305,10 @@ export function negate(out, a) { /** * Returns the inverse of the components of a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to invert - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function inverse(out, a) { out[0] = 1.0 / a[0]; @@ -304,9 +319,10 @@ export function inverse(out, a) { /** * Normalize a vec2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a vector to normalize - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function normalize(out, a) { var x = a[0], @@ -336,10 +352,11 @@ export function dot(a, b) { * Computes the cross product of two vec2's * Note that the cross product must by definition produce a 3D vector * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec2} out */ export function cross(out, a, b) { var z = a[0] * b[1] - a[1] * b[0]; @@ -351,11 +368,12 @@ export function cross(out, a, b) { /** * Performs a linear interpolation between two vec2's * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the first operand * @param {ReadonlyVec2} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function lerp(out, a, b, t) { var ax = a[0], @@ -368,9 +386,10 @@ export function lerp(out, a, b, t) { /** * Generates a random vector with the given scale * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function random(out, scale) { scale = scale === undefined ? 1.0 : scale; @@ -383,10 +402,11 @@ export function random(out, scale) { /** * Transforms the vec2 with a mat2 * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat2} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function transformMat2(out, a, m) { var x = a[0], @@ -399,10 +419,11 @@ export function transformMat2(out, a, m) { /** * Transforms the vec2 with a mat2d * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat2d} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function transformMat2d(out, a, m) { var x = a[0], @@ -416,10 +437,11 @@ export function transformMat2d(out, a, m) { * Transforms the vec2 with a mat3 * 3rd vector component is implicitly '1' * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat3} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function transformMat3(out, a, m) { var x = a[0], @@ -434,10 +456,11 @@ export function transformMat3(out, a, m) { * 3rd vector component is implicitly '0' * 4th vector component is implicitly '1' * - * @param {vec2} out the receiving vector + * @template {vec2} T + * @param {T} out the receiving vector * @param {ReadonlyVec2} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function transformMat4(out, a, m) { let x = a[0]; @@ -449,11 +472,12 @@ export function transformMat4(out, a, m) { /** * Rotate a 2D vector - * @param {vec2} out The receiving vec2 + * @template {vec2} T + * @param {T} out The receiving vec2 * @param {ReadonlyVec2} a The vec2 point to rotate * @param {ReadonlyVec2} b The origin of the rotation * @param {Number} rad The angle of rotation in radians - * @returns {vec2} out + * @returns {ReturnType.Vec2} out */ export function rotate(out, a, b, rad) { //Translate point to the origin @@ -498,8 +522,9 @@ export function signedAngle(a, b) { /** * Set the components of a vec2 to zero * - * @param {vec2} out the receiving vector - * @returns {vec2} out + * @template {vec2} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec2} out */ export function zero(out) { out[0] = 0.0; diff --git a/src/vec3.js b/src/vec3.js index c54c5fab..0fe8ffdf 100644 --- a/src/vec3.js +++ b/src/vec3.js @@ -8,7 +8,7 @@ import * as glMatrix from "./common.js"; /** * Creates a new, empty vec3 * - * @returns {vec3} a new 3D vector + * @returns {ArrayType} a new 3D vector */ export function create() { let out = new glMatrix.ARRAY_TYPE(3); @@ -24,7 +24,7 @@ export function create() { * Creates a new vec3 initialized with values from an existing vector * * @param {ReadonlyVec3} a vector to clone - * @returns {vec3} a new 3D vector + * @returns {ArrayType} a new 3D vector */ export function clone(a) { var out = new glMatrix.ARRAY_TYPE(3); @@ -53,7 +53,7 @@ export function length(a) { * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component - * @returns {vec3} a new 3D vector + * @returns {ArrayType} a new 3D vector */ export function fromValues(x, y, z) { let out = new glMatrix.ARRAY_TYPE(3); @@ -66,9 +66,10 @@ export function fromValues(x, y, z) { /** * Copy the values from one vec3 to another * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the source vector - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function copy(out, a) { out[0] = a[0]; @@ -80,11 +81,12 @@ export function copy(out, a) { /** * Set the components of a vec3 to the given values * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function set(out, x, y, z) { out[0] = x; @@ -96,10 +98,11 @@ export function set(out, x, y, z) { /** * Adds two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -111,10 +114,11 @@ export function add(out, a, b) { /** * Subtracts vector b from vector a * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -126,10 +130,11 @@ export function subtract(out, a, b) { /** * Multiplies two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function multiply(out, a, b) { out[0] = a[0] * b[0]; @@ -141,10 +146,11 @@ export function multiply(out, a, b) { /** * Divides two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function divide(out, a, b) { out[0] = a[0] / b[0]; @@ -156,9 +162,10 @@ export function divide(out, a, b) { /** * Math.ceil the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to ceil - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function ceil(out, a) { out[0] = Math.ceil(a[0]); @@ -170,9 +177,10 @@ export function ceil(out, a) { /** * Math.floor the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to floor - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function floor(out, a) { out[0] = Math.floor(a[0]); @@ -184,10 +192,11 @@ export function floor(out, a) { /** * Returns the minimum of two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function min(out, a, b) { out[0] = Math.min(a[0], b[0]); @@ -199,10 +208,11 @@ export function min(out, a, b) { /** * Returns the maximum of two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function max(out, a, b) { out[0] = Math.max(a[0], b[0]); @@ -214,9 +224,10 @@ export function max(out, a, b) { /** * symmetric round the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to round - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function round(out, a) { out[0] = glMatrix.round(a[0]); @@ -228,10 +239,11 @@ export function round(out, a) { /** * Scales a vec3 by a scalar number * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function scale(out, a, b) { out[0] = a[0] * b; @@ -243,11 +255,12 @@ export function scale(out, a, b) { /** * Adds two vec3's after scaling the second operand by a scalar value * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -300,9 +313,10 @@ export function squaredLength(a) { /** * Negates the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to negate - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function negate(out, a) { out[0] = -a[0]; @@ -314,9 +328,10 @@ export function negate(out, a) { /** * Returns the inverse of the components of a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to invert - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function inverse(out, a) { out[0] = 1.0 / a[0]; @@ -328,9 +343,10 @@ export function inverse(out, a) { /** * Normalize a vec3 * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a vector to normalize - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function normalize(out, a) { let x = a[0]; @@ -361,10 +377,11 @@ export function dot(a, b) { /** * Computes the cross product of two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function cross(out, a, b) { let ax = a[0], @@ -383,11 +400,12 @@ export function cross(out, a, b) { /** * Performs a linear interpolation between two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function lerp(out, a, b, t) { let ax = a[0]; @@ -402,11 +420,12 @@ export function lerp(out, a, b, t) { /** * Performs a spherical linear interpolation between two vec3's * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function slerp(out, a, b, t) { let angle = Math.acos(Math.min(Math.max(dot(a, b), -1), 1)); @@ -424,13 +443,14 @@ export function slerp(out, a, b, t) { /** * Performs a hermite interpolation with two control points * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {ReadonlyVec3} c the third operand * @param {ReadonlyVec3} d the fourth operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function hermite(out, a, b, c, d, t) { let factorTimes2 = t * t; @@ -449,13 +469,14 @@ export function hermite(out, a, b, c, d, t) { /** * Performs a bezier interpolation with two control points * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the first operand * @param {ReadonlyVec3} b the second operand * @param {ReadonlyVec3} c the third operand * @param {ReadonlyVec3} d the fourth operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function bezier(out, a, b, c, d, t) { let inverseFactor = 1 - t; @@ -476,9 +497,10 @@ export function bezier(out, a, b, c, d, t) { /** * Generates a random vector with the given scale * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function random(out, scale) { scale = scale === undefined ? 1.0 : scale; @@ -497,10 +519,11 @@ export function random(out, scale) { * Transforms the vec3 with a mat4. * 4th vector component is implicitly '1' * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function transformMat4(out, a, m) { let x = a[0], @@ -517,10 +540,11 @@ export function transformMat4(out, a, m) { /** * Transforms the vec3 with a mat3. * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to transform * @param {ReadonlyMat3} m the 3x3 matrix to transform with - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function transformMat3(out, a, m) { let x = a[0], @@ -536,10 +560,11 @@ export function transformMat3(out, a, m) { * Transforms the vec3 with a quat * Can also be used for dual quaternions. (Multiply it with the real part) * - * @param {vec3} out the receiving vector + * @template {vec3} T + * @param {T} out the receiving vector * @param {ReadonlyVec3} a the vector to transform * @param {ReadonlyQuat} q normalized quaternion to transform with - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function transformQuat(out, a, q) { @@ -575,11 +600,12 @@ export function transformQuat(out, a, q) { /** * Rotate a 3D vector around the x-axis - * @param {vec3} out The receiving vec3 + * @template {vec3} T + * @param {T} out The receiving vec3 * @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 - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function rotateX(out, a, b, rad) { let p = [], @@ -604,11 +630,12 @@ export function rotateX(out, a, b, rad) { /** * Rotate a 3D vector around the y-axis - * @param {vec3} out The receiving vec3 + * @template {vec3} T + * @param {T} out The receiving vec3 * @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 - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function rotateY(out, a, b, rad) { let p = [], @@ -633,11 +660,12 @@ export function rotateY(out, a, b, rad) { /** * Rotate a 3D vector around the z-axis - * @param {vec3} out The receiving vec3 + * @template {vec3} T + * @param {T} out The receiving vec3 * @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 - * @returns {vec3} out + * @returns {ReturnType.Vec3} out */ export function rotateZ(out, a, b, rad) { let p = [], @@ -681,8 +709,9 @@ export function angle(a, b) { /** * Set the components of a vec3 to zero * - * @param {vec3} out the receiving vector - * @returns {vec3} out + * @template {vec3} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec3} out */ export function zero(out) { out[0] = 0.0; diff --git a/src/vec4.js b/src/vec4.js index 6044df0a..a368c04c 100644 --- a/src/vec4.js +++ b/src/vec4.js @@ -3,12 +3,12 @@ import * as glMatrix from "./common.js"; /** * 4 Dimensional Vector * @module vec4 - */ +*/ /** * Creates a new, empty vec4 * - * @returns {vec4} a new 4D vector + * @returns {ArrayType} a new 4D vector */ export function create() { let out = new glMatrix.ARRAY_TYPE(4); @@ -25,7 +25,7 @@ export function create() { * Creates a new vec4 initialized with values from an existing vector * * @param {ReadonlyVec4} a vector to clone - * @returns {vec4} a new 4D vector + * @returns {ArrayType} a new 4D vector */ export function clone(a) { let out = new glMatrix.ARRAY_TYPE(4); @@ -43,7 +43,7 @@ export function clone(a) { * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {vec4} a new 4D vector + * @returns {ArrayType} a new 4D vector */ export function fromValues(x, y, z, w) { let out = new glMatrix.ARRAY_TYPE(4); @@ -57,9 +57,10 @@ export function fromValues(x, y, z, w) { /** * Copy the values from one vec4 to another * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the source vector - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function copy(out, a) { out[0] = a[0]; @@ -72,12 +73,13 @@ export function copy(out, a) { /** * Set the components of a vec4 to the given values * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component * @param {Number} w W component - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function set(out, x, y, z, w) { out[0] = x; @@ -90,10 +92,11 @@ export function set(out, x, y, z, w) { /** * Adds two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function add(out, a, b) { out[0] = a[0] + b[0]; @@ -106,10 +109,11 @@ export function add(out, a, b) { /** * Subtracts vector b from vector a * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -122,10 +126,11 @@ export function subtract(out, a, b) { /** * Multiplies two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function multiply(out, a, b) { out[0] = a[0] * b[0]; @@ -138,10 +143,11 @@ export function multiply(out, a, b) { /** * Divides two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function divide(out, a, b) { out[0] = a[0] / b[0]; @@ -154,9 +160,10 @@ export function divide(out, a, b) { /** * Math.ceil the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to ceil - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function ceil(out, a) { out[0] = Math.ceil(a[0]); @@ -169,9 +176,10 @@ export function ceil(out, a) { /** * Math.floor the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to floor - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function floor(out, a) { out[0] = Math.floor(a[0]); @@ -184,10 +192,11 @@ export function floor(out, a) { /** * Returns the minimum of two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function min(out, a, b) { out[0] = Math.min(a[0], b[0]); @@ -200,10 +209,11 @@ export function min(out, a, b) { /** * Returns the maximum of two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function max(out, a, b) { out[0] = Math.max(a[0], b[0]); @@ -216,9 +226,10 @@ export function max(out, a, b) { /** * symmetric round the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to round - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function round(out, a) { out[0] = glMatrix.round(a[0]); @@ -231,10 +242,11 @@ export function round(out, a) { /** * Scales a vec4 by a scalar number * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function scale(out, a, b) { out[0] = a[0] * b; @@ -247,11 +259,12 @@ export function scale(out, a, b) { /** * Adds two vec4's after scaling the second operand by a scalar value * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; @@ -322,9 +335,10 @@ export function squaredLength(a) { /** * Negates the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to negate - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function negate(out, a) { out[0] = -a[0]; @@ -337,9 +351,10 @@ export function negate(out, a) { /** * Returns the inverse of the components of a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to invert - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function inverse(out, a) { out[0] = 1.0 / a[0]; @@ -352,9 +367,10 @@ export function inverse(out, a) { /** * Normalize a vec4 * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a vector to normalize - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function normalize(out, a) { let x = a[0]; @@ -386,11 +402,12 @@ export function dot(a, b) { /** * Returns the cross-product of three vectors in a 4-dimensional space * - * @param {ReadonlyVec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} u the first vector * @param {ReadonlyVec4} v the second vector * @param {ReadonlyVec4} w the third vector - * @returns {vec4} result + * @returns {ReturnType.Vec4} result */ export function cross(out, u, v, w) { let A = v[0] * w[1] - v[1] * w[0], @@ -415,11 +432,12 @@ export function cross(out, u, v, w) { /** * Performs a linear interpolation between two vec4's * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the first operand * @param {ReadonlyVec4} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function lerp(out, a, b, t) { let ax = a[0]; @@ -436,9 +454,10 @@ export function lerp(out, a, b, t) { /** * Generates a random vector with the given scale * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function random(out, scale) { scale = scale === undefined ? 1.0 : scale; @@ -471,10 +490,11 @@ export function random(out, scale) { /** * Transforms the vec4 with a mat4. * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function transformMat4(out, a, m) { let x = a[0], @@ -491,10 +511,11 @@ export function transformMat4(out, a, m) { /** * Transforms the vec4 with a quat * - * @param {vec4} out the receiving vector + * @template {vec4} T + * @param {T} out the receiving vector * @param {ReadonlyVec4} a the vector to transform * @param {ReadonlyQuat} q normalized quaternion to transform with - * @returns {vec4} out + * @returns {ReturnType.Vec4} out */ export function transformQuat(out, a, q) { @@ -531,8 +552,9 @@ export function transformQuat(out, a, q) { /** * Set the components of a vec4 to zero * - * @param {vec4} out the receiving vector - * @returns {vec4} out + * @template {vec4} T + * @param {T} out the receiving vector + * @returns {ReturnType.Vec4} out */ export function zero(out) { out[0] = 0.0;