@vertexvis/geometry 0.24.3-testing.0 → 0.24.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.esm.min.js","sources":["../../src/math.ts","../../src/point.ts","../../src/angle.ts","../../../../node_modules/tslib/tslib.es6.js","../../src/matrix4.ts","../../src/euler.ts","../../src/quaternion.ts","../../src/vector3.ts","../../src/boundingBox.ts","../../src/boundingSphere.ts","../../src/rectangle.ts","../../src/dimensions.ts","../../src/line3.ts","../../src/matrix.ts","../../src/matrix2.ts","../../src/plane.ts","../../src/ray.ts","../../src/vector4.ts"],"sourcesContent":["/**\n * Clamps the given value between `min` and `max`.\n *\n * @param value The value to clamp.\n * @param min The min possible value.\n * @param max The max possible value.\n * @returns `value` or a value clamped to `min` or `max`.\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value));\n}\n\n/**\n * Linear interpolates a value between `a` and `b` by `t`. If `t` is 0, then the\n * result will be `a`. If `t` is 1, then the result will be `b`. `t` will be\n * clamped to a value between 0 and 1.\n *\n * @param a The start value.\n * @param b The end value.\n * @param t The interpolation value between 0 and 1.\n * @returns The interpolated value between `a` and `b`.\n */\nexport function lerp(a: number, b: number, t: number): number {\n t = clamp(t, 0, 1);\n return t * (b - a) + a;\n}\n","import * as Angle from './angle';\nimport { lerp as lerpNumber } from './math';\n\n/**\n * A `Point` represents a cartesian coordinate with a horizontal and vertical\n * position or length.\n */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * Returns a new `Point` with the given horizontal and vertical position.\n */\nexport function create(x = 0, y = 0): Point {\n return { x, y };\n}\n\n/**\n * Converts a polar coordinate (length and angle) into a Cartesian coordinate.\n */\nexport function polar(length: number, radians: Angle.Angle): Point {\n const x = Math.cos(radians) * length;\n const y = Math.sin(radians) * length;\n return create(x, y);\n}\n\n/**\n * Returns the distance between two points.\n */\nexport function distance(a: Point, b: Point): number {\n const delta = subtract(a, b);\n return Math.sqrt(delta.x * delta.x + delta.y * delta.y);\n}\n\n/**\n * Returns a new `Point` where `b` is subtracted from `a`.\n */\nexport function subtract(a: Point, b: Point): Point {\n return { x: a.x - b.x, y: a.y - b.y };\n}\n\n/**\n * Returns a new `Point` where `b` is added to `a`.\n */\nexport function add(a: Point, b: Point): Point {\n return { x: a.x + b.x, y: a.y + b.y };\n}\n\n/**\n * Returns `true` if the `x` and `y` positions of `a` and `b` are equal.\n */\nexport function isEqual(a: Point, b: Point): boolean {\n return a.x === b.x && a.y === b.y;\n}\n\n/**\n * Performs a linear interpolation between `a` and `b` and returns the result.\n * The value of `t` is clamped between `[0, 1]`.\n *\n * @param a The start value.\n * @param b The end value.\n * @param t A value between 0 and 1.\n * @returns A point between `a` and `b`.\n */\nexport function lerp(a: Point, b: Point, t: number): Point {\n return {\n x: lerpNumber(a.x, b.x, t),\n y: lerpNumber(a.y, b.y, t),\n };\n}\n\n/**\n * Returns a new `Point` where `x` and `y` are inverted.\n */\nexport function negate(pt: Point): Point {\n return create(-pt.x, -pt.y);\n}\n\n/**\n * Returns a new `Point` where `x` and `y` are multiplied by the given scale\n * factors.\n */\nexport function scale(pt: Point, scaleX: number, scaleY: number): Point {\n return {\n x: pt.x * scaleX,\n y: pt.y * scaleY,\n };\n}\n\n/**\n * Returns a new `Point` where `x` and `y` are multiplied by the given scale\n * factor.\n */\nexport function scaleProportional(pt: Point, scale: number): Point {\n return {\n x: pt.x * scale,\n y: pt.y * scale,\n };\n}\n\n/**\n * Returns the magnitude of a point.\n */\nexport function magnitude(pt: Point): number {\n return Math.sqrt(pt.x * pt.x + pt.y * pt.y);\n}\n\n/**\n * Transforms a vector into the corresponding normal (unit) vector.\n */\nexport function normalizeVector(pt: Point): Point {\n const magnitudeOfPoint = magnitude(pt);\n if (magnitudeOfPoint === 0) {\n return create(0, 0);\n } else {\n return scaleProportional(pt, 1 / magnitudeOfPoint);\n }\n}\n\n/**\n * Returns a new normal (unit) vector pointing between the two given points.\n */\nexport function normalDirectionVector(ptA: Point, ptB: Point): Point {\n return normalizeVector(subtract(ptB, ptA));\n}\n\n/**\n * Returns a vector orthogonal to the vector between the two given points.\n */\nexport function orthogonalVector(ptA: Point, ptB: Point): Point {\n const unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);\n\n // Handle vectors that are parallel to the x or y axis\n if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {\n return create(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);\n }\n\n if (\n Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)\n ) {\n const vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);\n const vectorYValue =\n -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;\n return normalizeVector(create(vectorXValue, vectorYValue));\n } else {\n const vectorXValue =\n -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;\n const vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);\n return normalizeVector(create(vectorXValue, vectorYValue));\n }\n}\n\n/**\n * Parses a JSON string representation of a Point and returns an object.\n *\n * @param json A JSON string, either in the form `[x,y]` or `{\"x\": 0, \"y\": 0}`\n * @returns A parsed Point.\n */\nexport function fromJson(json: string): Point {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y] = obj;\n return create(x, y);\n } else {\n const { x, y } = obj;\n return create(x, y);\n }\n}\n","import * as Point from './point';\n\nexport type Angle = number;\n\n/**\n * Returns an `Angle` between two points, in radians.\n *\n * @param a The starting point.\n * @param b The ending point.\n * @returns An angle in radians.\n */\nexport function fromPoints(a: Point.Point, b: Point.Point): Angle {\n const delta = Point.subtract(b, a);\n const theta = Math.atan2(delta.y, delta.x);\n return theta;\n}\n\n/**\n * Returns an `Angle` between two points, in degrees.\n *\n * An angle of 0 represents an upward vector, and increases in a clockwise\n * direction.\n *\n * @deprecated Use {@link fromPoints} instead.\n */\nexport function fromPointsInDegrees(a: Point.Point, b: Point.Point): Angle {\n const delta = Point.subtract(b, a);\n const theta = Math.atan2(delta.y, delta.x);\n return normalize(toDegrees(theta) - 270);\n}\n\n/**\n * Normalizes the given angle, in degrees, to a number greater than or equal to 0 and less than 360.\n */\nexport function normalize(degrees: Angle): Angle {\n return (degrees + 3600) % 360;\n}\n\n/**\n * Normalizes the given angle, in radians, to a number greater than or equal to 0 and less than 2 PI.\n */\nexport function normalizeRadians(radians: Angle): Angle {\n return toRadians(normalize(toDegrees(radians)));\n}\n\n/**\n * Converts the given radians to degrees.\n */\nexport function toDegrees(radians: Angle): Angle {\n return radians * (180 / Math.PI);\n}\n\n/**\n * Converts the given degrees to radians.\n */\nexport function toRadians(degrees: Angle): Angle {\n return degrees * (Math.PI / 180);\n}\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import * as Angle from './angle';\nimport * as Quaternion from './quaternion';\nimport * as Vector3 from './vector3';\n\n/**\n * A type alias representing a 4x4 column-major matrix.\n *\n * The common use-case for 4x4 matrices in 3D computer graphics are for\n * [transformation\n * matrices](https://en.wikipedia.org/wiki/Transformation_matrix). This allows a\n * point in 3D space to be projected onto a 2D screen using transformations such\n * as translation, rotation and scale.\n */\nexport type Matrix4 = [\n /* eslint-disable prettier/prettier */\n number, number, number, number,\n number, number, number, number,\n number, number, number, number,\n number, number, number, number,\n /* eslint-enable prettier/prettier */\n];\n\n/**\n * An object representation of a `Matrix4`, where each value is represented as:\n *\n * ```\n * m11 m12 m13 m14\n * m21 m22 m23 m24\n * m31 m32 m33 m34\n * m41 m42 m43 m44\n * ```\n *\n * `Matrix4` arrays can be converted to an object using {@link toObject}.\n */\nexport interface Matrix4AsObject {\n m11: number;\n m12: number;\n m13: number;\n m14: number;\n\n m21: number;\n m22: number;\n m23: number;\n m24: number;\n\n m31: number;\n m32: number;\n m33: number;\n m34: number;\n\n m41: number;\n m42: number;\n m43: number;\n m44: number;\n}\n\n/**\n * Creates a 4x4 matrix from a set of row-major components.\n */\nexport function fromValues(\n /* eslint-disable prettier/prettier */\n m11: number, m12: number, m13: number, m14: number,\n m21: number, m22: number, m23: number, m24: number,\n m31: number, m32: number, m33: number, m34: number,\n m41: number, m42: number, m43: number, m44: number,\n /* eslint-enable prettier/prettier */\n): Matrix4 {\n /* eslint-disable prettier/prettier */\n return [\n m11, m21, m31, m41,\n m12, m22, m32, m42,\n m13, m23, m33, m43,\n m14, m24, m34, m44,\n ]\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a `Matrix4` from an object representation.\n */\nexport function fromObject(obj: Matrix4AsObject): Matrix4 {\n /* eslint-disable prettier/prettier */\n return fromValues(\n obj.m11, obj.m12, obj.m13, obj.m14,\n obj.m21, obj.m22, obj.m23, obj.m24,\n obj.m31, obj.m32, obj.m33, obj.m34,\n obj.m41, obj.m42, obj.m43, obj.m44\n );\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Returns a new [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix).\n */\nexport function makeIdentity(): Matrix4 {\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n}\n\n/**\n * Returns a matrix with all values as 0.\n */\nexport function makeZero(): Matrix4 {\n return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n}\n\n/**\n * Creates a translation matrix.\n *\n * ```\n * 1, 0, 0, 0,\n * 0, 1, 0, 0,\n * 0, 0, 1, 0,\n * x, y, z, 1\n * ```\n *\n * @param translation A vector representing the translation components.\n * @returns A translation matrix.\n */\nexport function makeTranslation(translation: Vector3.Vector3): Matrix4 {\n const { x, y, z } = translation;\n /* eslint-disable prettier/prettier */\n return [\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n x, y, z, 1,\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a rotation matrix.\n *\n * ```\n * 1-2y²-2z², 2xy-2zw, 2xz+2yw, 0,\n * 2xy+2zw, 1-2x²-2z², 2yz-2xw, 0,\n * 2xz-2yw, 2yz+2xw, 1-2x²-2y², 0,\n * 0, 0, 0, 1,\n * ```\n *\n * @param rotation A quaternion representing the rotation.\n * @see https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion\n * @returns A rotation matrix.\n */\nexport function makeRotation(rotation: Quaternion.Quaternion): Matrix4 {\n const { x, y, z, w } = rotation;\n\n const x2 = x + x,\n y2 = y + y,\n z2 = z + z;\n const xx = x * x2,\n xy = x * y2,\n xz = x * z2;\n const yy = y * y2,\n yz = y * z2,\n zz = z * z2;\n const wx = w * x2,\n wy = w * y2,\n wz = w * z2;\n\n /* eslint-disable prettier/prettier */\n return [\n 1 - ( yy + zz ), xy + wz, xz - wy, 0,\n xy - wz, 1 - ( xx + zz ), yz + wx, 0,\n xz + wy, yz - wx, 1 - ( xx + yy ), 0,\n 0, 0, 0, 1\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a scale matrix.\n *\n * ```\n * x, 0, 0, 0,\n * 0, y, 0, 0,\n * 0, 0, z, 0,\n * 0, 0, 0, 1\n * ```\n *\n * @param scale A vector representing the different scale components.\n * @returns A scale matrix.\n */\nexport function makeScale(scale: Vector3.Vector3): Matrix4 {\n const { x, y, z } = scale;\n /* eslint-disable prettier/prettier */\n return [\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1,\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a matrix that has translation, rotation and scale applied to it.\n *\n * @param translation The translation applied to the matrix.\n * @param rotation The rotation applied to the matrix.\n * @param scale The scale applied to the matrix.\n * @returns A transformed matrix.\n */\nexport function makeTRS(\n translation: Vector3.Vector3,\n rotation: Quaternion.Quaternion,\n scale: Vector3.Vector3\n): Matrix4 {\n const t = makeTranslation(translation);\n const r = makeRotation(rotation);\n const s = makeScale(scale);\n return multiply(multiply(t, r), s);\n}\n\n/**\n * Returns a matrix that has the basis components (upper left 3x3 matrix) set to\n * the following x, y, and z axis.\n *\n * ```\n * x.x y.x z.x 0\n * x.y y.y z.y 0\n * x.z y.z z.z 0\n * 0 0 0 0\n * ```\n *\n * @param x The x axis to set.\n * @param y The y axis to set.\n * @param z The z axis to set.\n * @returns A matrix with its basis components populated.\n */\nexport function makeBasis(\n x: Vector3.Vector3,\n y: Vector3.Vector3,\n z: Vector3.Vector3\n): Matrix4 {\n /* eslint-disable prettier/prettier */\n return [\n x.x, x.y, x.z, 0,\n y.x, y.y, y.z, 0,\n z.x, z.y, z.z, 0,\n 0, 0, 0, 1\n ]\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a rotation matrix that is rotated around a given axis by the given\n * angle.\n *\n * @param axis The axis of rotation.\n * @param radians The angle of rotation.\n * @returns A rotation matrix.\n */\nexport function makeRotationAxis(\n axis: Vector3.Vector3,\n radians: number\n): Matrix4 {\n const c = Math.cos(radians);\n const s = Math.sin(radians);\n const t = 1 - c;\n\n const { x, y, z } = axis;\n\n const tx = t * x;\n const ty = t * y;\n\n /* eslint-disable prettier/prettier */\n return [\n tx * x + c, tx * y + s * z, tx * z - s * y, 0,\n tx * y - s * z, ty * y + c, ty * z + s * x, 0,\n tx * z + s * y, ty * z - s * x, t * z * z + c, 0,\n 0, 0, 0, 1\n ]\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a matrix used for [perspective\n * projections](https://en.wikipedia.org/wiki/3D_projection#Perspective_projection).\n *\n * The viewing volume is frustum-shaped and defined by the six parameters. Left,\n * right, top, and bottom specify coordinates in the near clipping plane where\n * the frustum edges intersect it, and the near and far parameters define the\n * forward distances of the view volume. The resulting volume can be vertically\n * and horizontally asymmetrical around the center of the near plane.\n *\n * @param left The left coordinate at the near plane.\n * @param right The right coordinate at the near plane.\n * @param top The top coordinate at the near plane.\n * @param bottom The bottom coordinate at the near plane.\n * @param near The near distance.\n * @param far The far distance.\n * @returns A matrix representing a view frustum.\n */\nexport function makeFrustum(\n left: number,\n right: number,\n top: number,\n bottom: number,\n near: number,\n far: number\n): Matrix4 {\n const x = (2 * near) / (right - left);\n const y = (2 * near) / (top - bottom);\n\n const a = (right + left) / (right - left);\n const b = (top + bottom) / (top - bottom);\n const c = -(far + near) / (far - near);\n const d = (-2 * far * near) / (far - near);\n\n /* eslint-disable prettier/prettier */\n return [\n x, 0, 0, 0,\n 0, y, 0, 0,\n a, b, c, -1,\n 0, 0, d, 0\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a perspective projection matrix.\n *\n * Related to: gluPerspective. The viewing volume is frustum-shaped amd defined\n * by the four parameters. The fovy and aspect ratio are used to compute the\n * positions of the left, right, top, and bottom sides of the viewing volume in\n * the zNear plane. The fovy is the y field-of-view, the angle made by the top\n * and bottom sides of frustum if they were to intersect. The aspect ratio is\n * the width of the frustum divided by its height. Note that the resulting\n * volume is both vertically and horizontally symmetrical around the center of\n * the near plane.\n *\n * @param near The near Z value.\n * @param far The far Z value.\n * @param fovY The field of view.\n * @param aspect The aspect ratio.\n * @returns A matrix.\n */\nexport function makePerspective(\n near: number,\n far: number,\n fovY: number,\n aspect: number\n): Matrix4 {\n const ymax = near * Math.tan(Angle.toRadians(fovY / 2.0));\n const xmax = ymax * aspect;\n\n const left = -xmax;\n const right = xmax;\n const top = ymax;\n const bottom = -ymax;\n\n return makeFrustum(left, right, top, bottom, near, far);\n}\n\n/**\n * Creates an orthographic projection matrix.\n *\n * Related to: gluOrtho. The viewing volume is cube-shaped and defined by\n * the six parameters. The left and right values represent the coordinates of\n * the vertical clipping planes, top and bottom values represent the coordinates\n * of the horizontal clipping planes, and near and far values represent the\n * coordinates of the depth clipping planes.\n *\n * @param left The coordinate of the left horizontal clipping plane.\n * @param right The coordinate of the right horizontal clipping plane.\n * @param bottom The coordinate of the bottom vertical clipping plane.\n * @param top The coordinate of the top vertical clipping plane.\n * @param near The coordinate of the near depth clipping plane.\n * @param far The coordinate of the far depth clipping plane.\n * @returns A matrix.\n */\nexport function makeOrthographic(\n left: number,\n right: number,\n bottom: number,\n top: number,\n near: number,\n far: number\n): Matrix4 {\n const w = 1.0 / (right - left);\n const h = 1.0 / (top - bottom);\n const d = 1.0 / (far - near);\n\n const x = (right + left) * w;\n const y = (top + bottom) * h;\n const z = (far + near) * d;\n\n /* eslint-disable prettier/prettier */\n return [\n 2 * w, 0, 0, -x,\n 0, 2 * h, 0, -y,\n 0, 0, -2 * d, -z,\n 0, 0, 0, 1\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Matrix becomes a combination of an inverse translation and rotation.\n *\n * Related to: gluLookAt. This creates the inverse of makeLookAtMatrix. The\n * matrix will be an opposite translation from the 'eye' position, and it will\n * rotate things in the opposite direction of the eye-to-center orientation.\n * This is definitely confusing, but the main reason to use this transform is to\n * set up a view matrix for a camera that's looking at a certain point. To\n * achieve the effect of moving the camera somewhere and rotating it so that it\n * points at something, the rest of the world is moved in the opposite direction\n * and rotated in the opposite way around the camera. This way, you get the same\n * effect as moving the actual camera, but all the projection math can still be\n * done with the camera positioned at the origin (which makes it way simpler).\n *\n * @param position The position of the object.\n * @param lookAt The point which the object is looking at.\n * @param up The direction which the object considers up.\n * @returns A matrix.\n */\nexport function makeLookAtView(\n position: Vector3.Vector3,\n lookAt: Vector3.Vector3,\n up: Vector3.Vector3\n): Matrix4 {\n const z = Vector3.normalize(Vector3.subtract(position, lookAt));\n const x = Vector3.normalize(Vector3.cross(up, z));\n const y = Vector3.cross(z, x);\n\n const dotX = -Vector3.dot(x, position);\n const dotY = -Vector3.dot(y, position);\n const dotZ = -Vector3.dot(z, position);\n\n /* eslint-disable prettier/prettier */\n return [\n x.x, y.x, z.x, 0,\n x.y, y.y, z.y, 0,\n x.z, y.z, z.z, 0,\n dotX, dotY, dotZ, 1,\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Matrix becomes a combination of translation and rotation.\n *\n * Matrix becomes a combination of a translation to the position of 'eye' and a\n * rotation matrix which orients an object to point towards 'center' along its\n * z-axis. Use this function if you want an object to look at a point from\n * another point in space.\n *\n * @param position The position of the object.\n * @param lookAt The point which the object is looking at.\n * @param up The direction which the object considers up.\n * @returns A matrix.\n */\nexport function makeLookAt(\n position: Vector3.Vector3,\n lookAt: Vector3.Vector3,\n up: Vector3.Vector3\n): Matrix4 {\n const z = Vector3.normalize(Vector3.subtract(position, lookAt));\n const x = Vector3.normalize(Vector3.cross(up, z));\n const y = Vector3.cross(z, x);\n\n /* eslint-disable prettier/prettier */\n return [\n x.x, x.y, x.z, 0,\n y.x, y.y, y.z, 0,\n z.x, z.y, z.z, 0,\n position.x, position.y, position.z, 1\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Returns the inverse of the given matrix. If the determinate of the matrix is\n * zero, then a zero matrix is returned.\n */\nexport function invert(matrix: Matrix4): Matrix4 {\n const a00 = matrix[0],\n a01 = matrix[1],\n a02 = matrix[2],\n a03 = matrix[3];\n const a10 = matrix[4],\n a11 = matrix[5],\n a12 = matrix[6],\n a13 = matrix[7];\n const a20 = matrix[8],\n a21 = matrix[9],\n a22 = matrix[10],\n a23 = matrix[11];\n const a30 = matrix[12],\n a31 = matrix[13],\n a32 = matrix[14],\n a33 = matrix[15];\n\n const b00 = a00 * a11 - a01 * a10;\n const b01 = a00 * a12 - a02 * a10;\n const b02 = a00 * a13 - a03 * a10;\n const b03 = a01 * a12 - a02 * a11;\n const b04 = a01 * a13 - a03 * a11;\n const b05 = a02 * a13 - a03 * a12;\n const b06 = a20 * a31 - a21 * a30;\n const b07 = a20 * a32 - a22 * a30;\n const b08 = a20 * a33 - a23 * a30;\n const b09 = a21 * a32 - a22 * a31;\n const b10 = a21 * a33 - a23 * a31;\n const b11 = a22 * a33 - a23 * a32;\n\n // Calculate the determinant\n let det =\n b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return makeZero();\n }\n det = 1.0 / det;\n\n return [\n (a11 * b11 - a12 * b10 + a13 * b09) * det,\n (a02 * b10 - a01 * b11 - a03 * b09) * det,\n (a31 * b05 - a32 * b04 + a33 * b03) * det,\n (a22 * b04 - a21 * b05 - a23 * b03) * det,\n\n (a12 * b08 - a10 * b11 - a13 * b07) * det,\n (a00 * b11 - a02 * b08 + a03 * b07) * det,\n (a32 * b02 - a30 * b05 - a33 * b01) * det,\n (a20 * b05 - a22 * b02 + a23 * b01) * det,\n\n (a10 * b10 - a11 * b08 + a13 * b06) * det,\n (a01 * b08 - a00 * b10 - a03 * b06) * det,\n (a30 * b04 - a31 * b02 + a33 * b00) * det,\n (a21 * b02 - a20 * b04 - a23 * b00) * det,\n\n (a11 * b07 - a10 * b09 - a12 * b06) * det,\n (a00 * b09 - a01 * b07 + a02 * b06) * det,\n (a31 * b01 - a30 * b03 - a32 * b00) * det,\n (a20 * b03 - a21 * b01 + a22 * b00) * det,\n ];\n}\n\n/**\n * Returns a rotation matrix looking from position towards target and oriented\n * by an up vector.\n *\n * @param m The matrix to transform.\n * @param position The point from which to look at target.\n * @param target The point to look at.\n * @param up The orientation.\n * @returns A rotation matrix.\n */\nexport function lookAt(\n m: Matrix4,\n position: Vector3.Vector3,\n target: Vector3.Vector3,\n up: Vector3.Vector3\n): Matrix4 {\n let z = Vector3.subtract(position, target);\n if (Vector3.magnitudeSquared(z) === 0) {\n z = { ...z, z: 1 };\n }\n z = Vector3.normalize(z);\n\n let x = Vector3.cross(up, z);\n if (Vector3.magnitudeSquared(x) === 0) {\n if (Math.abs(up.z) === 1) {\n z = { ...z, x: z.x + 0.0001 };\n } else {\n z = { ...z, z: z.z + 0.0001 };\n }\n\n z = Vector3.normalize(z);\n x = Vector3.cross(up, z);\n }\n x = Vector3.normalize(x);\n\n const y = Vector3.cross(z, x);\n\n const res: Matrix4 = [...m];\n /* eslint-disable prettier/prettier */\n res[0] = x.x; res[4] = y.x; res[8] = z.x;\n res[1] = x.y; res[5] = y.y; res[9] = z.y;\n res[2] = x.z; res[6] = y.z; res[10] = z.z;\n /* eslint-enable prettier/prettier */\n return res;\n}\n\n/**\n * Returns a post-multiplied matrix.\n */\nexport function multiply(a: Matrix4, b: Matrix4): Matrix4 {\n const ae = a;\n const be = b;\n\n const a11 = ae[0],\n a12 = ae[4],\n a13 = ae[8],\n a14 = ae[12];\n const a21 = ae[1],\n a22 = ae[5],\n a23 = ae[9],\n a24 = ae[13];\n const a31 = ae[2],\n a32 = ae[6],\n a33 = ae[10],\n a34 = ae[14];\n const a41 = ae[3],\n a42 = ae[7],\n a43 = ae[11],\n a44 = ae[15];\n\n const b11 = be[0],\n b12 = be[4],\n b13 = be[8],\n b14 = be[12];\n const b21 = be[1],\n b22 = be[5],\n b23 = be[9],\n b24 = be[13];\n const b31 = be[2],\n b32 = be[6],\n b33 = be[10],\n b34 = be[14];\n const b41 = be[3],\n b42 = be[7],\n b43 = be[11],\n b44 = be[15];\n\n const mat = makeIdentity();\n mat[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n mat[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n mat[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n mat[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\n mat[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n mat[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n mat[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n mat[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\n mat[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n mat[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n mat[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n mat[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\n mat[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n mat[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n mat[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n mat[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\n return mat;\n}\n\n/**\n * Returns the [transpose](https://en.wikipedia.org/wiki/Transpose) of the given\n * matrix.\n */\nexport function transpose(matrix: Matrix4): Matrix4 {\n /* eslint-disable prettier/prettier */\n return [\n matrix[0], matrix[4], matrix[8], matrix[12],\n matrix[1], matrix[5], matrix[9], matrix[13],\n matrix[2], matrix[6], matrix[10], matrix[14],\n matrix[3], matrix[7], matrix[11], matrix[15],\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Multiplies the columns of a matrix by the given vector.\n */\nexport function scale(matrix: Matrix4, scale: Vector3.Vector3): Matrix4 {\n const { x, y, z } = scale;\n const m: Matrix4 = [...matrix];\n /* eslint-disable prettier/prettier */\n m[0] *= x; m[4] *= y; m[8] *= z;\n m[1] *= x; m[5] *= y; m[9] *= z;\n m[2] *= x; m[6] *= y; m[10] *= z;\n m[3] *= x; m[7] *= y; m[11] *= z;\n /* eslint-enable prettier/prettier */\n return m;\n}\n\nexport function position(matrix: Matrix4, other: Matrix4): Matrix4 {\n const m: Matrix4 = [...matrix];\n m[12] = other[12];\n m[13] = other[13];\n m[14] = other[14];\n return m;\n}\n\n/**\n * Returns true if the matrix is an identity matrix.\n */\nexport function isIdentity(matrix: Matrix4): boolean {\n const identity = makeIdentity();\n\n return matrix.every((v, i) => v === identity[i]);\n}\n\n/**\n * Returns an object representation of a `Matrix4`.\n */\nexport function toObject(m: Matrix4): Matrix4AsObject {\n /* eslint-disable prettier/prettier */\n return {\n m11: m[0], m12: m[4], m13: m[8], m14: m[12],\n m21: m[1], m22: m[5], m23: m[9], m24: m[13],\n m31: m[2], m32: m[6], m33: m[10], m34: m[14],\n m41: m[3], m42: m[7], m43: m[11], m44: m[15],\n }\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * A type guard to check if `obj` is of type `Matrix4`.\n */\nexport function isType(obj: unknown): obj is Matrix4 {\n return Array.isArray(obj) && obj.length === 16;\n}\n","import * as Angle from './angle';\nimport { clamp } from './math';\nimport * as Matrix4 from './matrix4';\n\n/**\n * A string representing the axis order of rotation.\n */\nexport type EulerOrder = 'xyz' | 'yzx' | 'zxy' | 'xzy' | 'yxz' | 'zyx';\n\n/**\n * A type that represents [Euler Angles](http://en.wikipedia.org/wiki/Euler_angles).\n */\nexport interface Euler {\n x: number;\n y: number;\n z: number;\n order: EulerOrder;\n}\n\n/**\n * Creates a new euler angle where each axis of rotation is defined by an angle,\n * in radians. If no value is given, then `{x: 0, y: 0, z: 0, order: 'xyz'}` is\n * returned.\n *\n * @param value The values to populate the euler angle with.\n * @returns A euler angle.\n */\nexport function create(value: Partial<Euler> = {}): Euler {\n return {\n x: value.x ?? 0,\n y: value.y ?? 0,\n z: value.z ?? 0,\n order: value.order ?? 'xyz',\n };\n}\n\n/**\n * Creates a new euler angle where each axis of rotation is defined by an angle,\n * in degrees. If no value is given, then `{x: 0, y: 0, z: 0, order: 'xyz'}` is\n * returned.\n *\n * @param value The values to populate the euler angle with.\n * @returns A euler angle.\n */\nexport function fromDegrees(value: Partial<Euler> = {}): Euler {\n const { x = 0, y = 0, z = 0, order } = value;\n return create({\n x: Angle.toRadians(x),\n y: Angle.toRadians(y),\n z: Angle.toRadians(z),\n order,\n });\n}\n\n/**\n * Creates a euler angle from the rotation components of a 4x4 matrix. The\n * rotation components are represented by the upper 3x3 of the matrix.\n *\n * @param matrix A pure rotation matrix, unscaled.\n * @param order The order that the rotations are applied.\n */\nexport function fromRotationMatrix(\n matrix: Matrix4.Matrix4,\n order: EulerOrder = 'xyz'\n): Euler {\n const m = Matrix4.toObject(matrix);\n\n let x = 0,\n y = 0,\n z = 0;\n\n if (order === 'xyz') {\n y = Math.asin(clamp(m.m13, -1, 1));\n if (Math.abs(m.m13) < 0.9999999) {\n x = Math.atan2(-m.m23, m.m33);\n z = Math.atan2(-m.m12, m.m11);\n } else {\n x = Math.atan2(m.m32, m.m22);\n z = 0;\n }\n } else if (order === 'yxz') {\n x = Math.asin(-clamp(m.m23, -1, 1));\n if (Math.abs(m.m23) < 0.9999999) {\n y = Math.atan2(m.m13, m.m33);\n z = Math.atan2(m.m21, m.m22);\n } else {\n y = Math.atan2(-m.m31, m.m11);\n z = 0;\n }\n } else if (order === 'zxy') {\n x = Math.asin(clamp(m.m32, -1, 1));\n if (Math.abs(m.m32) < 0.9999999) {\n y = Math.atan2(-m.m31, m.m33);\n z = Math.atan2(-m.m12, m.m22);\n } else {\n y = 0;\n z = Math.atan2(m.m21, m.m11);\n }\n } else if (order === 'zyx') {\n y = Math.asin(-clamp(m.m31, -1, 1));\n if (Math.abs(m.m31) < 0.9999999) {\n x = Math.atan2(m.m32, m.m33);\n z = Math.atan2(m.m21, m.m11);\n } else {\n x = 0;\n z = Math.atan2(-m.m12, m.m22);\n }\n } else if (order === 'yzx') {\n z = Math.asin(clamp(m.m21, -1, 1));\n if (Math.abs(m.m21) < 0.9999999) {\n x = Math.atan2(-m.m23, m.m22);\n y = Math.atan2(-m.m31, m.m11);\n } else {\n x = 0;\n y = Math.atan2(m.m13, m.m33);\n }\n } else if (order === 'xzy') {\n z = Math.asin(-clamp(m.m12, -1, 1));\n if (Math.abs(m.m12) < 0.9999999) {\n x = Math.atan2(m.m32, m.m22);\n y = Math.atan2(m.m13, m.m11);\n } else {\n x = Math.atan2(-m.m23, m.m33);\n y = 0;\n }\n }\n\n return { x, y, z, order };\n}\n\n/**\n * Returns a euler angle that was decoded from a JSON string. Supports either\n * extracting values from an array `[x, y, z, order]` or object `{x, y, z,\n * order}`.\n *\n * @param json A JSON object.\n * @returns A euler angle.\n */\nexport function fromJson(json: string): Euler {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, z, order = 'xyz'] = obj;\n return { x, y, z, order };\n } else {\n const { x, y, z, order = 'xyz' } = obj;\n return { x, y, z, order };\n }\n}\n\n/**\n * Type guard that checks if the given type is a Euler.\n */\nexport function isType(obj: unknown): obj is Euler {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const o = obj as any;\n return (\n o != null &&\n o.hasOwnProperty('x') &&\n o.hasOwnProperty('y') &&\n o.hasOwnProperty('z') &&\n o.hasOwnProperty('order')\n );\n}\n","import * as Euler from './euler';\nimport * as Matrix4 from './matrix4';\nimport * as Vector3 from './vector3';\n\n/**\n * A type that represents a\n * [quaternion](http://en.wikipedia.org/wiki/Quaternion). Quaternions are used\n * in 3D graphics to represent\n * [rotations](https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation).\n */\nexport interface Quaternion {\n x: number;\n y: number;\n z: number;\n w: number;\n}\n\n/**\n * An array representation of a `Quaternion`.\n */\nexport type QuaternionAsArray = [x: number, y: number, z: number, w: number];\n\n/**\n * Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,\n * w: 1}` is returned.\n */\nexport function create(value: Partial<Quaternion> = {}): Quaternion {\n return { x: 0, y: 0, z: 0, w: 1, ...value };\n}\n\n/**\n * Parses a JSON string representation of a `Quaternion`.\n *\n * @param json A JSON string either in the form of `[x, y, z, w]` or `{\"x\": 0, \"y\": 0, \"z\": 0, \"w\": 0}`.\n * @returns A parsed `Quaternion`.\n */\nexport function fromJson(json: string): Quaternion {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, z, w] = obj;\n return create({ x, y, z, w });\n } else {\n return create(obj);\n }\n}\n\n/**\n * Returns a quaternion with that will have a magnitude of 1.\n */\nexport function normalize(q: Quaternion): Quaternion {\n return scale(1 / magnitude(q), q);\n}\n\n/**\n * Returns the magnitude of the provided quaternion.\n */\nexport function magnitude(q: Quaternion): number {\n return Math.sqrt(q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z);\n}\n\n/**\n * Returns a quaternion where each component is multiplied by the `scalar`.\n */\nexport function scale(scalar: number, q: Quaternion): Quaternion {\n return create({\n w: q.w * scalar,\n x: q.x * scalar,\n y: q.y * scalar,\n z: q.z * scalar,\n });\n}\n\n/**\n * Creates a `Quaternion` that is rotated the given radians around an axis.\n *\n * @param axis The axis to rotate around.\n * @param radians The rotation, in radians.\n * @returns A rotated quaternion.\n */\nexport function fromAxisAngle(\n axis: Vector3.Vector3,\n radians: number\n): Quaternion {\n const halfAngle = radians / 2;\n const s = Math.sin(halfAngle);\n\n const x = axis.x * s;\n const y = axis.y * s;\n const z = axis.z * s;\n const w = Math.cos(halfAngle);\n return { x, y, z, w };\n}\n\n/**\n * Returns a quaternion using the upper 3x3 of a pure rotation matrix\n * (unscaled).\n */\nexport function fromMatrixRotation(matrix: Matrix4.Matrix4): Quaternion {\n const m = Matrix4.toObject(matrix);\n const scale = Vector3.fromMatrixScale(matrix);\n\n const is1 = 1 / scale.x;\n const is2 = 1 / scale.y;\n const is3 = 1 / scale.z;\n\n const sm11 = m.m11 * is1;\n const sm12 = m.m21 * is2;\n const sm13 = m.m31 * is3;\n const sm21 = m.m12 * is1;\n const sm22 = m.m22 * is2;\n const sm23 = m.m32 * is3;\n const sm31 = m.m13 * is1;\n const sm32 = m.m23 * is2;\n const sm33 = m.m33 * is3;\n\n const trace = sm11 + sm22 + sm33;\n if (trace > 0) {\n const s = Math.sqrt(trace + 1.0) * 2;\n return {\n x: (sm23 - sm32) / s,\n y: (sm31 - sm13) / s,\n z: (sm12 - sm21) / s,\n w: 0.25 * s,\n };\n } else if (sm11 > sm22 && sm11 > sm33) {\n const s = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;\n return {\n x: 0.25 * s,\n y: (sm12 + sm21) / s,\n z: (sm31 + sm13) / s,\n w: (sm23 - sm32) / s,\n };\n } else if (sm22 > sm33) {\n const s = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;\n return {\n x: (sm12 + sm21) / s,\n y: 0.25 * s,\n z: (sm23 + sm32) / s,\n w: (sm31 - sm13) / s,\n };\n } else {\n const s = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;\n return {\n x: (sm31 + sm13) / s,\n y: (sm23 + sm32) / s,\n z: 0.25 * s,\n w: (sm12 - sm21) / s,\n };\n }\n}\n\nexport function fromEuler(euler: Euler.Euler): Quaternion {\n const { x: ex, y: ey, z: ez, order } = euler;\n const c1 = Math.cos(ex / 2);\n const c2 = Math.cos(ey / 2);\n const c3 = Math.cos(ez / 2);\n\n const s1 = Math.sin(ex / 2);\n const s2 = Math.sin(ey / 2);\n const s3 = Math.sin(ez / 2);\n\n let x = 0,\n y = 0,\n z = 0,\n w = 0;\n\n switch (order) {\n case 'xyz':\n x = s1 * c2 * c3 + c1 * s2 * s3;\n y = c1 * s2 * c3 - s1 * c2 * s3;\n z = c1 * c2 * s3 + s1 * s2 * c3;\n w = c1 * c2 * c3 - s1 * s2 * s3;\n break;\n\n case 'yxz':\n x = s1 * c2 * c3 + c1 * s2 * s3;\n y = c1 * s2 * c3 - s1 * c2 * s3;\n z = c1 * c2 * s3 - s1 * s2 * c3;\n w = c1 * c2 * c3 + s1 * s2 * s3;\n break;\n\n case 'zxy':\n x = s1 * c2 * c3 - c1 * s2 * s3;\n y = c1 * s2 * c3 + s1 * c2 * s3;\n z = c1 * c2 * s3 + s1 * s2 * c3;\n w = c1 * c2 * c3 - s1 * s2 * s3;\n break;\n\n case 'zyx':\n x = s1 * c2 * c3 - c1 * s2 * s3;\n y = c1 * s2 * c3 + s1 * c2 * s3;\n z = c1 * c2 * s3 - s1 * s2 * c3;\n w = c1 * c2 * c3 + s1 * s2 * s3;\n break;\n\n case 'yzx':\n x = s1 * c2 * c3 + c1 * s2 * s3;\n y = c1 * s2 * c3 + s1 * c2 * s3;\n z = c1 * c2 * s3 - s1 * s2 * c3;\n w = c1 * c2 * c3 - s1 * s2 * s3;\n break;\n\n case 'xzy':\n x = s1 * c2 * c3 - c1 * s2 * s3;\n y = c1 * s2 * c3 - s1 * c2 * s3;\n z = c1 * c2 * s3 + s1 * s2 * c3;\n w = c1 * c2 * c3 + s1 * s2 * s3;\n break;\n }\n\n return { x, y, z, w };\n}\n\n/**\n * Multiplies `a` x `b` and returns a new quaternion with the result.\n */\nexport function multiply(a: Quaternion, b: Quaternion): Quaternion {\n // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\n return {\n x: a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y,\n y: a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z,\n z: a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x,\n w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z,\n };\n}\n\n/**\n * Type guard that checks if the given type is a Quaternion.\n */\nexport function isType(obj: unknown): obj is Quaternion {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const o = obj as any;\n return (\n o != null &&\n o.hasOwnProperty('x') &&\n o.hasOwnProperty('y') &&\n o.hasOwnProperty('z') &&\n o.hasOwnProperty('w')\n );\n}\n","import { Angle, Vector3 } from '.';\nimport * as Euler from './euler';\nimport { lerp as lerpNumber } from './math';\nimport * as Matrix4 from './matrix4';\nimport * as Quaternion from './quaternion';\n\n/**\n * A `Vector3` represents a vector of 3 dimensions values. It may represent a\n * point or direction.\n */\nexport interface Vector3 {\n x: number;\n y: number;\n z: number;\n}\n\n/**\n * A `Vector3` representation as an array.\n */\nexport type Vector3AsArray = [x: number, y: number, z: number];\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable padding-line-between-statements */\n/**\n * Returns a new `Vector3` either with the provided x, y, and z dimensions,\n * or from the provided `Partial<Vector3>` object populated with zeroes\n * wherever a component is missing.\n *\n * Providing no values to this function will result in a zero-length vector.\n */\n\nexport function create(x: number, y: number, z: number): Vector3;\nexport function create(partialVector: Partial<Vector3>): Vector3;\nexport function create(): Vector3;\nexport function create(...args: any[]): Vector3 {\n if (args.length === 1) {\n return {\n x: args[0].x ?? 0,\n y: args[0].y ?? 0,\n z: args[0].z ?? 0,\n };\n } else if (args.length === 3) {\n return {\n x: args[0] ?? 0,\n y: args[1] ?? 0,\n z: args[2] ?? 0,\n };\n }\n\n return {\n x: 0,\n y: 0,\n z: 0,\n };\n}\n/* eslint-enable @typescript-eslint/no-explicit-any */\n/* eslint-enable padding-line-between-statements */\n\n/**\n * Checks if each component of the given vector is populated with a numeric\n * component. A component is invalid if it contains a non-finite or NaN value.\n */\nexport function isValid({ x, y, z }: Vector3): boolean {\n return [x, y, z].every((v) => isFinite(v) && !isNaN(v));\n}\n\n/**\n * Returns a vector representing the scale elements of `matrix`.\n */\nexport function fromMatrixScale(matrix: Matrix4.Matrix4): Vector3 {\n const m = Matrix4.toObject(matrix);\n return {\n x: Math.hypot(m.m11, m.m21, m.m31),\n y: Math.hypot(m.m12, m.m22, m.m32),\n z: Math.hypot(m.m13, m.m23, m.m33),\n };\n}\n\n/**\n * Returns a vector representing the position elements of `matrix`.\n */\nexport function fromMatrixPosition(matrix: Matrix4.Matrix4): Vector3 {\n const m = Matrix4.toObject(matrix);\n return { x: m.m14, y: m.m24, z: m.m34 };\n}\n\n/**\n * Parses a JSON string representation of a Vector3 and returns an object.\n *\n * @param json A JSON string, either in the form `[x,y,z]` or `{\"x\": 0, \"y\": 0, \"z\": 0}`\n * @returns A parsed Vector3.\n */\nexport function fromJson(json: string): Vector3 {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, z] = obj;\n return create(x, y, z);\n } else {\n const { x, y, z } = obj;\n return create(x, y, z);\n }\n}\n\n/**\n * Creates a `Vector3` from an array. Pass `offset` to read values from the\n * starting index.\n *\n * @see #toArray()\n * @see #create()\n */\nexport function fromArray(nums: number[], offset = 0): Vector3 {\n const x = nums[offset];\n const y = nums[offset + 1];\n const z = nums[offset + 2];\n return create(x, y, z);\n}\n\n/**\n * Converts a Vector3 to an array where the values of the vector will be\n * represented as [x, y, z];\n *\n * @see #fromArray()\n * @see #create()\n */\nexport function toArray({ x, y, z }: Vector3): Vector3AsArray {\n return [x, y, z];\n}\n\n/**\n * Returns a directional vector on the positive x axis, Vector3(1, 0, 0).\n */\nexport function right(): Vector3 {\n return create(1, 0, 0);\n}\n\n/**\n * Returns a directional vector on the positive y axis, Vector3(0, 1, 0).\n */\nexport function up(): Vector3 {\n return create(0, 1, 0);\n}\n\n/**\n * Returns a directional vector on the positive z axis, Vector3(0, 0, -1).\n */\nexport function forward(): Vector3 {\n return create(0, 0, -1);\n}\n\n/**\n * Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).\n */\nexport function left(): Vector3 {\n return create(-1, 0, 0);\n}\n\n/**\n * Returns a directional vector on the negative y axis, Vector3(0, -1, 0).\n */\nexport function down(): Vector3 {\n return create(0, -1, 0);\n}\n\n/**\n * Returns a directional vector on the negative z axis, Vector3(0, 0, 1).\n */\nexport function back(): Vector3 {\n return create(0, 0, 1);\n}\n\n/**\n * Returns a vector at the origin, Vector3(0, 0, 0).\n */\nexport function origin(): Vector3 {\n return create(0, 0, 0);\n}\n\n/**\n * Returns a vector with that will have a magnitude of 1.\n */\nexport function normalize(vector: Vector3): Vector3 {\n const length = magnitude(vector);\n return { x: vector.x / length, y: vector.y / length, z: vector.z / length };\n}\n\n/**\n * Returns the straight-line length from (0, 0, 0) to the given vector.\n */\nexport function magnitude(vector: Vector3): number {\n return Math.sqrt(magnitudeSquared(vector));\n}\n\n/**\n * Returns the straight-line length from (0, 0, 0) to the given vector).\n *\n * When comparing lengths of vectors, you should use this function as it's\n * slightly more efficient to calculate.\n */\nexport function magnitudeSquared(vector: Vector3): number {\n return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;\n}\n\n/**\n * Returns a vector that is the cross product of two vectors.\n *\n * The cross product of two vectors results in a third vector which is\n * perpendicular to the two input vectors. The result's magnitude is equal to\n * the magnitudes of the two inputs multiplied together and then multiplied by\n * the sine of the angle between the inputs. You can determine the direction of\n * the result vector using the \"left hand rule\".\n */\nexport function cross(a: Vector3, b: Vector3): Vector3 {\n return {\n x: a.y * b.z - a.z * b.y,\n y: a.z * b.x - a.x * b.z,\n z: a.x * b.y - a.y * b.x,\n };\n}\n\n/**\n * Returns a vector that is the sum of two vectors.\n */\nexport function add(a: Vector3, ...vectors: Vector3[]): Vector3 {\n return vectors.reduce((res, next) => {\n return { x: res.x + next.x, y: res.y + next.y, z: res.z + next.z };\n }, a);\n}\n\n/**\n * Returns a vector that is the difference between two vectors.\n */\nexport function subtract(a: Vector3, ...vectors: Vector3[]): Vector3 {\n return vectors.reduce((res, next) => {\n return { x: res.x - next.x, y: res.y - next.y, z: res.z - next.z };\n }, a);\n}\n\n/**\n * Returns a vector that where each component of `b` is multiplied with `a`.\n */\nexport function multiply(a: Vector3, b: Vector3): Vector3 {\n return { x: a.x * b.x, y: a.y * b.y, z: a.z * b.z };\n}\n\n/**\n * Returns a vector where each value of a vector is multiplied by the `scalar`.\n */\nexport function scale(scalar: number, vector: Vector3): Vector3 {\n return { x: vector.x * scalar, y: vector.y * scalar, z: vector.z * scalar };\n}\n\n/**\n * Returns a value representing the dot product of two vectors.\n *\n * The dot product is a float value equal to the magnitudes of the two vectors\n * multiplied together and then multiplied by the cosine of the angle between\n * them.\n */\nexport function dot(a: Vector3, b: Vector3): number {\n return a.x * b.x + a.y * b.y + a.z * b.z;\n}\n\n/**\n * Returns the angle, in radians, between two vectors.\n *\n * The angle returned is the unsigned angle between the two vectors. This means\n * the smaller of the two possible angles between the two vectors is used. The\n * result is never greater than 180 degrees.\n */\nexport function angleTo(a: Vector3, b: Vector3): number {\n const theta = dot(a, b) / (magnitude(a) * magnitude(b));\n // Clamp to avoid numerical problems.\n return Math.acos(theta);\n}\n\n/**\n * Returns the Euler angle, in radians with the `xyz` ordering, between two vectors.\n *\n * This method will normalize both vectors for the calculation, and uses the\n * algorithm described in https://www.xarg.org/proof/quaternion-from-two-vectors/.\n */\nexport function eulerTo(a: Vector3, b: Vector3): Euler.Euler {\n const normalizedA = normalize(a);\n const normalizedB = normalize(b);\n\n const dotDelta = Math.cos(Angle.toRadians(1));\n const dotAB = dot(normalizedA, normalizedB);\n const vectorsAreParallel = Math.abs(dotAB) > dotDelta;\n\n if (vectorsAreParallel) {\n return dotAB > 1 - 1e-6 ? Euler.create() : Euler.create({ x: Math.PI });\n }\n\n const normalizedQ = Quaternion.normalize(\n Quaternion.create({\n w: 1 + dotAB,\n ...cross(normalizedA, normalizedB),\n })\n );\n\n return Euler.fromRotationMatrix(Matrix4.makeRotation(normalizedQ));\n}\n\n/**\n * Performs a projection of a `vector` onto `onNormal`.\n *\n * A projection is represented as the nearest point along a normal to a vector,\n * which constructs a triangle from the origin, to the vector, to the projected\n * point.\n *\n * ```\n * Vector --> * * <-- Projected\n * \\\n * \\ | <-- Normal\n * \\|\n * * <-- Origin\n * ```\n */\nexport function project(vector: Vector3, onNormal: Vector3): Vector3 {\n return scale(dot(onNormal, vector) / magnitude(onNormal), onNormal);\n}\n\n/**\n * Returns a vector that is rotated about an origin point.\n *\n * @param angle The angle to rotate, in radians.\n * @param point The origin point to rotate around.\n * @param axisDirection The direction used to compute the axis.\n * @param axisPosition The point of the axis.\n */\nexport function rotateAboutAxis(\n angle: number,\n point: Vector3,\n axisDirection: Vector3,\n axisPosition: Vector3\n): Vector3 {\n if (angle !== 0) {\n const { x, y, z } = point;\n const { x: a, y: b, z: c } = axisPosition;\n const { x: u, y: v, z: w } = axisDirection;\n\n const newX =\n (a * (v * v + w * w) - u * (b * v + c * w - u * x - v * y - w * z)) *\n (1 - Math.cos(angle)) +\n x * Math.cos(angle) +\n (-c * v + b * w - w * y + v * z) * Math.sin(angle);\n\n const newY =\n (b * (u * u + w * w) - v * (a * u + c * w - u * x - v * y - w * z)) *\n (1 - Math.cos(angle)) +\n y * Math.cos(angle) +\n (c * u - a * w + w * x - u * z) * Math.sin(angle);\n\n const newZ =\n (c * (u * u + v * v) - w * (a * u + b * v - u * x - v * y - w * z)) *\n (1 - Math.cos(angle)) +\n z * Math.cos(angle) +\n (-b * u + a * v - v * x + u * y) * Math.sin(angle);\n\n return { x: newX, y: newY, z: newZ };\n } else {\n return point;\n }\n}\n\n/**\n * Returns a vector that is multiplied with a matrix.\n */\nexport function transformMatrix(vector: Vector3, m: Matrix4.Matrix4): Vector3 {\n const { x, y, z } = vector;\n const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);\n return {\n x: (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,\n y: (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,\n z: (m[2] * x + m[6] * y + m[10] * z + m[14]) * w,\n };\n}\n\n/**\n * Euclidean distance between two vectors\n */\nexport function distance(a: Vector3, b: Vector3): number {\n return Math.sqrt(distanceSquared(a, b));\n}\n\n/**\n * Returns the squared distance between two vectors. If you're just comparing\n * distances, this is slightly more efficient than `distanceTo`.\n */\nexport function distanceSquared(a: Vector3, b: Vector3): number {\n const { x: dx, y: dy, z: dz } = subtract(a, b);\n return dx * dx + dy * dy + dz * dz;\n}\n\n/**\n * Returns `true` if two vectors have the same values.\n */\nexport function isEqual(a: Vector3, b: Vector3): boolean {\n return a.x === b.x && a.y === b.y && a.z === b.z;\n}\n\n/**\n * Returns a vector that contains the largest components of `a` and `b`.\n */\nexport function max(a: Vector3, b: Vector3): Vector3 {\n return create(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));\n}\n\n/**\n * Returns a vector that contains the smallest components of `a` and `b`.\n */\nexport function min(a: Vector3, b: Vector3): Vector3 {\n return create(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));\n}\n\n/**\n * Returns a vector that each of its component negated.\n */\nexport function negate(vector: Vector3): Vector3 {\n return { x: -vector.x, y: -vector.y, z: -vector.z };\n}\n\n/**\n * Performs a linear interpolation between `a` and `b` and returns the result.\n * The value of `t` is clamped between `[0, 1]`.\n *\n * @param a The start value.\n * @param b The end value.\n * @param t A value between 0 and 1.\n * @returns A point between `a` and `b`.\n */\nexport function lerp(a: Vector3, b: Vector3, t: number): Vector3 {\n return {\n x: lerpNumber(a.x, b.x, t),\n y: lerpNumber(a.y, b.y, t),\n z: lerpNumber(a.z, b.z, t),\n };\n}\n\n/**\n * Maps a normalized device coordinate (NDC) space to world space coordinates.\n *\n * @param ndc A point in normalized device coordinates.\n * @param worldMatrix A camera's world matrix.\n * @param projectionMatrixInverse A camera's inverse projection matrix.\n * @returns A point in world space coordinates.\n */\nexport function transformNdcToWorldSpace(\n ndc: Vector3,\n worldMatrix: Matrix4.Matrix4,\n projectionMatrixInverse: Matrix4.Matrix4\n): Vector3 {\n return transformMatrix(\n transformMatrix(ndc, projectionMatrixInverse),\n worldMatrix\n );\n}\n","import * as Vector3 from './vector3';\n\n/**\n * A `BoundingBox` describes a bounding volume as an axis-aligned box.\n */\nexport interface BoundingBox {\n min: Vector3.Vector3;\n max: Vector3.Vector3;\n}\n\n/**\n * Returns a `BoundingBox` with the given min and max points.\n */\nexport const create = (\n min: Vector3.Vector3,\n max: Vector3.Vector3\n): BoundingBox => {\n return { min, max };\n};\n\n/**\n * Construct a minimal bounding box for a set of vectors, such that all vectors\n * are contained by the bounding box.\n */\nexport const fromVectors = (\n vectors: Vector3.Vector3[]\n): BoundingBox | undefined => {\n return union(...vectors.map((v) => create(v, v)));\n};\n\n/**\n * Returns the center point of the given `BoundingBox`.\n */\nexport const center = (boundingBox: BoundingBox): Vector3.Vector3 => {\n return Vector3.scale(0.5, Vector3.add(boundingBox.min, boundingBox.max));\n};\n\n/**\n * Returns the diagonal vector between the `min` and `max` vectors of the\n * given `BoundingBox`.\n */\nexport const diagonal = (boundingBox: BoundingBox): Vector3.Vector3 => {\n return Vector3.subtract(boundingBox.max, boundingBox.min);\n};\n\n/**\n * Returns a floating-point spatial error tolerance based on the extents of the box.\n */\nexport const epsilon = (boundingBox: BoundingBox): number => {\n return (\n Math.max(\n Math.max(\n Vector3.magnitude(boundingBox.max),\n Vector3.magnitude(boundingBox.min)\n ),\n Vector3.magnitude(diagonal(boundingBox))\n ) * 1e-6\n );\n};\n\n/* eslint-disable padding-line-between-statements */\n/**\n * Combine two or more bounding boxes into a new minimal bounding box that\n * contains both.\n */\nexport function union(a: BoundingBox): BoundingBox;\nexport function union(a: BoundingBox, b: BoundingBox): BoundingBox;\nexport function union(\n a: BoundingBox,\n b: BoundingBox,\n c: BoundingBox\n): BoundingBox;\nexport function union(\n a: BoundingBox,\n b: BoundingBox,\n c: BoundingBox,\n d: BoundingBox\n): BoundingBox;\nexport function union(...boxes: BoundingBox[]): BoundingBox | undefined;\nexport function union(box: BoundingBox, ...rest: BoundingBox[]): BoundingBox {\n const boxes = [box, ...rest];\n return boxes.reduce((a, b) => {\n return create(Vector3.min(a.min, b.min), Vector3.max(a.max, b.max));\n });\n}\n/* eslint-enable padding-line-between-statements */\n\n/**\n * Returns the distance between the min and max for the provided\n * bounding box for each axis.\n */\nexport const lengths = (box: BoundingBox): Vector3.Vector3 => {\n return Vector3.create(\n box.max.x - box.min.x,\n box.max.y - box.min.y,\n box.max.z - box.min.z\n );\n};\n\n/**\n * Checks if each component of the given bounding box is populated with a numeric\n * component. A component is invalid if it contains a non-finite or NaN value.\n */\nexport function isValid(boundingBox: BoundingBox): boolean {\n const maxIsValid = Vector3.isValid(boundingBox.max);\n const minIsValid = Vector3.isValid(boundingBox.min);\n\n return maxIsValid && minIsValid;\n}\n","import * as BoundingBox from './boundingBox';\nimport * as Vector3 from './vector3';\n\n/**\n * A `BoundingSphere` describes a bounding volume as a sphere.\n */\nexport interface BoundingSphere {\n center: Vector3.Vector3;\n radius: number;\n epsilon: number;\n}\n\n/**\n * Returns a `BoundingSphere` that encompasses the provided `BoundingBox`.\n */\nexport const create = (\n boundingBox: BoundingBox.BoundingBox\n): BoundingSphere => {\n const boundingBoxCenter = BoundingBox.center(boundingBox);\n const centerToBoundingPlane = Vector3.subtract(\n boundingBox.max,\n boundingBoxCenter\n );\n const radius = Vector3.magnitude(centerToBoundingPlane);\n const length = Math.max(radius, Vector3.magnitude(boundingBoxCenter));\n const epsilon = length === 0 ? 1.0 : length * 1e-6;\n\n return { center: boundingBoxCenter, radius, epsilon };\n};\n","import * as Dimensions from './dimensions';\nimport * as Point from './point';\n\n/**\n * A `Rectangle` is an object with position and size.\n */\nexport interface Rectangle {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Returns a new `Rectangle` with the given position and size.\n */\nexport function create(\n x: number,\n y: number,\n width: number,\n height: number\n): Rectangle {\n return { x, y, width, height };\n}\n\n/**\n * Returns a new `Rectangle` at the origin point and given size.\n */\nexport function fromDimensions(dimensions: Dimensions.Dimensions): Rectangle {\n return create(0, 0, dimensions.width, dimensions.height);\n}\n\n/**\n * Returns a new `Rectangle` with the given position and size.\n */\nexport function fromPointAndDimensions(\n point: Point.Point,\n dimensions: Dimensions.Dimensions\n): Rectangle {\n return create(point.x, point.y, dimensions.width, dimensions.height);\n}\n\n/**\n * Returns a new `Rectangle` with the given top-left and bottom-right positions.\n * The returned rectangle will always returns a positive width and height.\n */\nexport function fromPoints(\n topLeftPt: Point.Point,\n bottomRightPt: Point.Point\n): Rectangle {\n const minX = Math.min(topLeftPt.x, bottomRightPt.x);\n const minY = Math.min(topLeftPt.y, bottomRightPt.y);\n const maxX = Math.max(topLeftPt.x, bottomRightPt.x);\n const maxY = Math.max(topLeftPt.y, bottomRightPt.y);\n return create(minX, minY, maxX - minX, maxY - minY);\n}\n\n/**\n * Returns a rectangle where the longest length of `rect` will be equal to the\n * shortest length of `to`. The shortest length of `rect` will be proportionally\n * scaled to match the aspect ratio of `rect`. The returned rectangle will be\n * centered within `to`.\n *\n * @see {@link cropFit}\n */\nexport function containFit(to: Rectangle, rect: Rectangle): Rectangle {\n const scale = Math.min(to.width / rect.width, to.height / rect.height);\n const dimensions = Dimensions.proportionalScale(scale, rect);\n const position = Point.subtract(center(to), Dimensions.center(dimensions));\n return fromPointAndDimensions(position, dimensions);\n}\n\n/**\n * Returns a rectangle where the shortest length of `rect` will be equal to the\n * longest length of `to`. The longest length of `rect` will be proportionally\n * scaled to match the aspect ratio of `rect`. The returned rectangle will be\n * centered within `to`.\n *\n * @see {@link containFit}\n */\nexport function cropFit(to: Rectangle, rect: Rectangle): Rectangle {\n const scale = Math.max(to.width / rect.width, to.height / rect.height);\n const dimensions = Dimensions.proportionalScale(scale, rect);\n const position = Point.subtract(center(to), Dimensions.center(dimensions));\n return fromPointAndDimensions(position, dimensions);\n}\n\n/**\n * Returns a rectangle where each side of `rect` will be reduced proportionally\n * to have an area less than or equal to the provided `to` value. The returned\n * rectangle will be centered within the original bounds of `rect`.\n *\n * @param to - the maximum area this rectangle can have\n * @param rect - the rectangle to scale to fit the specified area\n */\nexport function scaleFit(to: number, rect: Rectangle): Rectangle {\n const scale = Math.min(Math.sqrt(to / area(rect)), 1);\n const dimensions = Dimensions.floor(\n Dimensions.proportionalScale(scale, rect)\n );\n const position = Point.subtract(center(rect), Dimensions.center(dimensions));\n return fromPointAndDimensions(position, dimensions);\n}\n\n/**\n * Returns a rectangle where the position and dimensions are scaled by the given\n * factors. If `scaleY` is omitted, then the position and dimensions are scaled\n * uniformly by `scaleOrScaleX`.\n *\n * @param rect The rectangle to scale.\n * @param scaleOrScaleX The uniform scale factor, or the horizontal scale\n * factor.\n * @param scaleY The vertical scale factor.\n * @returns A scaled rectangle.\n */\nexport function scale(\n rect: Rectangle,\n scaleOrScaleX: number,\n scaleY?: number\n): Rectangle {\n if (scaleY == null) {\n return scale(rect, scaleOrScaleX, scaleOrScaleX);\n } else {\n const { x, y, width, height } = rect;\n const scaleX = scaleOrScaleX;\n return create(x * scaleX, y * scaleY, width * scaleX, height * scaleY);\n }\n}\n\n/**\n * Returns true if two rectangles are equal in position and size.\n */\nexport function isEqual(a: Rectangle, b: Rectangle): boolean {\n return Point.isEqual(a, b) && Dimensions.isEqual(a, b);\n}\n\n/**\n * Returns a rectangle that has its position shifted by a given offset. The\n * size of the rectangle is unchanged.\n */\nexport function offset(delta: Point.Point, rect: Rectangle): Rectangle {\n return fromPointAndDimensions(Point.add(topLeft(rect), delta), rect);\n}\n\n/**\n * Returns the area of the rectangle.\n */\nexport function area(rect: Rectangle): number {\n return rect.width * rect.height;\n}\n\n/**\n * Returns the center point of the rectangle.\n */\nexport function center(rect: Rectangle): Point.Point {\n return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };\n}\n\n/**\n * Returns the top-left position of the rectangle, as a point.\n */\nexport function topLeft(rect: Rectangle): Point.Point {\n return Point.create(rect.x, rect.y);\n}\n\n/**\n * Returns the bottom-right position of the rectangle, as a point.\n */\nexport function bottomRight(rect: Rectangle): Point.Point {\n return Point.create(rect.x + rect.width, rect.y + rect.height);\n}\n\n/**\n * Returns `true` if the given rectangle has a portrait aspect ratio.\n */\nexport function isPortrait(rect: Rectangle): boolean {\n return rect.width < rect.height;\n}\n\n/**\n * Returns `true` if the given rectangle has a landscape aspect ratio.\n */\nexport function isLandscape(rect: Rectangle): boolean {\n return rect.width > rect.height;\n}\n\n/**\n * Returns `true` if the given rectangle has a square aspect ratio.\n */\nexport function isSquare(rect: Rectangle): boolean {\n return rect.width === rect.height;\n}\n\n/**\n * Pads a rectangle by the given amount, maintaining the center position.\n *\n * @param rect The rectangle to apply padding to.\n * @param padding The padding to add.\n */\nexport function pad(rect: Rectangle, padding: number): Rectangle {\n return create(\n rect.x - padding,\n rect.y - padding,\n rect.width + padding * 2,\n rect.height + padding * 2\n );\n}\n\n/**\n * Returns `true` if the given rectangle contains all the given `points`.\n *\n * @param rect The rectangle to check against.\n * @param points The points to check.\n */\nexport function containsPoints(\n rect: Rectangle,\n ...points: Point.Point[]\n): boolean {\n return points.every((point) => {\n return (\n rect.x <= point.x &&\n rect.x + rect.width >= point.x &&\n rect.y <= point.y &&\n rect.y + rect.height >= point.y\n );\n });\n}\n\n/**\n * Parses a JSON string representation of a Rectangle and returns an object.\n *\n * @param json A JSON string, either in the form `[x,y,width,height]` or `{\"x\": 0, \"y\": 0, \"width\": 10, \"height\": 10}`\n * @returns A parsed Point.\n */\nexport function fromJson(json: string): Rectangle {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, width, height] = obj;\n return create(x, y, width, height);\n } else {\n const { x, y, width, height } = obj;\n return create(x, y, width, height);\n }\n}\n","import * as Point from './point';\nimport * as Rectangle from './rectangle';\n\n/**\n * `Dimensions` represent an object with a length of `width` and `height`.\n */\nexport interface Dimensions {\n width: number;\n height: number;\n}\n\n/**\n * Returns a `Dimensions` with the given width and height.\n *\n */\nexport const create = (width: number, height: number): Dimensions => {\n return { width, height };\n};\n\n/**\n * Returns a `Dimensions` with the same width and height.\n */\nexport const square = (size: number): Dimensions => {\n return create(size, size);\n};\n\n/**\n * Returns `true` if two dimensions have the same width and height. Otherwise\n * `false`.\n */\nexport const isEqual = (a: Dimensions, b: Dimensions): boolean => {\n return a.width === b.width && a.height === b.height;\n};\n\n/**\n * Returns a scaled dimensions, where the width is scaled by `scaleX` and height\n * is scaled by `scaleY`.\n */\nexport const scale = (\n scaleX: number,\n scaleY: number,\n dimensions: Dimensions\n): Dimensions => {\n return {\n width: dimensions.width * scaleX,\n height: dimensions.height * scaleY,\n };\n};\n\n/**\n * Returns a dimension where each length is scaled by `scaleFactor`.\n */\nexport const proportionalScale = (\n scaleFactor: number,\n dimensions: Dimensions\n): Dimensions => {\n return scale(scaleFactor, scaleFactor, dimensions);\n};\n\n/**\n * Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit\n * into `to`.\n */\nexport const trim = (to: Dimensions, dimensions: Dimensions): Dimensions => {\n return {\n width: Math.min(to.width, dimensions.width),\n height: Math.min(to.height, dimensions.height),\n };\n};\n\n/**\n * Returns a `Dimensions` where the longest length of `dimensions` will be equal\n * to the shortest length of `to`. The shortest length of `dimensions` will be\n * proportionally scaled to match the aspect ratio of `dimensions`.\n *\n * @see #cropFit()\n */\nexport const containFit = (\n to: Dimensions,\n dimensions: Dimensions\n): Dimensions => {\n const { width, height } = Rectangle.containFit(\n toRectangle(to),\n toRectangle(dimensions)\n );\n return { width, height };\n};\n\n/**\n * Returns a `Dimensions` where the shortest length of `dimensions` will be\n * equal to the longest length of `to`. The longest length of `dimensions` will\n * be proportionally scaled to match the aspect ratio of `dimensions`.\n *\n * @see #containFit()\n */\nexport const cropFit = (to: Dimensions, dimensions: Dimensions): Dimensions => {\n const { width, height } = Rectangle.cropFit(\n toRectangle(to),\n toRectangle(dimensions)\n );\n return { width, height };\n};\n\n/**\n * Returns a `Dimensions` where each side of `dimensions` will be reduced proportionally\n * to have an area less than or equal to the provided `to` value. The returned\n * dimensions will be centered within the original bounds of `dimensions`.\n *\n * @param to - the maximum area this dimensions can have\n * @param dimensions - the dimensions to scale to fit the specified area\n */\nexport const scaleFit = (to: number, dimensions: Dimensions): Dimensions => {\n const { width, height } = Rectangle.scaleFit(to, toRectangle(dimensions));\n return { width, height };\n};\n\n/**\n * Returns a `Dimensions` with each length rounded.\n */\nexport const round = (dimensions: Dimensions): Dimensions => {\n return {\n width: Math.round(dimensions.width),\n height: Math.round(dimensions.height),\n };\n};\n\n/**\n * Returns a `Dimensions` with each length rounded down.\n */\nexport const floor = (dimensions: Dimensions): Dimensions => {\n return {\n width: Math.floor(dimensions.width),\n height: Math.floor(dimensions.height),\n };\n};\n\n/**\n * Returns the center point of the given `dimensions`.\n */\nexport const center = (dimensions: Dimensions): Point.Point => {\n return { x: dimensions.width / 2, y: dimensions.height / 2 };\n};\n\n/**\n * Returns the aspect ratio of the given `dimensions`, as defined by width over\n * height.\n */\nexport const aspectRatio = ({ width, height }: Dimensions): number => {\n return width / height;\n};\n\n/**\n * Returns the area of the given `dimensions`.\n */\nexport const area = ({ width, height }: Dimensions): number => {\n return width * height;\n};\n\n/**\n * Returns a `Dimensions` fitted to the provided aspect ratio.\n *\n * @param ratio - Aspect ratio to fit the provided Dimensions to\n * @param dimensions - Dimensions to fit to the specified ratio\n */\nexport const fitToRatio = (\n ratio: number,\n dimensions: Dimensions\n): Dimensions => {\n if (dimensions.width >= dimensions.height * ratio) {\n return create(dimensions.height * ratio, dimensions.height);\n }\n\n return create(dimensions.width, dimensions.width / ratio);\n};\n\n/**\n * Converts a dimension to a rectangle, with an optional position.\n */\nexport function toRectangle(\n dimensions: Dimensions,\n position: Point.Point = Point.create()\n): Rectangle.Rectangle {\n return Rectangle.fromPointAndDimensions(position, dimensions);\n}\n","import * as Matrix4 from './matrix4';\nimport * as Vector3 from './vector3';\n\n/**\n * A `Line3` represents a line segment between a `start` and `end` point.\n */\nexport interface Line3 {\n /**\n * The start of the line segment.\n */\n start: Vector3.Vector3;\n\n /**\n * The end of the line segment.\n */\n end: Vector3.Vector3;\n}\n\n/**\n * Creates a new `Line3`. If unspecified, the start and end values of the line\n * will be at origin.\n *\n * @param values The values to assign to the line.\n */\nexport function create(values: Partial<Line3> = {}): Line3 {\n return {\n start: values.start ?? Vector3.origin(),\n end: values.end ?? Vector3.origin(),\n };\n}\n\n/**\n * Returns the point that is halfway between start and end.\n */\nexport function center(line: Line3): Vector3.Vector3 {\n return Vector3.lerp(line.start, line.end, 0.5);\n}\n\n/**\n * Returns a line where the start and end points are transformed with the given\n * matrix.\n *\n * @param line The line to transform.\n * @param matrix The matrix to apply.\n * @returns A transformed line.\n */\nexport function transformMatrix(line: Line3, matrix: Matrix4.Matrix4): Line3 {\n const start = Vector3.transformMatrix(line.start, matrix);\n const end = Vector3.transformMatrix(line.end, matrix);\n return { start, end };\n}\n\n/**\n * Euclidean distance between the start and end points of the line.\n */\nexport function distance(line: Line3): number {\n return Vector3.distance(line.start, line.end);\n}\n\n/**\n * Returns the squared distance between a line's start and end point. If you're\n * just comparing distances, this is slightly more efficient than `distanceTo`.\n */\nexport function distanceSquared(line: Line3): number {\n return Vector3.distanceSquared(line.start, line.end);\n}\n\n/**\n * Returns a vector describing the direction of the line from start to end.\n */\nexport function direction(line: Line3): Vector3.Vector3 {\n return Vector3.subtract(line.end, line.start);\n}\n","import { toRadians } from './angle';\nimport * as Point from './point';\n\n/**\n * Represents a 2D transformation matrix.\n *\n * The values of this matrix are meant to represent a 3x3 matrix where the\n * contents are mapped as the following:\n *\n * ```\n * a b tx\n * c d ty\n * u v w\n * ```\n */\nexport interface Matrix {\n /**\n * Value that affects the positioning along the x axis when scaling or\n * rotating.\n */\n a: number;\n\n /**\n * Value that affects the positioning along the y axis when rotating or\n * skewing.\n */\n b: number;\n\n /**\n * Value that affects the positioning along the x axis when rotating or\n * skewing.\n */\n c: number;\n\n /**\n * Value that affects the positioning along the y axis when scaling or\n * rotating.\n */\n d: number;\n\n /**\n * The distance to translate along the x axis.\n */\n tx: number;\n\n /**\n * The distance to translate along the y axis.\n */\n ty: number;\n}\n\n/**\n * Creates a new matrix. If arguments are undefined, returns an identity matrix.\n */\nexport const create = (a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0): Matrix => {\n return { a, b, c, d, tx, ty };\n};\n\n/**\n * Returns an identity matrix.\n */\nexport const identity = (): Matrix => {\n return create();\n};\n\n/**\n * Creates a matrix that is translated by the given `tx` and `ty` values.\n */\nexport const translation = (tx: number, ty: number): Matrix => {\n return translate(tx, ty, identity());\n};\n\n/**\n * Creates a matrix that is rotated by the given degrees.\n */\nexport const rotation = (degrees: number): Matrix => {\n return rotate(degrees, identity());\n};\n\n/**\n * Rotates the given matrix by the given degrees.\n */\nexport const rotate = (degrees: number, matrix: Matrix): Matrix => {\n const radians = toRadians(degrees);\n const cos = Math.cos(radians);\n const sin = Math.sin(radians);\n\n const a = matrix.a * cos + matrix.c * sin;\n const b = matrix.b * cos + matrix.d * sin;\n const c = matrix.a * -sin + matrix.c * cos;\n const d = matrix.b * -sin + matrix.d * cos;\n\n return create(a, b, c, d, matrix.tx, matrix.ty);\n};\n\n/**\n * Translates the given matrix along the horizontal and vertical axis by the\n * given `dx` and `dy` delta values.\n */\nexport const translate = (dx: number, dy: number, matrix: Matrix): Matrix => {\n const newTx = matrix.a * dx + matrix.c * dy + matrix.tx;\n const newTy = matrix.b * dx + matrix.d * dy + matrix.ty;\n return create(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);\n};\n\n/**\n * Returns the result of applying a geometric transformation of a matrix on the\n * given point.\n */\nexport const transformPoint = (\n matrix: Matrix,\n pt: Point.Point\n): Point.Point => {\n const x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;\n const y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;\n return Point.create(x, y);\n};\n","import * as Point from './point';\n\n/**\n * A 2x2 matrix. The contents are mapped as follows:\n *\n * ```\n * a b\n * c d\n * ```\n */\nexport interface Matrix {\n a: number;\n b: number;\n c: number;\n d: number;\n}\n\n/**\n * Creates a new matrix.\n */\nexport function create(a: Point.Point, b: Point.Point): Matrix;\n\nexport function create(a: number, b: number, c: number, d: number): Matrix;\n\nexport function create(): Matrix;\n\nexport function create(...args: any[]): Matrix {\n if (args.length === 2) {\n return {\n a: args[0].x,\n b: args[0].y,\n c: args[1].x,\n d: args[1].y,\n };\n } else if (args.length === 4) {\n return {\n a: args[0],\n b: args[1],\n c: args[2],\n d: args[3],\n };\n }\n\n return {\n a: 0,\n b: 0,\n c: 0,\n d: 0,\n };\n}\n\n/**\n * Returns the determinant of the provided matrix.\n */\nexport function determinant(matrix: Matrix): number {\n return matrix.a * matrix.d - matrix.b * matrix.c;\n}\n\n/**\n * Returns the dot product of the two vectors represented in this matrix.\n */\nexport function dot(matrix: Matrix): number {\n return matrix.a * matrix.c + matrix.b * matrix.d;\n}\n","import * as Line3 from './line3';\nimport * as Vector3 from './vector3';\n\n/**\n * A two dimensional surface in 3D space that extends indefinitely. Represented\n * as a direction normal and distance.\n */\nexport interface Plane {\n normal: Vector3.Vector3;\n constant: number;\n}\n\n/**\n * Creates a new plane. Defaults to a normal of `[0,0,0]` and constant of `0`.\n *\n * @param values Values to assign to the plane.\n * @returns A new plane.\n */\nexport function create(values: Partial<Plane> = {}): Plane {\n return { normal: Vector3.origin(), constant: 0, ...values };\n}\n\n/**\n * Creates a plane from a normal and an arbitrary point on a plane.\n *\n * @param normal A normal.\n * @param point A point on the plane.\n * @returns A new plane.\n */\nexport function fromNormalAndCoplanarPoint(\n normal: Vector3.Vector3,\n point: Vector3.Vector3\n): Plane {\n const constant = -Vector3.dot(point, normal);\n return create({ normal, constant });\n}\n\n/**\n * Returns the perpendicular distance from the plane to the given point.\n *\n * @param plane The plane.\n * @param point The point to calculate distance from `plane`.\n * @returns A distance.\n */\nexport function distanceToPoint(plane: Plane, point: Vector3.Vector3): number {\n return Vector3.dot(plane.normal, point) + plane.constant;\n}\n\n/**\n * Returns the point where the line intersects with this plane. If the line does\n * not intersect, then `undefined` is returned. If the line is on the plane,\n * then the starting point of the line is returned.\n *\n * @param plane The plane to intersect.\n * @param line The line to intersect.\n * @returns An intersecting point on the plane and line.\n */\nexport function intersectLine(\n plane: Plane,\n line: Line3.Line3\n): Vector3.Vector3 | undefined {\n const direction = Line3.direction(line);\n const denominator = Vector3.dot(plane.normal, direction);\n\n if (denominator === 0) {\n if (distanceToPoint(plane, line.start) === 0) {\n return line.start;\n } else {\n return undefined;\n }\n }\n\n const t =\n -(Vector3.dot(line.start, plane.normal) + plane.constant) / denominator;\n if (t < 0 || t > 1) {\n return undefined;\n } else {\n return Vector3.add(Vector3.scale(t, direction), line.start);\n }\n}\n\n/**\n * Projects the given `point` onto the given `plane`.\n *\n * @param plane The plane to project onto.\n * @param point The point to project.\n * @returns The projected point.\n */\nexport function projectPoint(\n plane: Plane,\n point: Vector3.Vector3\n): Vector3.Vector3 {\n const d = distanceToPoint(plane, point);\n return Vector3.add(point, Vector3.scale(-d, plane.normal));\n}\n","import * as Plane from './plane';\nimport * as Vector3 from './vector3';\n\n/**\n * A `Ray` represents an infinite line starting at `origin` and going in\n * `direction`.\n */\nexport interface Ray {\n /**\n * The origin point of the ray.\n */\n origin: Vector3.Vector3;\n\n /**\n * A normal that describes the direction of the ray from origin.\n */\n direction: Vector3.Vector3;\n}\n\n/**\n * Creates a new ray with the given values, or using default values if none are\n * provided. The direction defaults to `{x: 0, y: 0, z: -1}` if undefined.\n *\n * @param value The values of the ray.\n * @returns A new ray.\n */\nexport function create(value: Partial<Ray> = {}): Ray {\n return {\n origin: value.origin ?? Vector3.origin(),\n direction: value.direction ?? Vector3.forward(),\n };\n}\n\n/**\n * Returns a point at the given distance along this ray.\n *\n * @param ray The ray to get the point on.\n * @param distance A distance from origin along the ray's direction.\n * @returns A point on the ray.\n */\nexport function at(ray: Ray, distance: number): Vector3.Vector3 {\n return Vector3.add(Vector3.scale(distance, ray.direction), ray.origin);\n}\n\n/**\n * Computes the distance of the `ray`s origin to the given `plane`. Returns a\n * distance of 0 if the ray is coplanar and returns `undefined` if the ray does\n * not intersect with the plane.\n *\n * @param ray The ray to get the distance for.\n * @param plane The plane to compute the distance to.\n * @returns The distance to the plane, or `undefined` if it cannot be computed.\n */\nexport function distanceToPlane(\n ray: Ray,\n plane: Plane.Plane\n): number | undefined {\n const d = Vector3.dot(plane.normal, ray.direction);\n if (d === 0) {\n // Ray is on plane.\n return Plane.distanceToPoint(plane, ray.origin) === 0 ? 0 : undefined;\n } else {\n const t = -(Vector3.dot(ray.origin, plane.normal) + plane.constant) / d;\n // Checks if ray intersects plane.\n return t >= 0 ? t : undefined;\n }\n}\n\n/**\n * Computes the intersection point of the given `ray` to the given `plane`. If\n * the ray does not intersect with the plane, then `undefined` is returned.\n *\n * @param ray The ray to intersect.\n * @param plane The plane to intersect with.\n * @returns The intersection point, or `undefined` if the ray does not\n * intersect.\n */\nexport function intersectPlane(\n ray: Ray,\n plane: Plane.Plane\n): Vector3.Vector3 | undefined {\n const t = distanceToPlane(ray, plane);\n return t != null ? at(ray, t) : undefined;\n}\n","/**\n * A `Vector4` represents a vector of 4 dimension values. It may represent a\n * point or direction. It may also be used to represent a quadruplet of values,\n * such as a row or column in a transformation matrix.\n */\nexport interface Vector4 {\n x: number;\n y: number;\n z: number;\n w: number;\n}\n\n/**\n * Returns a new Vector4. If `value` is undefined, then `{x: 0, y: 0, z: 0,\n * w: 0}` is returned.\n */\nexport function create(value: Partial<Vector4> = {}): Vector4 {\n return { x: 0, y: 0, z: 0, w: 0, ...value };\n}\n\n/**\n * Parses a JSON string representation of a `Vector4`.\n *\n * @param json A JSON string either in the form of `[x, y, z, w]` or `{\"x\": 0, \"y\": 0, \"z\": 0, \"w\": 0}`.\n * @returns A parsed `Vector4`.\n */\nexport function fromJson(json: string): Vector4 {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, z, w] = obj;\n return create({ x, y, z, w });\n } else {\n return create(obj);\n }\n}\n"],"names":["clamp","value","min","max","Math","lerp","a","b","t","create","x","y","subtract","add","isEqual","scaleProportional","pt","scale","magnitude","sqrt","normalizeVector","magnitudeOfPoint","normalDirectionVector","ptA","ptB","length","radians","cos","sin","delta","lerpNumber","scaleX","scaleY","unitVectorBetweenPoints","abs","pow","json","obj","JSON","parse","Array","isArray","normalize","degrees","toDegrees","PI","toRadians","Point.subtract","atan2","__assign","Object","assign","s","i","n","arguments","p","prototype","hasOwnProperty","call","apply","this","__spreadArray","to","from","pack","ar","l","slice","concat","fromValues","m11","m12","m13","m14","m21","m22","m23","m24","m31","m32","m33","m34","m41","m42","m43","m44","makeIdentity","makeZero","makeTranslation","translation","makeRotation","rotation","z","w","x2","y2","z2","xx","xy","xz","yy","yz","zz","wx","wy","wz","makeScale","makeFrustum","left","right","top","bottom","near","far","multiply","ae","be","a11","a12","a13","a14","a21","a22","a23","a24","a31","a32","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","mat","toObject","m","r","axis","c","tx","ty","fovY","aspect","ymax","tan","Angle.toRadians","xmax","h","d","position","lookAt","up","Vector3.normalize","Vector3.subtract","Vector3.cross","dotX","Vector3.dot","dotY","dotZ","matrix","a00","a01","a02","a03","a10","a20","a30","b00","b01","b02","b03","b04","b05","b06","b07","b08","b09","b10","det","target","Vector3.magnitudeSquared","res","other","identity","every","v","_a","_b","_c","order","_d","fromRotationMatrix","Matrix4.toObject","asin","o","q","scalar","halfAngle","Vector3.fromMatrixScale","is1","is2","is3","sm11","sm12","sm13","sm21","sm22","sm23","sm31","sm32","sm33","trace","euler","ex","ey","ez","c1","c2","c3","s1","s2","s3","args","_i","_e","_f","isValid","isFinite","isNaN","fromMatrixScale","hypot","forward","origin","vector","magnitudeSquared","cross","vectors","reduce","next","dot","transformMatrix","distance","distanceSquared","dx","dy","dz","nums","offset","theta","acos","normalizedA","normalizedB","dotDelta","dotAB","Euler.create","Euler.fromRotationMatrix","Matrix4.makeRotation","Quaternion.normalize","Quaternion.create","onNormal","angle","point","axisDirection","axisPosition","u","ndc","worldMatrix","projectionMatrixInverse","center","boundingBox","Vector3.scale","Vector3.add","diagonal","union","box","rest","boxes","Vector3.min","Vector3.max","map","Vector3.magnitude","Vector3.create","maxIsValid","Vector3.isValid","minIsValid","boundingBoxCenter","BoundingBox.center","radius","epsilon","width","height","fromPointAndDimensions","dimensions","containFit","rect","Dimensions.proportionalScale","Dimensions.center","cropFit","scaleFit","area","Dimensions.floor","topLeft","Point.create","topLeftPt","bottomRightPt","minX","minY","scaleOrScaleX","Point.isEqual","Dimensions.isEqual","Point.add","padding","points","proportionalScale","scaleFactor","floor","toRectangle","Rectangle.fromPointAndDimensions","size","Rectangle.containFit","Rectangle.cropFit","Rectangle.scaleFit","round","ratio","direction","line","end","start","values","Vector3.origin","Vector3.lerp","Vector3.transformMatrix","Vector3.distance","Vector3.distanceSquared","rotate","translate","newTx","newTy","normal","constant","distanceToPoint","plane","Line3.direction","denominator","at","ray","distanceToPlane","Plane.distanceToPoint","undefined","Vector3.forward"],"mappings":"SAQgBA,EAAMC,EAAeC,EAAaC,GAChD,OAAOC,KAAKD,IAAID,EAAKE,KAAKF,IAAIC,EAAKF,GACrC,UAYgBI,EAAKC,EAAWC,EAAWC,GAEzC,OADAA,EAAIR,EAAMQ,EAAG,EAAG,KACJD,EAAID,GAAKA,CACvB,CCVgB,SAAAG,EAAOC,EAAOC,GAC5B,YADqB,IAAAD,IAAAA,EAAK,QAAE,IAAAC,IAAAA,EAAK,GAC1B,CAAED,EAACA,EAAEC,EAACA,EACf,CAsBgB,SAAAC,EAASN,EAAUC,GACjC,MAAO,CAAEG,EAAGJ,EAAEI,EAAIH,EAAEG,EAAGC,EAAGL,EAAEK,EAAIJ,EAAEI,EACpC,CAKgB,SAAAE,EAAIP,EAAUC,GAC5B,MAAO,CAAEG,EAAGJ,EAAEI,EAAIH,EAAEG,EAAGC,EAAGL,EAAEK,EAAIJ,EAAEI,EACpC,CAKgB,SAAAG,EAAQR,EAAUC,GAChC,OAAOD,EAAEI,IAAMH,EAAEG,GAAKJ,EAAEK,IAAMJ,EAAEI,CAClC,CAwCgB,SAAAI,EAAkBC,EAAWC,GAC3C,MAAO,CACLP,EAAGM,EAAGN,EAAIO,EACVN,EAAGK,EAAGL,EAAIM,EAEd,CAKM,SAAUC,EAAUF,GACxB,OAAOZ,KAAKe,KAAKH,EAAGN,EAAIM,EAAGN,EAAIM,EAAGL,EAAIK,EAAGL,EAC3C,CAKM,SAAUS,EAAgBJ,GAC9B,IAAMK,EAAmBH,EAAUF,GACnC,OAAyB,IAArBK,EACKZ,EAAO,EAAG,GAEVM,EAAkBC,EAAI,EAAIK,EAErC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EAAAA,EAAA+I,IACxBL,UAA8B,UAAnBpV,EAAMoV,iBAAa,IAAAzI,EAAAA,EAAAkK,IAElC,0CA8CgB,SACdJ,EACAJ,GAEA,IAAM9V,EAAImW,GAAgBD,EAAKJ,GAC/B,OAAY,MAAL9V,EAAYiW,GAAGC,EAAKlW,QAAKqW,CAClC,ICnEM,SAAUpW,GAAOR,GACrB,YADqB,IAAAA,IAAAA,EAA4B,CAAA,GACjDgD,EAAA,CAASvC,EAAG,EAAGC,EAAG,EAAGkF,EAAG,EAAGC,EAAG,GAAM7F,EACtC,yDAQM,SAAmBmC,GACvB,IAAMC,EAAMC,KAAKC,MAAMH,GACvB,OAAII,MAAMC,QAAQJ,GAET5B,GAAO,CAAEC,EADK2B,KACF1B,EADE0B,EAAG,GACFwD,EADDxD,EAAP,GACWyD,EADJzD,OAGd5B,GAAO4B,EAElB"}
1
+ {"version":3,"file":"bundle.esm.min.js","sources":["../../src/math.ts","../../src/point.ts","../../src/angle.ts","../../../../node_modules/tslib/tslib.es6.js","../../src/matrix4.ts","../../src/euler.ts","../../src/quaternion.ts","../../src/vector3.ts","../../src/boundingBox.ts","../../src/boundingSphere.ts","../../src/rectangle.ts","../../src/dimensions.ts","../../src/line3.ts","../../src/matrix.ts","../../src/matrix2.ts","../../src/plane.ts","../../src/ray.ts","../../src/vector4.ts"],"sourcesContent":["/**\n * Clamps the given value between `min` and `max`.\n *\n * @param value The value to clamp.\n * @param min The min possible value.\n * @param max The max possible value.\n * @returns `value` or a value clamped to `min` or `max`.\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value));\n}\n\n/**\n * Linear interpolates a value between `a` and `b` by `t`. If `t` is 0, then the\n * result will be `a`. If `t` is 1, then the result will be `b`. `t` will be\n * clamped to a value between 0 and 1.\n *\n * @param a The start value.\n * @param b The end value.\n * @param t The interpolation value between 0 and 1.\n * @returns The interpolated value between `a` and `b`.\n */\nexport function lerp(a: number, b: number, t: number): number {\n t = clamp(t, 0, 1);\n return t * (b - a) + a;\n}\n","import * as Angle from './angle';\nimport { lerp as lerpNumber } from './math';\n\n/**\n * A `Point` represents a cartesian coordinate with a horizontal and vertical\n * position or length.\n */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * Returns a new `Point` with the given horizontal and vertical position.\n */\nexport function create(x = 0, y = 0): Point {\n return { x, y };\n}\n\n/**\n * Converts a polar coordinate (length and angle) into a Cartesian coordinate.\n */\nexport function polar(length: number, radians: Angle.Angle): Point {\n const x = Math.cos(radians) * length;\n const y = Math.sin(radians) * length;\n return create(x, y);\n}\n\n/**\n * Returns the distance between two points.\n */\nexport function distance(a: Point, b: Point): number {\n const delta = subtract(a, b);\n return Math.sqrt(delta.x * delta.x + delta.y * delta.y);\n}\n\n/**\n * Returns a new `Point` where `b` is subtracted from `a`.\n */\nexport function subtract(a: Point, b: Point): Point {\n return { x: a.x - b.x, y: a.y - b.y };\n}\n\n/**\n * Returns a new `Point` where `b` is added to `a`.\n */\nexport function add(a: Point, b: Point): Point {\n return { x: a.x + b.x, y: a.y + b.y };\n}\n\n/**\n * Returns `true` if the `x` and `y` positions of `a` and `b` are equal.\n */\nexport function isEqual(a: Point, b: Point): boolean {\n return a.x === b.x && a.y === b.y;\n}\n\n/**\n * Performs a linear interpolation between `a` and `b` and returns the result.\n * The value of `t` is clamped between `[0, 1]`.\n *\n * @param a The start value.\n * @param b The end value.\n * @param t A value between 0 and 1.\n * @returns A point between `a` and `b`.\n */\nexport function lerp(a: Point, b: Point, t: number): Point {\n return {\n x: lerpNumber(a.x, b.x, t),\n y: lerpNumber(a.y, b.y, t),\n };\n}\n\n/**\n * Returns a new `Point` where `x` and `y` are inverted.\n */\nexport function negate(pt: Point): Point {\n return create(-pt.x, -pt.y);\n}\n\n/**\n * Returns a new `Point` where `x` and `y` are multiplied by the given scale\n * factors.\n */\nexport function scale(pt: Point, scaleX: number, scaleY: number): Point {\n return {\n x: pt.x * scaleX,\n y: pt.y * scaleY,\n };\n}\n\n/**\n * Returns a new `Point` where `x` and `y` are multiplied by the given scale\n * factor.\n */\nexport function scaleProportional(pt: Point, scale: number): Point {\n return {\n x: pt.x * scale,\n y: pt.y * scale,\n };\n}\n\n/**\n * Returns the magnitude of a point.\n */\nexport function magnitude(pt: Point): number {\n return Math.sqrt(pt.x * pt.x + pt.y * pt.y);\n}\n\n/**\n * Transforms a vector into the corresponding normal (unit) vector.\n */\nexport function normalizeVector(pt: Point): Point {\n const magnitudeOfPoint = magnitude(pt);\n if (magnitudeOfPoint === 0) {\n return create(0, 0);\n } else {\n return scaleProportional(pt, 1 / magnitudeOfPoint);\n }\n}\n\n/**\n * Returns a new normal (unit) vector pointing between the two given points.\n */\nexport function normalDirectionVector(ptA: Point, ptB: Point): Point {\n return normalizeVector(subtract(ptB, ptA));\n}\n\n/**\n * Returns a vector orthogonal to the vector between the two given points.\n */\nexport function orthogonalVector(ptA: Point, ptB: Point): Point {\n const unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);\n\n // Handle vectors that are parallel to the x or y axis\n if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {\n return create(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);\n }\n\n if (\n Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)\n ) {\n const vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);\n const vectorYValue =\n -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;\n return normalizeVector(create(vectorXValue, vectorYValue));\n } else {\n const vectorXValue =\n -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;\n const vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);\n return normalizeVector(create(vectorXValue, vectorYValue));\n }\n}\n\n/**\n * Parses a JSON string representation of a Point and returns an object.\n *\n * @param json A JSON string, either in the form `[x,y]` or `{\"x\": 0, \"y\": 0}`\n * @returns A parsed Point.\n */\nexport function fromJson(json: string): Point {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y] = obj;\n return create(x, y);\n } else {\n const { x, y } = obj;\n return create(x, y);\n }\n}\n","import * as Point from './point';\n\nexport type Angle = number;\n\n/**\n * Returns an `Angle` between two points, in radians.\n *\n * @param a The starting point.\n * @param b The ending point.\n * @returns An angle in radians.\n */\nexport function fromPoints(a: Point.Point, b: Point.Point): Angle {\n const delta = Point.subtract(b, a);\n const theta = Math.atan2(delta.y, delta.x);\n return theta;\n}\n\n/**\n * Returns an `Angle` between two points, in degrees.\n *\n * An angle of 0 represents an upward vector, and increases in a clockwise\n * direction.\n *\n * @deprecated Use {@link fromPoints} instead.\n */\nexport function fromPointsInDegrees(a: Point.Point, b: Point.Point): Angle {\n const delta = Point.subtract(b, a);\n const theta = Math.atan2(delta.y, delta.x);\n return normalize(toDegrees(theta) - 270);\n}\n\n/**\n * Normalizes the given angle, in degrees, to a number greater than or equal to 0 and less than 360.\n */\nexport function normalize(degrees: Angle): Angle {\n return (degrees + 3600) % 360;\n}\n\n/**\n * Normalizes the given angle, in radians, to a number greater than or equal to 0 and less than 2 PI.\n */\nexport function normalizeRadians(radians: Angle): Angle {\n return toRadians(normalize(toDegrees(radians)));\n}\n\n/**\n * Converts the given radians to degrees.\n */\nexport function toDegrees(radians: Angle): Angle {\n return radians * (180 / Math.PI);\n}\n\n/**\n * Converts the given degrees to radians.\n */\nexport function toRadians(degrees: Angle): Angle {\n return degrees * (Math.PI / 180);\n}\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import * as Angle from './angle';\nimport * as Quaternion from './quaternion';\nimport * as Vector3 from './vector3';\n\n/**\n * A type alias representing a 4x4 column-major matrix.\n *\n * The common use-case for 4x4 matrices in 3D computer graphics are for\n * [transformation\n * matrices](https://en.wikipedia.org/wiki/Transformation_matrix). This allows a\n * point in 3D space to be projected onto a 2D screen using transformations such\n * as translation, rotation and scale.\n */\nexport type Matrix4 = [\n /* eslint-disable prettier/prettier */\n number, number, number, number,\n number, number, number, number,\n number, number, number, number,\n number, number, number, number,\n /* eslint-enable prettier/prettier */\n];\n\n/**\n * An object representation of a `Matrix4`, where each value is represented as:\n *\n * ```\n * m11 m12 m13 m14\n * m21 m22 m23 m24\n * m31 m32 m33 m34\n * m41 m42 m43 m44\n * ```\n *\n * `Matrix4` arrays can be converted to an object using {@link toObject}.\n */\nexport interface Matrix4AsObject {\n m11: number;\n m12: number;\n m13: number;\n m14: number;\n\n m21: number;\n m22: number;\n m23: number;\n m24: number;\n\n m31: number;\n m32: number;\n m33: number;\n m34: number;\n\n m41: number;\n m42: number;\n m43: number;\n m44: number;\n}\n\n/**\n * Creates a 4x4 matrix from a set of row-major components.\n */\nexport function fromValues(\n /* eslint-disable prettier/prettier */\n m11: number, m12: number, m13: number, m14: number,\n m21: number, m22: number, m23: number, m24: number,\n m31: number, m32: number, m33: number, m34: number,\n m41: number, m42: number, m43: number, m44: number,\n /* eslint-enable prettier/prettier */\n): Matrix4 {\n /* eslint-disable prettier/prettier */\n return [\n m11, m21, m31, m41,\n m12, m22, m32, m42,\n m13, m23, m33, m43,\n m14, m24, m34, m44,\n ]\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a `Matrix4` from an object representation.\n */\nexport function fromObject(obj: Matrix4AsObject): Matrix4 {\n /* eslint-disable prettier/prettier */\n return fromValues(\n obj.m11, obj.m12, obj.m13, obj.m14,\n obj.m21, obj.m22, obj.m23, obj.m24,\n obj.m31, obj.m32, obj.m33, obj.m34,\n obj.m41, obj.m42, obj.m43, obj.m44\n );\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Returns a new [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix).\n */\nexport function makeIdentity(): Matrix4 {\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n}\n\n/**\n * Returns a matrix with all values as 0.\n */\nexport function makeZero(): Matrix4 {\n return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n}\n\n/**\n * Creates a translation matrix.\n *\n * ```\n * 1, 0, 0, 0,\n * 0, 1, 0, 0,\n * 0, 0, 1, 0,\n * x, y, z, 1\n * ```\n *\n * @param translation A vector representing the translation components.\n * @returns A translation matrix.\n */\nexport function makeTranslation(translation: Vector3.Vector3): Matrix4 {\n const { x, y, z } = translation;\n /* eslint-disable prettier/prettier */\n return [\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n x, y, z, 1,\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a rotation matrix.\n *\n * ```\n * 1-2y²-2z², 2xy-2zw, 2xz+2yw, 0,\n * 2xy+2zw, 1-2x²-2z², 2yz-2xw, 0,\n * 2xz-2yw, 2yz+2xw, 1-2x²-2y², 0,\n * 0, 0, 0, 1,\n * ```\n *\n * @param rotation A quaternion representing the rotation.\n * @see https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion\n * @returns A rotation matrix.\n */\nexport function makeRotation(rotation: Quaternion.Quaternion): Matrix4 {\n const { x, y, z, w } = rotation;\n\n const x2 = x + x,\n y2 = y + y,\n z2 = z + z;\n const xx = x * x2,\n xy = x * y2,\n xz = x * z2;\n const yy = y * y2,\n yz = y * z2,\n zz = z * z2;\n const wx = w * x2,\n wy = w * y2,\n wz = w * z2;\n\n /* eslint-disable prettier/prettier */\n return [\n 1 - ( yy + zz ), xy + wz, xz - wy, 0,\n xy - wz, 1 - ( xx + zz ), yz + wx, 0,\n xz + wy, yz - wx, 1 - ( xx + yy ), 0,\n 0, 0, 0, 1\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a scale matrix.\n *\n * ```\n * x, 0, 0, 0,\n * 0, y, 0, 0,\n * 0, 0, z, 0,\n * 0, 0, 0, 1\n * ```\n *\n * @param scale A vector representing the different scale components.\n * @returns A scale matrix.\n */\nexport function makeScale(scale: Vector3.Vector3): Matrix4 {\n const { x, y, z } = scale;\n /* eslint-disable prettier/prettier */\n return [\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1,\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a matrix that has translation, rotation and scale applied to it.\n *\n * @param translation The translation applied to the matrix.\n * @param rotation The rotation applied to the matrix.\n * @param scale The scale applied to the matrix.\n * @returns A transformed matrix.\n */\nexport function makeTRS(\n translation: Vector3.Vector3,\n rotation: Quaternion.Quaternion,\n scale: Vector3.Vector3\n): Matrix4 {\n const t = makeTranslation(translation);\n const r = makeRotation(rotation);\n const s = makeScale(scale);\n return multiply(multiply(t, r), s);\n}\n\n/**\n * Returns a matrix that has the basis components (upper left 3x3 matrix) set to\n * the following x, y, and z axis.\n *\n * ```\n * x.x y.x z.x 0\n * x.y y.y z.y 0\n * x.z y.z z.z 0\n * 0 0 0 0\n * ```\n *\n * @param x The x axis to set.\n * @param y The y axis to set.\n * @param z The z axis to set.\n * @returns A matrix with its basis components populated.\n */\nexport function makeBasis(\n x: Vector3.Vector3,\n y: Vector3.Vector3,\n z: Vector3.Vector3\n): Matrix4 {\n /* eslint-disable prettier/prettier */\n return [\n x.x, x.y, x.z, 0,\n y.x, y.y, y.z, 0,\n z.x, z.y, z.z, 0,\n 0, 0, 0, 1\n ]\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a rotation matrix that is rotated around a given axis by the given\n * angle.\n *\n * @param axis The axis of rotation.\n * @param radians The angle of rotation.\n * @returns A rotation matrix.\n */\nexport function makeRotationAxis(\n axis: Vector3.Vector3,\n radians: number\n): Matrix4 {\n const c = Math.cos(radians);\n const s = Math.sin(radians);\n const t = 1 - c;\n\n const { x, y, z } = axis;\n\n const tx = t * x;\n const ty = t * y;\n\n /* eslint-disable prettier/prettier */\n return [\n tx * x + c, tx * y + s * z, tx * z - s * y, 0,\n tx * y - s * z, ty * y + c, ty * z + s * x, 0,\n tx * z + s * y, ty * z - s * x, t * z * z + c, 0,\n 0, 0, 0, 1\n ]\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a matrix used for [perspective\n * projections](https://en.wikipedia.org/wiki/3D_projection#Perspective_projection).\n *\n * The viewing volume is frustum-shaped and defined by the six parameters. Left,\n * right, top, and bottom specify coordinates in the near clipping plane where\n * the frustum edges intersect it, and the near and far parameters define the\n * forward distances of the view volume. The resulting volume can be vertically\n * and horizontally asymmetrical around the center of the near plane.\n *\n * @param left The left coordinate at the near plane.\n * @param right The right coordinate at the near plane.\n * @param top The top coordinate at the near plane.\n * @param bottom The bottom coordinate at the near plane.\n * @param near The near distance.\n * @param far The far distance.\n * @returns A matrix representing a view frustum.\n */\nexport function makeFrustum(\n left: number,\n right: number,\n top: number,\n bottom: number,\n near: number,\n far: number\n): Matrix4 {\n const x = (2 * near) / (right - left);\n const y = (2 * near) / (top - bottom);\n\n const a = (right + left) / (right - left);\n const b = (top + bottom) / (top - bottom);\n const c = -(far + near) / (far - near);\n const d = (-2 * far * near) / (far - near);\n\n /* eslint-disable prettier/prettier */\n return [\n x, 0, 0, 0,\n 0, y, 0, 0,\n a, b, c, -1,\n 0, 0, d, 0\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Creates a perspective projection matrix.\n *\n * Related to: gluPerspective. The viewing volume is frustum-shaped amd defined\n * by the four parameters. The fovy and aspect ratio are used to compute the\n * positions of the left, right, top, and bottom sides of the viewing volume in\n * the zNear plane. The fovy is the y field-of-view, the angle made by the top\n * and bottom sides of frustum if they were to intersect. The aspect ratio is\n * the width of the frustum divided by its height. Note that the resulting\n * volume is both vertically and horizontally symmetrical around the center of\n * the near plane.\n *\n * @param near The near Z value.\n * @param far The far Z value.\n * @param fovY The field of view.\n * @param aspect The aspect ratio.\n * @returns A matrix.\n */\nexport function makePerspective(\n near: number,\n far: number,\n fovY: number,\n aspect: number\n): Matrix4 {\n const ymax = near * Math.tan(Angle.toRadians(fovY / 2.0));\n const xmax = ymax * aspect;\n\n const left = -xmax;\n const right = xmax;\n const top = ymax;\n const bottom = -ymax;\n\n return makeFrustum(left, right, top, bottom, near, far);\n}\n\n/**\n * Creates an orthographic projection matrix.\n *\n * Related to: gluOrtho. The viewing volume is cube-shaped and defined by\n * the six parameters. The left and right values represent the coordinates of\n * the vertical clipping planes, top and bottom values represent the coordinates\n * of the horizontal clipping planes, and near and far values represent the\n * coordinates of the depth clipping planes.\n *\n * @param left The coordinate of the left horizontal clipping plane.\n * @param right The coordinate of the right horizontal clipping plane.\n * @param bottom The coordinate of the bottom vertical clipping plane.\n * @param top The coordinate of the top vertical clipping plane.\n * @param near The coordinate of the near depth clipping plane.\n * @param far The coordinate of the far depth clipping plane.\n * @returns A matrix.\n */\nexport function makeOrthographic(\n left: number,\n right: number,\n bottom: number,\n top: number,\n near: number,\n far: number\n): Matrix4 {\n const w = 1.0 / (right - left);\n const h = 1.0 / (top - bottom);\n const d = 1.0 / (far - near);\n\n const x = (right + left) * w;\n const y = (top + bottom) * h;\n const z = (far + near) * d;\n\n /* eslint-disable prettier/prettier */\n return [\n 2 * w, 0, 0, -x,\n 0, 2 * h, 0, -y,\n 0, 0, -2 * d, -z,\n 0, 0, 0, 1\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Matrix becomes a combination of an inverse translation and rotation.\n *\n * Related to: gluLookAt. This creates the inverse of makeLookAtMatrix. The\n * matrix will be an opposite translation from the 'eye' position, and it will\n * rotate things in the opposite direction of the eye-to-center orientation.\n * This is definitely confusing, but the main reason to use this transform is to\n * set up a view matrix for a camera that's looking at a certain point. To\n * achieve the effect of moving the camera somewhere and rotating it so that it\n * points at something, the rest of the world is moved in the opposite direction\n * and rotated in the opposite way around the camera. This way, you get the same\n * effect as moving the actual camera, but all the projection math can still be\n * done with the camera positioned at the origin (which makes it way simpler).\n *\n * @param position The position of the object.\n * @param lookAt The point which the object is looking at.\n * @param up The direction which the object considers up.\n * @returns A matrix.\n */\nexport function makeLookAtView(\n position: Vector3.Vector3,\n lookAt: Vector3.Vector3,\n up: Vector3.Vector3\n): Matrix4 {\n const z = Vector3.normalize(Vector3.subtract(position, lookAt));\n const x = Vector3.normalize(Vector3.cross(up, z));\n const y = Vector3.cross(z, x);\n\n const dotX = -Vector3.dot(x, position);\n const dotY = -Vector3.dot(y, position);\n const dotZ = -Vector3.dot(z, position);\n\n /* eslint-disable prettier/prettier */\n return [\n x.x, y.x, z.x, 0,\n x.y, y.y, z.y, 0,\n x.z, y.z, z.z, 0,\n dotX, dotY, dotZ, 1,\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Matrix becomes a combination of translation and rotation.\n *\n * Matrix becomes a combination of a translation to the position of 'eye' and a\n * rotation matrix which orients an object to point towards 'center' along its\n * z-axis. Use this function if you want an object to look at a point from\n * another point in space.\n *\n * @param position The position of the object.\n * @param lookAt The point which the object is looking at.\n * @param up The direction which the object considers up.\n * @returns A matrix.\n */\nexport function makeLookAt(\n position: Vector3.Vector3,\n lookAt: Vector3.Vector3,\n up: Vector3.Vector3\n): Matrix4 {\n const z = Vector3.normalize(Vector3.subtract(position, lookAt));\n const x = Vector3.normalize(Vector3.cross(up, z));\n const y = Vector3.cross(z, x);\n\n /* eslint-disable prettier/prettier */\n return [\n x.x, x.y, x.z, 0,\n y.x, y.y, y.z, 0,\n z.x, z.y, z.z, 0,\n position.x, position.y, position.z, 1\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Returns the inverse of the given matrix. If the determinate of the matrix is\n * zero, then a zero matrix is returned.\n */\nexport function invert(matrix: Matrix4): Matrix4 {\n const a00 = matrix[0],\n a01 = matrix[1],\n a02 = matrix[2],\n a03 = matrix[3];\n const a10 = matrix[4],\n a11 = matrix[5],\n a12 = matrix[6],\n a13 = matrix[7];\n const a20 = matrix[8],\n a21 = matrix[9],\n a22 = matrix[10],\n a23 = matrix[11];\n const a30 = matrix[12],\n a31 = matrix[13],\n a32 = matrix[14],\n a33 = matrix[15];\n\n const b00 = a00 * a11 - a01 * a10;\n const b01 = a00 * a12 - a02 * a10;\n const b02 = a00 * a13 - a03 * a10;\n const b03 = a01 * a12 - a02 * a11;\n const b04 = a01 * a13 - a03 * a11;\n const b05 = a02 * a13 - a03 * a12;\n const b06 = a20 * a31 - a21 * a30;\n const b07 = a20 * a32 - a22 * a30;\n const b08 = a20 * a33 - a23 * a30;\n const b09 = a21 * a32 - a22 * a31;\n const b10 = a21 * a33 - a23 * a31;\n const b11 = a22 * a33 - a23 * a32;\n\n // Calculate the determinant\n let det =\n b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return makeZero();\n }\n det = 1.0 / det;\n\n return [\n (a11 * b11 - a12 * b10 + a13 * b09) * det,\n (a02 * b10 - a01 * b11 - a03 * b09) * det,\n (a31 * b05 - a32 * b04 + a33 * b03) * det,\n (a22 * b04 - a21 * b05 - a23 * b03) * det,\n\n (a12 * b08 - a10 * b11 - a13 * b07) * det,\n (a00 * b11 - a02 * b08 + a03 * b07) * det,\n (a32 * b02 - a30 * b05 - a33 * b01) * det,\n (a20 * b05 - a22 * b02 + a23 * b01) * det,\n\n (a10 * b10 - a11 * b08 + a13 * b06) * det,\n (a01 * b08 - a00 * b10 - a03 * b06) * det,\n (a30 * b04 - a31 * b02 + a33 * b00) * det,\n (a21 * b02 - a20 * b04 - a23 * b00) * det,\n\n (a11 * b07 - a10 * b09 - a12 * b06) * det,\n (a00 * b09 - a01 * b07 + a02 * b06) * det,\n (a31 * b01 - a30 * b03 - a32 * b00) * det,\n (a20 * b03 - a21 * b01 + a22 * b00) * det,\n ];\n}\n\n/**\n * Returns a rotation matrix looking from position towards target and oriented\n * by an up vector.\n *\n * @param m The matrix to transform.\n * @param position The point from which to look at target.\n * @param target The point to look at.\n * @param up The orientation.\n * @returns A rotation matrix.\n */\nexport function lookAt(\n m: Matrix4,\n position: Vector3.Vector3,\n target: Vector3.Vector3,\n up: Vector3.Vector3\n): Matrix4 {\n let z = Vector3.subtract(position, target);\n if (Vector3.magnitudeSquared(z) === 0) {\n z = { ...z, z: 1 };\n }\n z = Vector3.normalize(z);\n\n let x = Vector3.cross(up, z);\n if (Vector3.magnitudeSquared(x) === 0) {\n if (Math.abs(up.z) === 1) {\n z = { ...z, x: z.x + 0.0001 };\n } else {\n z = { ...z, z: z.z + 0.0001 };\n }\n\n z = Vector3.normalize(z);\n x = Vector3.cross(up, z);\n }\n x = Vector3.normalize(x);\n\n const y = Vector3.cross(z, x);\n\n const res: Matrix4 = [...m];\n /* eslint-disable prettier/prettier */\n res[0] = x.x; res[4] = y.x; res[8] = z.x;\n res[1] = x.y; res[5] = y.y; res[9] = z.y;\n res[2] = x.z; res[6] = y.z; res[10] = z.z;\n /* eslint-enable prettier/prettier */\n return res;\n}\n\n/**\n * Returns a post-multiplied matrix.\n */\nexport function multiply(a: Matrix4, b: Matrix4): Matrix4 {\n const ae = a;\n const be = b;\n\n const a11 = ae[0],\n a12 = ae[4],\n a13 = ae[8],\n a14 = ae[12];\n const a21 = ae[1],\n a22 = ae[5],\n a23 = ae[9],\n a24 = ae[13];\n const a31 = ae[2],\n a32 = ae[6],\n a33 = ae[10],\n a34 = ae[14];\n const a41 = ae[3],\n a42 = ae[7],\n a43 = ae[11],\n a44 = ae[15];\n\n const b11 = be[0],\n b12 = be[4],\n b13 = be[8],\n b14 = be[12];\n const b21 = be[1],\n b22 = be[5],\n b23 = be[9],\n b24 = be[13];\n const b31 = be[2],\n b32 = be[6],\n b33 = be[10],\n b34 = be[14];\n const b41 = be[3],\n b42 = be[7],\n b43 = be[11],\n b44 = be[15];\n\n const mat = makeIdentity();\n mat[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n mat[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n mat[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n mat[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\n mat[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n mat[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n mat[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n mat[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\n mat[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n mat[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n mat[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n mat[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\n mat[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n mat[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n mat[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n mat[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\n return mat;\n}\n\n/**\n * Returns the [transpose](https://en.wikipedia.org/wiki/Transpose) of the given\n * matrix.\n */\nexport function transpose(matrix: Matrix4): Matrix4 {\n /* eslint-disable prettier/prettier */\n return [\n matrix[0], matrix[4], matrix[8], matrix[12],\n matrix[1], matrix[5], matrix[9], matrix[13],\n matrix[2], matrix[6], matrix[10], matrix[14],\n matrix[3], matrix[7], matrix[11], matrix[15],\n ];\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * Multiplies the columns of a matrix by the given vector.\n */\nexport function scale(matrix: Matrix4, scale: Vector3.Vector3): Matrix4 {\n const { x, y, z } = scale;\n const m: Matrix4 = [...matrix];\n /* eslint-disable prettier/prettier */\n m[0] *= x; m[4] *= y; m[8] *= z;\n m[1] *= x; m[5] *= y; m[9] *= z;\n m[2] *= x; m[6] *= y; m[10] *= z;\n m[3] *= x; m[7] *= y; m[11] *= z;\n /* eslint-enable prettier/prettier */\n return m;\n}\n\nexport function position(matrix: Matrix4, other: Matrix4): Matrix4 {\n const m: Matrix4 = [...matrix];\n m[12] = other[12];\n m[13] = other[13];\n m[14] = other[14];\n return m;\n}\n\n/**\n * Returns true if the matrix is an identity matrix.\n */\nexport function isIdentity(matrix: Matrix4): boolean {\n const identity = makeIdentity();\n\n return matrix.every((v, i) => v === identity[i]);\n}\n\n/**\n * Returns an object representation of a `Matrix4`.\n */\nexport function toObject(m: Matrix4): Matrix4AsObject {\n /* eslint-disable prettier/prettier */\n return {\n m11: m[0], m12: m[4], m13: m[8], m14: m[12],\n m21: m[1], m22: m[5], m23: m[9], m24: m[13],\n m31: m[2], m32: m[6], m33: m[10], m34: m[14],\n m41: m[3], m42: m[7], m43: m[11], m44: m[15],\n }\n /* eslint-enable prettier/prettier */\n}\n\n/**\n * A type guard to check if `obj` is of type `Matrix4`.\n */\nexport function isType(obj: unknown): obj is Matrix4 {\n return Array.isArray(obj) && obj.length === 16;\n}\n","import * as Angle from './angle';\nimport { clamp } from './math';\nimport * as Matrix4 from './matrix4';\n\n/**\n * A string representing the axis order of rotation.\n */\nexport type EulerOrder = 'xyz' | 'yzx' | 'zxy' | 'xzy' | 'yxz' | 'zyx';\n\n/**\n * A type that represents [Euler Angles](http://en.wikipedia.org/wiki/Euler_angles).\n */\nexport interface Euler {\n x: number;\n y: number;\n z: number;\n order: EulerOrder;\n}\n\n/**\n * Creates a new set of Euler angles where each axis of rotation is defined by an angle,\n * in radians. If no value is given, then `{x: 0, y: 0, z: 0, order: 'xyz'}` is\n * returned.\n *\n * @param value The values to populate the Euler angles with.\n * @returns A set of Euler angles.\n */\nexport function create(value: Partial<Euler> = {}): Euler {\n return {\n x: value.x ?? 0,\n y: value.y ?? 0,\n z: value.z ?? 0,\n order: value.order ?? 'xyz',\n };\n}\n\n/**\n * Creates a new set of Euler angles where each axis of rotation is defined by an angle,\n * in degrees. If no value is given, then `{x: 0, y: 0, z: 0, order: 'xyz'}` is\n * returned.\n *\n * @param value The values to populate the Euler angles with.\n * @returns A set of Euler angles.\n */\nexport function fromDegrees(value: Partial<Euler> = {}): Euler {\n const { x = 0, y = 0, z = 0, order } = value;\n return create({\n x: Angle.toRadians(x),\n y: Angle.toRadians(y),\n z: Angle.toRadians(z),\n order,\n });\n}\n\n/**\n * Creates a set of Euler angles from the rotation components of a 4x4 matrix. The\n * rotation components are represented by the upper 3x3 of the matrix.\n *\n * Note that there are two solutions for the Euler angle of the 2nd applied\n * rotation (i.e. y for xyz) because sin(theta) = sin(PI-theta).\n * The returned angle will always be the solution between -PI/2 and PI/2.\n *\n * @param matrix A pure rotation matrix, unscaled.\n * @param order The order that the rotations are applied.\n */\nexport function fromRotationMatrix(\n matrix: Matrix4.Matrix4,\n order: EulerOrder = 'xyz'\n): Euler {\n const m = Matrix4.toObject(matrix);\n\n let x = 0,\n y = 0,\n z = 0;\n\n if (order === 'xyz') {\n y = Math.asin(clamp(m.m13, -1, 1));\n if (Math.abs(m.m13) < 0.9999999) {\n x = Math.atan2(-m.m23, m.m33);\n z = Math.atan2(-m.m12, m.m11);\n } else {\n x = Math.atan2(m.m32, m.m22);\n z = 0;\n }\n } else if (order === 'yxz') {\n x = Math.asin(-clamp(m.m23, -1, 1));\n if (Math.abs(m.m23) < 0.9999999) {\n y = Math.atan2(m.m13, m.m33);\n z = Math.atan2(m.m21, m.m22);\n } else {\n y = Math.atan2(-m.m31, m.m11);\n z = 0;\n }\n } else if (order === 'zxy') {\n x = Math.asin(clamp(m.m32, -1, 1));\n if (Math.abs(m.m32) < 0.9999999) {\n y = Math.atan2(-m.m31, m.m33);\n z = Math.atan2(-m.m12, m.m22);\n } else {\n y = 0;\n z = Math.atan2(m.m21, m.m11);\n }\n } else if (order === 'zyx') {\n y = Math.asin(-clamp(m.m31, -1, 1));\n if (Math.abs(m.m31) < 0.9999999) {\n x = Math.atan2(m.m32, m.m33);\n z = Math.atan2(m.m21, m.m11);\n } else {\n x = 0;\n z = Math.atan2(-m.m12, m.m22);\n }\n } else if (order === 'yzx') {\n z = Math.asin(clamp(m.m21, -1, 1));\n if (Math.abs(m.m21) < 0.9999999) {\n x = Math.atan2(-m.m23, m.m22);\n y = Math.atan2(-m.m31, m.m11);\n } else {\n x = 0;\n y = Math.atan2(m.m13, m.m33);\n }\n } else if (order === 'xzy') {\n z = Math.asin(-clamp(m.m12, -1, 1));\n if (Math.abs(m.m12) < 0.9999999) {\n x = Math.atan2(m.m32, m.m22);\n y = Math.atan2(m.m13, m.m11);\n } else {\n x = Math.atan2(-m.m23, m.m33);\n y = 0;\n }\n }\n\n return { x, y, z, order };\n}\n\n/**\n * Returns a set of Euler angles that was decoded from a JSON string. Supports either\n * extracting values from an array `[x, y, z, order]` or object `{x, y, z,\n * order}`.\n *\n * @param json A JSON object.\n * @returns A set of Euler angles.\n */\nexport function fromJson(json: string): Euler {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, z, order = 'xyz'] = obj;\n return { x, y, z, order };\n } else {\n const { x, y, z, order = 'xyz' } = obj;\n return { x, y, z, order };\n }\n}\n\n/**\n * Type guard that checks if the given type is a set of Euler angles.\n */\nexport function isType(obj: unknown): obj is Euler {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const o = obj as any;\n return (\n o != null &&\n o.hasOwnProperty('x') &&\n o.hasOwnProperty('y') &&\n o.hasOwnProperty('z') &&\n o.hasOwnProperty('order')\n );\n}\n","import * as Euler from './euler';\nimport * as Matrix4 from './matrix4';\nimport * as Vector3 from './vector3';\n\n/**\n * A type that represents a\n * [quaternion](http://en.wikipedia.org/wiki/Quaternion). Quaternions are used\n * in 3D graphics to represent\n * [rotations](https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation).\n */\nexport interface Quaternion {\n x: number;\n y: number;\n z: number;\n w: number;\n}\n\n/**\n * An array representation of a `Quaternion`.\n */\nexport type QuaternionAsArray = [x: number, y: number, z: number, w: number];\n\n/**\n * Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,\n * w: 1}` is returned.\n */\nexport function create(value: Partial<Quaternion> = {}): Quaternion {\n return { x: 0, y: 0, z: 0, w: 1, ...value };\n}\n\n/**\n * Parses a JSON string representation of a `Quaternion`.\n *\n * @param json A JSON string either in the form of `[x, y, z, w]` or `{\"x\": 0, \"y\": 0, \"z\": 0, \"w\": 0}`.\n * @returns A parsed `Quaternion`.\n */\nexport function fromJson(json: string): Quaternion {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, z, w] = obj;\n return create({ x, y, z, w });\n } else {\n return create(obj);\n }\n}\n\n/**\n * Returns a quaternion with that will have a magnitude of 1.\n */\nexport function normalize(q: Quaternion): Quaternion {\n return scale(1 / magnitude(q), q);\n}\n\n/**\n * Returns the magnitude of the provided quaternion.\n */\nexport function magnitude(q: Quaternion): number {\n return Math.sqrt(q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z);\n}\n\n/**\n * Returns a quaternion where each component is multiplied by the `scalar`.\n */\nexport function scale(scalar: number, q: Quaternion): Quaternion {\n return create({\n w: q.w * scalar,\n x: q.x * scalar,\n y: q.y * scalar,\n z: q.z * scalar,\n });\n}\n\n/**\n * Creates a `Quaternion` that is rotated the given radians around an axis.\n *\n * @param axis The axis to rotate around.\n * @param radians The rotation, in radians.\n * @returns A rotated quaternion.\n */\nexport function fromAxisAngle(\n axis: Vector3.Vector3,\n radians: number\n): Quaternion {\n const halfAngle = radians / 2;\n const s = Math.sin(halfAngle);\n\n const x = axis.x * s;\n const y = axis.y * s;\n const z = axis.z * s;\n const w = Math.cos(halfAngle);\n return { x, y, z, w };\n}\n\n/**\n * Returns a quaternion using the upper 3x3 of a pure rotation matrix\n * (unscaled).\n */\nexport function fromMatrixRotation(matrix: Matrix4.Matrix4): Quaternion {\n const m = Matrix4.toObject(matrix);\n const scale = Vector3.fromMatrixScale(matrix);\n\n const is1 = 1 / scale.x;\n const is2 = 1 / scale.y;\n const is3 = 1 / scale.z;\n\n const sm11 = m.m11 * is1;\n const sm12 = m.m21 * is2;\n const sm13 = m.m31 * is3;\n const sm21 = m.m12 * is1;\n const sm22 = m.m22 * is2;\n const sm23 = m.m32 * is3;\n const sm31 = m.m13 * is1;\n const sm32 = m.m23 * is2;\n const sm33 = m.m33 * is3;\n\n const trace = sm11 + sm22 + sm33;\n if (trace > 0) {\n const s = Math.sqrt(trace + 1.0) * 2;\n return {\n x: (sm23 - sm32) / s,\n y: (sm31 - sm13) / s,\n z: (sm12 - sm21) / s,\n w: 0.25 * s,\n };\n } else if (sm11 > sm22 && sm11 > sm33) {\n const s = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;\n return {\n x: 0.25 * s,\n y: (sm12 + sm21) / s,\n z: (sm31 + sm13) / s,\n w: (sm23 - sm32) / s,\n };\n } else if (sm22 > sm33) {\n const s = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;\n return {\n x: (sm12 + sm21) / s,\n y: 0.25 * s,\n z: (sm23 + sm32) / s,\n w: (sm31 - sm13) / s,\n };\n } else {\n const s = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;\n return {\n x: (sm31 + sm13) / s,\n y: (sm23 + sm32) / s,\n z: 0.25 * s,\n w: (sm12 - sm21) / s,\n };\n }\n}\n\nexport function fromEuler(euler: Euler.Euler): Quaternion {\n const { x: ex, y: ey, z: ez, order } = euler;\n const c1 = Math.cos(ex / 2);\n const c2 = Math.cos(ey / 2);\n const c3 = Math.cos(ez / 2);\n\n const s1 = Math.sin(ex / 2);\n const s2 = Math.sin(ey / 2);\n const s3 = Math.sin(ez / 2);\n\n let x = 0,\n y = 0,\n z = 0,\n w = 0;\n\n switch (order) {\n case 'xyz':\n x = s1 * c2 * c3 + c1 * s2 * s3;\n y = c1 * s2 * c3 - s1 * c2 * s3;\n z = c1 * c2 * s3 + s1 * s2 * c3;\n w = c1 * c2 * c3 - s1 * s2 * s3;\n break;\n\n case 'yxz':\n x = s1 * c2 * c3 + c1 * s2 * s3;\n y = c1 * s2 * c3 - s1 * c2 * s3;\n z = c1 * c2 * s3 - s1 * s2 * c3;\n w = c1 * c2 * c3 + s1 * s2 * s3;\n break;\n\n case 'zxy':\n x = s1 * c2 * c3 - c1 * s2 * s3;\n y = c1 * s2 * c3 + s1 * c2 * s3;\n z = c1 * c2 * s3 + s1 * s2 * c3;\n w = c1 * c2 * c3 - s1 * s2 * s3;\n break;\n\n case 'zyx':\n x = s1 * c2 * c3 - c1 * s2 * s3;\n y = c1 * s2 * c3 + s1 * c2 * s3;\n z = c1 * c2 * s3 - s1 * s2 * c3;\n w = c1 * c2 * c3 + s1 * s2 * s3;\n break;\n\n case 'yzx':\n x = s1 * c2 * c3 + c1 * s2 * s3;\n y = c1 * s2 * c3 + s1 * c2 * s3;\n z = c1 * c2 * s3 - s1 * s2 * c3;\n w = c1 * c2 * c3 - s1 * s2 * s3;\n break;\n\n case 'xzy':\n x = s1 * c2 * c3 - c1 * s2 * s3;\n y = c1 * s2 * c3 - s1 * c2 * s3;\n z = c1 * c2 * s3 + s1 * s2 * c3;\n w = c1 * c2 * c3 + s1 * s2 * s3;\n break;\n }\n\n return { x, y, z, w };\n}\n\n/**\n * Multiplies `a` x `b` and returns a new quaternion with the result.\n */\nexport function multiply(a: Quaternion, b: Quaternion): Quaternion {\n // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\n return {\n x: a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y,\n y: a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z,\n z: a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x,\n w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z,\n };\n}\n\n/**\n * Type guard that checks if the given type is a Quaternion.\n */\nexport function isType(obj: unknown): obj is Quaternion {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const o = obj as any;\n return (\n o != null &&\n o.hasOwnProperty('x') &&\n o.hasOwnProperty('y') &&\n o.hasOwnProperty('z') &&\n o.hasOwnProperty('w')\n );\n}\n","import { Angle, Vector3 } from '.';\nimport * as Euler from './euler';\nimport { lerp as lerpNumber } from './math';\nimport * as Matrix4 from './matrix4';\nimport * as Quaternion from './quaternion';\n\n/**\n * A `Vector3` represents a vector of 3 dimensions values. It may represent a\n * point or direction.\n */\nexport interface Vector3 {\n x: number;\n y: number;\n z: number;\n}\n\n/**\n * A `Vector3` representation as an array.\n */\nexport type Vector3AsArray = [x: number, y: number, z: number];\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable padding-line-between-statements */\n/**\n * Returns a new `Vector3` either with the provided x, y, and z dimensions,\n * or from the provided `Partial<Vector3>` object populated with zeroes\n * wherever a component is missing.\n *\n * Providing no values to this function will result in a zero-length vector.\n */\n\nexport function create(x: number, y: number, z: number): Vector3;\nexport function create(partialVector: Partial<Vector3>): Vector3;\nexport function create(): Vector3;\nexport function create(...args: any[]): Vector3 {\n if (args.length === 1) {\n return {\n x: args[0].x ?? 0,\n y: args[0].y ?? 0,\n z: args[0].z ?? 0,\n };\n } else if (args.length === 3) {\n return {\n x: args[0] ?? 0,\n y: args[1] ?? 0,\n z: args[2] ?? 0,\n };\n }\n\n return {\n x: 0,\n y: 0,\n z: 0,\n };\n}\n/* eslint-enable @typescript-eslint/no-explicit-any */\n/* eslint-enable padding-line-between-statements */\n\n/**\n * Checks if each component of the given vector is populated with a numeric\n * component. A component is invalid if it contains a non-finite or NaN value.\n */\nexport function isValid({ x, y, z }: Vector3): boolean {\n return [x, y, z].every((v) => isFinite(v) && !isNaN(v));\n}\n\n/**\n * Returns a vector representing the scale elements of `matrix`.\n */\nexport function fromMatrixScale(matrix: Matrix4.Matrix4): Vector3 {\n const m = Matrix4.toObject(matrix);\n return {\n x: Math.hypot(m.m11, m.m21, m.m31),\n y: Math.hypot(m.m12, m.m22, m.m32),\n z: Math.hypot(m.m13, m.m23, m.m33),\n };\n}\n\n/**\n * Returns a vector representing the position elements of `matrix`.\n */\nexport function fromMatrixPosition(matrix: Matrix4.Matrix4): Vector3 {\n const m = Matrix4.toObject(matrix);\n return { x: m.m14, y: m.m24, z: m.m34 };\n}\n\n/**\n * Parses a JSON string representation of a Vector3 and returns an object.\n *\n * @param json A JSON string, either in the form `[x,y,z]` or `{\"x\": 0, \"y\": 0, \"z\": 0}`\n * @returns A parsed Vector3.\n */\nexport function fromJson(json: string): Vector3 {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, z] = obj;\n return create(x, y, z);\n } else {\n const { x, y, z } = obj;\n return create(x, y, z);\n }\n}\n\n/**\n * Creates a `Vector3` from an array. Pass `offset` to read values from the\n * starting index.\n *\n * @see #toArray()\n * @see #create()\n */\nexport function fromArray(nums: number[], offset = 0): Vector3 {\n const x = nums[offset];\n const y = nums[offset + 1];\n const z = nums[offset + 2];\n return create(x, y, z);\n}\n\n/**\n * Converts a Vector3 to an array where the values of the vector will be\n * represented as [x, y, z];\n *\n * @see #fromArray()\n * @see #create()\n */\nexport function toArray({ x, y, z }: Vector3): Vector3AsArray {\n return [x, y, z];\n}\n\n/**\n * Returns a directional vector on the positive x axis, Vector3(1, 0, 0).\n */\nexport function right(): Vector3 {\n return create(1, 0, 0);\n}\n\n/**\n * Returns a directional vector on the positive y axis, Vector3(0, 1, 0).\n */\nexport function up(): Vector3 {\n return create(0, 1, 0);\n}\n\n/**\n * Returns a directional vector on the positive z axis, Vector3(0, 0, -1).\n */\nexport function forward(): Vector3 {\n return create(0, 0, -1);\n}\n\n/**\n * Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).\n */\nexport function left(): Vector3 {\n return create(-1, 0, 0);\n}\n\n/**\n * Returns a directional vector on the negative y axis, Vector3(0, -1, 0).\n */\nexport function down(): Vector3 {\n return create(0, -1, 0);\n}\n\n/**\n * Returns a directional vector on the negative z axis, Vector3(0, 0, 1).\n */\nexport function back(): Vector3 {\n return create(0, 0, 1);\n}\n\n/**\n * Returns a vector at the origin, Vector3(0, 0, 0).\n */\nexport function origin(): Vector3 {\n return create(0, 0, 0);\n}\n\n/**\n * Returns a vector with that will have a magnitude of 1.\n */\nexport function normalize(vector: Vector3): Vector3 {\n const length = magnitude(vector);\n return { x: vector.x / length, y: vector.y / length, z: vector.z / length };\n}\n\n/**\n * Returns the straight-line length from (0, 0, 0) to the given vector.\n */\nexport function magnitude(vector: Vector3): number {\n return Math.sqrt(magnitudeSquared(vector));\n}\n\n/**\n * Returns the straight-line length from (0, 0, 0) to the given vector).\n *\n * When comparing lengths of vectors, you should use this function as it's\n * slightly more efficient to calculate.\n */\nexport function magnitudeSquared(vector: Vector3): number {\n return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;\n}\n\n/**\n * Returns a vector that is the cross product of two vectors.\n *\n * The cross product of two vectors results in a third vector which is\n * perpendicular to the two input vectors. The result's magnitude is equal to\n * the magnitudes of the two inputs multiplied together and then multiplied by\n * the sine of the angle between the inputs. You can determine the direction of\n * the result vector using the \"left hand rule\".\n */\nexport function cross(a: Vector3, b: Vector3): Vector3 {\n return {\n x: a.y * b.z - a.z * b.y,\n y: a.z * b.x - a.x * b.z,\n z: a.x * b.y - a.y * b.x,\n };\n}\n\n/**\n * Returns a vector that is the sum of two vectors.\n */\nexport function add(a: Vector3, ...vectors: Vector3[]): Vector3 {\n return vectors.reduce((res, next) => {\n return { x: res.x + next.x, y: res.y + next.y, z: res.z + next.z };\n }, a);\n}\n\n/**\n * Returns a vector that is the difference between two vectors.\n */\nexport function subtract(a: Vector3, ...vectors: Vector3[]): Vector3 {\n return vectors.reduce((res, next) => {\n return { x: res.x - next.x, y: res.y - next.y, z: res.z - next.z };\n }, a);\n}\n\n/**\n * Returns a vector that where each component of `b` is multiplied with `a`.\n */\nexport function multiply(a: Vector3, b: Vector3): Vector3 {\n return { x: a.x * b.x, y: a.y * b.y, z: a.z * b.z };\n}\n\n/**\n * Returns a vector where each value of a vector is multiplied by the `scalar`.\n */\nexport function scale(scalar: number, vector: Vector3): Vector3 {\n return { x: vector.x * scalar, y: vector.y * scalar, z: vector.z * scalar };\n}\n\n/**\n * Returns a value representing the dot product of two vectors.\n *\n * The dot product is a float value equal to the magnitudes of the two vectors\n * multiplied together and then multiplied by the cosine of the angle between\n * them.\n */\nexport function dot(a: Vector3, b: Vector3): number {\n return a.x * b.x + a.y * b.y + a.z * b.z;\n}\n\n/**\n * Returns the angle, in radians, between two vectors.\n *\n * The angle returned is the unsigned angle between the two vectors. This means\n * the smaller of the two possible angles between the two vectors is used. The\n * result is never greater than 180 degrees.\n */\nexport function angleTo(a: Vector3, b: Vector3): number {\n const theta = dot(a, b) / (magnitude(a) * magnitude(b));\n // Clamp to avoid numerical problems.\n return Math.acos(theta);\n}\n\n/**\n * Returns the Euler angle, in radians with the `xyz` ordering, between two vectors.\n *\n * This method will normalize both vectors for the calculation, and uses the\n * algorithm described in https://www.xarg.org/proof/quaternion-from-two-vectors/.\n */\nexport function eulerTo(a: Vector3, b: Vector3): Euler.Euler {\n const normalizedA = normalize(a);\n const normalizedB = normalize(b);\n\n const dotDelta = Math.cos(Angle.toRadians(1));\n const dotAB = dot(normalizedA, normalizedB);\n const vectorsAreParallel = Math.abs(dotAB) > dotDelta;\n\n if (vectorsAreParallel) {\n return dotAB > 1 - 1e-6 ? Euler.create() : Euler.create({ x: Math.PI });\n }\n\n const normalizedQ = Quaternion.normalize(\n Quaternion.create({\n w: 1 + dotAB,\n ...cross(normalizedA, normalizedB),\n })\n );\n\n return Euler.fromRotationMatrix(Matrix4.makeRotation(normalizedQ));\n}\n\n/**\n * Performs a projection of a `vector` onto `onNormal`.\n *\n * A projection is represented as the nearest point along a normal to a vector,\n * which constructs a triangle from the origin, to the vector, to the projected\n * point.\n *\n * ```\n * Vector --> * * <-- Projected\n * \\\n * \\ | <-- Normal\n * \\|\n * * <-- Origin\n * ```\n */\nexport function project(vector: Vector3, onNormal: Vector3): Vector3 {\n return scale(dot(onNormal, vector) / magnitude(onNormal), onNormal);\n}\n\n/**\n * Returns a vector that is rotated about an origin point.\n *\n * @param angle The angle to rotate, in radians.\n * @param point The origin point to rotate around.\n * @param axisDirection The direction used to compute the axis.\n * @param axisPosition The point of the axis.\n */\nexport function rotateAboutAxis(\n angle: number,\n point: Vector3,\n axisDirection: Vector3,\n axisPosition: Vector3\n): Vector3 {\n if (angle !== 0) {\n const { x, y, z } = point;\n const { x: a, y: b, z: c } = axisPosition;\n const { x: u, y: v, z: w } = axisDirection;\n\n const newX =\n (a * (v * v + w * w) - u * (b * v + c * w - u * x - v * y - w * z)) *\n (1 - Math.cos(angle)) +\n x * Math.cos(angle) +\n (-c * v + b * w - w * y + v * z) * Math.sin(angle);\n\n const newY =\n (b * (u * u + w * w) - v * (a * u + c * w - u * x - v * y - w * z)) *\n (1 - Math.cos(angle)) +\n y * Math.cos(angle) +\n (c * u - a * w + w * x - u * z) * Math.sin(angle);\n\n const newZ =\n (c * (u * u + v * v) - w * (a * u + b * v - u * x - v * y - w * z)) *\n (1 - Math.cos(angle)) +\n z * Math.cos(angle) +\n (-b * u + a * v - v * x + u * y) * Math.sin(angle);\n\n return { x: newX, y: newY, z: newZ };\n } else {\n return point;\n }\n}\n\n/**\n * Returns a vector that is multiplied with a matrix.\n */\nexport function transformMatrix(vector: Vector3, m: Matrix4.Matrix4): Vector3 {\n const { x, y, z } = vector;\n const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);\n return {\n x: (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,\n y: (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,\n z: (m[2] * x + m[6] * y + m[10] * z + m[14]) * w,\n };\n}\n\n/**\n * Euclidean distance between two vectors\n */\nexport function distance(a: Vector3, b: Vector3): number {\n return Math.sqrt(distanceSquared(a, b));\n}\n\n/**\n * Returns the squared distance between two vectors. If you're just comparing\n * distances, this is slightly more efficient than `distanceTo`.\n */\nexport function distanceSquared(a: Vector3, b: Vector3): number {\n const { x: dx, y: dy, z: dz } = subtract(a, b);\n return dx * dx + dy * dy + dz * dz;\n}\n\n/**\n * Returns `true` if two vectors have the same values.\n */\nexport function isEqual(a: Vector3, b: Vector3): boolean {\n return a.x === b.x && a.y === b.y && a.z === b.z;\n}\n\n/**\n * Returns a vector that contains the largest components of `a` and `b`.\n */\nexport function max(a: Vector3, b: Vector3): Vector3 {\n return create(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));\n}\n\n/**\n * Returns a vector that contains the smallest components of `a` and `b`.\n */\nexport function min(a: Vector3, b: Vector3): Vector3 {\n return create(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));\n}\n\n/**\n * Returns a vector that each of its component negated.\n */\nexport function negate(vector: Vector3): Vector3 {\n return { x: -vector.x, y: -vector.y, z: -vector.z };\n}\n\n/**\n * Performs a linear interpolation between `a` and `b` and returns the result.\n * The value of `t` is clamped between `[0, 1]`.\n *\n * @param a The start value.\n * @param b The end value.\n * @param t A value between 0 and 1.\n * @returns A point between `a` and `b`.\n */\nexport function lerp(a: Vector3, b: Vector3, t: number): Vector3 {\n return {\n x: lerpNumber(a.x, b.x, t),\n y: lerpNumber(a.y, b.y, t),\n z: lerpNumber(a.z, b.z, t),\n };\n}\n\n/**\n * Maps a normalized device coordinate (NDC) space to world space coordinates.\n *\n * @param ndc A point in normalized device coordinates.\n * @param worldMatrix A camera's world matrix.\n * @param projectionMatrixInverse A camera's inverse projection matrix.\n * @returns A point in world space coordinates.\n */\nexport function transformNdcToWorldSpace(\n ndc: Vector3,\n worldMatrix: Matrix4.Matrix4,\n projectionMatrixInverse: Matrix4.Matrix4\n): Vector3 {\n return transformMatrix(\n transformMatrix(ndc, projectionMatrixInverse),\n worldMatrix\n );\n}\n","import * as Vector3 from './vector3';\n\n/**\n * A `BoundingBox` describes a bounding volume as an axis-aligned box.\n */\nexport interface BoundingBox {\n min: Vector3.Vector3;\n max: Vector3.Vector3;\n}\n\n/**\n * Returns a `BoundingBox` with the given min and max points.\n */\nexport const create = (\n min: Vector3.Vector3,\n max: Vector3.Vector3\n): BoundingBox => {\n return { min, max };\n};\n\n/**\n * Construct a minimal bounding box for a set of vectors, such that all vectors\n * are contained by the bounding box.\n */\nexport const fromVectors = (\n vectors: Vector3.Vector3[]\n): BoundingBox | undefined => {\n return union(...vectors.map((v) => create(v, v)));\n};\n\n/**\n * Returns the center point of the given `BoundingBox`.\n */\nexport const center = (boundingBox: BoundingBox): Vector3.Vector3 => {\n return Vector3.scale(0.5, Vector3.add(boundingBox.min, boundingBox.max));\n};\n\n/**\n * Returns the diagonal vector between the `min` and `max` vectors of the\n * given `BoundingBox`.\n */\nexport const diagonal = (boundingBox: BoundingBox): Vector3.Vector3 => {\n return Vector3.subtract(boundingBox.max, boundingBox.min);\n};\n\n/**\n * Returns a floating-point spatial error tolerance based on the extents of the box.\n */\nexport const epsilon = (boundingBox: BoundingBox): number => {\n return (\n Math.max(\n Math.max(\n Vector3.magnitude(boundingBox.max),\n Vector3.magnitude(boundingBox.min)\n ),\n Vector3.magnitude(diagonal(boundingBox))\n ) * 1e-6\n );\n};\n\n/* eslint-disable padding-line-between-statements */\n/**\n * Combine two or more bounding boxes into a new minimal bounding box that\n * contains both.\n */\nexport function union(a: BoundingBox): BoundingBox;\nexport function union(a: BoundingBox, b: BoundingBox): BoundingBox;\nexport function union(\n a: BoundingBox,\n b: BoundingBox,\n c: BoundingBox\n): BoundingBox;\nexport function union(\n a: BoundingBox,\n b: BoundingBox,\n c: BoundingBox,\n d: BoundingBox\n): BoundingBox;\nexport function union(...boxes: BoundingBox[]): BoundingBox | undefined;\nexport function union(box: BoundingBox, ...rest: BoundingBox[]): BoundingBox {\n const boxes = [box, ...rest];\n return boxes.reduce((a, b) => {\n return create(Vector3.min(a.min, b.min), Vector3.max(a.max, b.max));\n });\n}\n/* eslint-enable padding-line-between-statements */\n\n/**\n * Returns the distance between the min and max for the provided\n * bounding box for each axis.\n */\nexport const lengths = (box: BoundingBox): Vector3.Vector3 => {\n return Vector3.create(\n box.max.x - box.min.x,\n box.max.y - box.min.y,\n box.max.z - box.min.z\n );\n};\n\n/**\n * Checks if each component of the given bounding box is populated with a numeric\n * component. A component is invalid if it contains a non-finite or NaN value.\n */\nexport function isValid(boundingBox: BoundingBox): boolean {\n const maxIsValid = Vector3.isValid(boundingBox.max);\n const minIsValid = Vector3.isValid(boundingBox.min);\n\n return maxIsValid && minIsValid;\n}\n","import * as BoundingBox from './boundingBox';\nimport * as Vector3 from './vector3';\n\n/**\n * A `BoundingSphere` describes a bounding volume as a sphere.\n */\nexport interface BoundingSphere {\n center: Vector3.Vector3;\n radius: number;\n epsilon: number;\n}\n\n/**\n * Returns a `BoundingSphere` that encompasses the provided `BoundingBox`.\n */\nexport const create = (\n boundingBox: BoundingBox.BoundingBox\n): BoundingSphere => {\n const boundingBoxCenter = BoundingBox.center(boundingBox);\n const centerToBoundingPlane = Vector3.subtract(\n boundingBox.max,\n boundingBoxCenter\n );\n const radius = Vector3.magnitude(centerToBoundingPlane);\n const length = Math.max(radius, Vector3.magnitude(boundingBoxCenter));\n const epsilon = length === 0 ? 1.0 : length * 1e-6;\n\n return { center: boundingBoxCenter, radius, epsilon };\n};\n","import * as Dimensions from './dimensions';\nimport * as Point from './point';\n\n/**\n * A `Rectangle` is an object with position and size.\n */\nexport interface Rectangle {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Returns a new `Rectangle` with the given position and size.\n */\nexport function create(\n x: number,\n y: number,\n width: number,\n height: number\n): Rectangle {\n return { x, y, width, height };\n}\n\n/**\n * Returns a new `Rectangle` at the origin point and given size.\n */\nexport function fromDimensions(dimensions: Dimensions.Dimensions): Rectangle {\n return create(0, 0, dimensions.width, dimensions.height);\n}\n\n/**\n * Returns a new `Rectangle` with the given position and size.\n */\nexport function fromPointAndDimensions(\n point: Point.Point,\n dimensions: Dimensions.Dimensions\n): Rectangle {\n return create(point.x, point.y, dimensions.width, dimensions.height);\n}\n\n/**\n * Returns a new `Rectangle` with the given top-left and bottom-right positions.\n * The returned rectangle will always returns a positive width and height.\n */\nexport function fromPoints(\n topLeftPt: Point.Point,\n bottomRightPt: Point.Point\n): Rectangle {\n const minX = Math.min(topLeftPt.x, bottomRightPt.x);\n const minY = Math.min(topLeftPt.y, bottomRightPt.y);\n const maxX = Math.max(topLeftPt.x, bottomRightPt.x);\n const maxY = Math.max(topLeftPt.y, bottomRightPt.y);\n return create(minX, minY, maxX - minX, maxY - minY);\n}\n\n/**\n * Returns a rectangle where the longest length of `rect` will be equal to the\n * shortest length of `to`. The shortest length of `rect` will be proportionally\n * scaled to match the aspect ratio of `rect`. The returned rectangle will be\n * centered within `to`.\n *\n * @see {@link cropFit}\n */\nexport function containFit(to: Rectangle, rect: Rectangle): Rectangle {\n const scale = Math.min(to.width / rect.width, to.height / rect.height);\n const dimensions = Dimensions.proportionalScale(scale, rect);\n const position = Point.subtract(center(to), Dimensions.center(dimensions));\n return fromPointAndDimensions(position, dimensions);\n}\n\n/**\n * Returns a rectangle where the shortest length of `rect` will be equal to the\n * longest length of `to`. The longest length of `rect` will be proportionally\n * scaled to match the aspect ratio of `rect`. The returned rectangle will be\n * centered within `to`.\n *\n * @see {@link containFit}\n */\nexport function cropFit(to: Rectangle, rect: Rectangle): Rectangle {\n const scale = Math.max(to.width / rect.width, to.height / rect.height);\n const dimensions = Dimensions.proportionalScale(scale, rect);\n const position = Point.subtract(center(to), Dimensions.center(dimensions));\n return fromPointAndDimensions(position, dimensions);\n}\n\n/**\n * Returns a rectangle where each side of `rect` will be reduced proportionally\n * to have an area less than or equal to the provided `to` value. The returned\n * rectangle will be centered within the original bounds of `rect`.\n *\n * @param to - the maximum area this rectangle can have\n * @param rect - the rectangle to scale to fit the specified area\n */\nexport function scaleFit(to: number, rect: Rectangle): Rectangle {\n const scale = Math.min(Math.sqrt(to / area(rect)), 1);\n const dimensions = Dimensions.floor(\n Dimensions.proportionalScale(scale, rect)\n );\n const position = Point.subtract(center(rect), Dimensions.center(dimensions));\n return fromPointAndDimensions(position, dimensions);\n}\n\n/**\n * Returns a rectangle where the position and dimensions are scaled by the given\n * factors. If `scaleY` is omitted, then the position and dimensions are scaled\n * uniformly by `scaleOrScaleX`.\n *\n * @param rect The rectangle to scale.\n * @param scaleOrScaleX The uniform scale factor, or the horizontal scale\n * factor.\n * @param scaleY The vertical scale factor.\n * @returns A scaled rectangle.\n */\nexport function scale(\n rect: Rectangle,\n scaleOrScaleX: number,\n scaleY?: number\n): Rectangle {\n if (scaleY == null) {\n return scale(rect, scaleOrScaleX, scaleOrScaleX);\n } else {\n const { x, y, width, height } = rect;\n const scaleX = scaleOrScaleX;\n return create(x * scaleX, y * scaleY, width * scaleX, height * scaleY);\n }\n}\n\n/**\n * Returns true if two rectangles are equal in position and size.\n */\nexport function isEqual(a: Rectangle, b: Rectangle): boolean {\n return Point.isEqual(a, b) && Dimensions.isEqual(a, b);\n}\n\n/**\n * Returns a rectangle that has its position shifted by a given offset. The\n * size of the rectangle is unchanged.\n */\nexport function offset(delta: Point.Point, rect: Rectangle): Rectangle {\n return fromPointAndDimensions(Point.add(topLeft(rect), delta), rect);\n}\n\n/**\n * Returns the area of the rectangle.\n */\nexport function area(rect: Rectangle): number {\n return rect.width * rect.height;\n}\n\n/**\n * Returns the center point of the rectangle.\n */\nexport function center(rect: Rectangle): Point.Point {\n return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };\n}\n\n/**\n * Returns the top-left position of the rectangle, as a point.\n */\nexport function topLeft(rect: Rectangle): Point.Point {\n return Point.create(rect.x, rect.y);\n}\n\n/**\n * Returns the bottom-right position of the rectangle, as a point.\n */\nexport function bottomRight(rect: Rectangle): Point.Point {\n return Point.create(rect.x + rect.width, rect.y + rect.height);\n}\n\n/**\n * Returns `true` if the given rectangle has a portrait aspect ratio.\n */\nexport function isPortrait(rect: Rectangle): boolean {\n return rect.width < rect.height;\n}\n\n/**\n * Returns `true` if the given rectangle has a landscape aspect ratio.\n */\nexport function isLandscape(rect: Rectangle): boolean {\n return rect.width > rect.height;\n}\n\n/**\n * Returns `true` if the given rectangle has a square aspect ratio.\n */\nexport function isSquare(rect: Rectangle): boolean {\n return rect.width === rect.height;\n}\n\n/**\n * Pads a rectangle by the given amount, maintaining the center position.\n *\n * @param rect The rectangle to apply padding to.\n * @param padding The padding to add.\n */\nexport function pad(rect: Rectangle, padding: number): Rectangle {\n return create(\n rect.x - padding,\n rect.y - padding,\n rect.width + padding * 2,\n rect.height + padding * 2\n );\n}\n\n/**\n * Returns `true` if the given rectangle contains all the given `points`.\n *\n * @param rect The rectangle to check against.\n * @param points The points to check.\n */\nexport function containsPoints(\n rect: Rectangle,\n ...points: Point.Point[]\n): boolean {\n return points.every((point) => {\n return (\n rect.x <= point.x &&\n rect.x + rect.width >= point.x &&\n rect.y <= point.y &&\n rect.y + rect.height >= point.y\n );\n });\n}\n\n/**\n * Parses a JSON string representation of a Rectangle and returns an object.\n *\n * @param json A JSON string, either in the form `[x,y,width,height]` or `{\"x\": 0, \"y\": 0, \"width\": 10, \"height\": 10}`\n * @returns A parsed Point.\n */\nexport function fromJson(json: string): Rectangle {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, width, height] = obj;\n return create(x, y, width, height);\n } else {\n const { x, y, width, height } = obj;\n return create(x, y, width, height);\n }\n}\n","import * as Point from './point';\nimport * as Rectangle from './rectangle';\n\n/**\n * `Dimensions` represent an object with a length of `width` and `height`.\n */\nexport interface Dimensions {\n width: number;\n height: number;\n}\n\n/**\n * Returns a `Dimensions` with the given width and height.\n *\n */\nexport const create = (width: number, height: number): Dimensions => {\n return { width, height };\n};\n\n/**\n * Returns a `Dimensions` with the same width and height.\n */\nexport const square = (size: number): Dimensions => {\n return create(size, size);\n};\n\n/**\n * Returns `true` if two dimensions have the same width and height. Otherwise\n * `false`.\n */\nexport const isEqual = (a: Dimensions, b: Dimensions): boolean => {\n return a.width === b.width && a.height === b.height;\n};\n\n/**\n * Returns a scaled dimensions, where the width is scaled by `scaleX` and height\n * is scaled by `scaleY`.\n */\nexport const scale = (\n scaleX: number,\n scaleY: number,\n dimensions: Dimensions\n): Dimensions => {\n return {\n width: dimensions.width * scaleX,\n height: dimensions.height * scaleY,\n };\n};\n\n/**\n * Returns a dimension where each length is scaled by `scaleFactor`.\n */\nexport const proportionalScale = (\n scaleFactor: number,\n dimensions: Dimensions\n): Dimensions => {\n return scale(scaleFactor, scaleFactor, dimensions);\n};\n\n/**\n * Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit\n * into `to`.\n */\nexport const trim = (to: Dimensions, dimensions: Dimensions): Dimensions => {\n return {\n width: Math.min(to.width, dimensions.width),\n height: Math.min(to.height, dimensions.height),\n };\n};\n\n/**\n * Returns a `Dimensions` where the longest length of `dimensions` will be equal\n * to the shortest length of `to`. The shortest length of `dimensions` will be\n * proportionally scaled to match the aspect ratio of `dimensions`.\n *\n * @see #cropFit()\n */\nexport const containFit = (\n to: Dimensions,\n dimensions: Dimensions\n): Dimensions => {\n const { width, height } = Rectangle.containFit(\n toRectangle(to),\n toRectangle(dimensions)\n );\n return { width, height };\n};\n\n/**\n * Returns a `Dimensions` where the shortest length of `dimensions` will be\n * equal to the longest length of `to`. The longest length of `dimensions` will\n * be proportionally scaled to match the aspect ratio of `dimensions`.\n *\n * @see #containFit()\n */\nexport const cropFit = (to: Dimensions, dimensions: Dimensions): Dimensions => {\n const { width, height } = Rectangle.cropFit(\n toRectangle(to),\n toRectangle(dimensions)\n );\n return { width, height };\n};\n\n/**\n * Returns a `Dimensions` where each side of `dimensions` will be reduced proportionally\n * to have an area less than or equal to the provided `to` value. The returned\n * dimensions will be centered within the original bounds of `dimensions`.\n *\n * @param to - the maximum area this dimensions can have\n * @param dimensions - the dimensions to scale to fit the specified area\n */\nexport const scaleFit = (to: number, dimensions: Dimensions): Dimensions => {\n const { width, height } = Rectangle.scaleFit(to, toRectangle(dimensions));\n return { width, height };\n};\n\n/**\n * Returns a `Dimensions` with each length rounded.\n */\nexport const round = (dimensions: Dimensions): Dimensions => {\n return {\n width: Math.round(dimensions.width),\n height: Math.round(dimensions.height),\n };\n};\n\n/**\n * Returns a `Dimensions` with each length rounded down.\n */\nexport const floor = (dimensions: Dimensions): Dimensions => {\n return {\n width: Math.floor(dimensions.width),\n height: Math.floor(dimensions.height),\n };\n};\n\n/**\n * Returns the center point of the given `dimensions`.\n */\nexport const center = (dimensions: Dimensions): Point.Point => {\n return { x: dimensions.width / 2, y: dimensions.height / 2 };\n};\n\n/**\n * Returns the aspect ratio of the given `dimensions`, as defined by width over\n * height.\n */\nexport const aspectRatio = ({ width, height }: Dimensions): number => {\n return width / height;\n};\n\n/**\n * Returns the area of the given `dimensions`.\n */\nexport const area = ({ width, height }: Dimensions): number => {\n return width * height;\n};\n\n/**\n * Returns a `Dimensions` fitted to the provided aspect ratio.\n *\n * @param ratio - Aspect ratio to fit the provided Dimensions to\n * @param dimensions - Dimensions to fit to the specified ratio\n */\nexport const fitToRatio = (\n ratio: number,\n dimensions: Dimensions\n): Dimensions => {\n if (dimensions.width >= dimensions.height * ratio) {\n return create(dimensions.height * ratio, dimensions.height);\n }\n\n return create(dimensions.width, dimensions.width / ratio);\n};\n\n/**\n * Converts a dimension to a rectangle, with an optional position.\n */\nexport function toRectangle(\n dimensions: Dimensions,\n position: Point.Point = Point.create()\n): Rectangle.Rectangle {\n return Rectangle.fromPointAndDimensions(position, dimensions);\n}\n","import * as Matrix4 from './matrix4';\nimport * as Vector3 from './vector3';\n\n/**\n * A `Line3` represents a line segment between a `start` and `end` point.\n */\nexport interface Line3 {\n /**\n * The start of the line segment.\n */\n start: Vector3.Vector3;\n\n /**\n * The end of the line segment.\n */\n end: Vector3.Vector3;\n}\n\n/**\n * Creates a new `Line3`. If unspecified, the start and end values of the line\n * will be at origin.\n *\n * @param values The values to assign to the line.\n */\nexport function create(values: Partial<Line3> = {}): Line3 {\n return {\n start: values.start ?? Vector3.origin(),\n end: values.end ?? Vector3.origin(),\n };\n}\n\n/**\n * Returns the point that is halfway between start and end.\n */\nexport function center(line: Line3): Vector3.Vector3 {\n return Vector3.lerp(line.start, line.end, 0.5);\n}\n\n/**\n * Returns a line where the start and end points are transformed with the given\n * matrix.\n *\n * @param line The line to transform.\n * @param matrix The matrix to apply.\n * @returns A transformed line.\n */\nexport function transformMatrix(line: Line3, matrix: Matrix4.Matrix4): Line3 {\n const start = Vector3.transformMatrix(line.start, matrix);\n const end = Vector3.transformMatrix(line.end, matrix);\n return { start, end };\n}\n\n/**\n * Euclidean distance between the start and end points of the line.\n */\nexport function distance(line: Line3): number {\n return Vector3.distance(line.start, line.end);\n}\n\n/**\n * Returns the squared distance between a line's start and end point. If you're\n * just comparing distances, this is slightly more efficient than `distanceTo`.\n */\nexport function distanceSquared(line: Line3): number {\n return Vector3.distanceSquared(line.start, line.end);\n}\n\n/**\n * Returns a vector describing the direction of the line from start to end.\n */\nexport function direction(line: Line3): Vector3.Vector3 {\n return Vector3.subtract(line.end, line.start);\n}\n","import { toRadians } from './angle';\nimport * as Point from './point';\n\n/**\n * Represents a 2D transformation matrix.\n *\n * The values of this matrix are meant to represent a 3x3 matrix where the\n * contents are mapped as the following:\n *\n * ```\n * a b tx\n * c d ty\n * u v w\n * ```\n */\nexport interface Matrix {\n /**\n * Value that affects the positioning along the x axis when scaling or\n * rotating.\n */\n a: number;\n\n /**\n * Value that affects the positioning along the y axis when rotating or\n * skewing.\n */\n b: number;\n\n /**\n * Value that affects the positioning along the x axis when rotating or\n * skewing.\n */\n c: number;\n\n /**\n * Value that affects the positioning along the y axis when scaling or\n * rotating.\n */\n d: number;\n\n /**\n * The distance to translate along the x axis.\n */\n tx: number;\n\n /**\n * The distance to translate along the y axis.\n */\n ty: number;\n}\n\n/**\n * Creates a new matrix. If arguments are undefined, returns an identity matrix.\n */\nexport const create = (a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0): Matrix => {\n return { a, b, c, d, tx, ty };\n};\n\n/**\n * Returns an identity matrix.\n */\nexport const identity = (): Matrix => {\n return create();\n};\n\n/**\n * Creates a matrix that is translated by the given `tx` and `ty` values.\n */\nexport const translation = (tx: number, ty: number): Matrix => {\n return translate(tx, ty, identity());\n};\n\n/**\n * Creates a matrix that is rotated by the given degrees.\n */\nexport const rotation = (degrees: number): Matrix => {\n return rotate(degrees, identity());\n};\n\n/**\n * Rotates the given matrix by the given degrees.\n */\nexport const rotate = (degrees: number, matrix: Matrix): Matrix => {\n const radians = toRadians(degrees);\n const cos = Math.cos(radians);\n const sin = Math.sin(radians);\n\n const a = matrix.a * cos + matrix.c * sin;\n const b = matrix.b * cos + matrix.d * sin;\n const c = matrix.a * -sin + matrix.c * cos;\n const d = matrix.b * -sin + matrix.d * cos;\n\n return create(a, b, c, d, matrix.tx, matrix.ty);\n};\n\n/**\n * Translates the given matrix along the horizontal and vertical axis by the\n * given `dx` and `dy` delta values.\n */\nexport const translate = (dx: number, dy: number, matrix: Matrix): Matrix => {\n const newTx = matrix.a * dx + matrix.c * dy + matrix.tx;\n const newTy = matrix.b * dx + matrix.d * dy + matrix.ty;\n return create(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);\n};\n\n/**\n * Returns the result of applying a geometric transformation of a matrix on the\n * given point.\n */\nexport const transformPoint = (\n matrix: Matrix,\n pt: Point.Point\n): Point.Point => {\n const x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;\n const y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;\n return Point.create(x, y);\n};\n","import * as Point from './point';\n\n/**\n * A 2x2 matrix. The contents are mapped as follows:\n *\n * ```\n * a b\n * c d\n * ```\n */\nexport interface Matrix {\n a: number;\n b: number;\n c: number;\n d: number;\n}\n\n/**\n * Creates a new matrix.\n */\nexport function create(a: Point.Point, b: Point.Point): Matrix;\n\nexport function create(a: number, b: number, c: number, d: number): Matrix;\n\nexport function create(): Matrix;\n\nexport function create(...args: any[]): Matrix {\n if (args.length === 2) {\n return {\n a: args[0].x,\n b: args[0].y,\n c: args[1].x,\n d: args[1].y,\n };\n } else if (args.length === 4) {\n return {\n a: args[0],\n b: args[1],\n c: args[2],\n d: args[3],\n };\n }\n\n return {\n a: 0,\n b: 0,\n c: 0,\n d: 0,\n };\n}\n\n/**\n * Returns the determinant of the provided matrix.\n */\nexport function determinant(matrix: Matrix): number {\n return matrix.a * matrix.d - matrix.b * matrix.c;\n}\n\n/**\n * Returns the dot product of the two vectors represented in this matrix.\n */\nexport function dot(matrix: Matrix): number {\n return matrix.a * matrix.c + matrix.b * matrix.d;\n}\n","import * as Line3 from './line3';\nimport * as Vector3 from './vector3';\n\n/**\n * A two dimensional surface in 3D space that extends indefinitely. Represented\n * as a direction normal and distance.\n */\nexport interface Plane {\n normal: Vector3.Vector3;\n constant: number;\n}\n\n/**\n * Creates a new plane. Defaults to a normal of `[0,0,0]` and constant of `0`.\n *\n * @param values Values to assign to the plane.\n * @returns A new plane.\n */\nexport function create(values: Partial<Plane> = {}): Plane {\n return { normal: Vector3.origin(), constant: 0, ...values };\n}\n\n/**\n * Creates a plane from a normal and an arbitrary point on a plane.\n *\n * @param normal A normal.\n * @param point A point on the plane.\n * @returns A new plane.\n */\nexport function fromNormalAndCoplanarPoint(\n normal: Vector3.Vector3,\n point: Vector3.Vector3\n): Plane {\n const constant = -Vector3.dot(point, normal);\n return create({ normal, constant });\n}\n\n/**\n * Returns the perpendicular distance from the plane to the given point.\n *\n * @param plane The plane.\n * @param point The point to calculate distance from `plane`.\n * @returns A distance.\n */\nexport function distanceToPoint(plane: Plane, point: Vector3.Vector3): number {\n return Vector3.dot(plane.normal, point) + plane.constant;\n}\n\n/**\n * Returns the point where the line intersects with this plane. If the line does\n * not intersect, then `undefined` is returned. If the line is on the plane,\n * then the starting point of the line is returned.\n *\n * @param plane The plane to intersect.\n * @param line The line to intersect.\n * @returns An intersecting point on the plane and line.\n */\nexport function intersectLine(\n plane: Plane,\n line: Line3.Line3\n): Vector3.Vector3 | undefined {\n const direction = Line3.direction(line);\n const denominator = Vector3.dot(plane.normal, direction);\n\n if (denominator === 0) {\n if (distanceToPoint(plane, line.start) === 0) {\n return line.start;\n } else {\n return undefined;\n }\n }\n\n const t =\n -(Vector3.dot(line.start, plane.normal) + plane.constant) / denominator;\n if (t < 0 || t > 1) {\n return undefined;\n } else {\n return Vector3.add(Vector3.scale(t, direction), line.start);\n }\n}\n\n/**\n * Projects the given `point` onto the given `plane`.\n *\n * @param plane The plane to project onto.\n * @param point The point to project.\n * @returns The projected point.\n */\nexport function projectPoint(\n plane: Plane,\n point: Vector3.Vector3\n): Vector3.Vector3 {\n const d = distanceToPoint(plane, point);\n return Vector3.add(point, Vector3.scale(-d, plane.normal));\n}\n","import * as Plane from './plane';\nimport * as Vector3 from './vector3';\n\n/**\n * A `Ray` represents an infinite line starting at `origin` and going in\n * `direction`.\n */\nexport interface Ray {\n /**\n * The origin point of the ray.\n */\n origin: Vector3.Vector3;\n\n /**\n * A normal that describes the direction of the ray from origin.\n */\n direction: Vector3.Vector3;\n}\n\n/**\n * Creates a new ray with the given values, or using default values if none are\n * provided. The direction defaults to `{x: 0, y: 0, z: -1}` if undefined.\n *\n * @param value The values of the ray.\n * @returns A new ray.\n */\nexport function create(value: Partial<Ray> = {}): Ray {\n return {\n origin: value.origin ?? Vector3.origin(),\n direction: value.direction ?? Vector3.forward(),\n };\n}\n\n/**\n * Returns a point at the given distance along this ray.\n *\n * @param ray The ray to get the point on.\n * @param distance A distance from origin along the ray's direction.\n * @returns A point on the ray.\n */\nexport function at(ray: Ray, distance: number): Vector3.Vector3 {\n return Vector3.add(Vector3.scale(distance, ray.direction), ray.origin);\n}\n\n/**\n * Computes the distance of the `ray`s origin to the given `plane`. Returns a\n * distance of 0 if the ray is coplanar and returns `undefined` if the ray does\n * not intersect with the plane.\n *\n * @param ray The ray to get the distance for.\n * @param plane The plane to compute the distance to.\n * @returns The distance to the plane, or `undefined` if it cannot be computed.\n */\nexport function distanceToPlane(\n ray: Ray,\n plane: Plane.Plane\n): number | undefined {\n const d = Vector3.dot(plane.normal, ray.direction);\n if (d === 0) {\n // Ray is on plane.\n return Plane.distanceToPoint(plane, ray.origin) === 0 ? 0 : undefined;\n } else {\n const t = -(Vector3.dot(ray.origin, plane.normal) + plane.constant) / d;\n // Checks if ray intersects plane.\n return t >= 0 ? t : undefined;\n }\n}\n\n/**\n * Computes the intersection point of the given `ray` to the given `plane`. If\n * the ray does not intersect with the plane, then `undefined` is returned.\n *\n * @param ray The ray to intersect.\n * @param plane The plane to intersect with.\n * @returns The intersection point, or `undefined` if the ray does not\n * intersect.\n */\nexport function intersectPlane(\n ray: Ray,\n plane: Plane.Plane\n): Vector3.Vector3 | undefined {\n const t = distanceToPlane(ray, plane);\n return t != null ? at(ray, t) : undefined;\n}\n","/**\n * A `Vector4` represents a vector of 4 dimension values. It may represent a\n * point or direction. It may also be used to represent a quadruplet of values,\n * such as a row or column in a transformation matrix.\n */\nexport interface Vector4 {\n x: number;\n y: number;\n z: number;\n w: number;\n}\n\n/**\n * Returns a new Vector4. If `value` is undefined, then `{x: 0, y: 0, z: 0,\n * w: 0}` is returned.\n */\nexport function create(value: Partial<Vector4> = {}): Vector4 {\n return { x: 0, y: 0, z: 0, w: 0, ...value };\n}\n\n/**\n * Parses a JSON string representation of a `Vector4`.\n *\n * @param json A JSON string either in the form of `[x, y, z, w]` or `{\"x\": 0, \"y\": 0, \"z\": 0, \"w\": 0}`.\n * @returns A parsed `Vector4`.\n */\nexport function fromJson(json: string): Vector4 {\n const obj = JSON.parse(json);\n if (Array.isArray(obj)) {\n const [x, y, z, w] = obj;\n return create({ x, y, z, w });\n } else {\n return create(obj);\n }\n}\n"],"names":["clamp","value","min","max","Math","lerp","a","b","t","create","x","y","subtract","add","isEqual","scaleProportional","pt","scale","magnitude","sqrt","normalizeVector","magnitudeOfPoint","normalDirectionVector","ptA","ptB","length","radians","cos","sin","delta","lerpNumber","scaleX","scaleY","unitVectorBetweenPoints","abs","pow","json","obj","JSON","parse","Array","isArray","normalize","degrees","toDegrees","PI","toRadians","Point.subtract","atan2","__assign","Object","assign","s","i","n","arguments","p","prototype","hasOwnProperty","call","apply","this","__spreadArray","to","from","pack","ar","l","slice","concat","fromValues","m11","m12","m13","m14","m21","m22","m23","m24","m31","m32","m33","m34","m41","m42","m43","m44","makeIdentity","makeZero","makeTranslation","translation","makeRotation","rotation","z","w","x2","y2","z2","xx","xy","xz","yy","yz","zz","wx","wy","wz","makeScale","makeFrustum","left","right","top","bottom","near","far","multiply","ae","be","a11","a12","a13","a14","a21","a22","a23","a24","a31","a32","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","mat","toObject","m","r","axis","c","tx","ty","fovY","aspect","ymax","tan","Angle.toRadians","xmax","h","d","position","lookAt","up","Vector3.normalize","Vector3.subtract","Vector3.cross","dotX","Vector3.dot","dotY","dotZ","matrix","a00","a01","a02","a03","a10","a20","a30","b00","b01","b02","b03","b04","b05","b06","b07","b08","b09","b10","det","target","Vector3.magnitudeSquared","res","other","identity","every","v","_a","_b","_c","order","_d","fromRotationMatrix","Matrix4.toObject","asin","o","q","scalar","halfAngle","Vector3.fromMatrixScale","is1","is2","is3","sm11","sm12","sm13","sm21","sm22","sm23","sm31","sm32","sm33","trace","euler","ex","ey","ez","c1","c2","c3","s1","s2","s3","args","_i","_e","_f","isValid","isFinite","isNaN","fromMatrixScale","hypot","forward","origin","vector","magnitudeSquared","cross","vectors","reduce","next","dot","transformMatrix","distance","distanceSquared","dx","dy","dz","nums","offset","theta","acos","normalizedA","normalizedB","dotDelta","dotAB","Euler.create","Euler.fromRotationMatrix","Matrix4.makeRotation","Quaternion.normalize","Quaternion.create","onNormal","angle","point","axisDirection","axisPosition","u","ndc","worldMatrix","projectionMatrixInverse","center","boundingBox","Vector3.scale","Vector3.add","diagonal","union","box","rest","boxes","Vector3.min","Vector3.max","map","Vector3.magnitude","Vector3.create","maxIsValid","Vector3.isValid","minIsValid","boundingBoxCenter","BoundingBox.center","radius","epsilon","width","height","fromPointAndDimensions","dimensions","containFit","rect","Dimensions.proportionalScale","Dimensions.center","cropFit","scaleFit","area","Dimensions.floor","topLeft","Point.create","topLeftPt","bottomRightPt","minX","minY","scaleOrScaleX","Point.isEqual","Dimensions.isEqual","Point.add","padding","points","proportionalScale","scaleFactor","floor","toRectangle","Rectangle.fromPointAndDimensions","size","Rectangle.containFit","Rectangle.cropFit","Rectangle.scaleFit","round","ratio","direction","line","end","start","values","Vector3.origin","Vector3.lerp","Vector3.transformMatrix","Vector3.distance","Vector3.distanceSquared","rotate","translate","newTx","newTy","normal","constant","distanceToPoint","plane","Line3.direction","denominator","at","ray","distanceToPlane","Plane.distanceToPoint","undefined","Vector3.forward"],"mappings":"SAQgBA,EAAMC,EAAeC,EAAaC,GAChD,OAAOC,KAAKD,IAAID,EAAKE,KAAKF,IAAIC,EAAKF,GACrC,UAYgBI,EAAKC,EAAWC,EAAWC,GAEzC,OADAA,EAAIR,EAAMQ,EAAG,EAAG,KACJD,EAAID,GAAKA,CACvB,CCVgB,SAAAG,EAAOC,EAAOC,GAC5B,YADqB,IAAAD,IAAAA,EAAK,QAAE,IAAAC,IAAAA,EAAK,GAC1B,CAAED,EAACA,EAAEC,EAACA,EACf,CAsBgB,SAAAC,EAASN,EAAUC,GACjC,MAAO,CAAEG,EAAGJ,EAAEI,EAAIH,EAAEG,EAAGC,EAAGL,EAAEK,EAAIJ,EAAEI,EACpC,CAKgB,SAAA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