diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json
index 3973926..154afd9 100644
--- a/node_modules/.package-lock.json
+++ b/node_modules/.package-lock.json
@@ -4,43 +4,47 @@
"lockfileVersion": 3,
"requires": true,
"packages": {
- "node_modules/@esbuild/darwin-x64": {
+ "node_modules/@esbuild/linux-x64": {
"version": "0.27.2",
- "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.2.tgz",
- "integrity": "sha512-ZxtijOmlQCBWGwbVmwOF/UCzuGIbUkqB1faQRf5akQmxRJ1ujusWsb3CVfk/9iZKr2L5SMU5wPBi1UWbvL+VQA==",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.2.tgz",
+ "integrity": "sha512-uwp2Tip5aPmH+NRUwTcfLb+W32WXjpFejTIOWZFw/v7/KnpCDKG66u4DLcurQpiYTiYwQ9B7KOeMJvLCu/OvbA==",
"cpu": [
"x64"
],
+ "license": "MIT",
"optional": true,
"os": [
- "darwin"
+ "linux"
],
"engines": {
"node": ">=18"
}
},
- "node_modules/@rollup/rollup-darwin-x64": {
+ "node_modules/@rollup/rollup-linux-x64-gnu": {
"version": "4.54.0",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.54.0.tgz",
- "integrity": "sha512-cOo7biqwkpawslEfox5Vs8/qj83M/aZCSSNIWpVzfU2CYHa2G3P1UN5WF01RdTHSgCkri7XOlTdtk17BezlV3A==",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.54.0.tgz",
+ "integrity": "sha512-WGt5J8Ij/rvyqpFexxk3ffKqqbLf9AqrTBbWDk7ApGUzaIs6V+s2s84kAxklFwmMF/vBNGrVdYgbblCOFFezMQ==",
"cpu": [
"x64"
],
+ "license": "MIT",
"optional": true,
"os": [
- "darwin"
+ "linux"
]
},
"node_modules/@types/estree": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
- "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="
+ "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
+ "license": "MIT"
},
"node_modules/esbuild": {
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz",
"integrity": "sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw==",
"hasInstallScript": true,
+ "license": "MIT",
"bin": {
"esbuild": "bin/esbuild"
},
@@ -80,6 +84,7 @@
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
+ "license": "MIT",
"engines": {
"node": ">=12.0.0"
},
@@ -92,19 +97,6 @@
}
}
},
- "node_modules/fsevents": {
- "version": "2.3.3",
- "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
- "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
- "hasInstallScript": true,
- "optional": true,
- "os": [
- "darwin"
- ],
- "engines": {
- "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
- }
- },
"node_modules/nanoid": {
"version": "3.3.11",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",
@@ -115,6 +107,7 @@
"url": "https://github.com/sponsors/ai"
}
],
+ "license": "MIT",
"bin": {
"nanoid": "bin/nanoid.cjs"
},
@@ -125,12 +118,14 @@
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
- "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
+ "license": "ISC"
},
"node_modules/picomatch": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
+ "license": "MIT",
"engines": {
"node": ">=12"
},
@@ -156,6 +151,7 @@
"url": "https://github.com/sponsors/ai"
}
],
+ "license": "MIT",
"dependencies": {
"nanoid": "^3.3.11",
"picocolors": "^1.1.1",
@@ -169,6 +165,7 @@
"version": "4.54.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.54.0.tgz",
"integrity": "sha512-3nk8Y3a9Ea8szgKhinMlGMhGMw89mqule3KWczxhIzqudyHdCIOHw8WJlj/r329fACjKLEh13ZSk7oE22kyeIw==",
+ "license": "MIT",
"dependencies": {
"@types/estree": "1.0.8"
},
@@ -209,6 +206,7 @@
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
+ "license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
}
@@ -216,12 +214,14 @@
"node_modules/three": {
"version": "0.182.0",
"resolved": "https://registry.npmjs.org/three/-/three-0.182.0.tgz",
- "integrity": "sha512-GbHabT+Irv+ihI1/f5kIIsZ+Ef9Sl5A1Y7imvS5RQjWgtTPfPnZ43JmlYI7NtCRDK9zir20lQpfg8/9Yd02OvQ=="
+ "integrity": "sha512-GbHabT+Irv+ihI1/f5kIIsZ+Ef9Sl5A1Y7imvS5RQjWgtTPfPnZ43JmlYI7NtCRDK9zir20lQpfg8/9Yd02OvQ==",
+ "license": "MIT"
},
"node_modules/tinyglobby": {
"version": "0.2.15",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz",
"integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==",
+ "license": "MIT",
"dependencies": {
"fdir": "^6.5.0",
"picomatch": "^4.0.3"
@@ -237,6 +237,7 @@
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.0.tgz",
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
+ "license": "MIT",
"dependencies": {
"esbuild": "^0.27.0",
"fdir": "^6.5.0",
diff --git a/node_modules/.vite/deps/_metadata.json b/node_modules/.vite/deps/_metadata.json
new file mode 100644
index 0000000..d29f3e6
--- /dev/null
+++ b/node_modules/.vite/deps/_metadata.json
@@ -0,0 +1,34 @@
+{
+ "hash": "77190db0",
+ "configHash": "0fdb68c8",
+ "lockfileHash": "fe3966e1",
+ "browserHash": "bfeec663",
+ "optimized": {
+ "three": {
+ "src": "../../three/build/three.module.js",
+ "file": "three.js",
+ "fileHash": "3e7017a4",
+ "needsInterop": false
+ },
+ "three/addons/controls/PointerLockControls.js": {
+ "src": "../../three/examples/jsm/controls/PointerLockControls.js",
+ "file": "three_addons_controls_PointerLockControls__js.js",
+ "fileHash": "185d9100",
+ "needsInterop": false
+ },
+ "three/examples/jsm/controls/PointerLockControls.js": {
+ "src": "../../three/examples/jsm/controls/PointerLockControls.js",
+ "file": "three_examples_jsm_controls_PointerLockControls__js.js",
+ "fileHash": "98cdccce",
+ "needsInterop": false
+ }
+ },
+ "chunks": {
+ "chunk-PIN6L3XG": {
+ "file": "chunk-PIN6L3XG.js"
+ },
+ "chunk-XSTVJSXX": {
+ "file": "chunk-XSTVJSXX.js"
+ }
+ }
+}
\ No newline at end of file
diff --git a/node_modules/.vite/deps/chunk-PIN6L3XG.js b/node_modules/.vite/deps/chunk-PIN6L3XG.js
new file mode 100644
index 0000000..746992e
--- /dev/null
+++ b/node_modules/.vite/deps/chunk-PIN6L3XG.js
@@ -0,0 +1,125 @@
+import {
+ Controls,
+ Euler,
+ Vector3
+} from "./chunk-XSTVJSXX.js";
+
+// node_modules/three/examples/jsm/controls/PointerLockControls.js
+var _euler = new Euler(0, 0, 0, "YXZ");
+var _vector = new Vector3();
+var _changeEvent = { type: "change" };
+var _lockEvent = { type: "lock" };
+var _unlockEvent = { type: "unlock" };
+var _MOUSE_SENSITIVITY = 2e-3;
+var _PI_2 = Math.PI / 2;
+var PointerLockControls = class extends Controls {
+ /**
+ * Constructs a new controls instance.
+ *
+ * @param {Camera} camera - The camera that is managed by the controls.
+ * @param {?HTMLElement} domElement - The HTML element used for event listeners.
+ */
+ constructor(camera, domElement = null) {
+ super(camera, domElement);
+ this.isLocked = false;
+ this.minPolarAngle = 0;
+ this.maxPolarAngle = Math.PI;
+ this.pointerSpeed = 1;
+ this._onMouseMove = onMouseMove.bind(this);
+ this._onPointerlockChange = onPointerlockChange.bind(this);
+ this._onPointerlockError = onPointerlockError.bind(this);
+ if (this.domElement !== null) {
+ this.connect(this.domElement);
+ }
+ }
+ connect(element) {
+ super.connect(element);
+ this.domElement.ownerDocument.addEventListener("mousemove", this._onMouseMove);
+ this.domElement.ownerDocument.addEventListener("pointerlockchange", this._onPointerlockChange);
+ this.domElement.ownerDocument.addEventListener("pointerlockerror", this._onPointerlockError);
+ }
+ disconnect() {
+ this.domElement.ownerDocument.removeEventListener("mousemove", this._onMouseMove);
+ this.domElement.ownerDocument.removeEventListener("pointerlockchange", this._onPointerlockChange);
+ this.domElement.ownerDocument.removeEventListener("pointerlockerror", this._onPointerlockError);
+ }
+ dispose() {
+ this.disconnect();
+ }
+ /**
+ * Returns the look direction of the camera.
+ *
+ * @param {Vector3} v - The target vector that is used to store the method's result.
+ * @return {Vector3} The normalized direction vector.
+ */
+ getDirection(v) {
+ return v.set(0, 0, -1).applyQuaternion(this.object.quaternion);
+ }
+ /**
+ * Moves the camera forward parallel to the xz-plane. Assumes camera.up is y-up.
+ *
+ * @param {number} distance - The signed distance.
+ */
+ moveForward(distance) {
+ if (this.enabled === false) return;
+ const camera = this.object;
+ _vector.setFromMatrixColumn(camera.matrix, 0);
+ _vector.crossVectors(camera.up, _vector);
+ camera.position.addScaledVector(_vector, distance);
+ }
+ /**
+ * Moves the camera sidewards parallel to the xz-plane.
+ *
+ * @param {number} distance - The signed distance.
+ */
+ moveRight(distance) {
+ if (this.enabled === false) return;
+ const camera = this.object;
+ _vector.setFromMatrixColumn(camera.matrix, 0);
+ camera.position.addScaledVector(_vector, distance);
+ }
+ /**
+ * Activates the pointer lock.
+ *
+ * @param {boolean} [unadjustedMovement=false] - Disables OS-level adjustment for mouse acceleration, and accesses raw mouse input instead.
+ * Setting it to true will disable mouse acceleration.
+ */
+ lock(unadjustedMovement = false) {
+ this.domElement.requestPointerLock({
+ unadjustedMovement
+ });
+ }
+ /**
+ * Exits the pointer lock.
+ */
+ unlock() {
+ this.domElement.ownerDocument.exitPointerLock();
+ }
+};
+function onMouseMove(event) {
+ if (this.enabled === false || this.isLocked === false) return;
+ const camera = this.object;
+ _euler.setFromQuaternion(camera.quaternion);
+ _euler.y -= event.movementX * _MOUSE_SENSITIVITY * this.pointerSpeed;
+ _euler.x -= event.movementY * _MOUSE_SENSITIVITY * this.pointerSpeed;
+ _euler.x = Math.max(_PI_2 - this.maxPolarAngle, Math.min(_PI_2 - this.minPolarAngle, _euler.x));
+ camera.quaternion.setFromEuler(_euler);
+ this.dispatchEvent(_changeEvent);
+}
+function onPointerlockChange() {
+ if (this.domElement.ownerDocument.pointerLockElement === this.domElement) {
+ this.dispatchEvent(_lockEvent);
+ this.isLocked = true;
+ } else {
+ this.dispatchEvent(_unlockEvent);
+ this.isLocked = false;
+ }
+}
+function onPointerlockError() {
+ console.error("THREE.PointerLockControls: Unable to use Pointer Lock API");
+}
+
+export {
+ PointerLockControls
+};
+//# sourceMappingURL=chunk-PIN6L3XG.js.map
diff --git a/node_modules/.vite/deps/chunk-PIN6L3XG.js.map b/node_modules/.vite/deps/chunk-PIN6L3XG.js.map
new file mode 100644
index 0000000..ab8fde6
--- /dev/null
+++ b/node_modules/.vite/deps/chunk-PIN6L3XG.js.map
@@ -0,0 +1,7 @@
+{
+ "version": 3,
+ "sources": ["../../three/examples/jsm/controls/PointerLockControls.js"],
+ "sourcesContent": ["import {\n\tControls,\n\tEuler,\n\tVector3\n} from 'three';\n\nconst _euler = new Euler( 0, 0, 0, 'YXZ' );\nconst _vector = new Vector3();\n\n/**\n * Fires when the user moves the mouse.\n *\n * @event PointerLockControls#change\n * @type {Object}\n */\nconst _changeEvent = { type: 'change' };\n\n/**\n * Fires when the pointer lock status is \"locked\" (in other words: the mouse is captured).\n *\n * @event PointerLockControls#lock\n * @type {Object}\n */\nconst _lockEvent = { type: 'lock' };\n\n/**\n * Fires when the pointer lock status is \"unlocked\" (in other words: the mouse is not captured anymore).\n *\n * @event PointerLockControls#unlock\n * @type {Object}\n */\nconst _unlockEvent = { type: 'unlock' };\n\nconst _MOUSE_SENSITIVITY = 0.002;\nconst _PI_2 = Math.PI / 2;\n\n/**\n * The implementation of this class is based on the [Pointer Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API).\n * `PointerLockControls` is a perfect choice for first person 3D games.\n *\n * ```js\n * const controls = new PointerLockControls( camera, document.body );\n *\n * // add event listener to show/hide a UI (e.g. the game's menu)\n * controls.addEventListener( 'lock', function () {\n *\n * \tmenu.style.display = 'none';\n *\n * } );\n *\n * controls.addEventListener( 'unlock', function () {\n *\n * \tmenu.style.display = 'block';\n *\n * } );\n * ```\n *\n * @augments Controls\n * @three_import import { PointerLockControls } from 'three/addons/controls/PointerLockControls.js';\n */\nclass PointerLockControls extends Controls {\n\n\t/**\n\t * Constructs a new controls instance.\n\t *\n\t * @param {Camera} camera - The camera that is managed by the controls.\n\t * @param {?HTMLElement} domElement - The HTML element used for event listeners.\n\t */\n\tconstructor( camera, domElement = null ) {\n\n\t\tsuper( camera, domElement );\n\n\t\t/**\n\t\t * Whether the controls are locked or not.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default false\n\t\t */\n\t\tthis.isLocked = false;\n\n\t\t/**\n\t\t * Camera pitch, lower limit. Range is '[0, Math.PI]' in radians.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis.minPolarAngle = 0;\n\n\t\t/**\n\t\t * Camera pitch, upper limit. Range is '[0, Math.PI]' in radians.\n\t\t *\n\t\t * @type {number}\n\t\t * @default Math.PI\n\t\t */\n\t\tthis.maxPolarAngle = Math.PI;\n\n\t\t/**\n\t\t * Multiplier for how much the pointer movement influences the camera rotation.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 1\n\t\t */\n\t\tthis.pointerSpeed = 1.0;\n\n\t\t// event listeners\n\n\t\tthis._onMouseMove = onMouseMove.bind( this );\n\t\tthis._onPointerlockChange = onPointerlockChange.bind( this );\n\t\tthis._onPointerlockError = onPointerlockError.bind( this );\n\n\t\tif ( this.domElement !== null ) {\n\n\t\t\tthis.connect( this.domElement );\n\n\t\t}\n\n\t}\n\n\tconnect( element ) {\n\n\t\tsuper.connect( element );\n\n\t\tthis.domElement.ownerDocument.addEventListener( 'mousemove', this._onMouseMove );\n\t\tthis.domElement.ownerDocument.addEventListener( 'pointerlockchange', this._onPointerlockChange );\n\t\tthis.domElement.ownerDocument.addEventListener( 'pointerlockerror', this._onPointerlockError );\n\n\t}\n\n\tdisconnect() {\n\n\t\tthis.domElement.ownerDocument.removeEventListener( 'mousemove', this._onMouseMove );\n\t\tthis.domElement.ownerDocument.removeEventListener( 'pointerlockchange', this._onPointerlockChange );\n\t\tthis.domElement.ownerDocument.removeEventListener( 'pointerlockerror', this._onPointerlockError );\n\n\t}\n\n\tdispose() {\n\n\t\tthis.disconnect();\n\n\t}\n\n\t/**\n\t * Returns the look direction of the camera.\n\t *\n\t * @param {Vector3} v - The target vector that is used to store the method's result.\n\t * @return {Vector3} The normalized direction vector.\n\t */\n\tgetDirection( v ) {\n\n\t\treturn v.set( 0, 0, - 1 ).applyQuaternion( this.object.quaternion );\n\n\t}\n\n\t/**\n\t * Moves the camera forward parallel to the xz-plane. Assumes camera.up is y-up.\n\t *\n\t * @param {number} distance - The signed distance.\n\t */\n\tmoveForward( distance ) {\n\n\t\tif ( this.enabled === false ) return;\n\n\t\t// move forward parallel to the xz-plane\n\t\t// assumes camera.up is y-up\n\n\t\tconst camera = this.object;\n\n\t\t_vector.setFromMatrixColumn( camera.matrix, 0 );\n\n\t\t_vector.crossVectors( camera.up, _vector );\n\n\t\tcamera.position.addScaledVector( _vector, distance );\n\n\t}\n\n\t/**\n\t * Moves the camera sidewards parallel to the xz-plane.\n\t *\n\t * @param {number} distance - The signed distance.\n\t */\n\tmoveRight( distance ) {\n\n\t\tif ( this.enabled === false ) return;\n\n\t\tconst camera = this.object;\n\n\t\t_vector.setFromMatrixColumn( camera.matrix, 0 );\n\n\t\tcamera.position.addScaledVector( _vector, distance );\n\n\t}\n\n\t/**\n\t * Activates the pointer lock.\n\t *\n\t * @param {boolean} [unadjustedMovement=false] - Disables OS-level adjustment for mouse acceleration, and accesses raw mouse input instead.\n\t * Setting it to true will disable mouse acceleration.\n\t */\n\tlock( unadjustedMovement = false ) {\n\n\t\tthis.domElement.requestPointerLock( {\n\t\t\tunadjustedMovement\n\t\t} );\n\n\t}\n\n\t/**\n\t * Exits the pointer lock.\n\t */\n\tunlock() {\n\n\t\tthis.domElement.ownerDocument.exitPointerLock();\n\n\t}\n\n}\n\n// event listeners\n\nfunction onMouseMove( event ) {\n\n\tif ( this.enabled === false || this.isLocked === false ) return;\n\n\tconst camera = this.object;\n\t_euler.setFromQuaternion( camera.quaternion );\n\n\t_euler.y -= event.movementX * _MOUSE_SENSITIVITY * this.pointerSpeed;\n\t_euler.x -= event.movementY * _MOUSE_SENSITIVITY * this.pointerSpeed;\n\n\t_euler.x = Math.max( _PI_2 - this.maxPolarAngle, Math.min( _PI_2 - this.minPolarAngle, _euler.x ) );\n\n\tcamera.quaternion.setFromEuler( _euler );\n\n\tthis.dispatchEvent( _changeEvent );\n\n}\n\nfunction onPointerlockChange() {\n\n\tif ( this.domElement.ownerDocument.pointerLockElement === this.domElement ) {\n\n\t\tthis.dispatchEvent( _lockEvent );\n\n\t\tthis.isLocked = true;\n\n\t} else {\n\n\t\tthis.dispatchEvent( _unlockEvent );\n\n\t\tthis.isLocked = false;\n\n\t}\n\n}\n\nfunction onPointerlockError() {\n\n\tconsole.error( 'THREE.PointerLockControls: Unable to use Pointer Lock API' );\n\n}\n\nexport { PointerLockControls };\n"],
+ "mappings": ";;;;;;;AAMA,IAAM,SAAS,IAAI,MAAO,GAAG,GAAG,GAAG,KAAM;AACzC,IAAM,UAAU,IAAI,QAAQ;AAQ5B,IAAM,eAAe,EAAE,MAAM,SAAS;AAQtC,IAAM,aAAa,EAAE,MAAM,OAAO;AAQlC,IAAM,eAAe,EAAE,MAAM,SAAS;AAEtC,IAAM,qBAAqB;AAC3B,IAAM,QAAQ,KAAK,KAAK;AA0BxB,IAAM,sBAAN,cAAkC,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1C,YAAa,QAAQ,aAAa,MAAO;AAExC,UAAO,QAAQ,UAAW;AAS1B,SAAK,WAAW;AAQhB,SAAK,gBAAgB;AAQrB,SAAK,gBAAgB,KAAK;AAQ1B,SAAK,eAAe;AAIpB,SAAK,eAAe,YAAY,KAAM,IAAK;AAC3C,SAAK,uBAAuB,oBAAoB,KAAM,IAAK;AAC3D,SAAK,sBAAsB,mBAAmB,KAAM,IAAK;AAEzD,QAAK,KAAK,eAAe,MAAO;AAE/B,WAAK,QAAS,KAAK,UAAW;AAAA,IAE/B;AAAA,EAED;AAAA,EAEA,QAAS,SAAU;AAElB,UAAM,QAAS,OAAQ;AAEvB,SAAK,WAAW,cAAc,iBAAkB,aAAa,KAAK,YAAa;AAC/E,SAAK,WAAW,cAAc,iBAAkB,qBAAqB,KAAK,oBAAqB;AAC/F,SAAK,WAAW,cAAc,iBAAkB,oBAAoB,KAAK,mBAAoB;AAAA,EAE9F;AAAA,EAEA,aAAa;AAEZ,SAAK,WAAW,cAAc,oBAAqB,aAAa,KAAK,YAAa;AAClF,SAAK,WAAW,cAAc,oBAAqB,qBAAqB,KAAK,oBAAqB;AAClG,SAAK,WAAW,cAAc,oBAAqB,oBAAoB,KAAK,mBAAoB;AAAA,EAEjG;AAAA,EAEA,UAAU;AAET,SAAK,WAAW;AAAA,EAEjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,aAAc,GAAI;AAEjB,WAAO,EAAE,IAAK,GAAG,GAAG,EAAI,EAAE,gBAAiB,KAAK,OAAO,UAAW;AAAA,EAEnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAa,UAAW;AAEvB,QAAK,KAAK,YAAY,MAAQ;AAK9B,UAAM,SAAS,KAAK;AAEpB,YAAQ,oBAAqB,OAAO,QAAQ,CAAE;AAE9C,YAAQ,aAAc,OAAO,IAAI,OAAQ;AAEzC,WAAO,SAAS,gBAAiB,SAAS,QAAS;AAAA,EAEpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,UAAW,UAAW;AAErB,QAAK,KAAK,YAAY,MAAQ;AAE9B,UAAM,SAAS,KAAK;AAEpB,YAAQ,oBAAqB,OAAO,QAAQ,CAAE;AAE9C,WAAO,SAAS,gBAAiB,SAAS,QAAS;AAAA,EAEpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,KAAM,qBAAqB,OAAQ;AAElC,SAAK,WAAW,mBAAoB;AAAA,MACnC;AAAA,IACD,CAAE;AAAA,EAEH;AAAA;AAAA;AAAA;AAAA,EAKA,SAAS;AAER,SAAK,WAAW,cAAc,gBAAgB;AAAA,EAE/C;AAED;AAIA,SAAS,YAAa,OAAQ;AAE7B,MAAK,KAAK,YAAY,SAAS,KAAK,aAAa,MAAQ;AAEzD,QAAM,SAAS,KAAK;AACpB,SAAO,kBAAmB,OAAO,UAAW;AAE5C,SAAO,KAAK,MAAM,YAAY,qBAAqB,KAAK;AACxD,SAAO,KAAK,MAAM,YAAY,qBAAqB,KAAK;AAExD,SAAO,IAAI,KAAK,IAAK,QAAQ,KAAK,eAAe,KAAK,IAAK,QAAQ,KAAK,eAAe,OAAO,CAAE,CAAE;AAElG,SAAO,WAAW,aAAc,MAAO;AAEvC,OAAK,cAAe,YAAa;AAElC;AAEA,SAAS,sBAAsB;AAE9B,MAAK,KAAK,WAAW,cAAc,uBAAuB,KAAK,YAAa;AAE3E,SAAK,cAAe,UAAW;AAE/B,SAAK,WAAW;AAAA,EAEjB,OAAO;AAEN,SAAK,cAAe,YAAa;AAEjC,SAAK,WAAW;AAAA,EAEjB;AAED;AAEA,SAAS,qBAAqB;AAE7B,UAAQ,MAAO,2DAA4D;AAE5E;",
+ "names": []
+}
diff --git a/node_modules/.vite/deps/chunk-XSTVJSXX.js b/node_modules/.vite/deps/chunk-XSTVJSXX.js
new file mode 100644
index 0000000..2cab24b
--- /dev/null
+++ b/node_modules/.vite/deps/chunk-XSTVJSXX.js
@@ -0,0 +1,43003 @@
+// node_modules/three/build/three.core.js
+var REVISION = "182";
+var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
+var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
+var CullFaceNone = 0;
+var CullFaceBack = 1;
+var CullFaceFront = 2;
+var CullFaceFrontBack = 3;
+var BasicShadowMap = 0;
+var PCFShadowMap = 1;
+var PCFSoftShadowMap = 2;
+var VSMShadowMap = 3;
+var FrontSide = 0;
+var BackSide = 1;
+var DoubleSide = 2;
+var NoBlending = 0;
+var NormalBlending = 1;
+var AdditiveBlending = 2;
+var SubtractiveBlending = 3;
+var MultiplyBlending = 4;
+var CustomBlending = 5;
+var AddEquation = 100;
+var SubtractEquation = 101;
+var ReverseSubtractEquation = 102;
+var MinEquation = 103;
+var MaxEquation = 104;
+var ZeroFactor = 200;
+var OneFactor = 201;
+var SrcColorFactor = 202;
+var OneMinusSrcColorFactor = 203;
+var SrcAlphaFactor = 204;
+var OneMinusSrcAlphaFactor = 205;
+var DstAlphaFactor = 206;
+var OneMinusDstAlphaFactor = 207;
+var DstColorFactor = 208;
+var OneMinusDstColorFactor = 209;
+var SrcAlphaSaturateFactor = 210;
+var ConstantColorFactor = 211;
+var OneMinusConstantColorFactor = 212;
+var ConstantAlphaFactor = 213;
+var OneMinusConstantAlphaFactor = 214;
+var NeverDepth = 0;
+var AlwaysDepth = 1;
+var LessDepth = 2;
+var LessEqualDepth = 3;
+var EqualDepth = 4;
+var GreaterEqualDepth = 5;
+var GreaterDepth = 6;
+var NotEqualDepth = 7;
+var MultiplyOperation = 0;
+var MixOperation = 1;
+var AddOperation = 2;
+var NoToneMapping = 0;
+var LinearToneMapping = 1;
+var ReinhardToneMapping = 2;
+var CineonToneMapping = 3;
+var ACESFilmicToneMapping = 4;
+var CustomToneMapping = 5;
+var AgXToneMapping = 6;
+var NeutralToneMapping = 7;
+var AttachedBindMode = "attached";
+var DetachedBindMode = "detached";
+var UVMapping = 300;
+var CubeReflectionMapping = 301;
+var CubeRefractionMapping = 302;
+var EquirectangularReflectionMapping = 303;
+var EquirectangularRefractionMapping = 304;
+var CubeUVReflectionMapping = 306;
+var RepeatWrapping = 1e3;
+var ClampToEdgeWrapping = 1001;
+var MirroredRepeatWrapping = 1002;
+var NearestFilter = 1003;
+var NearestMipmapNearestFilter = 1004;
+var NearestMipMapNearestFilter = 1004;
+var NearestMipmapLinearFilter = 1005;
+var NearestMipMapLinearFilter = 1005;
+var LinearFilter = 1006;
+var LinearMipmapNearestFilter = 1007;
+var LinearMipMapNearestFilter = 1007;
+var LinearMipmapLinearFilter = 1008;
+var LinearMipMapLinearFilter = 1008;
+var UnsignedByteType = 1009;
+var ByteType = 1010;
+var ShortType = 1011;
+var UnsignedShortType = 1012;
+var IntType = 1013;
+var UnsignedIntType = 1014;
+var FloatType = 1015;
+var HalfFloatType = 1016;
+var UnsignedShort4444Type = 1017;
+var UnsignedShort5551Type = 1018;
+var UnsignedInt248Type = 1020;
+var UnsignedInt5999Type = 35902;
+var UnsignedInt101111Type = 35899;
+var AlphaFormat = 1021;
+var RGBFormat = 1022;
+var RGBAFormat = 1023;
+var DepthFormat = 1026;
+var DepthStencilFormat = 1027;
+var RedFormat = 1028;
+var RedIntegerFormat = 1029;
+var RGFormat = 1030;
+var RGIntegerFormat = 1031;
+var RGBIntegerFormat = 1032;
+var RGBAIntegerFormat = 1033;
+var RGB_S3TC_DXT1_Format = 33776;
+var RGBA_S3TC_DXT1_Format = 33777;
+var RGBA_S3TC_DXT3_Format = 33778;
+var RGBA_S3TC_DXT5_Format = 33779;
+var RGB_PVRTC_4BPPV1_Format = 35840;
+var RGB_PVRTC_2BPPV1_Format = 35841;
+var RGBA_PVRTC_4BPPV1_Format = 35842;
+var RGBA_PVRTC_2BPPV1_Format = 35843;
+var RGB_ETC1_Format = 36196;
+var RGB_ETC2_Format = 37492;
+var RGBA_ETC2_EAC_Format = 37496;
+var R11_EAC_Format = 37488;
+var SIGNED_R11_EAC_Format = 37489;
+var RG11_EAC_Format = 37490;
+var SIGNED_RG11_EAC_Format = 37491;
+var RGBA_ASTC_4x4_Format = 37808;
+var RGBA_ASTC_5x4_Format = 37809;
+var RGBA_ASTC_5x5_Format = 37810;
+var RGBA_ASTC_6x5_Format = 37811;
+var RGBA_ASTC_6x6_Format = 37812;
+var RGBA_ASTC_8x5_Format = 37813;
+var RGBA_ASTC_8x6_Format = 37814;
+var RGBA_ASTC_8x8_Format = 37815;
+var RGBA_ASTC_10x5_Format = 37816;
+var RGBA_ASTC_10x6_Format = 37817;
+var RGBA_ASTC_10x8_Format = 37818;
+var RGBA_ASTC_10x10_Format = 37819;
+var RGBA_ASTC_12x10_Format = 37820;
+var RGBA_ASTC_12x12_Format = 37821;
+var RGBA_BPTC_Format = 36492;
+var RGB_BPTC_SIGNED_Format = 36494;
+var RGB_BPTC_UNSIGNED_Format = 36495;
+var RED_RGTC1_Format = 36283;
+var SIGNED_RED_RGTC1_Format = 36284;
+var RED_GREEN_RGTC2_Format = 36285;
+var SIGNED_RED_GREEN_RGTC2_Format = 36286;
+var LoopOnce = 2200;
+var LoopRepeat = 2201;
+var LoopPingPong = 2202;
+var InterpolateDiscrete = 2300;
+var InterpolateLinear = 2301;
+var InterpolateSmooth = 2302;
+var ZeroCurvatureEnding = 2400;
+var ZeroSlopeEnding = 2401;
+var WrapAroundEnding = 2402;
+var NormalAnimationBlendMode = 2500;
+var AdditiveAnimationBlendMode = 2501;
+var TrianglesDrawMode = 0;
+var TriangleStripDrawMode = 1;
+var TriangleFanDrawMode = 2;
+var BasicDepthPacking = 3200;
+var RGBADepthPacking = 3201;
+var RGBDepthPacking = 3202;
+var RGDepthPacking = 3203;
+var TangentSpaceNormalMap = 0;
+var ObjectSpaceNormalMap = 1;
+var NoColorSpace = "";
+var SRGBColorSpace = "srgb";
+var LinearSRGBColorSpace = "srgb-linear";
+var LinearTransfer = "linear";
+var SRGBTransfer = "srgb";
+var NoNormalPacking = "";
+var NormalRGPacking = "rg";
+var NormalGAPacking = "ga";
+var ZeroStencilOp = 0;
+var KeepStencilOp = 7680;
+var ReplaceStencilOp = 7681;
+var IncrementStencilOp = 7682;
+var DecrementStencilOp = 7683;
+var IncrementWrapStencilOp = 34055;
+var DecrementWrapStencilOp = 34056;
+var InvertStencilOp = 5386;
+var NeverStencilFunc = 512;
+var LessStencilFunc = 513;
+var EqualStencilFunc = 514;
+var LessEqualStencilFunc = 515;
+var GreaterStencilFunc = 516;
+var NotEqualStencilFunc = 517;
+var GreaterEqualStencilFunc = 518;
+var AlwaysStencilFunc = 519;
+var NeverCompare = 512;
+var LessCompare = 513;
+var EqualCompare = 514;
+var LessEqualCompare = 515;
+var GreaterCompare = 516;
+var NotEqualCompare = 517;
+var GreaterEqualCompare = 518;
+var AlwaysCompare = 519;
+var StaticDrawUsage = 35044;
+var DynamicDrawUsage = 35048;
+var StreamDrawUsage = 35040;
+var StaticReadUsage = 35045;
+var DynamicReadUsage = 35049;
+var StreamReadUsage = 35041;
+var StaticCopyUsage = 35046;
+var DynamicCopyUsage = 35050;
+var StreamCopyUsage = 35042;
+var GLSL1 = "100";
+var GLSL3 = "300 es";
+var WebGLCoordinateSystem = 2e3;
+var WebGPUCoordinateSystem = 2001;
+var TimestampQuery = {
+ COMPUTE: "compute",
+ RENDER: "render"
+};
+var InterpolationSamplingType = {
+ PERSPECTIVE: "perspective",
+ LINEAR: "linear",
+ FLAT: "flat"
+};
+var InterpolationSamplingMode = {
+ NORMAL: "normal",
+ CENTROID: "centroid",
+ SAMPLE: "sample",
+ FIRST: "first",
+ EITHER: "either"
+};
+function arrayNeedsUint32(array) {
+ for (let i = array.length - 1; i >= 0; --i) {
+ if (array[i] >= 65535) return true;
+ }
+ return false;
+}
+var TYPED_ARRAYS = {
+ Int8Array,
+ Uint8Array,
+ Uint8ClampedArray,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Float32Array,
+ Float64Array
+};
+function getTypedArray(type, buffer) {
+ return new TYPED_ARRAYS[type](buffer);
+}
+function isTypedArray(array) {
+ return ArrayBuffer.isView(array) && !(array instanceof DataView);
+}
+function createElementNS(name) {
+ return document.createElementNS("http://www.w3.org/1999/xhtml", name);
+}
+function createCanvasElement() {
+ const canvas = createElementNS("canvas");
+ canvas.style.display = "block";
+ return canvas;
+}
+var _cache = {};
+var _setConsoleFunction = null;
+function setConsoleFunction(fn) {
+ _setConsoleFunction = fn;
+}
+function getConsoleFunction() {
+ return _setConsoleFunction;
+}
+function log(...params) {
+ const message = "THREE." + params.shift();
+ if (_setConsoleFunction) {
+ _setConsoleFunction("log", message, ...params);
+ } else {
+ console.log(message, ...params);
+ }
+}
+function warn(...params) {
+ const message = "THREE." + params.shift();
+ if (_setConsoleFunction) {
+ _setConsoleFunction("warn", message, ...params);
+ } else {
+ console.warn(message, ...params);
+ }
+}
+function error(...params) {
+ const message = "THREE." + params.shift();
+ if (_setConsoleFunction) {
+ _setConsoleFunction("error", message, ...params);
+ } else {
+ console.error(message, ...params);
+ }
+}
+function warnOnce(...params) {
+ const message = params.join(" ");
+ if (message in _cache) return;
+ _cache[message] = true;
+ warn(...params);
+}
+function probeAsync(gl, sync, interval) {
+ return new Promise(function(resolve, reject) {
+ function probe() {
+ switch (gl.clientWaitSync(sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0)) {
+ case gl.WAIT_FAILED:
+ reject();
+ break;
+ case gl.TIMEOUT_EXPIRED:
+ setTimeout(probe, interval);
+ break;
+ default:
+ resolve();
+ }
+ }
+ setTimeout(probe, interval);
+ });
+}
+var EventDispatcher = class {
+ /**
+ * Adds the given event listener to the given event type.
+ *
+ * @param {string} type - The type of event to listen to.
+ * @param {Function} listener - The function that gets called when the event is fired.
+ */
+ addEventListener(type, listener) {
+ if (this._listeners === void 0) this._listeners = {};
+ const listeners = this._listeners;
+ if (listeners[type] === void 0) {
+ listeners[type] = [];
+ }
+ if (listeners[type].indexOf(listener) === -1) {
+ listeners[type].push(listener);
+ }
+ }
+ /**
+ * Returns `true` if the given event listener has been added to the given event type.
+ *
+ * @param {string} type - The type of event.
+ * @param {Function} listener - The listener to check.
+ * @return {boolean} Whether the given event listener has been added to the given event type.
+ */
+ hasEventListener(type, listener) {
+ const listeners = this._listeners;
+ if (listeners === void 0) return false;
+ return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
+ }
+ /**
+ * Removes the given event listener from the given event type.
+ *
+ * @param {string} type - The type of event.
+ * @param {Function} listener - The listener to remove.
+ */
+ removeEventListener(type, listener) {
+ const listeners = this._listeners;
+ if (listeners === void 0) return;
+ const listenerArray = listeners[type];
+ if (listenerArray !== void 0) {
+ const index = listenerArray.indexOf(listener);
+ if (index !== -1) {
+ listenerArray.splice(index, 1);
+ }
+ }
+ }
+ /**
+ * Dispatches an event object.
+ *
+ * @param {Object} event - The event that gets fired.
+ */
+ dispatchEvent(event) {
+ const listeners = this._listeners;
+ if (listeners === void 0) return;
+ const listenerArray = listeners[event.type];
+ if (listenerArray !== void 0) {
+ event.target = this;
+ const array = listenerArray.slice(0);
+ for (let i = 0, l = array.length; i < l; i++) {
+ array[i].call(this, event);
+ }
+ event.target = null;
+ }
+ }
+};
+var _lut = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
+var _seed = 1234567;
+var DEG2RAD = Math.PI / 180;
+var RAD2DEG = 180 / Math.PI;
+function generateUUID() {
+ const d0 = Math.random() * 4294967295 | 0;
+ const d1 = Math.random() * 4294967295 | 0;
+ const d2 = Math.random() * 4294967295 | 0;
+ const d3 = Math.random() * 4294967295 | 0;
+ const uuid = _lut[d0 & 255] + _lut[d0 >> 8 & 255] + _lut[d0 >> 16 & 255] + _lut[d0 >> 24 & 255] + "-" + _lut[d1 & 255] + _lut[d1 >> 8 & 255] + "-" + _lut[d1 >> 16 & 15 | 64] + _lut[d1 >> 24 & 255] + "-" + _lut[d2 & 63 | 128] + _lut[d2 >> 8 & 255] + "-" + _lut[d2 >> 16 & 255] + _lut[d2 >> 24 & 255] + _lut[d3 & 255] + _lut[d3 >> 8 & 255] + _lut[d3 >> 16 & 255] + _lut[d3 >> 24 & 255];
+ return uuid.toLowerCase();
+}
+function clamp(value, min, max) {
+ return Math.max(min, Math.min(max, value));
+}
+function euclideanModulo(n, m) {
+ return (n % m + m) % m;
+}
+function mapLinear(x, a1, a2, b1, b2) {
+ return b1 + (x - a1) * (b2 - b1) / (a2 - a1);
+}
+function inverseLerp(x, y, value) {
+ if (x !== y) {
+ return (value - x) / (y - x);
+ } else {
+ return 0;
+ }
+}
+function lerp(x, y, t) {
+ return (1 - t) * x + t * y;
+}
+function damp(x, y, lambda, dt) {
+ return lerp(x, y, 1 - Math.exp(-lambda * dt));
+}
+function pingpong(x, length = 1) {
+ return length - Math.abs(euclideanModulo(x, length * 2) - length);
+}
+function smoothstep(x, min, max) {
+ if (x <= min) return 0;
+ if (x >= max) return 1;
+ x = (x - min) / (max - min);
+ return x * x * (3 - 2 * x);
+}
+function smootherstep(x, min, max) {
+ if (x <= min) return 0;
+ if (x >= max) return 1;
+ x = (x - min) / (max - min);
+ return x * x * x * (x * (x * 6 - 15) + 10);
+}
+function randInt(low, high) {
+ return low + Math.floor(Math.random() * (high - low + 1));
+}
+function randFloat(low, high) {
+ return low + Math.random() * (high - low);
+}
+function randFloatSpread(range) {
+ return range * (0.5 - Math.random());
+}
+function seededRandom(s) {
+ if (s !== void 0) _seed = s;
+ let t = _seed += 1831565813;
+ t = Math.imul(t ^ t >>> 15, t | 1);
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
+}
+function degToRad(degrees) {
+ return degrees * DEG2RAD;
+}
+function radToDeg(radians) {
+ return radians * RAD2DEG;
+}
+function isPowerOfTwo(value) {
+ return (value & value - 1) === 0 && value !== 0;
+}
+function ceilPowerOfTwo(value) {
+ return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
+}
+function floorPowerOfTwo(value) {
+ return Math.pow(2, Math.floor(Math.log(value) / Math.LN2));
+}
+function setQuaternionFromProperEuler(q, a, b, c, order) {
+ const cos = Math.cos;
+ const sin = Math.sin;
+ const c2 = cos(b / 2);
+ const s2 = sin(b / 2);
+ const c13 = cos((a + c) / 2);
+ const s13 = sin((a + c) / 2);
+ const c1_3 = cos((a - c) / 2);
+ const s1_3 = sin((a - c) / 2);
+ const c3_1 = cos((c - a) / 2);
+ const s3_1 = sin((c - a) / 2);
+ switch (order) {
+ case "XYX":
+ q.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13);
+ break;
+ case "YZY":
+ q.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13);
+ break;
+ case "ZXZ":
+ q.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13);
+ break;
+ case "XZX":
+ q.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13);
+ break;
+ case "YXY":
+ q.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13);
+ break;
+ case "ZYZ":
+ q.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13);
+ break;
+ default:
+ warn("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + order);
+ }
+}
+function denormalize(value, array) {
+ switch (array.constructor) {
+ case Float32Array:
+ return value;
+ case Uint32Array:
+ return value / 4294967295;
+ case Uint16Array:
+ return value / 65535;
+ case Uint8Array:
+ return value / 255;
+ case Int32Array:
+ return Math.max(value / 2147483647, -1);
+ case Int16Array:
+ return Math.max(value / 32767, -1);
+ case Int8Array:
+ return Math.max(value / 127, -1);
+ default:
+ throw new Error("Invalid component type.");
+ }
+}
+function normalize(value, array) {
+ switch (array.constructor) {
+ case Float32Array:
+ return value;
+ case Uint32Array:
+ return Math.round(value * 4294967295);
+ case Uint16Array:
+ return Math.round(value * 65535);
+ case Uint8Array:
+ return Math.round(value * 255);
+ case Int32Array:
+ return Math.round(value * 2147483647);
+ case Int16Array:
+ return Math.round(value * 32767);
+ case Int8Array:
+ return Math.round(value * 127);
+ default:
+ throw new Error("Invalid component type.");
+ }
+}
+var MathUtils = {
+ DEG2RAD,
+ RAD2DEG,
+ /**
+ * Generate a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)
+ * (universally unique identifier).
+ *
+ * @static
+ * @method
+ * @return {string} The UUID.
+ */
+ generateUUID,
+ /**
+ * Clamps the given value between min and max.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to clamp.
+ * @param {number} min - The min value.
+ * @param {number} max - The max value.
+ * @return {number} The clamped value.
+ */
+ clamp,
+ /**
+ * Computes the Euclidean modulo of the given parameters that
+ * is `( ( n % m ) + m ) % m`.
+ *
+ * @static
+ * @method
+ * @param {number} n - The first parameter.
+ * @param {number} m - The second parameter.
+ * @return {number} The Euclidean modulo.
+ */
+ euclideanModulo,
+ /**
+ * Performs a linear mapping from range `
` to range ``
+ * for the given value.
+ *
+ * @static
+ * @method
+ * @param {number} x - The value to be mapped.
+ * @param {number} a1 - Minimum value for range A.
+ * @param {number} a2 - Maximum value for range A.
+ * @param {number} b1 - Minimum value for range B.
+ * @param {number} b2 - Maximum value for range B.
+ * @return {number} The mapped value.
+ */
+ mapLinear,
+ /**
+ * Returns the percentage in the closed interval `[0, 1]` of the given value
+ * between the start and end point.
+ *
+ * @static
+ * @method
+ * @param {number} x - The start point
+ * @param {number} y - The end point.
+ * @param {number} value - A value between start and end.
+ * @return {number} The interpolation factor.
+ */
+ inverseLerp,
+ /**
+ * Returns a value linearly interpolated from two known points based on the given interval -
+ * `t = 0` will return `x` and `t = 1` will return `y`.
+ *
+ * @static
+ * @method
+ * @param {number} x - The start point
+ * @param {number} y - The end point.
+ * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
+ * @return {number} The interpolated value.
+ */
+ lerp,
+ /**
+ * Smoothly interpolate a number from `x` to `y` in a spring-like manner using a delta
+ * time to maintain frame rate independent movement. For details, see
+ * [Frame rate independent damping using lerp](http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/).
+ *
+ * @static
+ * @method
+ * @param {number} x - The current point.
+ * @param {number} y - The target point.
+ * @param {number} lambda - A higher lambda value will make the movement more sudden,
+ * and a lower value will make the movement more gradual.
+ * @param {number} dt - Delta time in seconds.
+ * @return {number} The interpolated value.
+ */
+ damp,
+ /**
+ * Returns a value that alternates between `0` and the given `length` parameter.
+ *
+ * @static
+ * @method
+ * @param {number} x - The value to pingpong.
+ * @param {number} [length=1] - The positive value the function will pingpong to.
+ * @return {number} The alternated value.
+ */
+ pingpong,
+ /**
+ * Returns a value in the range `[0,1]` that represents the percentage that `x` has
+ * moved between `min` and `max`, but smoothed or slowed down the closer `x` is to
+ * the `min` and `max`.
+ *
+ * See [Smoothstep](http://en.wikipedia.org/wiki/Smoothstep) for more details.
+ *
+ * @static
+ * @method
+ * @param {number} x - The value to evaluate based on its position between min and max.
+ * @param {number} min - The min value. Any x value below min will be `0`.
+ * @param {number} max - The max value. Any x value above max will be `1`.
+ * @return {number} The alternated value.
+ */
+ smoothstep,
+ /**
+ * A [variation on smoothstep](https://en.wikipedia.org/wiki/Smoothstep#Variations)
+ * that has zero 1st and 2nd order derivatives at x=0 and x=1.
+ *
+ * @static
+ * @method
+ * @param {number} x - The value to evaluate based on its position between min and max.
+ * @param {number} min - The min value. Any x value below min will be `0`.
+ * @param {number} max - The max value. Any x value above max will be `1`.
+ * @return {number} The alternated value.
+ */
+ smootherstep,
+ /**
+ * Returns a random integer from `` interval.
+ *
+ * @static
+ * @method
+ * @param {number} low - The lower value boundary.
+ * @param {number} high - The upper value boundary
+ * @return {number} A random integer.
+ */
+ randInt,
+ /**
+ * Returns a random float from `` interval.
+ *
+ * @static
+ * @method
+ * @param {number} low - The lower value boundary.
+ * @param {number} high - The upper value boundary
+ * @return {number} A random float.
+ */
+ randFloat,
+ /**
+ * Returns a random integer from `<-range/2, range/2>` interval.
+ *
+ * @static
+ * @method
+ * @param {number} range - Defines the value range.
+ * @return {number} A random float.
+ */
+ randFloatSpread,
+ /**
+ * Returns a deterministic pseudo-random float in the interval `[0, 1]`.
+ *
+ * @static
+ * @method
+ * @param {number} [s] - The integer seed.
+ * @return {number} A random float.
+ */
+ seededRandom,
+ /**
+ * Converts degrees to radians.
+ *
+ * @static
+ * @method
+ * @param {number} degrees - A value in degrees.
+ * @return {number} The converted value in radians.
+ */
+ degToRad,
+ /**
+ * Converts radians to degrees.
+ *
+ * @static
+ * @method
+ * @param {number} radians - A value in radians.
+ * @return {number} The converted value in degrees.
+ */
+ radToDeg,
+ /**
+ * Returns `true` if the given number is a power of two.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to check.
+ * @return {boolean} Whether the given number is a power of two or not.
+ */
+ isPowerOfTwo,
+ /**
+ * Returns the smallest power of two that is greater than or equal to the given number.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to find a POT for.
+ * @return {number} The smallest power of two that is greater than or equal to the given number.
+ */
+ ceilPowerOfTwo,
+ /**
+ * Returns the largest power of two that is less than or equal to the given number.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to find a POT for.
+ * @return {number} The largest power of two that is less than or equal to the given number.
+ */
+ floorPowerOfTwo,
+ /**
+ * Sets the given quaternion from the [Intrinsic Proper Euler Angles](https://en.wikipedia.org/wiki/Euler_angles)
+ * defined by the given angles and order.
+ *
+ * Rotations are applied to the axes in the order specified by order:
+ * rotation by angle `a` is applied first, then by angle `b`, then by angle `c`.
+ *
+ * @static
+ * @method
+ * @param {Quaternion} q - The quaternion to set.
+ * @param {number} a - The rotation applied to the first axis, in radians.
+ * @param {number} b - The rotation applied to the second axis, in radians.
+ * @param {number} c - The rotation applied to the third axis, in radians.
+ * @param {('XYX'|'XZX'|'YXY'|'YZY'|'ZXZ'|'ZYZ')} order - A string specifying the axes order.
+ */
+ setQuaternionFromProperEuler,
+ /**
+ * Normalizes the given value according to the given typed array.
+ *
+ * @static
+ * @method
+ * @param {number} value - The float value in the range `[0,1]` to normalize.
+ * @param {TypedArray} array - The typed array that defines the data type of the value.
+ * @return {number} The normalize value.
+ */
+ normalize,
+ /**
+ * Denormalizes the given value according to the given typed array.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to denormalize.
+ * @param {TypedArray} array - The typed array that defines the data type of the value.
+ * @return {number} The denormalize (float) value in the range `[0,1]`.
+ */
+ denormalize
+};
+var Vector2 = class _Vector2 {
+ /**
+ * Constructs a new 2D vector.
+ *
+ * @param {number} [x=0] - The x value of this vector.
+ * @param {number} [y=0] - The y value of this vector.
+ */
+ constructor(x = 0, y = 0) {
+ _Vector2.prototype.isVector2 = true;
+ this.x = x;
+ this.y = y;
+ }
+ /**
+ * Alias for {@link Vector2#x}.
+ *
+ * @type {number}
+ */
+ get width() {
+ return this.x;
+ }
+ set width(value) {
+ this.x = value;
+ }
+ /**
+ * Alias for {@link Vector2#y}.
+ *
+ * @type {number}
+ */
+ get height() {
+ return this.y;
+ }
+ set height(value) {
+ this.y = value;
+ }
+ /**
+ * Sets the vector components.
+ *
+ * @param {number} x - The value of the x component.
+ * @param {number} y - The value of the y component.
+ * @return {Vector2} A reference to this vector.
+ */
+ set(x, y) {
+ this.x = x;
+ this.y = y;
+ return this;
+ }
+ /**
+ * Sets the vector components to the same value.
+ *
+ * @param {number} scalar - The value to set for all vector components.
+ * @return {Vector2} A reference to this vector.
+ */
+ setScalar(scalar) {
+ this.x = scalar;
+ this.y = scalar;
+ return this;
+ }
+ /**
+ * Sets the vector's x component to the given value
+ *
+ * @param {number} x - The value to set.
+ * @return {Vector2} A reference to this vector.
+ */
+ setX(x) {
+ this.x = x;
+ return this;
+ }
+ /**
+ * Sets the vector's y component to the given value
+ *
+ * @param {number} y - The value to set.
+ * @return {Vector2} A reference to this vector.
+ */
+ setY(y) {
+ this.y = y;
+ return this;
+ }
+ /**
+ * Allows to set a vector component with an index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y.
+ * @param {number} value - The value to set.
+ * @return {Vector2} A reference to this vector.
+ */
+ setComponent(index, value) {
+ switch (index) {
+ case 0:
+ this.x = value;
+ break;
+ case 1:
+ this.y = value;
+ break;
+ default:
+ throw new Error("index is out of range: " + index);
+ }
+ return this;
+ }
+ /**
+ * Returns the value of the vector component which matches the given index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y.
+ * @return {number} A vector component value.
+ */
+ getComponent(index) {
+ switch (index) {
+ case 0:
+ return this.x;
+ case 1:
+ return this.y;
+ default:
+ throw new Error("index is out of range: " + index);
+ }
+ }
+ /**
+ * Returns a new vector with copied values from this instance.
+ *
+ * @return {Vector2} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor(this.x, this.y);
+ }
+ /**
+ * Copies the values of the given vector to this instance.
+ *
+ * @param {Vector2} v - The vector to copy.
+ * @return {Vector2} A reference to this vector.
+ */
+ copy(v) {
+ this.x = v.x;
+ this.y = v.y;
+ return this;
+ }
+ /**
+ * Adds the given vector to this instance.
+ *
+ * @param {Vector2} v - The vector to add.
+ * @return {Vector2} A reference to this vector.
+ */
+ add(v) {
+ this.x += v.x;
+ this.y += v.y;
+ return this;
+ }
+ /**
+ * Adds the given scalar value to all components of this instance.
+ *
+ * @param {number} s - The scalar to add.
+ * @return {Vector2} A reference to this vector.
+ */
+ addScalar(s) {
+ this.x += s;
+ this.y += s;
+ return this;
+ }
+ /**
+ * Adds the given vectors and stores the result in this instance.
+ *
+ * @param {Vector2} a - The first vector.
+ * @param {Vector2} b - The second vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ addVectors(a, b) {
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+ return this;
+ }
+ /**
+ * Adds the given vector scaled by the given factor to this instance.
+ *
+ * @param {Vector2} v - The vector.
+ * @param {number} s - The factor that scales `v`.
+ * @return {Vector2} A reference to this vector.
+ */
+ addScaledVector(v, s) {
+ this.x += v.x * s;
+ this.y += v.y * s;
+ return this;
+ }
+ /**
+ * Subtracts the given vector from this instance.
+ *
+ * @param {Vector2} v - The vector to subtract.
+ * @return {Vector2} A reference to this vector.
+ */
+ sub(v) {
+ this.x -= v.x;
+ this.y -= v.y;
+ return this;
+ }
+ /**
+ * Subtracts the given scalar value from all components of this instance.
+ *
+ * @param {number} s - The scalar to subtract.
+ * @return {Vector2} A reference to this vector.
+ */
+ subScalar(s) {
+ this.x -= s;
+ this.y -= s;
+ return this;
+ }
+ /**
+ * Subtracts the given vectors and stores the result in this instance.
+ *
+ * @param {Vector2} a - The first vector.
+ * @param {Vector2} b - The second vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ subVectors(a, b) {
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+ return this;
+ }
+ /**
+ * Multiplies the given vector with this instance.
+ *
+ * @param {Vector2} v - The vector to multiply.
+ * @return {Vector2} A reference to this vector.
+ */
+ multiply(v) {
+ this.x *= v.x;
+ this.y *= v.y;
+ return this;
+ }
+ /**
+ * Multiplies the given scalar value with all components of this instance.
+ *
+ * @param {number} scalar - The scalar to multiply.
+ * @return {Vector2} A reference to this vector.
+ */
+ multiplyScalar(scalar) {
+ this.x *= scalar;
+ this.y *= scalar;
+ return this;
+ }
+ /**
+ * Divides this instance by the given vector.
+ *
+ * @param {Vector2} v - The vector to divide.
+ * @return {Vector2} A reference to this vector.
+ */
+ divide(v) {
+ this.x /= v.x;
+ this.y /= v.y;
+ return this;
+ }
+ /**
+ * Divides this vector by the given scalar.
+ *
+ * @param {number} scalar - The scalar to divide.
+ * @return {Vector2} A reference to this vector.
+ */
+ divideScalar(scalar) {
+ return this.multiplyScalar(1 / scalar);
+ }
+ /**
+ * Multiplies this vector (with an implicit 1 as the 3rd component) by
+ * the given 3x3 matrix.
+ *
+ * @param {Matrix3} m - The matrix to apply.
+ * @return {Vector2} A reference to this vector.
+ */
+ applyMatrix3(m) {
+ const x = this.x, y = this.y;
+ const e = m.elements;
+ this.x = e[0] * x + e[3] * y + e[6];
+ this.y = e[1] * x + e[4] * y + e[7];
+ return this;
+ }
+ /**
+ * If this vector's x or y value is greater than the given vector's x or y
+ * value, replace that value with the corresponding min value.
+ *
+ * @param {Vector2} v - The vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ min(v) {
+ this.x = Math.min(this.x, v.x);
+ this.y = Math.min(this.y, v.y);
+ return this;
+ }
+ /**
+ * If this vector's x or y value is less than the given vector's x or y
+ * value, replace that value with the corresponding max value.
+ *
+ * @param {Vector2} v - The vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ max(v) {
+ this.x = Math.max(this.x, v.x);
+ this.y = Math.max(this.y, v.y);
+ return this;
+ }
+ /**
+ * If this vector's x or y value is greater than the max vector's x or y
+ * value, it is replaced by the corresponding value.
+ * If this vector's x or y value is less than the min vector's x or y value,
+ * it is replaced by the corresponding value.
+ *
+ * @param {Vector2} min - The minimum x and y values.
+ * @param {Vector2} max - The maximum x and y values in the desired range.
+ * @return {Vector2} A reference to this vector.
+ */
+ clamp(min, max) {
+ this.x = clamp(this.x, min.x, max.x);
+ this.y = clamp(this.y, min.y, max.y);
+ return this;
+ }
+ /**
+ * If this vector's x or y values are greater than the max value, they are
+ * replaced by the max value.
+ * If this vector's x or y values are less than the min value, they are
+ * replaced by the min value.
+ *
+ * @param {number} minVal - The minimum value the components will be clamped to.
+ * @param {number} maxVal - The maximum value the components will be clamped to.
+ * @return {Vector2} A reference to this vector.
+ */
+ clampScalar(minVal, maxVal) {
+ this.x = clamp(this.x, minVal, maxVal);
+ this.y = clamp(this.y, minVal, maxVal);
+ return this;
+ }
+ /**
+ * If this vector's length is greater than the max value, it is replaced by
+ * the max value.
+ * If this vector's length is less than the min value, it is replaced by the
+ * min value.
+ *
+ * @param {number} min - The minimum value the vector length will be clamped to.
+ * @param {number} max - The maximum value the vector length will be clamped to.
+ * @return {Vector2} A reference to this vector.
+ */
+ clampLength(min, max) {
+ const length = this.length();
+ return this.divideScalar(length || 1).multiplyScalar(clamp(length, min, max));
+ }
+ /**
+ * The components of this vector are rounded down to the nearest integer value.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ floor() {
+ this.x = Math.floor(this.x);
+ this.y = Math.floor(this.y);
+ return this;
+ }
+ /**
+ * The components of this vector are rounded up to the nearest integer value.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ ceil() {
+ this.x = Math.ceil(this.x);
+ this.y = Math.ceil(this.y);
+ return this;
+ }
+ /**
+ * The components of this vector are rounded to the nearest integer value
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ round() {
+ this.x = Math.round(this.x);
+ this.y = Math.round(this.y);
+ return this;
+ }
+ /**
+ * The components of this vector are rounded towards zero (up if negative,
+ * down if positive) to an integer value.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ roundToZero() {
+ this.x = Math.trunc(this.x);
+ this.y = Math.trunc(this.y);
+ return this;
+ }
+ /**
+ * Inverts this vector - i.e. sets x = -x and y = -y.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ negate() {
+ this.x = -this.x;
+ this.y = -this.y;
+ return this;
+ }
+ /**
+ * Calculates the dot product of the given vector with this instance.
+ *
+ * @param {Vector2} v - The vector to compute the dot product with.
+ * @return {number} The result of the dot product.
+ */
+ dot(v) {
+ return this.x * v.x + this.y * v.y;
+ }
+ /**
+ * Calculates the cross product of the given vector with this instance.
+ *
+ * @param {Vector2} v - The vector to compute the cross product with.
+ * @return {number} The result of the cross product.
+ */
+ cross(v) {
+ return this.x * v.y - this.y * v.x;
+ }
+ /**
+ * Computes the square of the Euclidean length (straight-line length) from
+ * (0, 0) to (x, y). If you are comparing the lengths of vectors, you should
+ * compare the length squared instead as it is slightly more efficient to calculate.
+ *
+ * @return {number} The square length of this vector.
+ */
+ lengthSq() {
+ return this.x * this.x + this.y * this.y;
+ }
+ /**
+ * Computes the Euclidean length (straight-line length) from (0, 0) to (x, y).
+ *
+ * @return {number} The length of this vector.
+ */
+ length() {
+ return Math.sqrt(this.x * this.x + this.y * this.y);
+ }
+ /**
+ * Computes the Manhattan length of this vector.
+ *
+ * @return {number} The length of this vector.
+ */
+ manhattanLength() {
+ return Math.abs(this.x) + Math.abs(this.y);
+ }
+ /**
+ * Converts this vector to a unit vector - that is, sets it equal to a vector
+ * with the same direction as this one, but with a vector length of `1`.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ normalize() {
+ return this.divideScalar(this.length() || 1);
+ }
+ /**
+ * Computes the angle in radians of this vector with respect to the positive x-axis.
+ *
+ * @return {number} The angle in radians.
+ */
+ angle() {
+ const angle = Math.atan2(-this.y, -this.x) + Math.PI;
+ return angle;
+ }
+ /**
+ * Returns the angle between the given vector and this instance in radians.
+ *
+ * @param {Vector2} v - The vector to compute the angle with.
+ * @return {number} The angle in radians.
+ */
+ angleTo(v) {
+ const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
+ if (denominator === 0) return Math.PI / 2;
+ const theta = this.dot(v) / denominator;
+ return Math.acos(clamp(theta, -1, 1));
+ }
+ /**
+ * Computes the distance from the given vector to this instance.
+ *
+ * @param {Vector2} v - The vector to compute the distance to.
+ * @return {number} The distance.
+ */
+ distanceTo(v) {
+ return Math.sqrt(this.distanceToSquared(v));
+ }
+ /**
+ * Computes the squared distance from the given vector to this instance.
+ * If you are just comparing the distance with another distance, you should compare
+ * the distance squared instead as it is slightly more efficient to calculate.
+ *
+ * @param {Vector2} v - The vector to compute the squared distance to.
+ * @return {number} The squared distance.
+ */
+ distanceToSquared(v) {
+ const dx = this.x - v.x, dy = this.y - v.y;
+ return dx * dx + dy * dy;
+ }
+ /**
+ * Computes the Manhattan distance from the given vector to this instance.
+ *
+ * @param {Vector2} v - The vector to compute the Manhattan distance to.
+ * @return {number} The Manhattan distance.
+ */
+ manhattanDistanceTo(v) {
+ return Math.abs(this.x - v.x) + Math.abs(this.y - v.y);
+ }
+ /**
+ * Sets this vector to a vector with the same direction as this one, but
+ * with the specified length.
+ *
+ * @param {number} length - The new length of this vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ setLength(length) {
+ return this.normalize().multiplyScalar(length);
+ }
+ /**
+ * Linearly interpolates between the given vector and this instance, where
+ * alpha is the percent distance along the line - alpha = 0 will be this
+ * vector, and alpha = 1 will be the given one.
+ *
+ * @param {Vector2} v - The vector to interpolate towards.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector2} A reference to this vector.
+ */
+ lerp(v, alpha) {
+ this.x += (v.x - this.x) * alpha;
+ this.y += (v.y - this.y) * alpha;
+ return this;
+ }
+ /**
+ * Linearly interpolates between the given vectors, where alpha is the percent
+ * distance along the line - alpha = 0 will be first vector, and alpha = 1 will
+ * be the second one. The result is stored in this instance.
+ *
+ * @param {Vector2} v1 - The first vector.
+ * @param {Vector2} v2 - The second vector.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector2} A reference to this vector.
+ */
+ lerpVectors(v1, v2, alpha) {
+ this.x = v1.x + (v2.x - v1.x) * alpha;
+ this.y = v1.y + (v2.y - v1.y) * alpha;
+ return this;
+ }
+ /**
+ * Returns `true` if this vector is equal with the given one.
+ *
+ * @param {Vector2} v - The vector to test for equality.
+ * @return {boolean} Whether this vector is equal with the given one.
+ */
+ equals(v) {
+ return v.x === this.x && v.y === this.y;
+ }
+ /**
+ * Sets this vector's x value to be `array[ offset ]` and y
+ * value to be `array[ offset + 1 ]`.
+ *
+ * @param {Array} array - An array holding the vector component values.
+ * @param {number} [offset=0] - The offset into the array.
+ * @return {Vector2} A reference to this vector.
+ */
+ fromArray(array, offset = 0) {
+ this.x = array[offset];
+ this.y = array[offset + 1];
+ return this;
+ }
+ /**
+ * Writes the components of this vector to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the vector components.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The vector components.
+ */
+ toArray(array = [], offset = 0) {
+ array[offset] = this.x;
+ array[offset + 1] = this.y;
+ return array;
+ }
+ /**
+ * Sets the components of this vector from the given buffer attribute.
+ *
+ * @param {BufferAttribute} attribute - The buffer attribute holding vector data.
+ * @param {number} index - The index into the attribute.
+ * @return {Vector2} A reference to this vector.
+ */
+ fromBufferAttribute(attribute, index) {
+ this.x = attribute.getX(index);
+ this.y = attribute.getY(index);
+ return this;
+ }
+ /**
+ * Rotates this vector around the given center by the given angle.
+ *
+ * @param {Vector2} center - The point around which to rotate.
+ * @param {number} angle - The angle to rotate, in radians.
+ * @return {Vector2} A reference to this vector.
+ */
+ rotateAround(center, angle) {
+ const c = Math.cos(angle), s = Math.sin(angle);
+ const x = this.x - center.x;
+ const y = this.y - center.y;
+ this.x = x * c - y * s + center.x;
+ this.y = x * s + y * c + center.y;
+ return this;
+ }
+ /**
+ * Sets each component of this vector to a pseudo-random value between `0` and
+ * `1`, excluding `1`.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ random() {
+ this.x = Math.random();
+ this.y = Math.random();
+ return this;
+ }
+ *[Symbol.iterator]() {
+ yield this.x;
+ yield this.y;
+ }
+};
+var Quaternion = class {
+ /**
+ * Constructs a new quaternion.
+ *
+ * @param {number} [x=0] - The x value of this quaternion.
+ * @param {number} [y=0] - The y value of this quaternion.
+ * @param {number} [z=0] - The z value of this quaternion.
+ * @param {number} [w=1] - The w value of this quaternion.
+ */
+ constructor(x = 0, y = 0, z = 0, w = 1) {
+ this.isQuaternion = true;
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._w = w;
+ }
+ /**
+ * Interpolates between two quaternions via SLERP. This implementation assumes the
+ * quaternion data are managed in flat arrays.
+ *
+ * @param {Array} dst - The destination array.
+ * @param {number} dstOffset - An offset into the destination array.
+ * @param {Array} src0 - The source array of the first quaternion.
+ * @param {number} srcOffset0 - An offset into the first source array.
+ * @param {Array} src1 - The source array of the second quaternion.
+ * @param {number} srcOffset1 - An offset into the second source array.
+ * @param {number} t - The interpolation factor in the range `[0,1]`.
+ * @see {@link Quaternion#slerp}
+ */
+ static slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
+ let x0 = src0[srcOffset0 + 0], y0 = src0[srcOffset0 + 1], z0 = src0[srcOffset0 + 2], w0 = src0[srcOffset0 + 3];
+ let x1 = src1[srcOffset1 + 0], y1 = src1[srcOffset1 + 1], z1 = src1[srcOffset1 + 2], w1 = src1[srcOffset1 + 3];
+ if (t <= 0) {
+ dst[dstOffset + 0] = x0;
+ dst[dstOffset + 1] = y0;
+ dst[dstOffset + 2] = z0;
+ dst[dstOffset + 3] = w0;
+ return;
+ }
+ if (t >= 1) {
+ dst[dstOffset + 0] = x1;
+ dst[dstOffset + 1] = y1;
+ dst[dstOffset + 2] = z1;
+ dst[dstOffset + 3] = w1;
+ return;
+ }
+ if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
+ let dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;
+ if (dot < 0) {
+ x1 = -x1;
+ y1 = -y1;
+ z1 = -z1;
+ w1 = -w1;
+ dot = -dot;
+ }
+ let s = 1 - t;
+ if (dot < 0.9995) {
+ const theta = Math.acos(dot);
+ const sin = Math.sin(theta);
+ s = Math.sin(s * theta) / sin;
+ t = Math.sin(t * theta) / sin;
+ x0 = x0 * s + x1 * t;
+ y0 = y0 * s + y1 * t;
+ z0 = z0 * s + z1 * t;
+ w0 = w0 * s + w1 * t;
+ } else {
+ x0 = x0 * s + x1 * t;
+ y0 = y0 * s + y1 * t;
+ z0 = z0 * s + z1 * t;
+ w0 = w0 * s + w1 * t;
+ const f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
+ x0 *= f;
+ y0 *= f;
+ z0 *= f;
+ w0 *= f;
+ }
+ }
+ dst[dstOffset] = x0;
+ dst[dstOffset + 1] = y0;
+ dst[dstOffset + 2] = z0;
+ dst[dstOffset + 3] = w0;
+ }
+ /**
+ * Multiplies two quaternions. This implementation assumes the quaternion data are managed
+ * in flat arrays.
+ *
+ * @param {Array} dst - The destination array.
+ * @param {number} dstOffset - An offset into the destination array.
+ * @param {Array} src0 - The source array of the first quaternion.
+ * @param {number} srcOffset0 - An offset into the first source array.
+ * @param {Array} src1 - The source array of the second quaternion.
+ * @param {number} srcOffset1 - An offset into the second source array.
+ * @return {Array} The destination array.
+ * @see {@link Quaternion#multiplyQuaternions}.
+ */
+ static multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) {
+ const x0 = src0[srcOffset0];
+ const y0 = src0[srcOffset0 + 1];
+ const z0 = src0[srcOffset0 + 2];
+ const w0 = src0[srcOffset0 + 3];
+ const x1 = src1[srcOffset1];
+ const y1 = src1[srcOffset1 + 1];
+ const z1 = src1[srcOffset1 + 2];
+ const w1 = src1[srcOffset1 + 3];
+ dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
+ dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
+ dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
+ dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
+ return dst;
+ }
+ /**
+ * The x value of this quaternion.
+ *
+ * @type {number}
+ * @default 0
+ */
+ get x() {
+ return this._x;
+ }
+ set x(value) {
+ this._x = value;
+ this._onChangeCallback();
+ }
+ /**
+ * The y value of this quaternion.
+ *
+ * @type {number}
+ * @default 0
+ */
+ get y() {
+ return this._y;
+ }
+ set y(value) {
+ this._y = value;
+ this._onChangeCallback();
+ }
+ /**
+ * The z value of this quaternion.
+ *
+ * @type {number}
+ * @default 0
+ */
+ get z() {
+ return this._z;
+ }
+ set z(value) {
+ this._z = value;
+ this._onChangeCallback();
+ }
+ /**
+ * The w value of this quaternion.
+ *
+ * @type {number}
+ * @default 1
+ */
+ get w() {
+ return this._w;
+ }
+ set w(value) {
+ this._w = value;
+ this._onChangeCallback();
+ }
+ /**
+ * Sets the quaternion components.
+ *
+ * @param {number} x - The x value of this quaternion.
+ * @param {number} y - The y value of this quaternion.
+ * @param {number} z - The z value of this quaternion.
+ * @param {number} w - The w value of this quaternion.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ set(x, y, z, w) {
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._w = w;
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Returns a new quaternion with copied values from this instance.
+ *
+ * @return {Quaternion} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor(this._x, this._y, this._z, this._w);
+ }
+ /**
+ * Copies the values of the given quaternion to this instance.
+ *
+ * @param {Quaternion} quaternion - The quaternion to copy.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ copy(quaternion) {
+ this._x = quaternion.x;
+ this._y = quaternion.y;
+ this._z = quaternion.z;
+ this._w = quaternion.w;
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Sets this quaternion from the rotation specified by the given
+ * Euler angles.
+ *
+ * @param {Euler} euler - The Euler angles.
+ * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ setFromEuler(euler, update = true) {
+ const x = euler._x, y = euler._y, z = euler._z, order = euler._order;
+ const cos = Math.cos;
+ const sin = Math.sin;
+ const c1 = cos(x / 2);
+ const c2 = cos(y / 2);
+ const c3 = cos(z / 2);
+ const s1 = sin(x / 2);
+ const s2 = sin(y / 2);
+ const s3 = sin(z / 2);
+ switch (order) {
+ case "XYZ":
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ break;
+ case "YXZ":
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ break;
+ case "ZXY":
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ break;
+ case "ZYX":
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ break;
+ case "YZX":
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ break;
+ case "XZY":
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ break;
+ default:
+ warn("Quaternion: .setFromEuler() encountered an unknown order: " + order);
+ }
+ if (update === true) this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Sets this quaternion from the given axis and angle.
+ *
+ * @param {Vector3} axis - The normalized axis.
+ * @param {number} angle - The angle in radians.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ setFromAxisAngle(axis, angle) {
+ const halfAngle = angle / 2, s = Math.sin(halfAngle);
+ this._x = axis.x * s;
+ this._y = axis.y * s;
+ this._z = axis.z * s;
+ this._w = Math.cos(halfAngle);
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Sets this quaternion from the given rotation matrix.
+ *
+ * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ setFromRotationMatrix(m) {
+ const te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10], trace = m11 + m22 + m33;
+ if (trace > 0) {
+ const s = 0.5 / Math.sqrt(trace + 1);
+ this._w = 0.25 / s;
+ this._x = (m32 - m23) * s;
+ this._y = (m13 - m31) * s;
+ this._z = (m21 - m12) * s;
+ } else if (m11 > m22 && m11 > m33) {
+ const s = 2 * Math.sqrt(1 + m11 - m22 - m33);
+ this._w = (m32 - m23) / s;
+ this._x = 0.25 * s;
+ this._y = (m12 + m21) / s;
+ this._z = (m13 + m31) / s;
+ } else if (m22 > m33) {
+ const s = 2 * Math.sqrt(1 + m22 - m11 - m33);
+ this._w = (m13 - m31) / s;
+ this._x = (m12 + m21) / s;
+ this._y = 0.25 * s;
+ this._z = (m23 + m32) / s;
+ } else {
+ const s = 2 * Math.sqrt(1 + m33 - m11 - m22);
+ this._w = (m21 - m12) / s;
+ this._x = (m13 + m31) / s;
+ this._y = (m23 + m32) / s;
+ this._z = 0.25 * s;
+ }
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Sets this quaternion to the rotation required to rotate the direction vector
+ * `vFrom` to the direction vector `vTo`.
+ *
+ * @param {Vector3} vFrom - The first (normalized) direction vector.
+ * @param {Vector3} vTo - The second (normalized) direction vector.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ setFromUnitVectors(vFrom, vTo) {
+ let r = vFrom.dot(vTo) + 1;
+ if (r < 1e-8) {
+ r = 0;
+ if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
+ this._x = -vFrom.y;
+ this._y = vFrom.x;
+ this._z = 0;
+ this._w = r;
+ } else {
+ this._x = 0;
+ this._y = -vFrom.z;
+ this._z = vFrom.y;
+ this._w = r;
+ }
+ } else {
+ this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
+ this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
+ this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
+ this._w = r;
+ }
+ return this.normalize();
+ }
+ /**
+ * Returns the angle between this quaternion and the given one in radians.
+ *
+ * @param {Quaternion} q - The quaternion to compute the angle with.
+ * @return {number} The angle in radians.
+ */
+ angleTo(q) {
+ return 2 * Math.acos(Math.abs(clamp(this.dot(q), -1, 1)));
+ }
+ /**
+ * Rotates this quaternion by a given angular step to the given quaternion.
+ * The method ensures that the final quaternion will not overshoot `q`.
+ *
+ * @param {Quaternion} q - The target quaternion.
+ * @param {number} step - The angular step in radians.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ rotateTowards(q, step) {
+ const angle = this.angleTo(q);
+ if (angle === 0) return this;
+ const t = Math.min(1, step / angle);
+ this.slerp(q, t);
+ return this;
+ }
+ /**
+ * Sets this quaternion to the identity quaternion; that is, to the
+ * quaternion that represents "no rotation".
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ identity() {
+ return this.set(0, 0, 0, 1);
+ }
+ /**
+ * Inverts this quaternion via {@link Quaternion#conjugate}. The
+ * quaternion is assumed to have unit length.
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ invert() {
+ return this.conjugate();
+ }
+ /**
+ * Returns the rotational conjugate of this quaternion. The conjugate of a
+ * quaternion represents the same rotation in the opposite direction about
+ * the rotational axis.
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ conjugate() {
+ this._x *= -1;
+ this._y *= -1;
+ this._z *= -1;
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Calculates the dot product of this quaternion and the given one.
+ *
+ * @param {Quaternion} v - The quaternion to compute the dot product with.
+ * @return {number} The result of the dot product.
+ */
+ dot(v) {
+ return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
+ }
+ /**
+ * Computes the squared Euclidean length (straight-line length) of this quaternion,
+ * considered as a 4 dimensional vector. This can be useful if you are comparing the
+ * lengths of two quaternions, as this is a slightly more efficient calculation than
+ * {@link Quaternion#length}.
+ *
+ * @return {number} The squared Euclidean length.
+ */
+ lengthSq() {
+ return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
+ }
+ /**
+ * Computes the Euclidean length (straight-line length) of this quaternion,
+ * considered as a 4 dimensional vector.
+ *
+ * @return {number} The Euclidean length.
+ */
+ length() {
+ return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
+ }
+ /**
+ * Normalizes this quaternion - that is, calculated the quaternion that performs
+ * the same rotation as this one, but has a length equal to `1`.
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ normalize() {
+ let l = this.length();
+ if (l === 0) {
+ this._x = 0;
+ this._y = 0;
+ this._z = 0;
+ this._w = 1;
+ } else {
+ l = 1 / l;
+ this._x = this._x * l;
+ this._y = this._y * l;
+ this._z = this._z * l;
+ this._w = this._w * l;
+ }
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Multiplies this quaternion by the given one.
+ *
+ * @param {Quaternion} q - The quaternion.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ multiply(q) {
+ return this.multiplyQuaternions(this, q);
+ }
+ /**
+ * Pre-multiplies this quaternion by the given one.
+ *
+ * @param {Quaternion} q - The quaternion.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ premultiply(q) {
+ return this.multiplyQuaternions(q, this);
+ }
+ /**
+ * Multiplies the given quaternions and stores the result in this instance.
+ *
+ * @param {Quaternion} a - The first quaternion.
+ * @param {Quaternion} b - The second quaternion.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ multiplyQuaternions(a, b) {
+ const qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
+ const qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
+ this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
+ this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
+ this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
+ this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Performs a spherical linear interpolation between quaternions.
+ *
+ * @param {Quaternion} qb - The target quaternion.
+ * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ slerp(qb, t) {
+ if (t <= 0) return this;
+ if (t >= 1) return this.copy(qb);
+ let x = qb._x, y = qb._y, z = qb._z, w = qb._w;
+ let dot = this.dot(qb);
+ if (dot < 0) {
+ x = -x;
+ y = -y;
+ z = -z;
+ w = -w;
+ dot = -dot;
+ }
+ let s = 1 - t;
+ if (dot < 0.9995) {
+ const theta = Math.acos(dot);
+ const sin = Math.sin(theta);
+ s = Math.sin(s * theta) / sin;
+ t = Math.sin(t * theta) / sin;
+ this._x = this._x * s + x * t;
+ this._y = this._y * s + y * t;
+ this._z = this._z * s + z * t;
+ this._w = this._w * s + w * t;
+ this._onChangeCallback();
+ } else {
+ this._x = this._x * s + x * t;
+ this._y = this._y * s + y * t;
+ this._z = this._z * s + z * t;
+ this._w = this._w * s + w * t;
+ this.normalize();
+ }
+ return this;
+ }
+ /**
+ * Performs a spherical linear interpolation between the given quaternions
+ * and stores the result in this quaternion.
+ *
+ * @param {Quaternion} qa - The source quaternion.
+ * @param {Quaternion} qb - The target quaternion.
+ * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ slerpQuaternions(qa, qb, t) {
+ return this.copy(qa).slerp(qb, t);
+ }
+ /**
+ * Sets this quaternion to a uniformly random, normalized quaternion.
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ random() {
+ const theta1 = 2 * Math.PI * Math.random();
+ const theta2 = 2 * Math.PI * Math.random();
+ const x0 = Math.random();
+ const r1 = Math.sqrt(1 - x0);
+ const r2 = Math.sqrt(x0);
+ return this.set(
+ r1 * Math.sin(theta1),
+ r1 * Math.cos(theta1),
+ r2 * Math.sin(theta2),
+ r2 * Math.cos(theta2)
+ );
+ }
+ /**
+ * Returns `true` if this quaternion is equal with the given one.
+ *
+ * @param {Quaternion} quaternion - The quaternion to test for equality.
+ * @return {boolean} Whether this quaternion is equal with the given one.
+ */
+ equals(quaternion) {
+ return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;
+ }
+ /**
+ * Sets this quaternion's components from the given array.
+ *
+ * @param {Array} array - An array holding the quaternion component values.
+ * @param {number} [offset=0] - The offset into the array.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ fromArray(array, offset = 0) {
+ this._x = array[offset];
+ this._y = array[offset + 1];
+ this._z = array[offset + 2];
+ this._w = array[offset + 3];
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Writes the components of this quaternion to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the quaternion components.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The quaternion components.
+ */
+ toArray(array = [], offset = 0) {
+ array[offset] = this._x;
+ array[offset + 1] = this._y;
+ array[offset + 2] = this._z;
+ array[offset + 3] = this._w;
+ return array;
+ }
+ /**
+ * Sets the components of this quaternion from the given buffer attribute.
+ *
+ * @param {BufferAttribute} attribute - The buffer attribute holding quaternion data.
+ * @param {number} index - The index into the attribute.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ fromBufferAttribute(attribute, index) {
+ this._x = attribute.getX(index);
+ this._y = attribute.getY(index);
+ this._z = attribute.getZ(index);
+ this._w = attribute.getW(index);
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * This methods defines the serialization result of this class. Returns the
+ * numerical elements of this quaternion in an array of format `[x, y, z, w]`.
+ *
+ * @return {Array} The serialized quaternion.
+ */
+ toJSON() {
+ return this.toArray();
+ }
+ _onChange(callback) {
+ this._onChangeCallback = callback;
+ return this;
+ }
+ _onChangeCallback() {
+ }
+ *[Symbol.iterator]() {
+ yield this._x;
+ yield this._y;
+ yield this._z;
+ yield this._w;
+ }
+};
+var Vector3 = class _Vector3 {
+ /**
+ * Constructs a new 3D vector.
+ *
+ * @param {number} [x=0] - The x value of this vector.
+ * @param {number} [y=0] - The y value of this vector.
+ * @param {number} [z=0] - The z value of this vector.
+ */
+ constructor(x = 0, y = 0, z = 0) {
+ _Vector3.prototype.isVector3 = true;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+ /**
+ * Sets the vector components.
+ *
+ * @param {number} x - The value of the x component.
+ * @param {number} y - The value of the y component.
+ * @param {number} z - The value of the z component.
+ * @return {Vector3} A reference to this vector.
+ */
+ set(x, y, z) {
+ if (z === void 0) z = this.z;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ return this;
+ }
+ /**
+ * Sets the vector components to the same value.
+ *
+ * @param {number} scalar - The value to set for all vector components.
+ * @return {Vector3} A reference to this vector.
+ */
+ setScalar(scalar) {
+ this.x = scalar;
+ this.y = scalar;
+ this.z = scalar;
+ return this;
+ }
+ /**
+ * Sets the vector's x component to the given value
+ *
+ * @param {number} x - The value to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setX(x) {
+ this.x = x;
+ return this;
+ }
+ /**
+ * Sets the vector's y component to the given value
+ *
+ * @param {number} y - The value to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setY(y) {
+ this.y = y;
+ return this;
+ }
+ /**
+ * Sets the vector's z component to the given value
+ *
+ * @param {number} z - The value to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setZ(z) {
+ this.z = z;
+ return this;
+ }
+ /**
+ * Allows to set a vector component with an index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
+ * @param {number} value - The value to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setComponent(index, value) {
+ switch (index) {
+ case 0:
+ this.x = value;
+ break;
+ case 1:
+ this.y = value;
+ break;
+ case 2:
+ this.z = value;
+ break;
+ default:
+ throw new Error("index is out of range: " + index);
+ }
+ return this;
+ }
+ /**
+ * Returns the value of the vector component which matches the given index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
+ * @return {number} A vector component value.
+ */
+ getComponent(index) {
+ switch (index) {
+ case 0:
+ return this.x;
+ case 1:
+ return this.y;
+ case 2:
+ return this.z;
+ default:
+ throw new Error("index is out of range: " + index);
+ }
+ }
+ /**
+ * Returns a new vector with copied values from this instance.
+ *
+ * @return {Vector3} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor(this.x, this.y, this.z);
+ }
+ /**
+ * Copies the values of the given vector to this instance.
+ *
+ * @param {Vector3} v - The vector to copy.
+ * @return {Vector3} A reference to this vector.
+ */
+ copy(v) {
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ return this;
+ }
+ /**
+ * Adds the given vector to this instance.
+ *
+ * @param {Vector3} v - The vector to add.
+ * @return {Vector3} A reference to this vector.
+ */
+ add(v) {
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+ return this;
+ }
+ /**
+ * Adds the given scalar value to all components of this instance.
+ *
+ * @param {number} s - The scalar to add.
+ * @return {Vector3} A reference to this vector.
+ */
+ addScalar(s) {
+ this.x += s;
+ this.y += s;
+ this.z += s;
+ return this;
+ }
+ /**
+ * Adds the given vectors and stores the result in this instance.
+ *
+ * @param {Vector3} a - The first vector.
+ * @param {Vector3} b - The second vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ addVectors(a, b) {
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+ this.z = a.z + b.z;
+ return this;
+ }
+ /**
+ * Adds the given vector scaled by the given factor to this instance.
+ *
+ * @param {Vector3|Vector4} v - The vector.
+ * @param {number} s - The factor that scales `v`.
+ * @return {Vector3} A reference to this vector.
+ */
+ addScaledVector(v, s) {
+ this.x += v.x * s;
+ this.y += v.y * s;
+ this.z += v.z * s;
+ return this;
+ }
+ /**
+ * Subtracts the given vector from this instance.
+ *
+ * @param {Vector3} v - The vector to subtract.
+ * @return {Vector3} A reference to this vector.
+ */
+ sub(v) {
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
+ return this;
+ }
+ /**
+ * Subtracts the given scalar value from all components of this instance.
+ *
+ * @param {number} s - The scalar to subtract.
+ * @return {Vector3} A reference to this vector.
+ */
+ subScalar(s) {
+ this.x -= s;
+ this.y -= s;
+ this.z -= s;
+ return this;
+ }
+ /**
+ * Subtracts the given vectors and stores the result in this instance.
+ *
+ * @param {Vector3} a - The first vector.
+ * @param {Vector3} b - The second vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ subVectors(a, b) {
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+ this.z = a.z - b.z;
+ return this;
+ }
+ /**
+ * Multiplies the given vector with this instance.
+ *
+ * @param {Vector3} v - The vector to multiply.
+ * @return {Vector3} A reference to this vector.
+ */
+ multiply(v) {
+ this.x *= v.x;
+ this.y *= v.y;
+ this.z *= v.z;
+ return this;
+ }
+ /**
+ * Multiplies the given scalar value with all components of this instance.
+ *
+ * @param {number} scalar - The scalar to multiply.
+ * @return {Vector3} A reference to this vector.
+ */
+ multiplyScalar(scalar) {
+ this.x *= scalar;
+ this.y *= scalar;
+ this.z *= scalar;
+ return this;
+ }
+ /**
+ * Multiplies the given vectors and stores the result in this instance.
+ *
+ * @param {Vector3} a - The first vector.
+ * @param {Vector3} b - The second vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ multiplyVectors(a, b) {
+ this.x = a.x * b.x;
+ this.y = a.y * b.y;
+ this.z = a.z * b.z;
+ return this;
+ }
+ /**
+ * Applies the given Euler rotation to this vector.
+ *
+ * @param {Euler} euler - The Euler angles.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyEuler(euler) {
+ return this.applyQuaternion(_quaternion$4.setFromEuler(euler));
+ }
+ /**
+ * Applies a rotation specified by an axis and an angle to this vector.
+ *
+ * @param {Vector3} axis - A normalized vector representing the rotation axis.
+ * @param {number} angle - The angle in radians.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyAxisAngle(axis, angle) {
+ return this.applyQuaternion(_quaternion$4.setFromAxisAngle(axis, angle));
+ }
+ /**
+ * Multiplies this vector with the given 3x3 matrix.
+ *
+ * @param {Matrix3} m - The 3x3 matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyMatrix3(m) {
+ const x = this.x, y = this.y, z = this.z;
+ const e = m.elements;
+ this.x = e[0] * x + e[3] * y + e[6] * z;
+ this.y = e[1] * x + e[4] * y + e[7] * z;
+ this.z = e[2] * x + e[5] * y + e[8] * z;
+ return this;
+ }
+ /**
+ * Multiplies this vector by the given normal matrix and normalizes
+ * the result.
+ *
+ * @param {Matrix3} m - The normal matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyNormalMatrix(m) {
+ return this.applyMatrix3(m).normalize();
+ }
+ /**
+ * Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and
+ * divides by perspective.
+ *
+ * @param {Matrix4} m - The matrix to apply.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyMatrix4(m) {
+ const x = this.x, y = this.y, z = this.z;
+ const e = m.elements;
+ const w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
+ this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
+ this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
+ this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
+ return this;
+ }
+ /**
+ * Applies the given Quaternion to this vector.
+ *
+ * @param {Quaternion} q - The Quaternion.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyQuaternion(q) {
+ const vx = this.x, vy = this.y, vz = this.z;
+ const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
+ const tx = 2 * (qy * vz - qz * vy);
+ const ty = 2 * (qz * vx - qx * vz);
+ const tz = 2 * (qx * vy - qy * vx);
+ this.x = vx + qw * tx + qy * tz - qz * ty;
+ this.y = vy + qw * ty + qz * tx - qx * tz;
+ this.z = vz + qw * tz + qx * ty - qy * tx;
+ return this;
+ }
+ /**
+ * Projects this vector from world space into the camera's normalized
+ * device coordinate (NDC) space.
+ *
+ * @param {Camera} camera - The camera.
+ * @return {Vector3} A reference to this vector.
+ */
+ project(camera) {
+ return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
+ }
+ /**
+ * Unprojects this vector from the camera's normalized device coordinate (NDC)
+ * space into world space.
+ *
+ * @param {Camera} camera - The camera.
+ * @return {Vector3} A reference to this vector.
+ */
+ unproject(camera) {
+ return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
+ }
+ /**
+ * Transforms the direction of this vector by a matrix (the upper left 3 x 3
+ * subset of the given 4x4 matrix and then normalizes the result.
+ *
+ * @param {Matrix4} m - The matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ transformDirection(m) {
+ const x = this.x, y = this.y, z = this.z;
+ const e = m.elements;
+ this.x = e[0] * x + e[4] * y + e[8] * z;
+ this.y = e[1] * x + e[5] * y + e[9] * z;
+ this.z = e[2] * x + e[6] * y + e[10] * z;
+ return this.normalize();
+ }
+ /**
+ * Divides this instance by the given vector.
+ *
+ * @param {Vector3} v - The vector to divide.
+ * @return {Vector3} A reference to this vector.
+ */
+ divide(v) {
+ this.x /= v.x;
+ this.y /= v.y;
+ this.z /= v.z;
+ return this;
+ }
+ /**
+ * Divides this vector by the given scalar.
+ *
+ * @param {number} scalar - The scalar to divide.
+ * @return {Vector3} A reference to this vector.
+ */
+ divideScalar(scalar) {
+ return this.multiplyScalar(1 / scalar);
+ }
+ /**
+ * If this vector's x, y or z value is greater than the given vector's x, y or z
+ * value, replace that value with the corresponding min value.
+ *
+ * @param {Vector3} v - The vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ min(v) {
+ this.x = Math.min(this.x, v.x);
+ this.y = Math.min(this.y, v.y);
+ this.z = Math.min(this.z, v.z);
+ return this;
+ }
+ /**
+ * If this vector's x, y or z value is less than the given vector's x, y or z
+ * value, replace that value with the corresponding max value.
+ *
+ * @param {Vector3} v - The vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ max(v) {
+ this.x = Math.max(this.x, v.x);
+ this.y = Math.max(this.y, v.y);
+ this.z = Math.max(this.z, v.z);
+ return this;
+ }
+ /**
+ * If this vector's x, y or z value is greater than the max vector's x, y or z
+ * value, it is replaced by the corresponding value.
+ * If this vector's x, y or z value is less than the min vector's x, y or z value,
+ * it is replaced by the corresponding value.
+ *
+ * @param {Vector3} min - The minimum x, y and z values.
+ * @param {Vector3} max - The maximum x, y and z values in the desired range.
+ * @return {Vector3} A reference to this vector.
+ */
+ clamp(min, max) {
+ this.x = clamp(this.x, min.x, max.x);
+ this.y = clamp(this.y, min.y, max.y);
+ this.z = clamp(this.z, min.z, max.z);
+ return this;
+ }
+ /**
+ * If this vector's x, y or z values are greater than the max value, they are
+ * replaced by the max value.
+ * If this vector's x, y or z values are less than the min value, they are
+ * replaced by the min value.
+ *
+ * @param {number} minVal - The minimum value the components will be clamped to.
+ * @param {number} maxVal - The maximum value the components will be clamped to.
+ * @return {Vector3} A reference to this vector.
+ */
+ clampScalar(minVal, maxVal) {
+ this.x = clamp(this.x, minVal, maxVal);
+ this.y = clamp(this.y, minVal, maxVal);
+ this.z = clamp(this.z, minVal, maxVal);
+ return this;
+ }
+ /**
+ * If this vector's length is greater than the max value, it is replaced by
+ * the max value.
+ * If this vector's length is less than the min value, it is replaced by the
+ * min value.
+ *
+ * @param {number} min - The minimum value the vector length will be clamped to.
+ * @param {number} max - The maximum value the vector length will be clamped to.
+ * @return {Vector3} A reference to this vector.
+ */
+ clampLength(min, max) {
+ const length = this.length();
+ return this.divideScalar(length || 1).multiplyScalar(clamp(length, min, max));
+ }
+ /**
+ * The components of this vector are rounded down to the nearest integer value.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ floor() {
+ this.x = Math.floor(this.x);
+ this.y = Math.floor(this.y);
+ this.z = Math.floor(this.z);
+ return this;
+ }
+ /**
+ * The components of this vector are rounded up to the nearest integer value.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ ceil() {
+ this.x = Math.ceil(this.x);
+ this.y = Math.ceil(this.y);
+ this.z = Math.ceil(this.z);
+ return this;
+ }
+ /**
+ * The components of this vector are rounded to the nearest integer value
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ round() {
+ this.x = Math.round(this.x);
+ this.y = Math.round(this.y);
+ this.z = Math.round(this.z);
+ return this;
+ }
+ /**
+ * The components of this vector are rounded towards zero (up if negative,
+ * down if positive) to an integer value.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ roundToZero() {
+ this.x = Math.trunc(this.x);
+ this.y = Math.trunc(this.y);
+ this.z = Math.trunc(this.z);
+ return this;
+ }
+ /**
+ * Inverts this vector - i.e. sets x = -x, y = -y and z = -z.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ negate() {
+ this.x = -this.x;
+ this.y = -this.y;
+ this.z = -this.z;
+ return this;
+ }
+ /**
+ * Calculates the dot product of the given vector with this instance.
+ *
+ * @param {Vector3} v - The vector to compute the dot product with.
+ * @return {number} The result of the dot product.
+ */
+ dot(v) {
+ return this.x * v.x + this.y * v.y + this.z * v.z;
+ }
+ /**
+ * Computes the square of the Euclidean length (straight-line length) from
+ * (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should
+ * compare the length squared instead as it is slightly more efficient to calculate.
+ *
+ * @return {number} The square length of this vector.
+ */
+ lengthSq() {
+ return this.x * this.x + this.y * this.y + this.z * this.z;
+ }
+ /**
+ * Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).
+ *
+ * @return {number} The length of this vector.
+ */
+ length() {
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
+ }
+ /**
+ * Computes the Manhattan length of this vector.
+ *
+ * @return {number} The length of this vector.
+ */
+ manhattanLength() {
+ return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
+ }
+ /**
+ * Converts this vector to a unit vector - that is, sets it equal to a vector
+ * with the same direction as this one, but with a vector length of `1`.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ normalize() {
+ return this.divideScalar(this.length() || 1);
+ }
+ /**
+ * Sets this vector to a vector with the same direction as this one, but
+ * with the specified length.
+ *
+ * @param {number} length - The new length of this vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ setLength(length) {
+ return this.normalize().multiplyScalar(length);
+ }
+ /**
+ * Linearly interpolates between the given vector and this instance, where
+ * alpha is the percent distance along the line - alpha = 0 will be this
+ * vector, and alpha = 1 will be the given one.
+ *
+ * @param {Vector3} v - The vector to interpolate towards.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector3} A reference to this vector.
+ */
+ lerp(v, alpha) {
+ this.x += (v.x - this.x) * alpha;
+ this.y += (v.y - this.y) * alpha;
+ this.z += (v.z - this.z) * alpha;
+ return this;
+ }
+ /**
+ * Linearly interpolates between the given vectors, where alpha is the percent
+ * distance along the line - alpha = 0 will be first vector, and alpha = 1 will
+ * be the second one. The result is stored in this instance.
+ *
+ * @param {Vector3} v1 - The first vector.
+ * @param {Vector3} v2 - The second vector.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector3} A reference to this vector.
+ */
+ lerpVectors(v1, v2, alpha) {
+ this.x = v1.x + (v2.x - v1.x) * alpha;
+ this.y = v1.y + (v2.y - v1.y) * alpha;
+ this.z = v1.z + (v2.z - v1.z) * alpha;
+ return this;
+ }
+ /**
+ * Calculates the cross product of the given vector with this instance.
+ *
+ * @param {Vector3} v - The vector to compute the cross product with.
+ * @return {Vector3} The result of the cross product.
+ */
+ cross(v) {
+ return this.crossVectors(this, v);
+ }
+ /**
+ * Calculates the cross product of the given vectors and stores the result
+ * in this instance.
+ *
+ * @param {Vector3} a - The first vector.
+ * @param {Vector3} b - The second vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ crossVectors(a, b) {
+ const ax = a.x, ay = a.y, az = a.z;
+ const bx = b.x, by = b.y, bz = b.z;
+ this.x = ay * bz - az * by;
+ this.y = az * bx - ax * bz;
+ this.z = ax * by - ay * bx;
+ return this;
+ }
+ /**
+ * Projects this vector onto the given one.
+ *
+ * @param {Vector3} v - The vector to project to.
+ * @return {Vector3} A reference to this vector.
+ */
+ projectOnVector(v) {
+ const denominator = v.lengthSq();
+ if (denominator === 0) return this.set(0, 0, 0);
+ const scalar = v.dot(this) / denominator;
+ return this.copy(v).multiplyScalar(scalar);
+ }
+ /**
+ * Projects this vector onto a plane by subtracting this
+ * vector projected onto the plane's normal from this vector.
+ *
+ * @param {Vector3} planeNormal - The plane normal.
+ * @return {Vector3} A reference to this vector.
+ */
+ projectOnPlane(planeNormal) {
+ _vector$c.copy(this).projectOnVector(planeNormal);
+ return this.sub(_vector$c);
+ }
+ /**
+ * Reflects this vector off a plane orthogonal to the given normal vector.
+ *
+ * @param {Vector3} normal - The (normalized) normal vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ reflect(normal) {
+ return this.sub(_vector$c.copy(normal).multiplyScalar(2 * this.dot(normal)));
+ }
+ /**
+ * Returns the angle between the given vector and this instance in radians.
+ *
+ * @param {Vector3} v - The vector to compute the angle with.
+ * @return {number} The angle in radians.
+ */
+ angleTo(v) {
+ const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
+ if (denominator === 0) return Math.PI / 2;
+ const theta = this.dot(v) / denominator;
+ return Math.acos(clamp(theta, -1, 1));
+ }
+ /**
+ * Computes the distance from the given vector to this instance.
+ *
+ * @param {Vector3} v - The vector to compute the distance to.
+ * @return {number} The distance.
+ */
+ distanceTo(v) {
+ return Math.sqrt(this.distanceToSquared(v));
+ }
+ /**
+ * Computes the squared distance from the given vector to this instance.
+ * If you are just comparing the distance with another distance, you should compare
+ * the distance squared instead as it is slightly more efficient to calculate.
+ *
+ * @param {Vector3} v - The vector to compute the squared distance to.
+ * @return {number} The squared distance.
+ */
+ distanceToSquared(v) {
+ const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
+ return dx * dx + dy * dy + dz * dz;
+ }
+ /**
+ * Computes the Manhattan distance from the given vector to this instance.
+ *
+ * @param {Vector3} v - The vector to compute the Manhattan distance to.
+ * @return {number} The Manhattan distance.
+ */
+ manhattanDistanceTo(v) {
+ return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
+ }
+ /**
+ * Sets the vector components from the given spherical coordinates.
+ *
+ * @param {Spherical} s - The spherical coordinates.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromSpherical(s) {
+ return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
+ }
+ /**
+ * Sets the vector components from the given spherical coordinates.
+ *
+ * @param {number} radius - The radius.
+ * @param {number} phi - The phi angle in radians.
+ * @param {number} theta - The theta angle in radians.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromSphericalCoords(radius, phi, theta) {
+ const sinPhiRadius = Math.sin(phi) * radius;
+ this.x = sinPhiRadius * Math.sin(theta);
+ this.y = Math.cos(phi) * radius;
+ this.z = sinPhiRadius * Math.cos(theta);
+ return this;
+ }
+ /**
+ * Sets the vector components from the given cylindrical coordinates.
+ *
+ * @param {Cylindrical} c - The cylindrical coordinates.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromCylindrical(c) {
+ return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
+ }
+ /**
+ * Sets the vector components from the given cylindrical coordinates.
+ *
+ * @param {number} radius - The radius.
+ * @param {number} theta - The theta angle in radians.
+ * @param {number} y - The y value.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromCylindricalCoords(radius, theta, y) {
+ this.x = radius * Math.sin(theta);
+ this.y = y;
+ this.z = radius * Math.cos(theta);
+ return this;
+ }
+ /**
+ * Sets the vector components to the position elements of the
+ * given transformation matrix.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromMatrixPosition(m) {
+ const e = m.elements;
+ this.x = e[12];
+ this.y = e[13];
+ this.z = e[14];
+ return this;
+ }
+ /**
+ * Sets the vector components to the scale elements of the
+ * given transformation matrix.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromMatrixScale(m) {
+ const sx = this.setFromMatrixColumn(m, 0).length();
+ const sy = this.setFromMatrixColumn(m, 1).length();
+ const sz = this.setFromMatrixColumn(m, 2).length();
+ this.x = sx;
+ this.y = sy;
+ this.z = sz;
+ return this;
+ }
+ /**
+ * Sets the vector components from the specified matrix column.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @param {number} index - The column index.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromMatrixColumn(m, index) {
+ return this.fromArray(m.elements, index * 4);
+ }
+ /**
+ * Sets the vector components from the specified matrix column.
+ *
+ * @param {Matrix3} m - The 3x3 matrix.
+ * @param {number} index - The column index.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromMatrix3Column(m, index) {
+ return this.fromArray(m.elements, index * 3);
+ }
+ /**
+ * Sets the vector components from the given Euler angles.
+ *
+ * @param {Euler} e - The Euler angles to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromEuler(e) {
+ this.x = e._x;
+ this.y = e._y;
+ this.z = e._z;
+ return this;
+ }
+ /**
+ * Sets the vector components from the RGB components of the
+ * given color.
+ *
+ * @param {Color} c - The color to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromColor(c) {
+ this.x = c.r;
+ this.y = c.g;
+ this.z = c.b;
+ return this;
+ }
+ /**
+ * Returns `true` if this vector is equal with the given one.
+ *
+ * @param {Vector3} v - The vector to test for equality.
+ * @return {boolean} Whether this vector is equal with the given one.
+ */
+ equals(v) {
+ return v.x === this.x && v.y === this.y && v.z === this.z;
+ }
+ /**
+ * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`
+ * and z value to be `array[ offset + 2 ]`.
+ *
+ * @param {Array} array - An array holding the vector component values.
+ * @param {number} [offset=0] - The offset into the array.
+ * @return {Vector3} A reference to this vector.
+ */
+ fromArray(array, offset = 0) {
+ this.x = array[offset];
+ this.y = array[offset + 1];
+ this.z = array[offset + 2];
+ return this;
+ }
+ /**
+ * Writes the components of this vector to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the vector components.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The vector components.
+ */
+ toArray(array = [], offset = 0) {
+ array[offset] = this.x;
+ array[offset + 1] = this.y;
+ array[offset + 2] = this.z;
+ return array;
+ }
+ /**
+ * Sets the components of this vector from the given buffer attribute.
+ *
+ * @param {BufferAttribute} attribute - The buffer attribute holding vector data.
+ * @param {number} index - The index into the attribute.
+ * @return {Vector3} A reference to this vector.
+ */
+ fromBufferAttribute(attribute, index) {
+ this.x = attribute.getX(index);
+ this.y = attribute.getY(index);
+ this.z = attribute.getZ(index);
+ return this;
+ }
+ /**
+ * Sets each component of this vector to a pseudo-random value between `0` and
+ * `1`, excluding `1`.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ random() {
+ this.x = Math.random();
+ this.y = Math.random();
+ this.z = Math.random();
+ return this;
+ }
+ /**
+ * Sets this vector to a uniformly random point on a unit sphere.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ randomDirection() {
+ const theta = Math.random() * Math.PI * 2;
+ const u = Math.random() * 2 - 1;
+ const c = Math.sqrt(1 - u * u);
+ this.x = c * Math.cos(theta);
+ this.y = u;
+ this.z = c * Math.sin(theta);
+ return this;
+ }
+ *[Symbol.iterator]() {
+ yield this.x;
+ yield this.y;
+ yield this.z;
+ }
+};
+var _vector$c = new Vector3();
+var _quaternion$4 = new Quaternion();
+var Matrix3 = class _Matrix3 {
+ /**
+ * Constructs a new 3x3 matrix. The arguments are supposed to be
+ * in row-major order. If no arguments are provided, the constructor
+ * initializes the matrix as an identity matrix.
+ *
+ * @param {number} [n11] - 1-1 matrix element.
+ * @param {number} [n12] - 1-2 matrix element.
+ * @param {number} [n13] - 1-3 matrix element.
+ * @param {number} [n21] - 2-1 matrix element.
+ * @param {number} [n22] - 2-2 matrix element.
+ * @param {number} [n23] - 2-3 matrix element.
+ * @param {number} [n31] - 3-1 matrix element.
+ * @param {number} [n32] - 3-2 matrix element.
+ * @param {number} [n33] - 3-3 matrix element.
+ */
+ constructor(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
+ _Matrix3.prototype.isMatrix3 = true;
+ this.elements = [
+ 1,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 1
+ ];
+ if (n11 !== void 0) {
+ this.set(n11, n12, n13, n21, n22, n23, n31, n32, n33);
+ }
+ }
+ /**
+ * Sets the elements of the matrix.The arguments are supposed to be
+ * in row-major order.
+ *
+ * @param {number} [n11] - 1-1 matrix element.
+ * @param {number} [n12] - 1-2 matrix element.
+ * @param {number} [n13] - 1-3 matrix element.
+ * @param {number} [n21] - 2-1 matrix element.
+ * @param {number} [n22] - 2-2 matrix element.
+ * @param {number} [n23] - 2-3 matrix element.
+ * @param {number} [n31] - 3-1 matrix element.
+ * @param {number} [n32] - 3-2 matrix element.
+ * @param {number} [n33] - 3-3 matrix element.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ set(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
+ const te = this.elements;
+ te[0] = n11;
+ te[1] = n21;
+ te[2] = n31;
+ te[3] = n12;
+ te[4] = n22;
+ te[5] = n32;
+ te[6] = n13;
+ te[7] = n23;
+ te[8] = n33;
+ return this;
+ }
+ /**
+ * Sets this matrix to the 3x3 identity matrix.
+ *
+ * @return {Matrix3} A reference to this matrix.
+ */
+ identity() {
+ this.set(
+ 1,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Copies the values of the given matrix to this instance.
+ *
+ * @param {Matrix3} m - The matrix to copy.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ copy(m) {
+ const te = this.elements;
+ const me = m.elements;
+ te[0] = me[0];
+ te[1] = me[1];
+ te[2] = me[2];
+ te[3] = me[3];
+ te[4] = me[4];
+ te[5] = me[5];
+ te[6] = me[6];
+ te[7] = me[7];
+ te[8] = me[8];
+ return this;
+ }
+ /**
+ * Extracts the basis of this matrix into the three axis vectors provided.
+ *
+ * @param {Vector3} xAxis - The basis's x axis.
+ * @param {Vector3} yAxis - The basis's y axis.
+ * @param {Vector3} zAxis - The basis's z axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ extractBasis(xAxis, yAxis, zAxis) {
+ xAxis.setFromMatrix3Column(this, 0);
+ yAxis.setFromMatrix3Column(this, 1);
+ zAxis.setFromMatrix3Column(this, 2);
+ return this;
+ }
+ /**
+ * Set this matrix to the upper 3x3 matrix of the given 4x4 matrix.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ setFromMatrix4(m) {
+ const me = m.elements;
+ this.set(
+ me[0],
+ me[4],
+ me[8],
+ me[1],
+ me[5],
+ me[9],
+ me[2],
+ me[6],
+ me[10]
+ );
+ return this;
+ }
+ /**
+ * Post-multiplies this matrix by the given 3x3 matrix.
+ *
+ * @param {Matrix3} m - The matrix to multiply with.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ multiply(m) {
+ return this.multiplyMatrices(this, m);
+ }
+ /**
+ * Pre-multiplies this matrix by the given 3x3 matrix.
+ *
+ * @param {Matrix3} m - The matrix to multiply with.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ premultiply(m) {
+ return this.multiplyMatrices(m, this);
+ }
+ /**
+ * Multiples the given 3x3 matrices and stores the result
+ * in this matrix.
+ *
+ * @param {Matrix3} a - The first matrix.
+ * @param {Matrix3} b - The second matrix.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ multiplyMatrices(a, b) {
+ const ae = a.elements;
+ const be = b.elements;
+ const te = this.elements;
+ const a11 = ae[0], a12 = ae[3], a13 = ae[6];
+ const a21 = ae[1], a22 = ae[4], a23 = ae[7];
+ const a31 = ae[2], a32 = ae[5], a33 = ae[8];
+ const b11 = be[0], b12 = be[3], b13 = be[6];
+ const b21 = be[1], b22 = be[4], b23 = be[7];
+ const b31 = be[2], b32 = be[5], b33 = be[8];
+ te[0] = a11 * b11 + a12 * b21 + a13 * b31;
+ te[3] = a11 * b12 + a12 * b22 + a13 * b32;
+ te[6] = a11 * b13 + a12 * b23 + a13 * b33;
+ te[1] = a21 * b11 + a22 * b21 + a23 * b31;
+ te[4] = a21 * b12 + a22 * b22 + a23 * b32;
+ te[7] = a21 * b13 + a22 * b23 + a23 * b33;
+ te[2] = a31 * b11 + a32 * b21 + a33 * b31;
+ te[5] = a31 * b12 + a32 * b22 + a33 * b32;
+ te[8] = a31 * b13 + a32 * b23 + a33 * b33;
+ return this;
+ }
+ /**
+ * Multiplies every component of the matrix by the given scalar.
+ *
+ * @param {number} s - The scalar.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ multiplyScalar(s) {
+ const te = this.elements;
+ te[0] *= s;
+ te[3] *= s;
+ te[6] *= s;
+ te[1] *= s;
+ te[4] *= s;
+ te[7] *= s;
+ te[2] *= s;
+ te[5] *= s;
+ te[8] *= s;
+ return this;
+ }
+ /**
+ * Computes and returns the determinant of this matrix.
+ *
+ * @return {number} The determinant.
+ */
+ determinant() {
+ const te = this.elements;
+ const a = te[0], b = te[1], c = te[2], d = te[3], e = te[4], f = te[5], g = te[6], h = te[7], i = te[8];
+ return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
+ }
+ /**
+ * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).
+ * You can not invert with a determinant of zero. If you attempt this, the method produces
+ * a zero matrix instead.
+ *
+ * @return {Matrix3} A reference to this matrix.
+ */
+ invert() {
+ const te = this.elements, n11 = te[0], n21 = te[1], n31 = te[2], n12 = te[3], n22 = te[4], n32 = te[5], n13 = te[6], n23 = te[7], n33 = te[8], t11 = n33 * n22 - n32 * n23, t12 = n32 * n13 - n33 * n12, t13 = n23 * n12 - n22 * n13, det = n11 * t11 + n21 * t12 + n31 * t13;
+ if (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
+ const detInv = 1 / det;
+ te[0] = t11 * detInv;
+ te[1] = (n31 * n23 - n33 * n21) * detInv;
+ te[2] = (n32 * n21 - n31 * n22) * detInv;
+ te[3] = t12 * detInv;
+ te[4] = (n33 * n11 - n31 * n13) * detInv;
+ te[5] = (n31 * n12 - n32 * n11) * detInv;
+ te[6] = t13 * detInv;
+ te[7] = (n21 * n13 - n23 * n11) * detInv;
+ te[8] = (n22 * n11 - n21 * n12) * detInv;
+ return this;
+ }
+ /**
+ * Transposes this matrix in place.
+ *
+ * @return {Matrix3} A reference to this matrix.
+ */
+ transpose() {
+ let tmp2;
+ const m = this.elements;
+ tmp2 = m[1];
+ m[1] = m[3];
+ m[3] = tmp2;
+ tmp2 = m[2];
+ m[2] = m[6];
+ m[6] = tmp2;
+ tmp2 = m[5];
+ m[5] = m[7];
+ m[7] = tmp2;
+ return this;
+ }
+ /**
+ * Computes the normal matrix which is the inverse transpose of the upper
+ * left 3x3 portion of the given 4x4 matrix.
+ *
+ * @param {Matrix4} matrix4 - The 4x4 matrix.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ getNormalMatrix(matrix4) {
+ return this.setFromMatrix4(matrix4).invert().transpose();
+ }
+ /**
+ * Transposes this matrix into the supplied array, and returns itself unchanged.
+ *
+ * @param {Array} r - An array to store the transposed matrix elements.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ transposeIntoArray(r) {
+ const m = this.elements;
+ r[0] = m[0];
+ r[1] = m[3];
+ r[2] = m[6];
+ r[3] = m[1];
+ r[4] = m[4];
+ r[5] = m[7];
+ r[6] = m[2];
+ r[7] = m[5];
+ r[8] = m[8];
+ return this;
+ }
+ /**
+ * Sets the UV transform matrix from offset, repeat, rotation, and center.
+ *
+ * @param {number} tx - Offset x.
+ * @param {number} ty - Offset y.
+ * @param {number} sx - Repeat x.
+ * @param {number} sy - Repeat y.
+ * @param {number} rotation - Rotation, in radians. Positive values rotate counterclockwise.
+ * @param {number} cx - Center x of rotation.
+ * @param {number} cy - Center y of rotation
+ * @return {Matrix3} A reference to this matrix.
+ */
+ setUvTransform(tx, ty, sx, sy, rotation, cx, cy) {
+ const c = Math.cos(rotation);
+ const s = Math.sin(rotation);
+ this.set(
+ sx * c,
+ sx * s,
+ -sx * (c * cx + s * cy) + cx + tx,
+ -sy * s,
+ sy * c,
+ -sy * (-s * cx + c * cy) + cy + ty,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Scales this matrix with the given scalar values.
+ *
+ * @param {number} sx - The amount to scale in the X axis.
+ * @param {number} sy - The amount to scale in the Y axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ scale(sx, sy) {
+ this.premultiply(_m3.makeScale(sx, sy));
+ return this;
+ }
+ /**
+ * Rotates this matrix by the given angle.
+ *
+ * @param {number} theta - The rotation in radians.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ rotate(theta) {
+ this.premultiply(_m3.makeRotation(-theta));
+ return this;
+ }
+ /**
+ * Translates this matrix by the given scalar values.
+ *
+ * @param {number} tx - The amount to translate in the X axis.
+ * @param {number} ty - The amount to translate in the Y axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ translate(tx, ty) {
+ this.premultiply(_m3.makeTranslation(tx, ty));
+ return this;
+ }
+ // for 2D Transforms
+ /**
+ * Sets this matrix as a 2D translation transform.
+ *
+ * @param {number|Vector2} x - The amount to translate in the X axis or alternatively a translation vector.
+ * @param {number} y - The amount to translate in the Y axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ makeTranslation(x, y) {
+ if (x.isVector2) {
+ this.set(
+ 1,
+ 0,
+ x.x,
+ 0,
+ 1,
+ x.y,
+ 0,
+ 0,
+ 1
+ );
+ } else {
+ this.set(
+ 1,
+ 0,
+ x,
+ 0,
+ 1,
+ y,
+ 0,
+ 0,
+ 1
+ );
+ }
+ return this;
+ }
+ /**
+ * Sets this matrix as a 2D rotational transformation.
+ *
+ * @param {number} theta - The rotation in radians.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ makeRotation(theta) {
+ const c = Math.cos(theta);
+ const s = Math.sin(theta);
+ this.set(
+ c,
+ -s,
+ 0,
+ s,
+ c,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Sets this matrix as a 2D scale transform.
+ *
+ * @param {number} x - The amount to scale in the X axis.
+ * @param {number} y - The amount to scale in the Y axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ makeScale(x, y) {
+ this.set(
+ x,
+ 0,
+ 0,
+ 0,
+ y,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Returns `true` if this matrix is equal with the given one.
+ *
+ * @param {Matrix3} matrix - The matrix to test for equality.
+ * @return {boolean} Whether this matrix is equal with the given one.
+ */
+ equals(matrix) {
+ const te = this.elements;
+ const me = matrix.elements;
+ for (let i = 0; i < 9; i++) {
+ if (te[i] !== me[i]) return false;
+ }
+ return true;
+ }
+ /**
+ * Sets the elements of the matrix from the given array.
+ *
+ * @param {Array} array - The matrix elements in column-major order.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ fromArray(array, offset = 0) {
+ for (let i = 0; i < 9; i++) {
+ this.elements[i] = array[i + offset];
+ }
+ return this;
+ }
+ /**
+ * Writes the elements of this matrix to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the matrix elements in column-major order.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The matrix elements in column-major order.
+ */
+ toArray(array = [], offset = 0) {
+ const te = this.elements;
+ array[offset] = te[0];
+ array[offset + 1] = te[1];
+ array[offset + 2] = te[2];
+ array[offset + 3] = te[3];
+ array[offset + 4] = te[4];
+ array[offset + 5] = te[5];
+ array[offset + 6] = te[6];
+ array[offset + 7] = te[7];
+ array[offset + 8] = te[8];
+ return array;
+ }
+ /**
+ * Returns a matrix with copied values from this instance.
+ *
+ * @return {Matrix3} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor().fromArray(this.elements);
+ }
+};
+var _m3 = new Matrix3();
+var LINEAR_REC709_TO_XYZ = new Matrix3().set(
+ 0.4123908,
+ 0.3575843,
+ 0.1804808,
+ 0.212639,
+ 0.7151687,
+ 0.0721923,
+ 0.0193308,
+ 0.1191948,
+ 0.9505322
+);
+var XYZ_TO_LINEAR_REC709 = new Matrix3().set(
+ 3.2409699,
+ -1.5373832,
+ -0.4986108,
+ -0.9692436,
+ 1.8759675,
+ 0.0415551,
+ 0.0556301,
+ -0.203977,
+ 1.0569715
+);
+function createColorManagement() {
+ const ColorManagement2 = {
+ enabled: true,
+ workingColorSpace: LinearSRGBColorSpace,
+ /**
+ * Implementations of supported color spaces.
+ *
+ * Required:
+ * - primaries: chromaticity coordinates [ rx ry gx gy bx by ]
+ * - whitePoint: reference white [ x y ]
+ * - transfer: transfer function (pre-defined)
+ * - toXYZ: Matrix3 RGB to XYZ transform
+ * - fromXYZ: Matrix3 XYZ to RGB transform
+ * - luminanceCoefficients: RGB luminance coefficients
+ *
+ * Optional:
+ * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' }
+ * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
+ *
+ * Reference:
+ * - https://www.russellcottrell.com/photo/matrixCalculator.htm
+ */
+ spaces: {},
+ convert: function(color, sourceColorSpace, targetColorSpace) {
+ if (this.enabled === false || sourceColorSpace === targetColorSpace || !sourceColorSpace || !targetColorSpace) {
+ return color;
+ }
+ if (this.spaces[sourceColorSpace].transfer === SRGBTransfer) {
+ color.r = SRGBToLinear(color.r);
+ color.g = SRGBToLinear(color.g);
+ color.b = SRGBToLinear(color.b);
+ }
+ if (this.spaces[sourceColorSpace].primaries !== this.spaces[targetColorSpace].primaries) {
+ color.applyMatrix3(this.spaces[sourceColorSpace].toXYZ);
+ color.applyMatrix3(this.spaces[targetColorSpace].fromXYZ);
+ }
+ if (this.spaces[targetColorSpace].transfer === SRGBTransfer) {
+ color.r = LinearToSRGB(color.r);
+ color.g = LinearToSRGB(color.g);
+ color.b = LinearToSRGB(color.b);
+ }
+ return color;
+ },
+ workingToColorSpace: function(color, targetColorSpace) {
+ return this.convert(color, this.workingColorSpace, targetColorSpace);
+ },
+ colorSpaceToWorking: function(color, sourceColorSpace) {
+ return this.convert(color, sourceColorSpace, this.workingColorSpace);
+ },
+ getPrimaries: function(colorSpace) {
+ return this.spaces[colorSpace].primaries;
+ },
+ getTransfer: function(colorSpace) {
+ if (colorSpace === NoColorSpace) return LinearTransfer;
+ return this.spaces[colorSpace].transfer;
+ },
+ getToneMappingMode: function(colorSpace) {
+ return this.spaces[colorSpace].outputColorSpaceConfig.toneMappingMode || "standard";
+ },
+ getLuminanceCoefficients: function(target, colorSpace = this.workingColorSpace) {
+ return target.fromArray(this.spaces[colorSpace].luminanceCoefficients);
+ },
+ define: function(colorSpaces) {
+ Object.assign(this.spaces, colorSpaces);
+ },
+ // Internal APIs
+ _getMatrix: function(targetMatrix, sourceColorSpace, targetColorSpace) {
+ return targetMatrix.copy(this.spaces[sourceColorSpace].toXYZ).multiply(this.spaces[targetColorSpace].fromXYZ);
+ },
+ _getDrawingBufferColorSpace: function(colorSpace) {
+ return this.spaces[colorSpace].outputColorSpaceConfig.drawingBufferColorSpace;
+ },
+ _getUnpackColorSpace: function(colorSpace = this.workingColorSpace) {
+ return this.spaces[colorSpace].workingColorSpaceConfig.unpackColorSpace;
+ },
+ // Deprecated
+ fromWorkingColorSpace: function(color, targetColorSpace) {
+ warnOnce("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().");
+ return ColorManagement2.workingToColorSpace(color, targetColorSpace);
+ },
+ toWorkingColorSpace: function(color, sourceColorSpace) {
+ warnOnce("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().");
+ return ColorManagement2.colorSpaceToWorking(color, sourceColorSpace);
+ }
+ };
+ const REC709_PRIMARIES = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06];
+ const REC709_LUMINANCE_COEFFICIENTS = [0.2126, 0.7152, 0.0722];
+ const D65 = [0.3127, 0.329];
+ ColorManagement2.define({
+ [LinearSRGBColorSpace]: {
+ primaries: REC709_PRIMARIES,
+ whitePoint: D65,
+ transfer: LinearTransfer,
+ toXYZ: LINEAR_REC709_TO_XYZ,
+ fromXYZ: XYZ_TO_LINEAR_REC709,
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
+ workingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace },
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
+ },
+ [SRGBColorSpace]: {
+ primaries: REC709_PRIMARIES,
+ whitePoint: D65,
+ transfer: SRGBTransfer,
+ toXYZ: LINEAR_REC709_TO_XYZ,
+ fromXYZ: XYZ_TO_LINEAR_REC709,
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
+ }
+ });
+ return ColorManagement2;
+}
+var ColorManagement = createColorManagement();
+function SRGBToLinear(c) {
+ return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
+}
+function LinearToSRGB(c) {
+ return c < 31308e-7 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055;
+}
+var _canvas;
+var ImageUtils = class {
+ /**
+ * Returns a data URI containing a representation of the given image.
+ *
+ * @param {(HTMLImageElement|HTMLCanvasElement)} image - The image object.
+ * @param {string} [type='image/png'] - Indicates the image format.
+ * @return {string} The data URI.
+ */
+ static getDataURL(image, type = "image/png") {
+ if (/^data:/i.test(image.src)) {
+ return image.src;
+ }
+ if (typeof HTMLCanvasElement === "undefined") {
+ return image.src;
+ }
+ let canvas;
+ if (image instanceof HTMLCanvasElement) {
+ canvas = image;
+ } else {
+ if (_canvas === void 0) _canvas = createElementNS("canvas");
+ _canvas.width = image.width;
+ _canvas.height = image.height;
+ const context = _canvas.getContext("2d");
+ if (image instanceof ImageData) {
+ context.putImageData(image, 0, 0);
+ } else {
+ context.drawImage(image, 0, 0, image.width, image.height);
+ }
+ canvas = _canvas;
+ }
+ return canvas.toDataURL(type);
+ }
+ /**
+ * Converts the given sRGB image data to linear color space.
+ *
+ * @param {(HTMLImageElement|HTMLCanvasElement|ImageBitmap|Object)} image - The image object.
+ * @return {HTMLCanvasElement|Object} The converted image.
+ */
+ static sRGBToLinear(image) {
+ if (typeof HTMLImageElement !== "undefined" && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== "undefined" && image instanceof HTMLCanvasElement || typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
+ const canvas = createElementNS("canvas");
+ canvas.width = image.width;
+ canvas.height = image.height;
+ const context = canvas.getContext("2d");
+ context.drawImage(image, 0, 0, image.width, image.height);
+ const imageData = context.getImageData(0, 0, image.width, image.height);
+ const data = imageData.data;
+ for (let i = 0; i < data.length; i++) {
+ data[i] = SRGBToLinear(data[i] / 255) * 255;
+ }
+ context.putImageData(imageData, 0, 0);
+ return canvas;
+ } else if (image.data) {
+ const data = image.data.slice(0);
+ for (let i = 0; i < data.length; i++) {
+ if (data instanceof Uint8Array || data instanceof Uint8ClampedArray) {
+ data[i] = Math.floor(SRGBToLinear(data[i] / 255) * 255);
+ } else {
+ data[i] = SRGBToLinear(data[i]);
+ }
+ }
+ return {
+ data,
+ width: image.width,
+ height: image.height
+ };
+ } else {
+ warn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.");
+ return image;
+ }
+ }
+};
+var _sourceId = 0;
+var Source = class {
+ /**
+ * Constructs a new video texture.
+ *
+ * @param {any} [data=null] - The data definition of a texture.
+ */
+ constructor(data = null) {
+ this.isSource = true;
+ Object.defineProperty(this, "id", { value: _sourceId++ });
+ this.uuid = generateUUID();
+ this.data = data;
+ this.dataReady = true;
+ this.version = 0;
+ }
+ /**
+ * Returns the dimensions of the source into the given target vector.
+ *
+ * @param {(Vector2|Vector3)} target - The target object the result is written into.
+ * @return {(Vector2|Vector3)} The dimensions of the source.
+ */
+ getSize(target) {
+ const data = this.data;
+ if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
+ target.set(data.videoWidth, data.videoHeight, 0);
+ } else if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
+ target.set(data.displayHeight, data.displayWidth, 0);
+ } else if (data !== null) {
+ target.set(data.width, data.height, data.depth || 0);
+ } else {
+ target.set(0, 0, 0);
+ }
+ return target;
+ }
+ /**
+ * When the property is set to `true`, the engine allocates the memory
+ * for the texture (if necessary) and triggers the actual texture upload
+ * to the GPU next time the source is used.
+ *
+ * @type {boolean}
+ * @default false
+ * @param {boolean} value
+ */
+ set needsUpdate(value) {
+ if (value === true) this.version++;
+ }
+ /**
+ * Serializes the source into JSON.
+ *
+ * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
+ * @return {Object} A JSON object representing the serialized source.
+ * @see {@link ObjectLoader#parse}
+ */
+ toJSON(meta) {
+ const isRootObject = meta === void 0 || typeof meta === "string";
+ if (!isRootObject && meta.images[this.uuid] !== void 0) {
+ return meta.images[this.uuid];
+ }
+ const output = {
+ uuid: this.uuid,
+ url: ""
+ };
+ const data = this.data;
+ if (data !== null) {
+ let url;
+ if (Array.isArray(data)) {
+ url = [];
+ for (let i = 0, l = data.length; i < l; i++) {
+ if (data[i].isDataTexture) {
+ url.push(serializeImage(data[i].image));
+ } else {
+ url.push(serializeImage(data[i]));
+ }
+ }
+ } else {
+ url = serializeImage(data);
+ }
+ output.url = url;
+ }
+ if (!isRootObject) {
+ meta.images[this.uuid] = output;
+ }
+ return output;
+ }
+};
+function serializeImage(image) {
+ if (typeof HTMLImageElement !== "undefined" && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== "undefined" && image instanceof HTMLCanvasElement || typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
+ return ImageUtils.getDataURL(image);
+ } else {
+ if (image.data) {
+ return {
+ data: Array.from(image.data),
+ width: image.width,
+ height: image.height,
+ type: image.data.constructor.name
+ };
+ } else {
+ warn("Texture: Unable to serialize Texture.");
+ return {};
+ }
+ }
+}
+var _textureId = 0;
+var _tempVec3 = new Vector3();
+var Texture = class _Texture extends EventDispatcher {
+ /**
+ * Constructs a new texture.
+ *
+ * @param {?Object} [image=Texture.DEFAULT_IMAGE] - The image holding the texture data.
+ * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.
+ * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.
+ * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.
+ * @param {number} [magFilter=LinearFilter] - The mag filter value.
+ * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.
+ * @param {number} [format=RGBAFormat] - The texture format.
+ * @param {number} [type=UnsignedByteType] - The texture type.
+ * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
+ * @param {string} [colorSpace=NoColorSpace] - The color space.
+ */
+ constructor(image = _Texture.DEFAULT_IMAGE, mapping = _Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = _Texture.DEFAULT_ANISOTROPY, colorSpace = NoColorSpace) {
+ super();
+ this.isTexture = true;
+ Object.defineProperty(this, "id", { value: _textureId++ });
+ this.uuid = generateUUID();
+ this.name = "";
+ this.source = new Source(image);
+ this.mipmaps = [];
+ this.mapping = mapping;
+ this.channel = 0;
+ this.wrapS = wrapS;
+ this.wrapT = wrapT;
+ this.magFilter = magFilter;
+ this.minFilter = minFilter;
+ this.anisotropy = anisotropy;
+ this.format = format;
+ this.internalFormat = null;
+ this.type = type;
+ this.offset = new Vector2(0, 0);
+ this.repeat = new Vector2(1, 1);
+ this.center = new Vector2(0, 0);
+ this.rotation = 0;
+ this.matrixAutoUpdate = true;
+ this.matrix = new Matrix3();
+ this.generateMipmaps = true;
+ this.premultiplyAlpha = false;
+ this.flipY = true;
+ this.unpackAlignment = 4;
+ this.colorSpace = colorSpace;
+ this.userData = {};
+ this.updateRanges = [];
+ this.version = 0;
+ this.onUpdate = null;
+ this.renderTarget = null;
+ this.isRenderTargetTexture = false;
+ this.isArrayTexture = image && image.depth && image.depth > 1 ? true : false;
+ this.pmremVersion = 0;
+ }
+ /**
+ * The width of the texture in pixels.
+ */
+ get width() {
+ return this.source.getSize(_tempVec3).x;
+ }
+ /**
+ * The height of the texture in pixels.
+ */
+ get height() {
+ return this.source.getSize(_tempVec3).y;
+ }
+ /**
+ * The depth of the texture in pixels.
+ */
+ get depth() {
+ return this.source.getSize(_tempVec3).z;
+ }
+ /**
+ * The image object holding the texture data.
+ *
+ * @type {?Object}
+ */
+ get image() {
+ return this.source.data;
+ }
+ set image(value = null) {
+ this.source.data = value;
+ }
+ /**
+ * Updates the texture transformation matrix from the from the properties {@link Texture#offset},
+ * {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.
+ */
+ updateMatrix() {
+ this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
+ }
+ /**
+ * Adds a range of data in the data texture to be updated on the GPU.
+ *
+ * @param {number} start - Position at which to start update.
+ * @param {number} count - The number of components to update.
+ */
+ addUpdateRange(start, count) {
+ this.updateRanges.push({ start, count });
+ }
+ /**
+ * Clears the update ranges.
+ */
+ clearUpdateRanges() {
+ this.updateRanges.length = 0;
+ }
+ /**
+ * Returns a new texture with copied values from this instance.
+ *
+ * @return {Texture} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor().copy(this);
+ }
+ /**
+ * Copies the values of the given texture to this instance.
+ *
+ * @param {Texture} source - The texture to copy.
+ * @return {Texture} A reference to this instance.
+ */
+ copy(source) {
+ this.name = source.name;
+ this.source = source.source;
+ this.mipmaps = source.mipmaps.slice(0);
+ this.mapping = source.mapping;
+ this.channel = source.channel;
+ this.wrapS = source.wrapS;
+ this.wrapT = source.wrapT;
+ this.magFilter = source.magFilter;
+ this.minFilter = source.minFilter;
+ this.anisotropy = source.anisotropy;
+ this.format = source.format;
+ this.internalFormat = source.internalFormat;
+ this.type = source.type;
+ this.offset.copy(source.offset);
+ this.repeat.copy(source.repeat);
+ this.center.copy(source.center);
+ this.rotation = source.rotation;
+ this.matrixAutoUpdate = source.matrixAutoUpdate;
+ this.matrix.copy(source.matrix);
+ this.generateMipmaps = source.generateMipmaps;
+ this.premultiplyAlpha = source.premultiplyAlpha;
+ this.flipY = source.flipY;
+ this.unpackAlignment = source.unpackAlignment;
+ this.colorSpace = source.colorSpace;
+ this.renderTarget = source.renderTarget;
+ this.isRenderTargetTexture = source.isRenderTargetTexture;
+ this.isArrayTexture = source.isArrayTexture;
+ this.userData = JSON.parse(JSON.stringify(source.userData));
+ this.needsUpdate = true;
+ return this;
+ }
+ /**
+ * Sets this texture's properties based on `values`.
+ * @param {Object} values - A container with texture parameters.
+ */
+ setValues(values) {
+ for (const key in values) {
+ const newValue = values[key];
+ if (newValue === void 0) {
+ warn(`Texture.setValues(): parameter '${key}' has value of undefined.`);
+ continue;
+ }
+ const currentValue = this[key];
+ if (currentValue === void 0) {
+ warn(`Texture.setValues(): property '${key}' does not exist.`);
+ continue;
+ }
+ if (currentValue && newValue && (currentValue.isVector2 && newValue.isVector2)) {
+ currentValue.copy(newValue);
+ } else if (currentValue && newValue && (currentValue.isVector3 && newValue.isVector3)) {
+ currentValue.copy(newValue);
+ } else if (currentValue && newValue && (currentValue.isMatrix3 && newValue.isMatrix3)) {
+ currentValue.copy(newValue);
+ } else {
+ this[key] = newValue;
+ }
+ }
+ }
+ /**
+ * Serializes the texture into JSON.
+ *
+ * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
+ * @return {Object} A JSON object representing the serialized texture.
+ * @see {@link ObjectLoader#parse}
+ */
+ toJSON(meta) {
+ const isRootObject = meta === void 0 || typeof meta === "string";
+ if (!isRootObject && meta.textures[this.uuid] !== void 0) {
+ return meta.textures[this.uuid];
+ }
+ const output = {
+ metadata: {
+ version: 4.7,
+ type: "Texture",
+ generator: "Texture.toJSON"
+ },
+ uuid: this.uuid,
+ name: this.name,
+ image: this.source.toJSON(meta).uuid,
+ mapping: this.mapping,
+ channel: this.channel,
+ repeat: [this.repeat.x, this.repeat.y],
+ offset: [this.offset.x, this.offset.y],
+ center: [this.center.x, this.center.y],
+ rotation: this.rotation,
+ wrap: [this.wrapS, this.wrapT],
+ format: this.format,
+ internalFormat: this.internalFormat,
+ type: this.type,
+ colorSpace: this.colorSpace,
+ minFilter: this.minFilter,
+ magFilter: this.magFilter,
+ anisotropy: this.anisotropy,
+ flipY: this.flipY,
+ generateMipmaps: this.generateMipmaps,
+ premultiplyAlpha: this.premultiplyAlpha,
+ unpackAlignment: this.unpackAlignment
+ };
+ if (Object.keys(this.userData).length > 0) output.userData = this.userData;
+ if (!isRootObject) {
+ meta.textures[this.uuid] = output;
+ }
+ return output;
+ }
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever this instance is no longer used in your app.
+ *
+ * @fires Texture#dispose
+ */
+ dispose() {
+ this.dispatchEvent({ type: "dispose" });
+ }
+ /**
+ * Transforms the given uv vector with the textures uv transformation matrix.
+ *
+ * @param {Vector2} uv - The uv vector.
+ * @return {Vector2} The transformed uv vector.
+ */
+ transformUv(uv) {
+ if (this.mapping !== UVMapping) return uv;
+ uv.applyMatrix3(this.matrix);
+ if (uv.x < 0 || uv.x > 1) {
+ switch (this.wrapS) {
+ case RepeatWrapping:
+ uv.x = uv.x - Math.floor(uv.x);
+ break;
+ case ClampToEdgeWrapping:
+ uv.x = uv.x < 0 ? 0 : 1;
+ break;
+ case MirroredRepeatWrapping:
+ if (Math.abs(Math.floor(uv.x) % 2) === 1) {
+ uv.x = Math.ceil(uv.x) - uv.x;
+ } else {
+ uv.x = uv.x - Math.floor(uv.x);
+ }
+ break;
+ }
+ }
+ if (uv.y < 0 || uv.y > 1) {
+ switch (this.wrapT) {
+ case RepeatWrapping:
+ uv.y = uv.y - Math.floor(uv.y);
+ break;
+ case ClampToEdgeWrapping:
+ uv.y = uv.y < 0 ? 0 : 1;
+ break;
+ case MirroredRepeatWrapping:
+ if (Math.abs(Math.floor(uv.y) % 2) === 1) {
+ uv.y = Math.ceil(uv.y) - uv.y;
+ } else {
+ uv.y = uv.y - Math.floor(uv.y);
+ }
+ break;
+ }
+ }
+ if (this.flipY) {
+ uv.y = 1 - uv.y;
+ }
+ return uv;
+ }
+ /**
+ * Setting this property to `true` indicates the engine the texture
+ * must be updated in the next render. This triggers a texture upload
+ * to the GPU and ensures correct texture parameter configuration.
+ *
+ * @type {boolean}
+ * @default false
+ * @param {boolean} value
+ */
+ set needsUpdate(value) {
+ if (value === true) {
+ this.version++;
+ this.source.needsUpdate = true;
+ }
+ }
+ /**
+ * Setting this property to `true` indicates the engine the PMREM
+ * must be regenerated.
+ *
+ * @type {boolean}
+ * @default false
+ * @param {boolean} value
+ */
+ set needsPMREMUpdate(value) {
+ if (value === true) {
+ this.pmremVersion++;
+ }
+ }
+};
+Texture.DEFAULT_IMAGE = null;
+Texture.DEFAULT_MAPPING = UVMapping;
+Texture.DEFAULT_ANISOTROPY = 1;
+var Vector4 = class _Vector4 {
+ /**
+ * Constructs a new 4D vector.
+ *
+ * @param {number} [x=0] - The x value of this vector.
+ * @param {number} [y=0] - The y value of this vector.
+ * @param {number} [z=0] - The z value of this vector.
+ * @param {number} [w=1] - The w value of this vector.
+ */
+ constructor(x = 0, y = 0, z = 0, w = 1) {
+ _Vector4.prototype.isVector4 = true;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
+ /**
+ * Alias for {@link Vector4#z}.
+ *
+ * @type {number}
+ */
+ get width() {
+ return this.z;
+ }
+ set width(value) {
+ this.z = value;
+ }
+ /**
+ * Alias for {@link Vector4#w}.
+ *
+ * @type {number}
+ */
+ get height() {
+ return this.w;
+ }
+ set height(value) {
+ this.w = value;
+ }
+ /**
+ * Sets the vector components.
+ *
+ * @param {number} x - The value of the x component.
+ * @param {number} y - The value of the y component.
+ * @param {number} z - The value of the z component.
+ * @param {number} w - The value of the w component.
+ * @return {Vector4} A reference to this vector.
+ */
+ set(x, y, z, w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ return this;
+ }
+ /**
+ * Sets the vector components to the same value.
+ *
+ * @param {number} scalar - The value to set for all vector components.
+ * @return {Vector4} A reference to this vector.
+ */
+ setScalar(scalar) {
+ this.x = scalar;
+ this.y = scalar;
+ this.z = scalar;
+ this.w = scalar;
+ return this;
+ }
+ /**
+ * Sets the vector's x component to the given value
+ *
+ * @param {number} x - The value to set.
+ * @return {Vector4} A reference to this vector.
+ */
+ setX(x) {
+ this.x = x;
+ return this;
+ }
+ /**
+ * Sets the vector's y component to the given value
+ *
+ * @param {number} y - The value to set.
+ * @return {Vector4} A reference to this vector.
+ */
+ setY(y) {
+ this.y = y;
+ return this;
+ }
+ /**
+ * Sets the vector's z component to the given value
+ *
+ * @param {number} z - The value to set.
+ * @return {Vector4} A reference to this vector.
+ */
+ setZ(z) {
+ this.z = z;
+ return this;
+ }
+ /**
+ * Sets the vector's w component to the given value
+ *
+ * @param {number} w - The value to set.
+ * @return {Vector4} A reference to this vector.
+ */
+ setW(w) {
+ this.w = w;
+ return this;
+ }
+ /**
+ * Allows to set a vector component with an index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y,
+ * `2` equals to z, `3` equals to w.
+ * @param {number} value - The value to set.
+ * @return {Vector4} A reference to this vector.
+ */
+ setComponent(index, value) {
+ switch (index) {
+ case 0:
+ this.x = value;
+ break;
+ case 1:
+ this.y = value;
+ break;
+ case 2:
+ this.z = value;
+ break;
+ case 3:
+ this.w = value;
+ break;
+ default:
+ throw new Error("index is out of range: " + index);
+ }
+ return this;
+ }
+ /**
+ * Returns the value of the vector component which matches the given index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y,
+ * `2` equals to z, `3` equals to w.
+ * @return {number} A vector component value.
+ */
+ getComponent(index) {
+ switch (index) {
+ case 0:
+ return this.x;
+ case 1:
+ return this.y;
+ case 2:
+ return this.z;
+ case 3:
+ return this.w;
+ default:
+ throw new Error("index is out of range: " + index);
+ }
+ }
+ /**
+ * Returns a new vector with copied values from this instance.
+ *
+ * @return {Vector4} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor(this.x, this.y, this.z, this.w);
+ }
+ /**
+ * Copies the values of the given vector to this instance.
+ *
+ * @param {Vector3|Vector4} v - The vector to copy.
+ * @return {Vector4} A reference to this vector.
+ */
+ copy(v) {
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ this.w = v.w !== void 0 ? v.w : 1;
+ return this;
+ }
+ /**
+ * Adds the given vector to this instance.
+ *
+ * @param {Vector4} v - The vector to add.
+ * @return {Vector4} A reference to this vector.
+ */
+ add(v) {
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+ this.w += v.w;
+ return this;
+ }
+ /**
+ * Adds the given scalar value to all components of this instance.
+ *
+ * @param {number} s - The scalar to add.
+ * @return {Vector4} A reference to this vector.
+ */
+ addScalar(s) {
+ this.x += s;
+ this.y += s;
+ this.z += s;
+ this.w += s;
+ return this;
+ }
+ /**
+ * Adds the given vectors and stores the result in this instance.
+ *
+ * @param {Vector4} a - The first vector.
+ * @param {Vector4} b - The second vector.
+ * @return {Vector4} A reference to this vector.
+ */
+ addVectors(a, b) {
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+ this.z = a.z + b.z;
+ this.w = a.w + b.w;
+ return this;
+ }
+ /**
+ * Adds the given vector scaled by the given factor to this instance.
+ *
+ * @param {Vector4} v - The vector.
+ * @param {number} s - The factor that scales `v`.
+ * @return {Vector4} A reference to this vector.
+ */
+ addScaledVector(v, s) {
+ this.x += v.x * s;
+ this.y += v.y * s;
+ this.z += v.z * s;
+ this.w += v.w * s;
+ return this;
+ }
+ /**
+ * Subtracts the given vector from this instance.
+ *
+ * @param {Vector4} v - The vector to subtract.
+ * @return {Vector4} A reference to this vector.
+ */
+ sub(v) {
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
+ this.w -= v.w;
+ return this;
+ }
+ /**
+ * Subtracts the given scalar value from all components of this instance.
+ *
+ * @param {number} s - The scalar to subtract.
+ * @return {Vector4} A reference to this vector.
+ */
+ subScalar(s) {
+ this.x -= s;
+ this.y -= s;
+ this.z -= s;
+ this.w -= s;
+ return this;
+ }
+ /**
+ * Subtracts the given vectors and stores the result in this instance.
+ *
+ * @param {Vector4} a - The first vector.
+ * @param {Vector4} b - The second vector.
+ * @return {Vector4} A reference to this vector.
+ */
+ subVectors(a, b) {
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+ this.z = a.z - b.z;
+ this.w = a.w - b.w;
+ return this;
+ }
+ /**
+ * Multiplies the given vector with this instance.
+ *
+ * @param {Vector4} v - The vector to multiply.
+ * @return {Vector4} A reference to this vector.
+ */
+ multiply(v) {
+ this.x *= v.x;
+ this.y *= v.y;
+ this.z *= v.z;
+ this.w *= v.w;
+ return this;
+ }
+ /**
+ * Multiplies the given scalar value with all components of this instance.
+ *
+ * @param {number} scalar - The scalar to multiply.
+ * @return {Vector4} A reference to this vector.
+ */
+ multiplyScalar(scalar) {
+ this.x *= scalar;
+ this.y *= scalar;
+ this.z *= scalar;
+ this.w *= scalar;
+ return this;
+ }
+ /**
+ * Multiplies this vector with the given 4x4 matrix.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @return {Vector4} A reference to this vector.
+ */
+ applyMatrix4(m) {
+ const x = this.x, y = this.y, z = this.z, w = this.w;
+ const e = m.elements;
+ this.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;
+ this.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;
+ this.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;
+ this.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;
+ return this;
+ }
+ /**
+ * Divides this instance by the given vector.
+ *
+ * @param {Vector4} v - The vector to divide.
+ * @return {Vector4} A reference to this vector.
+ */
+ divide(v) {
+ this.x /= v.x;
+ this.y /= v.y;
+ this.z /= v.z;
+ this.w /= v.w;
+ return this;
+ }
+ /**
+ * Divides this vector by the given scalar.
+ *
+ * @param {number} scalar - The scalar to divide.
+ * @return {Vector4} A reference to this vector.
+ */
+ divideScalar(scalar) {
+ return this.multiplyScalar(1 / scalar);
+ }
+ /**
+ * Sets the x, y and z components of this
+ * vector to the quaternion's axis and w to the angle.
+ *
+ * @param {Quaternion} q - The Quaternion to set.
+ * @return {Vector4} A reference to this vector.
+ */
+ setAxisAngleFromQuaternion(q) {
+ this.w = 2 * Math.acos(q.w);
+ const s = Math.sqrt(1 - q.w * q.w);
+ if (s < 1e-4) {
+ this.x = 1;
+ this.y = 0;
+ this.z = 0;
+ } else {
+ this.x = q.x / s;
+ this.y = q.y / s;
+ this.z = q.z / s;
+ }
+ return this;
+ }
+ /**
+ * Sets the x, y and z components of this
+ * vector to the axis of rotation and w to the angle.
+ *
+ * @param {Matrix4} m - A 4x4 matrix of which the upper left 3x3 matrix is a pure rotation matrix.
+ * @return {Vector4} A reference to this vector.
+ */
+ setAxisAngleFromRotationMatrix(m) {
+ let angle, x, y, z;
+ const epsilon = 0.01, epsilon2 = 0.1, te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10];
+ if (Math.abs(m12 - m21) < epsilon && Math.abs(m13 - m31) < epsilon && Math.abs(m23 - m32) < epsilon) {
+ if (Math.abs(m12 + m21) < epsilon2 && Math.abs(m13 + m31) < epsilon2 && Math.abs(m23 + m32) < epsilon2 && Math.abs(m11 + m22 + m33 - 3) < epsilon2) {
+ this.set(1, 0, 0, 0);
+ return this;
+ }
+ angle = Math.PI;
+ const xx = (m11 + 1) / 2;
+ const yy = (m22 + 1) / 2;
+ const zz = (m33 + 1) / 2;
+ const xy = (m12 + m21) / 4;
+ const xz = (m13 + m31) / 4;
+ const yz = (m23 + m32) / 4;
+ if (xx > yy && xx > zz) {
+ if (xx < epsilon) {
+ x = 0;
+ y = 0.707106781;
+ z = 0.707106781;
+ } else {
+ x = Math.sqrt(xx);
+ y = xy / x;
+ z = xz / x;
+ }
+ } else if (yy > zz) {
+ if (yy < epsilon) {
+ x = 0.707106781;
+ y = 0;
+ z = 0.707106781;
+ } else {
+ y = Math.sqrt(yy);
+ x = xy / y;
+ z = yz / y;
+ }
+ } else {
+ if (zz < epsilon) {
+ x = 0.707106781;
+ y = 0.707106781;
+ z = 0;
+ } else {
+ z = Math.sqrt(zz);
+ x = xz / z;
+ y = yz / z;
+ }
+ }
+ this.set(x, y, z, angle);
+ return this;
+ }
+ let s = Math.sqrt((m32 - m23) * (m32 - m23) + (m13 - m31) * (m13 - m31) + (m21 - m12) * (m21 - m12));
+ if (Math.abs(s) < 1e-3) s = 1;
+ this.x = (m32 - m23) / s;
+ this.y = (m13 - m31) / s;
+ this.z = (m21 - m12) / s;
+ this.w = Math.acos((m11 + m22 + m33 - 1) / 2);
+ return this;
+ }
+ /**
+ * Sets the vector components to the position elements of the
+ * given transformation matrix.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @return {Vector4} A reference to this vector.
+ */
+ setFromMatrixPosition(m) {
+ const e = m.elements;
+ this.x = e[12];
+ this.y = e[13];
+ this.z = e[14];
+ this.w = e[15];
+ return this;
+ }
+ /**
+ * If this vector's x, y, z or w value is greater than the given vector's x, y, z or w
+ * value, replace that value with the corresponding min value.
+ *
+ * @param {Vector4} v - The vector.
+ * @return {Vector4} A reference to this vector.
+ */
+ min(v) {
+ this.x = Math.min(this.x, v.x);
+ this.y = Math.min(this.y, v.y);
+ this.z = Math.min(this.z, v.z);
+ this.w = Math.min(this.w, v.w);
+ return this;
+ }
+ /**
+ * If this vector's x, y, z or w value is less than the given vector's x, y, z or w
+ * value, replace that value with the corresponding max value.
+ *
+ * @param {Vector4} v - The vector.
+ * @return {Vector4} A reference to this vector.
+ */
+ max(v) {
+ this.x = Math.max(this.x, v.x);
+ this.y = Math.max(this.y, v.y);
+ this.z = Math.max(this.z, v.z);
+ this.w = Math.max(this.w, v.w);
+ return this;
+ }
+ /**
+ * If this vector's x, y, z or w value is greater than the max vector's x, y, z or w
+ * value, it is replaced by the corresponding value.
+ * If this vector's x, y, z or w value is less than the min vector's x, y, z or w value,
+ * it is replaced by the corresponding value.
+ *
+ * @param {Vector4} min - The minimum x, y and z values.
+ * @param {Vector4} max - The maximum x, y and z values in the desired range.
+ * @return {Vector4} A reference to this vector.
+ */
+ clamp(min, max) {
+ this.x = clamp(this.x, min.x, max.x);
+ this.y = clamp(this.y, min.y, max.y);
+ this.z = clamp(this.z, min.z, max.z);
+ this.w = clamp(this.w, min.w, max.w);
+ return this;
+ }
+ /**
+ * If this vector's x, y, z or w values are greater than the max value, they are
+ * replaced by the max value.
+ * If this vector's x, y, z or w values are less than the min value, they are
+ * replaced by the min value.
+ *
+ * @param {number} minVal - The minimum value the components will be clamped to.
+ * @param {number} maxVal - The maximum value the components will be clamped to.
+ * @return {Vector4} A reference to this vector.
+ */
+ clampScalar(minVal, maxVal) {
+ this.x = clamp(this.x, minVal, maxVal);
+ this.y = clamp(this.y, minVal, maxVal);
+ this.z = clamp(this.z, minVal, maxVal);
+ this.w = clamp(this.w, minVal, maxVal);
+ return this;
+ }
+ /**
+ * If this vector's length is greater than the max value, it is replaced by
+ * the max value.
+ * If this vector's length is less than the min value, it is replaced by the
+ * min value.
+ *
+ * @param {number} min - The minimum value the vector length will be clamped to.
+ * @param {number} max - The maximum value the vector length will be clamped to.
+ * @return {Vector4} A reference to this vector.
+ */
+ clampLength(min, max) {
+ const length = this.length();
+ return this.divideScalar(length || 1).multiplyScalar(clamp(length, min, max));
+ }
+ /**
+ * The components of this vector are rounded down to the nearest integer value.
+ *
+ * @return {Vector4} A reference to this vector.
+ */
+ floor() {
+ this.x = Math.floor(this.x);
+ this.y = Math.floor(this.y);
+ this.z = Math.floor(this.z);
+ this.w = Math.floor(this.w);
+ return this;
+ }
+ /**
+ * The components of this vector are rounded up to the nearest integer value.
+ *
+ * @return {Vector4} A reference to this vector.
+ */
+ ceil() {
+ this.x = Math.ceil(this.x);
+ this.y = Math.ceil(this.y);
+ this.z = Math.ceil(this.z);
+ this.w = Math.ceil(this.w);
+ return this;
+ }
+ /**
+ * The components of this vector are rounded to the nearest integer value
+ *
+ * @return {Vector4} A reference to this vector.
+ */
+ round() {
+ this.x = Math.round(this.x);
+ this.y = Math.round(this.y);
+ this.z = Math.round(this.z);
+ this.w = Math.round(this.w);
+ return this;
+ }
+ /**
+ * The components of this vector are rounded towards zero (up if negative,
+ * down if positive) to an integer value.
+ *
+ * @return {Vector4} A reference to this vector.
+ */
+ roundToZero() {
+ this.x = Math.trunc(this.x);
+ this.y = Math.trunc(this.y);
+ this.z = Math.trunc(this.z);
+ this.w = Math.trunc(this.w);
+ return this;
+ }
+ /**
+ * Inverts this vector - i.e. sets x = -x, y = -y, z = -z, w = -w.
+ *
+ * @return {Vector4} A reference to this vector.
+ */
+ negate() {
+ this.x = -this.x;
+ this.y = -this.y;
+ this.z = -this.z;
+ this.w = -this.w;
+ return this;
+ }
+ /**
+ * Calculates the dot product of the given vector with this instance.
+ *
+ * @param {Vector4} v - The vector to compute the dot product with.
+ * @return {number} The result of the dot product.
+ */
+ dot(v) {
+ return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
+ }
+ /**
+ * Computes the square of the Euclidean length (straight-line length) from
+ * (0, 0, 0, 0) to (x, y, z, w). If you are comparing the lengths of vectors, you should
+ * compare the length squared instead as it is slightly more efficient to calculate.
+ *
+ * @return {number} The square length of this vector.
+ */
+ lengthSq() {
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
+ }
+ /**
+ * Computes the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w).
+ *
+ * @return {number} The length of this vector.
+ */
+ length() {
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
+ }
+ /**
+ * Computes the Manhattan length of this vector.
+ *
+ * @return {number} The length of this vector.
+ */
+ manhattanLength() {
+ return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
+ }
+ /**
+ * Converts this vector to a unit vector - that is, sets it equal to a vector
+ * with the same direction as this one, but with a vector length of `1`.
+ *
+ * @return {Vector4} A reference to this vector.
+ */
+ normalize() {
+ return this.divideScalar(this.length() || 1);
+ }
+ /**
+ * Sets this vector to a vector with the same direction as this one, but
+ * with the specified length.
+ *
+ * @param {number} length - The new length of this vector.
+ * @return {Vector4} A reference to this vector.
+ */
+ setLength(length) {
+ return this.normalize().multiplyScalar(length);
+ }
+ /**
+ * Linearly interpolates between the given vector and this instance, where
+ * alpha is the percent distance along the line - alpha = 0 will be this
+ * vector, and alpha = 1 will be the given one.
+ *
+ * @param {Vector4} v - The vector to interpolate towards.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector4} A reference to this vector.
+ */
+ lerp(v, alpha) {
+ this.x += (v.x - this.x) * alpha;
+ this.y += (v.y - this.y) * alpha;
+ this.z += (v.z - this.z) * alpha;
+ this.w += (v.w - this.w) * alpha;
+ return this;
+ }
+ /**
+ * Linearly interpolates between the given vectors, where alpha is the percent
+ * distance along the line - alpha = 0 will be first vector, and alpha = 1 will
+ * be the second one. The result is stored in this instance.
+ *
+ * @param {Vector4} v1 - The first vector.
+ * @param {Vector4} v2 - The second vector.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector4} A reference to this vector.
+ */
+ lerpVectors(v1, v2, alpha) {
+ this.x = v1.x + (v2.x - v1.x) * alpha;
+ this.y = v1.y + (v2.y - v1.y) * alpha;
+ this.z = v1.z + (v2.z - v1.z) * alpha;
+ this.w = v1.w + (v2.w - v1.w) * alpha;
+ return this;
+ }
+ /**
+ * Returns `true` if this vector is equal with the given one.
+ *
+ * @param {Vector4} v - The vector to test for equality.
+ * @return {boolean} Whether this vector is equal with the given one.
+ */
+ equals(v) {
+ return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;
+ }
+ /**
+ * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`,
+ * z value to be `array[ offset + 2 ]`, w value to be `array[ offset + 3 ]`.
+ *
+ * @param {Array} array - An array holding the vector component values.
+ * @param {number} [offset=0] - The offset into the array.
+ * @return {Vector4} A reference to this vector.
+ */
+ fromArray(array, offset = 0) {
+ this.x = array[offset];
+ this.y = array[offset + 1];
+ this.z = array[offset + 2];
+ this.w = array[offset + 3];
+ return this;
+ }
+ /**
+ * Writes the components of this vector to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the vector components.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The vector components.
+ */
+ toArray(array = [], offset = 0) {
+ array[offset] = this.x;
+ array[offset + 1] = this.y;
+ array[offset + 2] = this.z;
+ array[offset + 3] = this.w;
+ return array;
+ }
+ /**
+ * Sets the components of this vector from the given buffer attribute.
+ *
+ * @param {BufferAttribute} attribute - The buffer attribute holding vector data.
+ * @param {number} index - The index into the attribute.
+ * @return {Vector4} A reference to this vector.
+ */
+ fromBufferAttribute(attribute, index) {
+ this.x = attribute.getX(index);
+ this.y = attribute.getY(index);
+ this.z = attribute.getZ(index);
+ this.w = attribute.getW(index);
+ return this;
+ }
+ /**
+ * Sets each component of this vector to a pseudo-random value between `0` and
+ * `1`, excluding `1`.
+ *
+ * @return {Vector4} A reference to this vector.
+ */
+ random() {
+ this.x = Math.random();
+ this.y = Math.random();
+ this.z = Math.random();
+ this.w = Math.random();
+ return this;
+ }
+ *[Symbol.iterator]() {
+ yield this.x;
+ yield this.y;
+ yield this.z;
+ yield this.w;
+ }
+};
+var RenderTarget = class extends EventDispatcher {
+ /**
+ * Render target options.
+ *
+ * @typedef {Object} RenderTarget~Options
+ * @property {boolean} [generateMipmaps=false] - Whether to generate mipmaps or not.
+ * @property {number} [magFilter=LinearFilter] - The mag filter.
+ * @property {number} [minFilter=LinearFilter] - The min filter.
+ * @property {number} [format=RGBAFormat] - The texture format.
+ * @property {number} [type=UnsignedByteType] - The texture type.
+ * @property {?string} [internalFormat=null] - The texture's internal format.
+ * @property {number} [wrapS=ClampToEdgeWrapping] - The texture's uv wrapping mode.
+ * @property {number} [wrapT=ClampToEdgeWrapping] - The texture's uv wrapping mode.
+ * @property {number} [anisotropy=1] - The texture's anisotropy value.
+ * @property {string} [colorSpace=NoColorSpace] - The texture's color space.
+ * @property {boolean} [depthBuffer=true] - Whether to allocate a depth buffer or not.
+ * @property {boolean} [stencilBuffer=false] - Whether to allocate a stencil buffer or not.
+ * @property {boolean} [resolveDepthBuffer=true] - Whether to resolve the depth buffer or not.
+ * @property {boolean} [resolveStencilBuffer=true] - Whether to resolve the stencil buffer or not.
+ * @property {?Texture} [depthTexture=null] - Reference to a depth texture.
+ * @property {number} [samples=0] - The MSAA samples count.
+ * @property {number} [count=1] - Defines the number of color attachments . Must be at least `1`.
+ * @property {number} [depth=1] - The texture depth.
+ * @property {boolean} [multiview=false] - Whether this target is used for multiview rendering.
+ */
+ /**
+ * Constructs a new render target.
+ *
+ * @param {number} [width=1] - The width of the render target.
+ * @param {number} [height=1] - The height of the render target.
+ * @param {RenderTarget~Options} [options] - The configuration object.
+ */
+ constructor(width = 1, height = 1, options = {}) {
+ super();
+ options = Object.assign({
+ generateMipmaps: false,
+ internalFormat: null,
+ minFilter: LinearFilter,
+ depthBuffer: true,
+ stencilBuffer: false,
+ resolveDepthBuffer: true,
+ resolveStencilBuffer: true,
+ depthTexture: null,
+ samples: 0,
+ count: 1,
+ depth: 1,
+ multiview: false
+ }, options);
+ this.isRenderTarget = true;
+ this.width = width;
+ this.height = height;
+ this.depth = options.depth;
+ this.scissor = new Vector4(0, 0, width, height);
+ this.scissorTest = false;
+ this.viewport = new Vector4(0, 0, width, height);
+ const image = { width, height, depth: options.depth };
+ const texture = new Texture(image);
+ this.textures = [];
+ const count = options.count;
+ for (let i = 0; i < count; i++) {
+ this.textures[i] = texture.clone();
+ this.textures[i].isRenderTargetTexture = true;
+ this.textures[i].renderTarget = this;
+ }
+ this._setTextureOptions(options);
+ this.depthBuffer = options.depthBuffer;
+ this.stencilBuffer = options.stencilBuffer;
+ this.resolveDepthBuffer = options.resolveDepthBuffer;
+ this.resolveStencilBuffer = options.resolveStencilBuffer;
+ this._depthTexture = null;
+ this.depthTexture = options.depthTexture;
+ this.samples = options.samples;
+ this.multiview = options.multiview;
+ }
+ _setTextureOptions(options = {}) {
+ const values = {
+ minFilter: LinearFilter,
+ generateMipmaps: false,
+ flipY: false,
+ internalFormat: null
+ };
+ if (options.mapping !== void 0) values.mapping = options.mapping;
+ if (options.wrapS !== void 0) values.wrapS = options.wrapS;
+ if (options.wrapT !== void 0) values.wrapT = options.wrapT;
+ if (options.wrapR !== void 0) values.wrapR = options.wrapR;
+ if (options.magFilter !== void 0) values.magFilter = options.magFilter;
+ if (options.minFilter !== void 0) values.minFilter = options.minFilter;
+ if (options.format !== void 0) values.format = options.format;
+ if (options.type !== void 0) values.type = options.type;
+ if (options.anisotropy !== void 0) values.anisotropy = options.anisotropy;
+ if (options.colorSpace !== void 0) values.colorSpace = options.colorSpace;
+ if (options.flipY !== void 0) values.flipY = options.flipY;
+ if (options.generateMipmaps !== void 0) values.generateMipmaps = options.generateMipmaps;
+ if (options.internalFormat !== void 0) values.internalFormat = options.internalFormat;
+ for (let i = 0; i < this.textures.length; i++) {
+ const texture = this.textures[i];
+ texture.setValues(values);
+ }
+ }
+ /**
+ * The texture representing the default color attachment.
+ *
+ * @type {Texture}
+ */
+ get texture() {
+ return this.textures[0];
+ }
+ set texture(value) {
+ this.textures[0] = value;
+ }
+ set depthTexture(current) {
+ if (this._depthTexture !== null) this._depthTexture.renderTarget = null;
+ if (current !== null) current.renderTarget = this;
+ this._depthTexture = current;
+ }
+ /**
+ * Instead of saving the depth in a renderbuffer, a texture
+ * can be used instead which is useful for further processing
+ * e.g. in context of post-processing.
+ *
+ * @type {?DepthTexture}
+ * @default null
+ */
+ get depthTexture() {
+ return this._depthTexture;
+ }
+ /**
+ * Sets the size of this render target.
+ *
+ * @param {number} width - The width.
+ * @param {number} height - The height.
+ * @param {number} [depth=1] - The depth.
+ */
+ setSize(width, height, depth = 1) {
+ if (this.width !== width || this.height !== height || this.depth !== depth) {
+ this.width = width;
+ this.height = height;
+ this.depth = depth;
+ for (let i = 0, il = this.textures.length; i < il; i++) {
+ this.textures[i].image.width = width;
+ this.textures[i].image.height = height;
+ this.textures[i].image.depth = depth;
+ if (this.textures[i].isData3DTexture !== true) {
+ this.textures[i].isArrayTexture = this.textures[i].image.depth > 1;
+ }
+ }
+ this.dispose();
+ }
+ this.viewport.set(0, 0, width, height);
+ this.scissor.set(0, 0, width, height);
+ }
+ /**
+ * Returns a new render target with copied values from this instance.
+ *
+ * @return {RenderTarget} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor().copy(this);
+ }
+ /**
+ * Copies the settings of the given render target. This is a structural copy so
+ * no resources are shared between render targets after the copy. That includes
+ * all MRT textures and the depth texture.
+ *
+ * @param {RenderTarget} source - The render target to copy.
+ * @return {RenderTarget} A reference to this instance.
+ */
+ copy(source) {
+ this.width = source.width;
+ this.height = source.height;
+ this.depth = source.depth;
+ this.scissor.copy(source.scissor);
+ this.scissorTest = source.scissorTest;
+ this.viewport.copy(source.viewport);
+ this.textures.length = 0;
+ for (let i = 0, il = source.textures.length; i < il; i++) {
+ this.textures[i] = source.textures[i].clone();
+ this.textures[i].isRenderTargetTexture = true;
+ this.textures[i].renderTarget = this;
+ const image = Object.assign({}, source.textures[i].image);
+ this.textures[i].source = new Source(image);
+ }
+ this.depthBuffer = source.depthBuffer;
+ this.stencilBuffer = source.stencilBuffer;
+ this.resolveDepthBuffer = source.resolveDepthBuffer;
+ this.resolveStencilBuffer = source.resolveStencilBuffer;
+ if (source.depthTexture !== null) this.depthTexture = source.depthTexture.clone();
+ this.samples = source.samples;
+ return this;
+ }
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever this instance is no longer used in your app.
+ *
+ * @fires RenderTarget#dispose
+ */
+ dispose() {
+ this.dispatchEvent({ type: "dispose" });
+ }
+};
+var WebGLRenderTarget = class extends RenderTarget {
+ /**
+ * Constructs a new 3D render target.
+ *
+ * @param {number} [width=1] - The width of the render target.
+ * @param {number} [height=1] - The height of the render target.
+ * @param {RenderTarget~Options} [options] - The configuration object.
+ */
+ constructor(width = 1, height = 1, options = {}) {
+ super(width, height, options);
+ this.isWebGLRenderTarget = true;
+ }
+};
+var DataArrayTexture = class extends Texture {
+ /**
+ * Constructs a new data array texture.
+ *
+ * @param {?TypedArray} [data=null] - The buffer data.
+ * @param {number} [width=1] - The width of the texture.
+ * @param {number} [height=1] - The height of the texture.
+ * @param {number} [depth=1] - The depth of the texture.
+ */
+ constructor(data = null, width = 1, height = 1, depth = 1) {
+ super(null);
+ this.isDataArrayTexture = true;
+ this.image = { data, width, height, depth };
+ this.magFilter = NearestFilter;
+ this.minFilter = NearestFilter;
+ this.wrapR = ClampToEdgeWrapping;
+ this.generateMipmaps = false;
+ this.flipY = false;
+ this.unpackAlignment = 1;
+ this.layerUpdates = /* @__PURE__ */ new Set();
+ }
+ /**
+ * Describes that a specific layer of the texture needs to be updated.
+ * Normally when {@link Texture#needsUpdate} is set to `true`, the
+ * entire data texture array is sent to the GPU. Marking specific
+ * layers will only transmit subsets of all mipmaps associated with a
+ * specific depth in the array which is often much more performant.
+ *
+ * @param {number} layerIndex - The layer index that should be updated.
+ */
+ addLayerUpdate(layerIndex) {
+ this.layerUpdates.add(layerIndex);
+ }
+ /**
+ * Resets the layer updates registry.
+ */
+ clearLayerUpdates() {
+ this.layerUpdates.clear();
+ }
+};
+var WebGLArrayRenderTarget = class extends WebGLRenderTarget {
+ /**
+ * Constructs a new array render target.
+ *
+ * @param {number} [width=1] - The width of the render target.
+ * @param {number} [height=1] - The height of the render target.
+ * @param {number} [depth=1] - The height of the render target.
+ * @param {RenderTarget~Options} [options] - The configuration object.
+ */
+ constructor(width = 1, height = 1, depth = 1, options = {}) {
+ super(width, height, options);
+ this.isWebGLArrayRenderTarget = true;
+ this.depth = depth;
+ this.texture = new DataArrayTexture(null, width, height, depth);
+ this._setTextureOptions(options);
+ this.texture.isRenderTargetTexture = true;
+ }
+};
+var Data3DTexture = class extends Texture {
+ /**
+ * Constructs a new data array texture.
+ *
+ * @param {?TypedArray} [data=null] - The buffer data.
+ * @param {number} [width=1] - The width of the texture.
+ * @param {number} [height=1] - The height of the texture.
+ * @param {number} [depth=1] - The depth of the texture.
+ */
+ constructor(data = null, width = 1, height = 1, depth = 1) {
+ super(null);
+ this.isData3DTexture = true;
+ this.image = { data, width, height, depth };
+ this.magFilter = NearestFilter;
+ this.minFilter = NearestFilter;
+ this.wrapR = ClampToEdgeWrapping;
+ this.generateMipmaps = false;
+ this.flipY = false;
+ this.unpackAlignment = 1;
+ }
+};
+var WebGL3DRenderTarget = class extends WebGLRenderTarget {
+ /**
+ * Constructs a new 3D render target.
+ *
+ * @param {number} [width=1] - The width of the render target.
+ * @param {number} [height=1] - The height of the render target.
+ * @param {number} [depth=1] - The height of the render target.
+ * @param {RenderTarget~Options} [options] - The configuration object.
+ */
+ constructor(width = 1, height = 1, depth = 1, options = {}) {
+ super(width, height, options);
+ this.isWebGL3DRenderTarget = true;
+ this.depth = depth;
+ this.texture = new Data3DTexture(null, width, height, depth);
+ this._setTextureOptions(options);
+ this.texture.isRenderTargetTexture = true;
+ }
+};
+var Box3 = class {
+ /**
+ * Constructs a new bounding box.
+ *
+ * @param {Vector3} [min=(Infinity,Infinity,Infinity)] - A vector representing the lower boundary of the box.
+ * @param {Vector3} [max=(-Infinity,-Infinity,-Infinity)] - A vector representing the upper boundary of the box.
+ */
+ constructor(min = new Vector3(Infinity, Infinity, Infinity), max = new Vector3(-Infinity, -Infinity, -Infinity)) {
+ this.isBox3 = true;
+ this.min = min;
+ this.max = max;
+ }
+ /**
+ * Sets the lower and upper boundaries of this box.
+ * Please note that this method only copies the values from the given objects.
+ *
+ * @param {Vector3} min - The lower boundary of the box.
+ * @param {Vector3} max - The upper boundary of the box.
+ * @return {Box3} A reference to this bounding box.
+ */
+ set(min, max) {
+ this.min.copy(min);
+ this.max.copy(max);
+ return this;
+ }
+ /**
+ * Sets the upper and lower bounds of this box so it encloses the position data
+ * in the given array.
+ *
+ * @param {Array} array - An array holding 3D position data.
+ * @return {Box3} A reference to this bounding box.
+ */
+ setFromArray(array) {
+ this.makeEmpty();
+ for (let i = 0, il = array.length; i < il; i += 3) {
+ this.expandByPoint(_vector$b.fromArray(array, i));
+ }
+ return this;
+ }
+ /**
+ * Sets the upper and lower bounds of this box so it encloses the position data
+ * in the given buffer attribute.
+ *
+ * @param {BufferAttribute} attribute - A buffer attribute holding 3D position data.
+ * @return {Box3} A reference to this bounding box.
+ */
+ setFromBufferAttribute(attribute) {
+ this.makeEmpty();
+ for (let i = 0, il = attribute.count; i < il; i++) {
+ this.expandByPoint(_vector$b.fromBufferAttribute(attribute, i));
+ }
+ return this;
+ }
+ /**
+ * Sets the upper and lower bounds of this box so it encloses the position data
+ * in the given array.
+ *
+ * @param {Array} points - An array holding 3D position data as instances of {@link Vector3}.
+ * @return {Box3} A reference to this bounding box.
+ */
+ setFromPoints(points) {
+ this.makeEmpty();
+ for (let i = 0, il = points.length; i < il; i++) {
+ this.expandByPoint(points[i]);
+ }
+ return this;
+ }
+ /**
+ * Centers this box on the given center vector and sets this box's width, height and
+ * depth to the given size values.
+ *
+ * @param {Vector3} center - The center of the box.
+ * @param {Vector3} size - The x, y and z dimensions of the box.
+ * @return {Box3} A reference to this bounding box.
+ */
+ setFromCenterAndSize(center, size) {
+ const halfSize = _vector$b.copy(size).multiplyScalar(0.5);
+ this.min.copy(center).sub(halfSize);
+ this.max.copy(center).add(halfSize);
+ return this;
+ }
+ /**
+ * Computes the world-axis-aligned bounding box for the given 3D object
+ * (including its children), accounting for the object's, and children's,
+ * world transforms. The function may result in a larger box than strictly necessary.
+ *
+ * @param {Object3D} object - The 3D object to compute the bounding box for.
+ * @param {boolean} [precise=false] - If set to `true`, the method computes the smallest
+ * world-axis-aligned bounding box at the expense of more computation.
+ * @return {Box3} A reference to this bounding box.
+ */
+ setFromObject(object, precise = false) {
+ this.makeEmpty();
+ return this.expandByObject(object, precise);
+ }
+ /**
+ * Returns a new box with copied values from this instance.
+ *
+ * @return {Box3} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor().copy(this);
+ }
+ /**
+ * Copies the values of the given box to this instance.
+ *
+ * @param {Box3} box - The box to copy.
+ * @return {Box3} A reference to this bounding box.
+ */
+ copy(box) {
+ this.min.copy(box.min);
+ this.max.copy(box.max);
+ return this;
+ }
+ /**
+ * Makes this box empty which means in encloses a zero space in 3D.
+ *
+ * @return {Box3} A reference to this bounding box.
+ */
+ makeEmpty() {
+ this.min.x = this.min.y = this.min.z = Infinity;
+ this.max.x = this.max.y = this.max.z = -Infinity;
+ return this;
+ }
+ /**
+ * Returns true if this box includes zero points within its bounds.
+ * Note that a box with equal lower and upper bounds still includes one
+ * point, the one both bounds share.
+ *
+ * @return {boolean} Whether this box is empty or not.
+ */
+ isEmpty() {
+ return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
+ }
+ /**
+ * Returns the center point of this box.
+ *
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {Vector3} The center point.
+ */
+ getCenter(target) {
+ return this.isEmpty() ? target.set(0, 0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);
+ }
+ /**
+ * Returns the dimensions of this box.
+ *
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {Vector3} The size.
+ */
+ getSize(target) {
+ return this.isEmpty() ? target.set(0, 0, 0) : target.subVectors(this.max, this.min);
+ }
+ /**
+ * Expands the boundaries of this box to include the given point.
+ *
+ * @param {Vector3} point - The point that should be included by the bounding box.
+ * @return {Box3} A reference to this bounding box.
+ */
+ expandByPoint(point) {
+ this.min.min(point);
+ this.max.max(point);
+ return this;
+ }
+ /**
+ * Expands this box equilaterally by the given vector. The width of this
+ * box will be expanded by the x component of the vector in both
+ * directions. The height of this box will be expanded by the y component of
+ * the vector in both directions. The depth of this box will be
+ * expanded by the z component of the vector in both directions.
+ *
+ * @param {Vector3} vector - The vector that should expand the bounding box.
+ * @return {Box3} A reference to this bounding box.
+ */
+ expandByVector(vector) {
+ this.min.sub(vector);
+ this.max.add(vector);
+ return this;
+ }
+ /**
+ * Expands each dimension of the box by the given scalar. If negative, the
+ * dimensions of the box will be contracted.
+ *
+ * @param {number} scalar - The scalar value that should expand the bounding box.
+ * @return {Box3} A reference to this bounding box.
+ */
+ expandByScalar(scalar) {
+ this.min.addScalar(-scalar);
+ this.max.addScalar(scalar);
+ return this;
+ }
+ /**
+ * Expands the boundaries of this box to include the given 3D object and
+ * its children, accounting for the object's, and children's, world
+ * transforms. The function may result in a larger box than strictly
+ * necessary (unless the precise parameter is set to true).
+ *
+ * @param {Object3D} object - The 3D object that should expand the bounding box.
+ * @param {boolean} precise - If set to `true`, the method expands the bounding box
+ * as little as necessary at the expense of more computation.
+ * @return {Box3} A reference to this bounding box.
+ */
+ expandByObject(object, precise = false) {
+ object.updateWorldMatrix(false, false);
+ const geometry = object.geometry;
+ if (geometry !== void 0) {
+ const positionAttribute = geometry.getAttribute("position");
+ if (precise === true && positionAttribute !== void 0 && object.isInstancedMesh !== true) {
+ for (let i = 0, l = positionAttribute.count; i < l; i++) {
+ if (object.isMesh === true) {
+ object.getVertexPosition(i, _vector$b);
+ } else {
+ _vector$b.fromBufferAttribute(positionAttribute, i);
+ }
+ _vector$b.applyMatrix4(object.matrixWorld);
+ this.expandByPoint(_vector$b);
+ }
+ } else {
+ if (object.boundingBox !== void 0) {
+ if (object.boundingBox === null) {
+ object.computeBoundingBox();
+ }
+ _box$4.copy(object.boundingBox);
+ } else {
+ if (geometry.boundingBox === null) {
+ geometry.computeBoundingBox();
+ }
+ _box$4.copy(geometry.boundingBox);
+ }
+ _box$4.applyMatrix4(object.matrixWorld);
+ this.union(_box$4);
+ }
+ }
+ const children = object.children;
+ for (let i = 0, l = children.length; i < l; i++) {
+ this.expandByObject(children[i], precise);
+ }
+ return this;
+ }
+ /**
+ * Returns `true` if the given point lies within or on the boundaries of this box.
+ *
+ * @param {Vector3} point - The point to test.
+ * @return {boolean} Whether the bounding box contains the given point or not.
+ */
+ containsPoint(point) {
+ return point.x >= this.min.x && point.x <= this.max.x && point.y >= this.min.y && point.y <= this.max.y && point.z >= this.min.z && point.z <= this.max.z;
+ }
+ /**
+ * Returns `true` if this bounding box includes the entirety of the given bounding box.
+ * If this box and the given one are identical, this function also returns `true`.
+ *
+ * @param {Box3} box - The bounding box to test.
+ * @return {boolean} Whether the bounding box contains the given bounding box or not.
+ */
+ containsBox(box) {
+ return this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y && this.min.z <= box.min.z && box.max.z <= this.max.z;
+ }
+ /**
+ * Returns a point as a proportion of this box's width, height and depth.
+ *
+ * @param {Vector3} point - A point in 3D space.
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {Vector3} A point as a proportion of this box's width, height and depth.
+ */
+ getParameter(point, target) {
+ return target.set(
+ (point.x - this.min.x) / (this.max.x - this.min.x),
+ (point.y - this.min.y) / (this.max.y - this.min.y),
+ (point.z - this.min.z) / (this.max.z - this.min.z)
+ );
+ }
+ /**
+ * Returns `true` if the given bounding box intersects with this bounding box.
+ *
+ * @param {Box3} box - The bounding box to test.
+ * @return {boolean} Whether the given bounding box intersects with this bounding box.
+ */
+ intersectsBox(box) {
+ return box.max.x >= this.min.x && box.min.x <= this.max.x && box.max.y >= this.min.y && box.min.y <= this.max.y && box.max.z >= this.min.z && box.min.z <= this.max.z;
+ }
+ /**
+ * Returns `true` if the given bounding sphere intersects with this bounding box.
+ *
+ * @param {Sphere} sphere - The bounding sphere to test.
+ * @return {boolean} Whether the given bounding sphere intersects with this bounding box.
+ */
+ intersectsSphere(sphere) {
+ this.clampPoint(sphere.center, _vector$b);
+ return _vector$b.distanceToSquared(sphere.center) <= sphere.radius * sphere.radius;
+ }
+ /**
+ * Returns `true` if the given plane intersects with this bounding box.
+ *
+ * @param {Plane} plane - The plane to test.
+ * @return {boolean} Whether the given plane intersects with this bounding box.
+ */
+ intersectsPlane(plane) {
+ let min, max;
+ if (plane.normal.x > 0) {
+ min = plane.normal.x * this.min.x;
+ max = plane.normal.x * this.max.x;
+ } else {
+ min = plane.normal.x * this.max.x;
+ max = plane.normal.x * this.min.x;
+ }
+ if (plane.normal.y > 0) {
+ min += plane.normal.y * this.min.y;
+ max += plane.normal.y * this.max.y;
+ } else {
+ min += plane.normal.y * this.max.y;
+ max += plane.normal.y * this.min.y;
+ }
+ if (plane.normal.z > 0) {
+ min += plane.normal.z * this.min.z;
+ max += plane.normal.z * this.max.z;
+ } else {
+ min += plane.normal.z * this.max.z;
+ max += plane.normal.z * this.min.z;
+ }
+ return min <= -plane.constant && max >= -plane.constant;
+ }
+ /**
+ * Returns `true` if the given triangle intersects with this bounding box.
+ *
+ * @param {Triangle} triangle - The triangle to test.
+ * @return {boolean} Whether the given triangle intersects with this bounding box.
+ */
+ intersectsTriangle(triangle) {
+ if (this.isEmpty()) {
+ return false;
+ }
+ this.getCenter(_center);
+ _extents.subVectors(this.max, _center);
+ _v0$2.subVectors(triangle.a, _center);
+ _v1$7.subVectors(triangle.b, _center);
+ _v2$4.subVectors(triangle.c, _center);
+ _f0.subVectors(_v1$7, _v0$2);
+ _f1.subVectors(_v2$4, _v1$7);
+ _f2.subVectors(_v0$2, _v2$4);
+ let axes = [
+ 0,
+ -_f0.z,
+ _f0.y,
+ 0,
+ -_f1.z,
+ _f1.y,
+ 0,
+ -_f2.z,
+ _f2.y,
+ _f0.z,
+ 0,
+ -_f0.x,
+ _f1.z,
+ 0,
+ -_f1.x,
+ _f2.z,
+ 0,
+ -_f2.x,
+ -_f0.y,
+ _f0.x,
+ 0,
+ -_f1.y,
+ _f1.x,
+ 0,
+ -_f2.y,
+ _f2.x,
+ 0
+ ];
+ if (!satForAxes(axes, _v0$2, _v1$7, _v2$4, _extents)) {
+ return false;
+ }
+ axes = [1, 0, 0, 0, 1, 0, 0, 0, 1];
+ if (!satForAxes(axes, _v0$2, _v1$7, _v2$4, _extents)) {
+ return false;
+ }
+ _triangleNormal.crossVectors(_f0, _f1);
+ axes = [_triangleNormal.x, _triangleNormal.y, _triangleNormal.z];
+ return satForAxes(axes, _v0$2, _v1$7, _v2$4, _extents);
+ }
+ /**
+ * Clamps the given point within the bounds of this box.
+ *
+ * @param {Vector3} point - The point to clamp.
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {Vector3} The clamped point.
+ */
+ clampPoint(point, target) {
+ return target.copy(point).clamp(this.min, this.max);
+ }
+ /**
+ * Returns the euclidean distance from any edge of this box to the specified point. If
+ * the given point lies inside of this box, the distance will be `0`.
+ *
+ * @param {Vector3} point - The point to compute the distance to.
+ * @return {number} The euclidean distance.
+ */
+ distanceToPoint(point) {
+ return this.clampPoint(point, _vector$b).distanceTo(point);
+ }
+ /**
+ * Returns a bounding sphere that encloses this bounding box.
+ *
+ * @param {Sphere} target - The target sphere that is used to store the method's result.
+ * @return {Sphere} The bounding sphere that encloses this bounding box.
+ */
+ getBoundingSphere(target) {
+ if (this.isEmpty()) {
+ target.makeEmpty();
+ } else {
+ this.getCenter(target.center);
+ target.radius = this.getSize(_vector$b).length() * 0.5;
+ }
+ return target;
+ }
+ /**
+ * Computes the intersection of this bounding box and the given one, setting the upper
+ * bound of this box to the lesser of the two boxes' upper bounds and the
+ * lower bound of this box to the greater of the two boxes' lower bounds. If
+ * there's no overlap, makes this box empty.
+ *
+ * @param {Box3} box - The bounding box to intersect with.
+ * @return {Box3} A reference to this bounding box.
+ */
+ intersect(box) {
+ this.min.max(box.min);
+ this.max.min(box.max);
+ if (this.isEmpty()) this.makeEmpty();
+ return this;
+ }
+ /**
+ * Computes the union of this box and another and the given one, setting the upper
+ * bound of this box to the greater of the two boxes' upper bounds and the
+ * lower bound of this box to the lesser of the two boxes' lower bounds.
+ *
+ * @param {Box3} box - The bounding box that will be unioned with this instance.
+ * @return {Box3} A reference to this bounding box.
+ */
+ union(box) {
+ this.min.min(box.min);
+ this.max.max(box.max);
+ return this;
+ }
+ /**
+ * Transforms this bounding box by the given 4x4 transformation matrix.
+ *
+ * @param {Matrix4} matrix - The transformation matrix.
+ * @return {Box3} A reference to this bounding box.
+ */
+ applyMatrix4(matrix) {
+ if (this.isEmpty()) return this;
+ _points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(matrix);
+ _points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(matrix);
+ _points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(matrix);
+ _points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(matrix);
+ _points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(matrix);
+ _points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(matrix);
+ _points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(matrix);
+ _points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(matrix);
+ this.setFromPoints(_points);
+ return this;
+ }
+ /**
+ * Adds the given offset to both the upper and lower bounds of this bounding box,
+ * effectively moving it in 3D space.
+ *
+ * @param {Vector3} offset - The offset that should be used to translate the bounding box.
+ * @return {Box3} A reference to this bounding box.
+ */
+ translate(offset) {
+ this.min.add(offset);
+ this.max.add(offset);
+ return this;
+ }
+ /**
+ * Returns `true` if this bounding box is equal with the given one.
+ *
+ * @param {Box3} box - The box to test for equality.
+ * @return {boolean} Whether this bounding box is equal with the given one.
+ */
+ equals(box) {
+ return box.min.equals(this.min) && box.max.equals(this.max);
+ }
+ /**
+ * Returns a serialized structure of the bounding box.
+ *
+ * @return {Object} Serialized structure with fields representing the object state.
+ */
+ toJSON() {
+ return {
+ min: this.min.toArray(),
+ max: this.max.toArray()
+ };
+ }
+ /**
+ * Returns a serialized structure of the bounding box.
+ *
+ * @param {Object} json - The serialized json to set the box from.
+ * @return {Box3} A reference to this bounding box.
+ */
+ fromJSON(json) {
+ this.min.fromArray(json.min);
+ this.max.fromArray(json.max);
+ return this;
+ }
+};
+var _points = [
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3()
+];
+var _vector$b = new Vector3();
+var _box$4 = new Box3();
+var _v0$2 = new Vector3();
+var _v1$7 = new Vector3();
+var _v2$4 = new Vector3();
+var _f0 = new Vector3();
+var _f1 = new Vector3();
+var _f2 = new Vector3();
+var _center = new Vector3();
+var _extents = new Vector3();
+var _triangleNormal = new Vector3();
+var _testAxis = new Vector3();
+function satForAxes(axes, v0, v1, v2, extents) {
+ for (let i = 0, j = axes.length - 3; i <= j; i += 3) {
+ _testAxis.fromArray(axes, i);
+ const r = extents.x * Math.abs(_testAxis.x) + extents.y * Math.abs(_testAxis.y) + extents.z * Math.abs(_testAxis.z);
+ const p0 = v0.dot(_testAxis);
+ const p1 = v1.dot(_testAxis);
+ const p2 = v2.dot(_testAxis);
+ if (Math.max(-Math.max(p0, p1, p2), Math.min(p0, p1, p2)) > r) {
+ return false;
+ }
+ }
+ return true;
+}
+var _box$3 = new Box3();
+var _v1$6 = new Vector3();
+var _v2$3 = new Vector3();
+var Sphere = class {
+ /**
+ * Constructs a new sphere.
+ *
+ * @param {Vector3} [center=(0,0,0)] - The center of the sphere
+ * @param {number} [radius=-1] - The radius of the sphere.
+ */
+ constructor(center = new Vector3(), radius = -1) {
+ this.isSphere = true;
+ this.center = center;
+ this.radius = radius;
+ }
+ /**
+ * Sets the sphere's components by copying the given values.
+ *
+ * @param {Vector3} center - The center.
+ * @param {number} radius - The radius.
+ * @return {Sphere} A reference to this sphere.
+ */
+ set(center, radius) {
+ this.center.copy(center);
+ this.radius = radius;
+ return this;
+ }
+ /**
+ * Computes the minimum bounding sphere for list of points.
+ * If the optional center point is given, it is used as the sphere's
+ * center. Otherwise, the center of the axis-aligned bounding box
+ * encompassing the points is calculated.
+ *
+ * @param {Array} points - A list of points in 3D space.
+ * @param {Vector3} [optionalCenter] - The center of the sphere.
+ * @return {Sphere} A reference to this sphere.
+ */
+ setFromPoints(points, optionalCenter) {
+ const center = this.center;
+ if (optionalCenter !== void 0) {
+ center.copy(optionalCenter);
+ } else {
+ _box$3.setFromPoints(points).getCenter(center);
+ }
+ let maxRadiusSq = 0;
+ for (let i = 0, il = points.length; i < il; i++) {
+ maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(points[i]));
+ }
+ this.radius = Math.sqrt(maxRadiusSq);
+ return this;
+ }
+ /**
+ * Copies the values of the given sphere to this instance.
+ *
+ * @param {Sphere} sphere - The sphere to copy.
+ * @return {Sphere} A reference to this sphere.
+ */
+ copy(sphere) {
+ this.center.copy(sphere.center);
+ this.radius = sphere.radius;
+ return this;
+ }
+ /**
+ * Returns `true` if the sphere is empty (the radius set to a negative number).
+ *
+ * Spheres with a radius of `0` contain only their center point and are not
+ * considered to be empty.
+ *
+ * @return {boolean} Whether this sphere is empty or not.
+ */
+ isEmpty() {
+ return this.radius < 0;
+ }
+ /**
+ * Makes this sphere empty which means in encloses a zero space in 3D.
+ *
+ * @return {Sphere} A reference to this sphere.
+ */
+ makeEmpty() {
+ this.center.set(0, 0, 0);
+ this.radius = -1;
+ return this;
+ }
+ /**
+ * Returns `true` if this sphere contains the given point inclusive of
+ * the surface of the sphere.
+ *
+ * @param {Vector3} point - The point to check.
+ * @return {boolean} Whether this sphere contains the given point or not.
+ */
+ containsPoint(point) {
+ return point.distanceToSquared(this.center) <= this.radius * this.radius;
+ }
+ /**
+ * Returns the closest distance from the boundary of the sphere to the
+ * given point. If the sphere contains the point, the distance will
+ * be negative.
+ *
+ * @param {Vector3} point - The point to compute the distance to.
+ * @return {number} The distance to the point.
+ */
+ distanceToPoint(point) {
+ return point.distanceTo(this.center) - this.radius;
+ }
+ /**
+ * Returns `true` if this sphere intersects with the given one.
+ *
+ * @param {Sphere} sphere - The sphere to test.
+ * @return {boolean} Whether this sphere intersects with the given one or not.
+ */
+ intersectsSphere(sphere) {
+ const radiusSum = this.radius + sphere.radius;
+ return sphere.center.distanceToSquared(this.center) <= radiusSum * radiusSum;
+ }
+ /**
+ * Returns `true` if this sphere intersects with the given box.
+ *
+ * @param {Box3} box - The box to test.
+ * @return {boolean} Whether this sphere intersects with the given box or not.
+ */
+ intersectsBox(box) {
+ return box.intersectsSphere(this);
+ }
+ /**
+ * Returns `true` if this sphere intersects with the given plane.
+ *
+ * @param {Plane} plane - The plane to test.
+ * @return {boolean} Whether this sphere intersects with the given plane or not.
+ */
+ intersectsPlane(plane) {
+ return Math.abs(plane.distanceToPoint(this.center)) <= this.radius;
+ }
+ /**
+ * Clamps a point within the sphere. If the point is outside the sphere, it
+ * will clamp it to the closest point on the edge of the sphere. Points
+ * already inside the sphere will not be affected.
+ *
+ * @param {Vector3} point - The plane to clamp.
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {Vector3} The clamped point.
+ */
+ clampPoint(point, target) {
+ const deltaLengthSq = this.center.distanceToSquared(point);
+ target.copy(point);
+ if (deltaLengthSq > this.radius * this.radius) {
+ target.sub(this.center).normalize();
+ target.multiplyScalar(this.radius).add(this.center);
+ }
+ return target;
+ }
+ /**
+ * Returns a bounding box that encloses this sphere.
+ *
+ * @param {Box3} target - The target box that is used to store the method's result.
+ * @return {Box3} The bounding box that encloses this sphere.
+ */
+ getBoundingBox(target) {
+ if (this.isEmpty()) {
+ target.makeEmpty();
+ return target;
+ }
+ target.set(this.center, this.center);
+ target.expandByScalar(this.radius);
+ return target;
+ }
+ /**
+ * Transforms this sphere with the given 4x4 transformation matrix.
+ *
+ * @param {Matrix4} matrix - The transformation matrix.
+ * @return {Sphere} A reference to this sphere.
+ */
+ applyMatrix4(matrix) {
+ this.center.applyMatrix4(matrix);
+ this.radius = this.radius * matrix.getMaxScaleOnAxis();
+ return this;
+ }
+ /**
+ * Translates the sphere's center by the given offset.
+ *
+ * @param {Vector3} offset - The offset.
+ * @return {Sphere} A reference to this sphere.
+ */
+ translate(offset) {
+ this.center.add(offset);
+ return this;
+ }
+ /**
+ * Expands the boundaries of this sphere to include the given point.
+ *
+ * @param {Vector3} point - The point to include.
+ * @return {Sphere} A reference to this sphere.
+ */
+ expandByPoint(point) {
+ if (this.isEmpty()) {
+ this.center.copy(point);
+ this.radius = 0;
+ return this;
+ }
+ _v1$6.subVectors(point, this.center);
+ const lengthSq = _v1$6.lengthSq();
+ if (lengthSq > this.radius * this.radius) {
+ const length = Math.sqrt(lengthSq);
+ const delta = (length - this.radius) * 0.5;
+ this.center.addScaledVector(_v1$6, delta / length);
+ this.radius += delta;
+ }
+ return this;
+ }
+ /**
+ * Expands this sphere to enclose both the original sphere and the given sphere.
+ *
+ * @param {Sphere} sphere - The sphere to include.
+ * @return {Sphere} A reference to this sphere.
+ */
+ union(sphere) {
+ if (sphere.isEmpty()) {
+ return this;
+ }
+ if (this.isEmpty()) {
+ this.copy(sphere);
+ return this;
+ }
+ if (this.center.equals(sphere.center) === true) {
+ this.radius = Math.max(this.radius, sphere.radius);
+ } else {
+ _v2$3.subVectors(sphere.center, this.center).setLength(sphere.radius);
+ this.expandByPoint(_v1$6.copy(sphere.center).add(_v2$3));
+ this.expandByPoint(_v1$6.copy(sphere.center).sub(_v2$3));
+ }
+ return this;
+ }
+ /**
+ * Returns `true` if this sphere is equal with the given one.
+ *
+ * @param {Sphere} sphere - The sphere to test for equality.
+ * @return {boolean} Whether this bounding sphere is equal with the given one.
+ */
+ equals(sphere) {
+ return sphere.center.equals(this.center) && sphere.radius === this.radius;
+ }
+ /**
+ * Returns a new sphere with copied values from this instance.
+ *
+ * @return {Sphere} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor().copy(this);
+ }
+ /**
+ * Returns a serialized structure of the bounding sphere.
+ *
+ * @return {Object} Serialized structure with fields representing the object state.
+ */
+ toJSON() {
+ return {
+ radius: this.radius,
+ center: this.center.toArray()
+ };
+ }
+ /**
+ * Returns a serialized structure of the bounding sphere.
+ *
+ * @param {Object} json - The serialized json to set the sphere from.
+ * @return {Sphere} A reference to this bounding sphere.
+ */
+ fromJSON(json) {
+ this.radius = json.radius;
+ this.center.fromArray(json.center);
+ return this;
+ }
+};
+var _vector$a = new Vector3();
+var _segCenter = new Vector3();
+var _segDir = new Vector3();
+var _diff = new Vector3();
+var _edge1 = new Vector3();
+var _edge2 = new Vector3();
+var _normal$1 = new Vector3();
+var Ray = class {
+ /**
+ * Constructs a new ray.
+ *
+ * @param {Vector3} [origin=(0,0,0)] - The origin of the ray.
+ * @param {Vector3} [direction=(0,0,-1)] - The (normalized) direction of the ray.
+ */
+ constructor(origin = new Vector3(), direction = new Vector3(0, 0, -1)) {
+ this.origin = origin;
+ this.direction = direction;
+ }
+ /**
+ * Sets the ray's components by copying the given values.
+ *
+ * @param {Vector3} origin - The origin.
+ * @param {Vector3} direction - The direction.
+ * @return {Ray} A reference to this ray.
+ */
+ set(origin, direction) {
+ this.origin.copy(origin);
+ this.direction.copy(direction);
+ return this;
+ }
+ /**
+ * Copies the values of the given ray to this instance.
+ *
+ * @param {Ray} ray - The ray to copy.
+ * @return {Ray} A reference to this ray.
+ */
+ copy(ray) {
+ this.origin.copy(ray.origin);
+ this.direction.copy(ray.direction);
+ return this;
+ }
+ /**
+ * Returns a vector that is located at a given distance along this ray.
+ *
+ * @param {number} t - The distance along the ray to retrieve a position for.
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {Vector3} A position on the ray.
+ */
+ at(t, target) {
+ return target.copy(this.origin).addScaledVector(this.direction, t);
+ }
+ /**
+ * Adjusts the direction of the ray to point at the given vector in world space.
+ *
+ * @param {Vector3} v - The target position.
+ * @return {Ray} A reference to this ray.
+ */
+ lookAt(v) {
+ this.direction.copy(v).sub(this.origin).normalize();
+ return this;
+ }
+ /**
+ * Shift the origin of this ray along its direction by the given distance.
+ *
+ * @param {number} t - The distance along the ray to interpolate.
+ * @return {Ray} A reference to this ray.
+ */
+ recast(t) {
+ this.origin.copy(this.at(t, _vector$a));
+ return this;
+ }
+ /**
+ * Returns the point along this ray that is closest to the given point.
+ *
+ * @param {Vector3} point - A point in 3D space to get the closet location on the ray for.
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {Vector3} The closest point on this ray.
+ */
+ closestPointToPoint(point, target) {
+ target.subVectors(point, this.origin);
+ const directionDistance = target.dot(this.direction);
+ if (directionDistance < 0) {
+ return target.copy(this.origin);
+ }
+ return target.copy(this.origin).addScaledVector(this.direction, directionDistance);
+ }
+ /**
+ * Returns the distance of the closest approach between this ray and the given point.
+ *
+ * @param {Vector3} point - A point in 3D space to compute the distance to.
+ * @return {number} The distance.
+ */
+ distanceToPoint(point) {
+ return Math.sqrt(this.distanceSqToPoint(point));
+ }
+ /**
+ * Returns the squared distance of the closest approach between this ray and the given point.
+ *
+ * @param {Vector3} point - A point in 3D space to compute the distance to.
+ * @return {number} The squared distance.
+ */
+ distanceSqToPoint(point) {
+ const directionDistance = _vector$a.subVectors(point, this.origin).dot(this.direction);
+ if (directionDistance < 0) {
+ return this.origin.distanceToSquared(point);
+ }
+ _vector$a.copy(this.origin).addScaledVector(this.direction, directionDistance);
+ return _vector$a.distanceToSquared(point);
+ }
+ /**
+ * Returns the squared distance between this ray and the given line segment.
+ *
+ * @param {Vector3} v0 - The start point of the line segment.
+ * @param {Vector3} v1 - The end point of the line segment.
+ * @param {Vector3} [optionalPointOnRay] - When provided, it receives the point on this ray that is closest to the segment.
+ * @param {Vector3} [optionalPointOnSegment] - When provided, it receives the point on the line segment that is closest to this ray.
+ * @return {number} The squared distance.
+ */
+ distanceSqToSegment(v0, v1, optionalPointOnRay, optionalPointOnSegment) {
+ _segCenter.copy(v0).add(v1).multiplyScalar(0.5);
+ _segDir.copy(v1).sub(v0).normalize();
+ _diff.copy(this.origin).sub(_segCenter);
+ const segExtent = v0.distanceTo(v1) * 0.5;
+ const a01 = -this.direction.dot(_segDir);
+ const b0 = _diff.dot(this.direction);
+ const b1 = -_diff.dot(_segDir);
+ const c = _diff.lengthSq();
+ const det = Math.abs(1 - a01 * a01);
+ let s0, s1, sqrDist, extDet;
+ if (det > 0) {
+ s0 = a01 * b1 - b0;
+ s1 = a01 * b0 - b1;
+ extDet = segExtent * det;
+ if (s0 >= 0) {
+ if (s1 >= -extDet) {
+ if (s1 <= extDet) {
+ const invDet = 1 / det;
+ s0 *= invDet;
+ s1 *= invDet;
+ sqrDist = s0 * (s0 + a01 * s1 + 2 * b0) + s1 * (a01 * s0 + s1 + 2 * b1) + c;
+ } else {
+ s1 = segExtent;
+ s0 = Math.max(0, -(a01 * s1 + b0));
+ sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
+ }
+ } else {
+ s1 = -segExtent;
+ s0 = Math.max(0, -(a01 * s1 + b0));
+ sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
+ }
+ } else {
+ if (s1 <= -extDet) {
+ s0 = Math.max(0, -(-a01 * segExtent + b0));
+ s1 = s0 > 0 ? -segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);
+ sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
+ } else if (s1 <= extDet) {
+ s0 = 0;
+ s1 = Math.min(Math.max(-segExtent, -b1), segExtent);
+ sqrDist = s1 * (s1 + 2 * b1) + c;
+ } else {
+ s0 = Math.max(0, -(a01 * segExtent + b0));
+ s1 = s0 > 0 ? segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);
+ sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
+ }
+ }
+ } else {
+ s1 = a01 > 0 ? -segExtent : segExtent;
+ s0 = Math.max(0, -(a01 * s1 + b0));
+ sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
+ }
+ if (optionalPointOnRay) {
+ optionalPointOnRay.copy(this.origin).addScaledVector(this.direction, s0);
+ }
+ if (optionalPointOnSegment) {
+ optionalPointOnSegment.copy(_segCenter).addScaledVector(_segDir, s1);
+ }
+ return sqrDist;
+ }
+ /**
+ * Intersects this ray with the given sphere, returning the intersection
+ * point or `null` if there is no intersection.
+ *
+ * @param {Sphere} sphere - The sphere to intersect.
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {?Vector3} The intersection point.
+ */
+ intersectSphere(sphere, target) {
+ _vector$a.subVectors(sphere.center, this.origin);
+ const tca = _vector$a.dot(this.direction);
+ const d2 = _vector$a.dot(_vector$a) - tca * tca;
+ const radius2 = sphere.radius * sphere.radius;
+ if (d2 > radius2) return null;
+ const thc = Math.sqrt(radius2 - d2);
+ const t0 = tca - thc;
+ const t1 = tca + thc;
+ if (t1 < 0) return null;
+ if (t0 < 0) return this.at(t1, target);
+ return this.at(t0, target);
+ }
+ /**
+ * Returns `true` if this ray intersects with the given sphere.
+ *
+ * @param {Sphere} sphere - The sphere to intersect.
+ * @return {boolean} Whether this ray intersects with the given sphere or not.
+ */
+ intersectsSphere(sphere) {
+ if (sphere.radius < 0) return false;
+ return this.distanceSqToPoint(sphere.center) <= sphere.radius * sphere.radius;
+ }
+ /**
+ * Computes the distance from the ray's origin to the given plane. Returns `null` if the ray
+ * does not intersect with the plane.
+ *
+ * @param {Plane} plane - The plane to compute the distance to.
+ * @return {?number} Whether this ray intersects with the given sphere or not.
+ */
+ distanceToPlane(plane) {
+ const denominator = plane.normal.dot(this.direction);
+ if (denominator === 0) {
+ if (plane.distanceToPoint(this.origin) === 0) {
+ return 0;
+ }
+ return null;
+ }
+ const t = -(this.origin.dot(plane.normal) + plane.constant) / denominator;
+ return t >= 0 ? t : null;
+ }
+ /**
+ * Intersects this ray with the given plane, returning the intersection
+ * point or `null` if there is no intersection.
+ *
+ * @param {Plane} plane - The plane to intersect.
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {?Vector3} The intersection point.
+ */
+ intersectPlane(plane, target) {
+ const t = this.distanceToPlane(plane);
+ if (t === null) {
+ return null;
+ }
+ return this.at(t, target);
+ }
+ /**
+ * Returns `true` if this ray intersects with the given plane.
+ *
+ * @param {Plane} plane - The plane to intersect.
+ * @return {boolean} Whether this ray intersects with the given plane or not.
+ */
+ intersectsPlane(plane) {
+ const distToPoint = plane.distanceToPoint(this.origin);
+ if (distToPoint === 0) {
+ return true;
+ }
+ const denominator = plane.normal.dot(this.direction);
+ if (denominator * distToPoint < 0) {
+ return true;
+ }
+ return false;
+ }
+ /**
+ * Intersects this ray with the given bounding box, returning the intersection
+ * point or `null` if there is no intersection.
+ *
+ * @param {Box3} box - The box to intersect.
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {?Vector3} The intersection point.
+ */
+ intersectBox(box, target) {
+ let tmin, tmax, tymin, tymax, tzmin, tzmax;
+ const invdirx = 1 / this.direction.x, invdiry = 1 / this.direction.y, invdirz = 1 / this.direction.z;
+ const origin = this.origin;
+ if (invdirx >= 0) {
+ tmin = (box.min.x - origin.x) * invdirx;
+ tmax = (box.max.x - origin.x) * invdirx;
+ } else {
+ tmin = (box.max.x - origin.x) * invdirx;
+ tmax = (box.min.x - origin.x) * invdirx;
+ }
+ if (invdiry >= 0) {
+ tymin = (box.min.y - origin.y) * invdiry;
+ tymax = (box.max.y - origin.y) * invdiry;
+ } else {
+ tymin = (box.max.y - origin.y) * invdiry;
+ tymax = (box.min.y - origin.y) * invdiry;
+ }
+ if (tmin > tymax || tymin > tmax) return null;
+ if (tymin > tmin || isNaN(tmin)) tmin = tymin;
+ if (tymax < tmax || isNaN(tmax)) tmax = tymax;
+ if (invdirz >= 0) {
+ tzmin = (box.min.z - origin.z) * invdirz;
+ tzmax = (box.max.z - origin.z) * invdirz;
+ } else {
+ tzmin = (box.max.z - origin.z) * invdirz;
+ tzmax = (box.min.z - origin.z) * invdirz;
+ }
+ if (tmin > tzmax || tzmin > tmax) return null;
+ if (tzmin > tmin || tmin !== tmin) tmin = tzmin;
+ if (tzmax < tmax || tmax !== tmax) tmax = tzmax;
+ if (tmax < 0) return null;
+ return this.at(tmin >= 0 ? tmin : tmax, target);
+ }
+ /**
+ * Returns `true` if this ray intersects with the given box.
+ *
+ * @param {Box3} box - The box to intersect.
+ * @return {boolean} Whether this ray intersects with the given box or not.
+ */
+ intersectsBox(box) {
+ return this.intersectBox(box, _vector$a) !== null;
+ }
+ /**
+ * Intersects this ray with the given triangle, returning the intersection
+ * point or `null` if there is no intersection.
+ *
+ * @param {Vector3} a - The first vertex of the triangle.
+ * @param {Vector3} b - The second vertex of the triangle.
+ * @param {Vector3} c - The third vertex of the triangle.
+ * @param {boolean} backfaceCulling - Whether to use backface culling or not.
+ * @param {Vector3} target - The target vector that is used to store the method's result.
+ * @return {?Vector3} The intersection point.
+ */
+ intersectTriangle(a, b, c, backfaceCulling, target) {
+ _edge1.subVectors(b, a);
+ _edge2.subVectors(c, a);
+ _normal$1.crossVectors(_edge1, _edge2);
+ let DdN = this.direction.dot(_normal$1);
+ let sign2;
+ if (DdN > 0) {
+ if (backfaceCulling) return null;
+ sign2 = 1;
+ } else if (DdN < 0) {
+ sign2 = -1;
+ DdN = -DdN;
+ } else {
+ return null;
+ }
+ _diff.subVectors(this.origin, a);
+ const DdQxE2 = sign2 * this.direction.dot(_edge2.crossVectors(_diff, _edge2));
+ if (DdQxE2 < 0) {
+ return null;
+ }
+ const DdE1xQ = sign2 * this.direction.dot(_edge1.cross(_diff));
+ if (DdE1xQ < 0) {
+ return null;
+ }
+ if (DdQxE2 + DdE1xQ > DdN) {
+ return null;
+ }
+ const QdN = -sign2 * _diff.dot(_normal$1);
+ if (QdN < 0) {
+ return null;
+ }
+ return this.at(QdN / DdN, target);
+ }
+ /**
+ * Transforms this ray with the given 4x4 transformation matrix.
+ *
+ * @param {Matrix4} matrix4 - The transformation matrix.
+ * @return {Ray} A reference to this ray.
+ */
+ applyMatrix4(matrix4) {
+ this.origin.applyMatrix4(matrix4);
+ this.direction.transformDirection(matrix4);
+ return this;
+ }
+ /**
+ * Returns `true` if this ray is equal with the given one.
+ *
+ * @param {Ray} ray - The ray to test for equality.
+ * @return {boolean} Whether this ray is equal with the given one.
+ */
+ equals(ray) {
+ return ray.origin.equals(this.origin) && ray.direction.equals(this.direction);
+ }
+ /**
+ * Returns a new ray with copied values from this instance.
+ *
+ * @return {Ray} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor().copy(this);
+ }
+};
+var Matrix4 = class _Matrix4 {
+ /**
+ * Constructs a new 4x4 matrix. The arguments are supposed to be
+ * in row-major order. If no arguments are provided, the constructor
+ * initializes the matrix as an identity matrix.
+ *
+ * @param {number} [n11] - 1-1 matrix element.
+ * @param {number} [n12] - 1-2 matrix element.
+ * @param {number} [n13] - 1-3 matrix element.
+ * @param {number} [n14] - 1-4 matrix element.
+ * @param {number} [n21] - 2-1 matrix element.
+ * @param {number} [n22] - 2-2 matrix element.
+ * @param {number} [n23] - 2-3 matrix element.
+ * @param {number} [n24] - 2-4 matrix element.
+ * @param {number} [n31] - 3-1 matrix element.
+ * @param {number} [n32] - 3-2 matrix element.
+ * @param {number} [n33] - 3-3 matrix element.
+ * @param {number} [n34] - 3-4 matrix element.
+ * @param {number} [n41] - 4-1 matrix element.
+ * @param {number} [n42] - 4-2 matrix element.
+ * @param {number} [n43] - 4-3 matrix element.
+ * @param {number} [n44] - 4-4 matrix element.
+ */
+ constructor(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
+ _Matrix4.prototype.isMatrix4 = true;
+ this.elements = [
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ ];
+ if (n11 !== void 0) {
+ this.set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44);
+ }
+ }
+ /**
+ * Sets the elements of the matrix.The arguments are supposed to be
+ * in row-major order.
+ *
+ * @param {number} [n11] - 1-1 matrix element.
+ * @param {number} [n12] - 1-2 matrix element.
+ * @param {number} [n13] - 1-3 matrix element.
+ * @param {number} [n14] - 1-4 matrix element.
+ * @param {number} [n21] - 2-1 matrix element.
+ * @param {number} [n22] - 2-2 matrix element.
+ * @param {number} [n23] - 2-3 matrix element.
+ * @param {number} [n24] - 2-4 matrix element.
+ * @param {number} [n31] - 3-1 matrix element.
+ * @param {number} [n32] - 3-2 matrix element.
+ * @param {number} [n33] - 3-3 matrix element.
+ * @param {number} [n34] - 3-4 matrix element.
+ * @param {number} [n41] - 4-1 matrix element.
+ * @param {number} [n42] - 4-2 matrix element.
+ * @param {number} [n43] - 4-3 matrix element.
+ * @param {number} [n44] - 4-4 matrix element.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
+ const te = this.elements;
+ te[0] = n11;
+ te[4] = n12;
+ te[8] = n13;
+ te[12] = n14;
+ te[1] = n21;
+ te[5] = n22;
+ te[9] = n23;
+ te[13] = n24;
+ te[2] = n31;
+ te[6] = n32;
+ te[10] = n33;
+ te[14] = n34;
+ te[3] = n41;
+ te[7] = n42;
+ te[11] = n43;
+ te[15] = n44;
+ return this;
+ }
+ /**
+ * Sets this matrix to the 4x4 identity matrix.
+ *
+ * @return {Matrix4} A reference to this matrix.
+ */
+ identity() {
+ this.set(
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Returns a matrix with copied values from this instance.
+ *
+ * @return {Matrix4} A clone of this instance.
+ */
+ clone() {
+ return new _Matrix4().fromArray(this.elements);
+ }
+ /**
+ * Copies the values of the given matrix to this instance.
+ *
+ * @param {Matrix4} m - The matrix to copy.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ copy(m) {
+ const te = this.elements;
+ const me = m.elements;
+ te[0] = me[0];
+ te[1] = me[1];
+ te[2] = me[2];
+ te[3] = me[3];
+ te[4] = me[4];
+ te[5] = me[5];
+ te[6] = me[6];
+ te[7] = me[7];
+ te[8] = me[8];
+ te[9] = me[9];
+ te[10] = me[10];
+ te[11] = me[11];
+ te[12] = me[12];
+ te[13] = me[13];
+ te[14] = me[14];
+ te[15] = me[15];
+ return this;
+ }
+ /**
+ * Copies the translation component of the given matrix
+ * into this matrix's translation component.
+ *
+ * @param {Matrix4} m - The matrix to copy the translation component.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ copyPosition(m) {
+ const te = this.elements, me = m.elements;
+ te[12] = me[12];
+ te[13] = me[13];
+ te[14] = me[14];
+ return this;
+ }
+ /**
+ * Set the upper 3x3 elements of this matrix to the values of given 3x3 matrix.
+ *
+ * @param {Matrix3} m - The 3x3 matrix.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ setFromMatrix3(m) {
+ const me = m.elements;
+ this.set(
+ me[0],
+ me[3],
+ me[6],
+ 0,
+ me[1],
+ me[4],
+ me[7],
+ 0,
+ me[2],
+ me[5],
+ me[8],
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Extracts the basis of this matrix into the three axis vectors provided.
+ *
+ * @param {Vector3} xAxis - The basis's x axis.
+ * @param {Vector3} yAxis - The basis's y axis.
+ * @param {Vector3} zAxis - The basis's z axis.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ extractBasis(xAxis, yAxis, zAxis) {
+ if (this.determinant() === 0) {
+ xAxis.set(1, 0, 0);
+ yAxis.set(0, 1, 0);
+ zAxis.set(0, 0, 1);
+ return this;
+ }
+ xAxis.setFromMatrixColumn(this, 0);
+ yAxis.setFromMatrixColumn(this, 1);
+ zAxis.setFromMatrixColumn(this, 2);
+ return this;
+ }
+ /**
+ * Sets the given basis vectors to this matrix.
+ *
+ * @param {Vector3} xAxis - The basis's x axis.
+ * @param {Vector3} yAxis - The basis's y axis.
+ * @param {Vector3} zAxis - The basis's z axis.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeBasis(xAxis, yAxis, zAxis) {
+ this.set(
+ xAxis.x,
+ yAxis.x,
+ zAxis.x,
+ 0,
+ xAxis.y,
+ yAxis.y,
+ zAxis.y,
+ 0,
+ xAxis.z,
+ yAxis.z,
+ zAxis.z,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Extracts the rotation component of the given matrix
+ * into this matrix's rotation component.
+ *
+ * Note: This method does not support reflection matrices.
+ *
+ * @param {Matrix4} m - The matrix.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ extractRotation(m) {
+ if (m.determinant() === 0) {
+ return this.identity();
+ }
+ const te = this.elements;
+ const me = m.elements;
+ const scaleX = 1 / _v1$5.setFromMatrixColumn(m, 0).length();
+ const scaleY = 1 / _v1$5.setFromMatrixColumn(m, 1).length();
+ const scaleZ = 1 / _v1$5.setFromMatrixColumn(m, 2).length();
+ te[0] = me[0] * scaleX;
+ te[1] = me[1] * scaleX;
+ te[2] = me[2] * scaleX;
+ te[3] = 0;
+ te[4] = me[4] * scaleY;
+ te[5] = me[5] * scaleY;
+ te[6] = me[6] * scaleY;
+ te[7] = 0;
+ te[8] = me[8] * scaleZ;
+ te[9] = me[9] * scaleZ;
+ te[10] = me[10] * scaleZ;
+ te[11] = 0;
+ te[12] = 0;
+ te[13] = 0;
+ te[14] = 0;
+ te[15] = 1;
+ return this;
+ }
+ /**
+ * Sets the rotation component (the upper left 3x3 matrix) of this matrix to
+ * the rotation specified by the given Euler angles. The rest of
+ * the matrix is set to the identity. Depending on the {@link Euler#order},
+ * there are six possible outcomes. See [this page](https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix)
+ * for a complete list.
+ *
+ * @param {Euler} euler - The Euler angles.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeRotationFromEuler(euler) {
+ const te = this.elements;
+ const x = euler.x, y = euler.y, z = euler.z;
+ const a = Math.cos(x), b = Math.sin(x);
+ const c = Math.cos(y), d = Math.sin(y);
+ const e = Math.cos(z), f = Math.sin(z);
+ if (euler.order === "XYZ") {
+ const ae = a * e, af = a * f, be = b * e, bf = b * f;
+ te[0] = c * e;
+ te[4] = -c * f;
+ te[8] = d;
+ te[1] = af + be * d;
+ te[5] = ae - bf * d;
+ te[9] = -b * c;
+ te[2] = bf - ae * d;
+ te[6] = be + af * d;
+ te[10] = a * c;
+ } else if (euler.order === "YXZ") {
+ const ce = c * e, cf = c * f, de = d * e, df = d * f;
+ te[0] = ce + df * b;
+ te[4] = de * b - cf;
+ te[8] = a * d;
+ te[1] = a * f;
+ te[5] = a * e;
+ te[9] = -b;
+ te[2] = cf * b - de;
+ te[6] = df + ce * b;
+ te[10] = a * c;
+ } else if (euler.order === "ZXY") {
+ const ce = c * e, cf = c * f, de = d * e, df = d * f;
+ te[0] = ce - df * b;
+ te[4] = -a * f;
+ te[8] = de + cf * b;
+ te[1] = cf + de * b;
+ te[5] = a * e;
+ te[9] = df - ce * b;
+ te[2] = -a * d;
+ te[6] = b;
+ te[10] = a * c;
+ } else if (euler.order === "ZYX") {
+ const ae = a * e, af = a * f, be = b * e, bf = b * f;
+ te[0] = c * e;
+ te[4] = be * d - af;
+ te[8] = ae * d + bf;
+ te[1] = c * f;
+ te[5] = bf * d + ae;
+ te[9] = af * d - be;
+ te[2] = -d;
+ te[6] = b * c;
+ te[10] = a * c;
+ } else if (euler.order === "YZX") {
+ const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+ te[0] = c * e;
+ te[4] = bd - ac * f;
+ te[8] = bc * f + ad;
+ te[1] = f;
+ te[5] = a * e;
+ te[9] = -b * e;
+ te[2] = -d * e;
+ te[6] = ad * f + bc;
+ te[10] = ac - bd * f;
+ } else if (euler.order === "XZY") {
+ const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+ te[0] = c * e;
+ te[4] = -f;
+ te[8] = d * e;
+ te[1] = ac * f + bd;
+ te[5] = a * e;
+ te[9] = ad * f - bc;
+ te[2] = bc * f - ad;
+ te[6] = b * e;
+ te[10] = bd * f + ac;
+ }
+ te[3] = 0;
+ te[7] = 0;
+ te[11] = 0;
+ te[12] = 0;
+ te[13] = 0;
+ te[14] = 0;
+ te[15] = 1;
+ return this;
+ }
+ /**
+ * Sets the rotation component of this matrix to the rotation specified by
+ * the given Quaternion as outlined [here](https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion)
+ * The rest of the matrix is set to the identity.
+ *
+ * @param {Quaternion} q - The Quaternion.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeRotationFromQuaternion(q) {
+ return this.compose(_zero, q, _one);
+ }
+ /**
+ * Sets the rotation component of the transformation matrix, looking from `eye` towards
+ * `target`, and oriented by the up-direction.
+ *
+ * @param {Vector3} eye - The eye vector.
+ * @param {Vector3} target - The target vector.
+ * @param {Vector3} up - The up vector.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ lookAt(eye, target, up) {
+ const te = this.elements;
+ _z.subVectors(eye, target);
+ if (_z.lengthSq() === 0) {
+ _z.z = 1;
+ }
+ _z.normalize();
+ _x.crossVectors(up, _z);
+ if (_x.lengthSq() === 0) {
+ if (Math.abs(up.z) === 1) {
+ _z.x += 1e-4;
+ } else {
+ _z.z += 1e-4;
+ }
+ _z.normalize();
+ _x.crossVectors(up, _z);
+ }
+ _x.normalize();
+ _y.crossVectors(_z, _x);
+ te[0] = _x.x;
+ te[4] = _y.x;
+ te[8] = _z.x;
+ te[1] = _x.y;
+ te[5] = _y.y;
+ te[9] = _z.y;
+ te[2] = _x.z;
+ te[6] = _y.z;
+ te[10] = _z.z;
+ return this;
+ }
+ /**
+ * Post-multiplies this matrix by the given 4x4 matrix.
+ *
+ * @param {Matrix4} m - The matrix to multiply with.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ multiply(m) {
+ return this.multiplyMatrices(this, m);
+ }
+ /**
+ * Pre-multiplies this matrix by the given 4x4 matrix.
+ *
+ * @param {Matrix4} m - The matrix to multiply with.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ premultiply(m) {
+ return this.multiplyMatrices(m, this);
+ }
+ /**
+ * Multiples the given 4x4 matrices and stores the result
+ * in this matrix.
+ *
+ * @param {Matrix4} a - The first matrix.
+ * @param {Matrix4} b - The second matrix.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ multiplyMatrices(a, b) {
+ const ae = a.elements;
+ const be = b.elements;
+ const te = this.elements;
+ const a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
+ const a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
+ const a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
+ const a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
+ const b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
+ const b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
+ const b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
+ const b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
+ te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
+ te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
+ te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
+ te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
+ te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
+ te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
+ te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
+ te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
+ te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
+ te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
+ te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
+ te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
+ te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
+ te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
+ te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
+ te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
+ return this;
+ }
+ /**
+ * Multiplies every component of the matrix by the given scalar.
+ *
+ * @param {number} s - The scalar.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ multiplyScalar(s) {
+ const te = this.elements;
+ te[0] *= s;
+ te[4] *= s;
+ te[8] *= s;
+ te[12] *= s;
+ te[1] *= s;
+ te[5] *= s;
+ te[9] *= s;
+ te[13] *= s;
+ te[2] *= s;
+ te[6] *= s;
+ te[10] *= s;
+ te[14] *= s;
+ te[3] *= s;
+ te[7] *= s;
+ te[11] *= s;
+ te[15] *= s;
+ return this;
+ }
+ /**
+ * Computes and returns the determinant of this matrix.
+ *
+ * Based on the method outlined [here](http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html).
+ *
+ * @return {number} The determinant.
+ */
+ determinant() {
+ const te = this.elements;
+ const n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
+ const n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
+ const n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
+ const n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
+ const t11 = n23 * n34 - n24 * n33;
+ const t12 = n22 * n34 - n24 * n32;
+ const t13 = n22 * n33 - n23 * n32;
+ const t21 = n21 * n34 - n24 * n31;
+ const t22 = n21 * n33 - n23 * n31;
+ const t23 = n21 * n32 - n22 * n31;
+ return n11 * (n42 * t11 - n43 * t12 + n44 * t13) - n12 * (n41 * t11 - n43 * t21 + n44 * t22) + n13 * (n41 * t12 - n42 * t21 + n44 * t23) - n14 * (n41 * t13 - n42 * t22 + n43 * t23);
+ }
+ /**
+ * Transposes this matrix in place.
+ *
+ * @return {Matrix4} A reference to this matrix.
+ */
+ transpose() {
+ const te = this.elements;
+ let tmp2;
+ tmp2 = te[1];
+ te[1] = te[4];
+ te[4] = tmp2;
+ tmp2 = te[2];
+ te[2] = te[8];
+ te[8] = tmp2;
+ tmp2 = te[6];
+ te[6] = te[9];
+ te[9] = tmp2;
+ tmp2 = te[3];
+ te[3] = te[12];
+ te[12] = tmp2;
+ tmp2 = te[7];
+ te[7] = te[13];
+ te[13] = tmp2;
+ tmp2 = te[11];
+ te[11] = te[14];
+ te[14] = tmp2;
+ return this;
+ }
+ /**
+ * Sets the position component for this matrix from the given vector,
+ * without affecting the rest of the matrix.
+ *
+ * @param {number|Vector3} x - The x component of the vector or alternatively the vector object.
+ * @param {number} y - The y component of the vector.
+ * @param {number} z - The z component of the vector.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ setPosition(x, y, z) {
+ const te = this.elements;
+ if (x.isVector3) {
+ te[12] = x.x;
+ te[13] = x.y;
+ te[14] = x.z;
+ } else {
+ te[12] = x;
+ te[13] = y;
+ te[14] = z;
+ }
+ return this;
+ }
+ /**
+ * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).
+ * You can not invert with a determinant of zero. If you attempt this, the method produces
+ * a zero matrix instead.
+ *
+ * @return {Matrix4} A reference to this matrix.
+ */
+ invert() {
+ const te = this.elements, n11 = te[0], n21 = te[1], n31 = te[2], n41 = te[3], n12 = te[4], n22 = te[5], n32 = te[6], n42 = te[7], n13 = te[8], n23 = te[9], n33 = te[10], n43 = te[11], n14 = te[12], n24 = te[13], n34 = te[14], n44 = te[15], t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44, t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44, t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44, t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
+ const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
+ if (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ const detInv = 1 / det;
+ te[0] = t11 * detInv;
+ te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
+ te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
+ te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
+ te[4] = t12 * detInv;
+ te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
+ te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
+ te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
+ te[8] = t13 * detInv;
+ te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
+ te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
+ te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
+ te[12] = t14 * detInv;
+ te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
+ te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
+ te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
+ return this;
+ }
+ /**
+ * Multiplies the columns of this matrix by the given vector.
+ *
+ * @param {Vector3} v - The scale vector.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ scale(v) {
+ const te = this.elements;
+ const x = v.x, y = v.y, z = v.z;
+ te[0] *= x;
+ te[4] *= y;
+ te[8] *= z;
+ te[1] *= x;
+ te[5] *= y;
+ te[9] *= z;
+ te[2] *= x;
+ te[6] *= y;
+ te[10] *= z;
+ te[3] *= x;
+ te[7] *= y;
+ te[11] *= z;
+ return this;
+ }
+ /**
+ * Gets the maximum scale value of the three axes.
+ *
+ * @return {number} The maximum scale.
+ */
+ getMaxScaleOnAxis() {
+ const te = this.elements;
+ const scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
+ const scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
+ const scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
+ return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
+ }
+ /**
+ * Sets this matrix as a translation transform from the given vector.
+ *
+ * @param {number|Vector3} x - The amount to translate in the X axis or alternatively a translation vector.
+ * @param {number} y - The amount to translate in the Y axis.
+ * @param {number} z - The amount to translate in the z axis.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeTranslation(x, y, z) {
+ if (x.isVector3) {
+ this.set(
+ 1,
+ 0,
+ 0,
+ x.x,
+ 0,
+ 1,
+ 0,
+ x.y,
+ 0,
+ 0,
+ 1,
+ x.z,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ } else {
+ this.set(
+ 1,
+ 0,
+ 0,
+ x,
+ 0,
+ 1,
+ 0,
+ y,
+ 0,
+ 0,
+ 1,
+ z,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ }
+ return this;
+ }
+ /**
+ * Sets this matrix as a rotational transformation around the X axis by
+ * the given angle.
+ *
+ * @param {number} theta - The rotation in radians.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeRotationX(theta) {
+ const c = Math.cos(theta), s = Math.sin(theta);
+ this.set(
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ c,
+ -s,
+ 0,
+ 0,
+ s,
+ c,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Sets this matrix as a rotational transformation around the Y axis by
+ * the given angle.
+ *
+ * @param {number} theta - The rotation in radians.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeRotationY(theta) {
+ const c = Math.cos(theta), s = Math.sin(theta);
+ this.set(
+ c,
+ 0,
+ s,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ -s,
+ 0,
+ c,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Sets this matrix as a rotational transformation around the Z axis by
+ * the given angle.
+ *
+ * @param {number} theta - The rotation in radians.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeRotationZ(theta) {
+ const c = Math.cos(theta), s = Math.sin(theta);
+ this.set(
+ c,
+ -s,
+ 0,
+ 0,
+ s,
+ c,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Sets this matrix as a rotational transformation around the given axis by
+ * the given angle.
+ *
+ * This is a somewhat controversial but mathematically sound alternative to
+ * rotating via Quaternions. See the discussion [here](https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199).
+ *
+ * @param {Vector3} axis - The normalized rotation axis.
+ * @param {number} angle - The rotation in radians.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeRotationAxis(axis, angle) {
+ const c = Math.cos(angle);
+ const s = Math.sin(angle);
+ const t = 1 - c;
+ const x = axis.x, y = axis.y, z = axis.z;
+ const tx = t * x, ty = t * y;
+ this.set(
+ tx * x + c,
+ tx * y - s * z,
+ tx * z + s * y,
+ 0,
+ tx * y + s * z,
+ ty * y + c,
+ ty * z - s * x,
+ 0,
+ tx * z - s * y,
+ ty * z + s * x,
+ t * z * z + c,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Sets this matrix as a scale transformation.
+ *
+ * @param {number} x - The amount to scale in the X axis.
+ * @param {number} y - The amount to scale in the Y axis.
+ * @param {number} z - The amount to scale in the Z axis.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeScale(x, y, z) {
+ this.set(
+ x,
+ 0,
+ 0,
+ 0,
+ 0,
+ y,
+ 0,
+ 0,
+ 0,
+ 0,
+ z,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Sets this matrix as a shear transformation.
+ *
+ * @param {number} xy - The amount to shear X by Y.
+ * @param {number} xz - The amount to shear X by Z.
+ * @param {number} yx - The amount to shear Y by X.
+ * @param {number} yz - The amount to shear Y by Z.
+ * @param {number} zx - The amount to shear Z by X.
+ * @param {number} zy - The amount to shear Z by Y.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeShear(xy, xz, yx, yz, zx, zy) {
+ this.set(
+ 1,
+ yx,
+ zx,
+ 0,
+ xy,
+ 1,
+ zy,
+ 0,
+ xz,
+ yz,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1
+ );
+ return this;
+ }
+ /**
+ * Sets this matrix to the transformation composed of the given position,
+ * rotation (Quaternion) and scale.
+ *
+ * @param {Vector3} position - The position vector.
+ * @param {Quaternion} quaternion - The rotation as a Quaternion.
+ * @param {Vector3} scale - The scale vector.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ compose(position, quaternion, scale) {
+ const te = this.elements;
+ const x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
+ const x2 = x + x, y2 = y + y, z2 = z + z;
+ const xx = x * x2, xy = x * y2, xz = x * z2;
+ const yy = y * y2, yz = y * z2, zz = z * z2;
+ const wx = w * x2, wy = w * y2, wz = w * z2;
+ const sx = scale.x, sy = scale.y, sz = scale.z;
+ te[0] = (1 - (yy + zz)) * sx;
+ te[1] = (xy + wz) * sx;
+ te[2] = (xz - wy) * sx;
+ te[3] = 0;
+ te[4] = (xy - wz) * sy;
+ te[5] = (1 - (xx + zz)) * sy;
+ te[6] = (yz + wx) * sy;
+ te[7] = 0;
+ te[8] = (xz + wy) * sz;
+ te[9] = (yz - wx) * sz;
+ te[10] = (1 - (xx + yy)) * sz;
+ te[11] = 0;
+ te[12] = position.x;
+ te[13] = position.y;
+ te[14] = position.z;
+ te[15] = 1;
+ return this;
+ }
+ /**
+ * Decomposes this matrix into its position, rotation and scale components
+ * and provides the result in the given objects.
+ *
+ * Note: Not all matrices are decomposable in this way. For example, if an
+ * object has a non-uniformly scaled parent, then the object's world matrix
+ * may not be decomposable, and this method may not be appropriate.
+ *
+ * @param {Vector3} position - The position vector.
+ * @param {Quaternion} quaternion - The rotation as a Quaternion.
+ * @param {Vector3} scale - The scale vector.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ decompose(position, quaternion, scale) {
+ const te = this.elements;
+ position.x = te[12];
+ position.y = te[13];
+ position.z = te[14];
+ if (this.determinant() === 0) {
+ scale.set(1, 1, 1);
+ quaternion.identity();
+ return this;
+ }
+ let sx = _v1$5.set(te[0], te[1], te[2]).length();
+ const sy = _v1$5.set(te[4], te[5], te[6]).length();
+ const sz = _v1$5.set(te[8], te[9], te[10]).length();
+ const det = this.determinant();
+ if (det < 0) sx = -sx;
+ _m1$2.copy(this);
+ const invSX = 1 / sx;
+ const invSY = 1 / sy;
+ const invSZ = 1 / sz;
+ _m1$2.elements[0] *= invSX;
+ _m1$2.elements[1] *= invSX;
+ _m1$2.elements[2] *= invSX;
+ _m1$2.elements[4] *= invSY;
+ _m1$2.elements[5] *= invSY;
+ _m1$2.elements[6] *= invSY;
+ _m1$2.elements[8] *= invSZ;
+ _m1$2.elements[9] *= invSZ;
+ _m1$2.elements[10] *= invSZ;
+ quaternion.setFromRotationMatrix(_m1$2);
+ scale.x = sx;
+ scale.y = sy;
+ scale.z = sz;
+ return this;
+ }
+ /**
+ * Creates a perspective projection matrix. This is used internally by
+ * {@link PerspectiveCamera#updateProjectionMatrix}.
+
+ * @param {number} left - Left boundary of the viewing frustum at the near plane.
+ * @param {number} right - Right boundary of the viewing frustum at the near plane.
+ * @param {number} top - Top boundary of the viewing frustum at the near plane.
+ * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.
+ * @param {number} near - The distance from the camera to the near plane.
+ * @param {number} far - The distance from the camera to the far plane.
+ * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
+ * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makePerspective(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false) {
+ const te = this.elements;
+ const x = 2 * near / (right - left);
+ const y = 2 * near / (top - bottom);
+ const a = (right + left) / (right - left);
+ const b = (top + bottom) / (top - bottom);
+ let c, d;
+ if (reversedDepth) {
+ c = near / (far - near);
+ d = far * near / (far - near);
+ } else {
+ if (coordinateSystem === WebGLCoordinateSystem) {
+ c = -(far + near) / (far - near);
+ d = -2 * far * near / (far - near);
+ } else if (coordinateSystem === WebGPUCoordinateSystem) {
+ c = -far / (far - near);
+ d = -far * near / (far - near);
+ } else {
+ throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + coordinateSystem);
+ }
+ }
+ te[0] = x;
+ te[4] = 0;
+ te[8] = a;
+ te[12] = 0;
+ te[1] = 0;
+ te[5] = y;
+ te[9] = b;
+ te[13] = 0;
+ te[2] = 0;
+ te[6] = 0;
+ te[10] = c;
+ te[14] = d;
+ te[3] = 0;
+ te[7] = 0;
+ te[11] = -1;
+ te[15] = 0;
+ return this;
+ }
+ /**
+ * Creates a orthographic projection matrix. This is used internally by
+ * {@link OrthographicCamera#updateProjectionMatrix}.
+
+ * @param {number} left - Left boundary of the viewing frustum at the near plane.
+ * @param {number} right - Right boundary of the viewing frustum at the near plane.
+ * @param {number} top - Top boundary of the viewing frustum at the near plane.
+ * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.
+ * @param {number} near - The distance from the camera to the near plane.
+ * @param {number} far - The distance from the camera to the far plane.
+ * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
+ * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ makeOrthographic(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false) {
+ const te = this.elements;
+ const x = 2 / (right - left);
+ const y = 2 / (top - bottom);
+ const a = -(right + left) / (right - left);
+ const b = -(top + bottom) / (top - bottom);
+ let c, d;
+ if (reversedDepth) {
+ c = 1 / (far - near);
+ d = far / (far - near);
+ } else {
+ if (coordinateSystem === WebGLCoordinateSystem) {
+ c = -2 / (far - near);
+ d = -(far + near) / (far - near);
+ } else if (coordinateSystem === WebGPUCoordinateSystem) {
+ c = -1 / (far - near);
+ d = -near / (far - near);
+ } else {
+ throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + coordinateSystem);
+ }
+ }
+ te[0] = x;
+ te[4] = 0;
+ te[8] = 0;
+ te[12] = a;
+ te[1] = 0;
+ te[5] = y;
+ te[9] = 0;
+ te[13] = b;
+ te[2] = 0;
+ te[6] = 0;
+ te[10] = c;
+ te[14] = d;
+ te[3] = 0;
+ te[7] = 0;
+ te[11] = 0;
+ te[15] = 1;
+ return this;
+ }
+ /**
+ * Returns `true` if this matrix is equal with the given one.
+ *
+ * @param {Matrix4} matrix - The matrix to test for equality.
+ * @return {boolean} Whether this matrix is equal with the given one.
+ */
+ equals(matrix) {
+ const te = this.elements;
+ const me = matrix.elements;
+ for (let i = 0; i < 16; i++) {
+ if (te[i] !== me[i]) return false;
+ }
+ return true;
+ }
+ /**
+ * Sets the elements of the matrix from the given array.
+ *
+ * @param {Array} array - The matrix elements in column-major order.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Matrix4} A reference to this matrix.
+ */
+ fromArray(array, offset = 0) {
+ for (let i = 0; i < 16; i++) {
+ this.elements[i] = array[i + offset];
+ }
+ return this;
+ }
+ /**
+ * Writes the elements of this matrix to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the matrix elements in column-major order.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The matrix elements in column-major order.
+ */
+ toArray(array = [], offset = 0) {
+ const te = this.elements;
+ array[offset] = te[0];
+ array[offset + 1] = te[1];
+ array[offset + 2] = te[2];
+ array[offset + 3] = te[3];
+ array[offset + 4] = te[4];
+ array[offset + 5] = te[5];
+ array[offset + 6] = te[6];
+ array[offset + 7] = te[7];
+ array[offset + 8] = te[8];
+ array[offset + 9] = te[9];
+ array[offset + 10] = te[10];
+ array[offset + 11] = te[11];
+ array[offset + 12] = te[12];
+ array[offset + 13] = te[13];
+ array[offset + 14] = te[14];
+ array[offset + 15] = te[15];
+ return array;
+ }
+};
+var _v1$5 = new Vector3();
+var _m1$2 = new Matrix4();
+var _zero = new Vector3(0, 0, 0);
+var _one = new Vector3(1, 1, 1);
+var _x = new Vector3();
+var _y = new Vector3();
+var _z = new Vector3();
+var _matrix$2 = new Matrix4();
+var _quaternion$3 = new Quaternion();
+var Euler = class _Euler {
+ /**
+ * Constructs a new euler instance.
+ *
+ * @param {number} [x=0] - The angle of the x axis in radians.
+ * @param {number} [y=0] - The angle of the y axis in radians.
+ * @param {number} [z=0] - The angle of the z axis in radians.
+ * @param {string} [order=Euler.DEFAULT_ORDER] - A string representing the order that the rotations are applied.
+ */
+ constructor(x = 0, y = 0, z = 0, order = _Euler.DEFAULT_ORDER) {
+ this.isEuler = true;
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._order = order;
+ }
+ /**
+ * The angle of the x axis in radians.
+ *
+ * @type {number}
+ * @default 0
+ */
+ get x() {
+ return this._x;
+ }
+ set x(value) {
+ this._x = value;
+ this._onChangeCallback();
+ }
+ /**
+ * The angle of the y axis in radians.
+ *
+ * @type {number}
+ * @default 0
+ */
+ get y() {
+ return this._y;
+ }
+ set y(value) {
+ this._y = value;
+ this._onChangeCallback();
+ }
+ /**
+ * The angle of the z axis in radians.
+ *
+ * @type {number}
+ * @default 0
+ */
+ get z() {
+ return this._z;
+ }
+ set z(value) {
+ this._z = value;
+ this._onChangeCallback();
+ }
+ /**
+ * A string representing the order that the rotations are applied.
+ *
+ * @type {string}
+ * @default 'XYZ'
+ */
+ get order() {
+ return this._order;
+ }
+ set order(value) {
+ this._order = value;
+ this._onChangeCallback();
+ }
+ /**
+ * Sets the Euler components.
+ *
+ * @param {number} x - The angle of the x axis in radians.
+ * @param {number} y - The angle of the y axis in radians.
+ * @param {number} z - The angle of the z axis in radians.
+ * @param {string} [order] - A string representing the order that the rotations are applied.
+ * @return {Euler} A reference to this Euler instance.
+ */
+ set(x, y, z, order = this._order) {
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._order = order;
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Returns a new Euler instance with copied values from this instance.
+ *
+ * @return {Euler} A clone of this instance.
+ */
+ clone() {
+ return new this.constructor(this._x, this._y, this._z, this._order);
+ }
+ /**
+ * Copies the values of the given Euler instance to this instance.
+ *
+ * @param {Euler} euler - The Euler instance to copy.
+ * @return {Euler} A reference to this Euler instance.
+ */
+ copy(euler) {
+ this._x = euler._x;
+ this._y = euler._y;
+ this._z = euler._z;
+ this._order = euler._order;
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Sets the angles of this Euler instance from a pure rotation matrix.
+ *
+ * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).
+ * @param {string} [order] - A string representing the order that the rotations are applied.
+ * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.
+ * @return {Euler} A reference to this Euler instance.
+ */
+ setFromRotationMatrix(m, order = this._order, update = true) {
+ const te = m.elements;
+ const m11 = te[0], m12 = te[4], m13 = te[8];
+ const m21 = te[1], m22 = te[5], m23 = te[9];
+ const m31 = te[2], m32 = te[6], m33 = te[10];
+ switch (order) {
+ case "XYZ":
+ this._y = Math.asin(clamp(m13, -1, 1));
+ if (Math.abs(m13) < 0.9999999) {
+ this._x = Math.atan2(-m23, m33);
+ this._z = Math.atan2(-m12, m11);
+ } else {
+ this._x = Math.atan2(m32, m22);
+ this._z = 0;
+ }
+ break;
+ case "YXZ":
+ this._x = Math.asin(-clamp(m23, -1, 1));
+ if (Math.abs(m23) < 0.9999999) {
+ this._y = Math.atan2(m13, m33);
+ this._z = Math.atan2(m21, m22);
+ } else {
+ this._y = Math.atan2(-m31, m11);
+ this._z = 0;
+ }
+ break;
+ case "ZXY":
+ this._x = Math.asin(clamp(m32, -1, 1));
+ if (Math.abs(m32) < 0.9999999) {
+ this._y = Math.atan2(-m31, m33);
+ this._z = Math.atan2(-m12, m22);
+ } else {
+ this._y = 0;
+ this._z = Math.atan2(m21, m11);
+ }
+ break;
+ case "ZYX":
+ this._y = Math.asin(-clamp(m31, -1, 1));
+ if (Math.abs(m31) < 0.9999999) {
+ this._x = Math.atan2(m32, m33);
+ this._z = Math.atan2(m21, m11);
+ } else {
+ this._x = 0;
+ this._z = Math.atan2(-m12, m22);
+ }
+ break;
+ case "YZX":
+ this._z = Math.asin(clamp(m21, -1, 1));
+ if (Math.abs(m21) < 0.9999999) {
+ this._x = Math.atan2(-m23, m22);
+ this._y = Math.atan2(-m31, m11);
+ } else {
+ this._x = 0;
+ this._y = Math.atan2(m13, m33);
+ }
+ break;
+ case "XZY":
+ this._z = Math.asin(-clamp(m12, -1, 1));
+ if (Math.abs(m12) < 0.9999999) {
+ this._x = Math.atan2(m32, m22);
+ this._y = Math.atan2(m13, m11);
+ } else {
+ this._x = Math.atan2(-m23, m33);
+ this._y = 0;
+ }
+ break;
+ default:
+ warn("Euler: .setFromRotationMatrix() encountered an unknown order: " + order);
+ }
+ this._order = order;
+ if (update === true) this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Sets the angles of this Euler instance from a normalized quaternion.
+ *
+ * @param {Quaternion} q - A normalized Quaternion.
+ * @param {string} [order] - A string representing the order that the rotations are applied.
+ * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.
+ * @return {Euler} A reference to this Euler instance.
+ */
+ setFromQuaternion(q, order, update) {
+ _matrix$2.makeRotationFromQuaternion(q);
+ return this.setFromRotationMatrix(_matrix$2, order, update);
+ }
+ /**
+ * Sets the angles of this Euler instance from the given vector.
+ *
+ * @param {Vector3} v - The vector.
+ * @param {string} [order] - A string representing the order that the rotations are applied.
+ * @return {Euler} A reference to this Euler instance.
+ */
+ setFromVector3(v, order = this._order) {
+ return this.set(v.x, v.y, v.z, order);
+ }
+ /**
+ * Resets the euler angle with a new order by creating a quaternion from this
+ * euler angle and then setting this euler angle with the quaternion and the
+ * new order.
+ *
+ * Warning: This discards revolution information.
+ *
+ * @param {string} [newOrder] - A string representing the new order that the rotations are applied.
+ * @return {Euler} A reference to this Euler instance.
+ */
+ reorder(newOrder) {
+ _quaternion$3.setFromEuler(this);
+ return this.setFromQuaternion(_quaternion$3, newOrder);
+ }
+ /**
+ * Returns `true` if this Euler instance is equal with the given one.
+ *
+ * @param {Euler} euler - The Euler instance to test for equality.
+ * @return {boolean} Whether this Euler instance is equal with the given one.
+ */
+ equals(euler) {
+ return euler._x === this._x && euler._y === this._y && euler._z === this._z && euler._order === this._order;
+ }
+ /**
+ * Sets this Euler instance's components to values from the given array. The first three
+ * entries of the array are assign to the x,y and z components. An optional fourth entry
+ * defines the Euler order.
+ *
+ * @param {Array} array - An array holding the Euler component values.
+ * @return {Euler} A reference to this Euler instance.
+ */
+ fromArray(array) {
+ this._x = array[0];
+ this._y = array[1];
+ this._z = array[2];
+ if (array[3] !== void 0) this._order = array[3];
+ this._onChangeCallback();
+ return this;
+ }
+ /**
+ * Writes the components of this Euler instance to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the Euler components.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The Euler components.
+ */
+ toArray(array = [], offset = 0) {
+ array[offset] = this._x;
+ array[offset + 1] = this._y;
+ array[offset + 2] = this._z;
+ array[offset + 3] = this._order;
+ return array;
+ }
+ _onChange(callback) {
+ this._onChangeCallback = callback;
+ return this;
+ }
+ _onChangeCallback() {
+ }
+ *[Symbol.iterator]() {
+ yield this._x;
+ yield this._y;
+ yield this._z;
+ yield this._order;
+ }
+};
+Euler.DEFAULT_ORDER = "XYZ";
+var Layers = class {
+ /**
+ * Constructs a new layers instance, with membership
+ * initially set to layer `0`.
+ */
+ constructor() {
+ this.mask = 1 | 0;
+ }
+ /**
+ * Sets membership to the given layer, and remove membership all other layers.
+ *
+ * @param {number} layer - The layer to set.
+ */
+ set(layer) {
+ this.mask = (1 << layer | 0) >>> 0;
+ }
+ /**
+ * Adds membership of the given layer.
+ *
+ * @param {number} layer - The layer to enable.
+ */
+ enable(layer) {
+ this.mask |= 1 << layer | 0;
+ }
+ /**
+ * Adds membership to all layers.
+ */
+ enableAll() {
+ this.mask = 4294967295 | 0;
+ }
+ /**
+ * Toggles the membership of the given layer.
+ *
+ * @param {number} layer - The layer to toggle.
+ */
+ toggle(layer) {
+ this.mask ^= 1 << layer | 0;
+ }
+ /**
+ * Removes membership of the given layer.
+ *
+ * @param {number} layer - The layer to enable.
+ */
+ disable(layer) {
+ this.mask &= ~(1 << layer | 0);
+ }
+ /**
+ * Removes the membership from all layers.
+ */
+ disableAll() {
+ this.mask = 0;
+ }
+ /**
+ * Returns `true` if this and the given layers object have at least one
+ * layer in common.
+ *
+ * @param {Layers} layers - The layers to test.
+ * @return {boolean } Whether this and the given layers object have at least one layer in common or not.
+ */
+ test(layers) {
+ return (this.mask & layers.mask) !== 0;
+ }
+ /**
+ * Returns `true` if the given layer is enabled.
+ *
+ * @param {number} layer - The layer to test.
+ * @return {boolean } Whether the given layer is enabled or not.
+ */
+ isEnabled(layer) {
+ return (this.mask & (1 << layer | 0)) !== 0;
+ }
+};
+var _object3DId = 0;
+var _v1$4 = new Vector3();
+var _q1 = new Quaternion();
+var _m1$1 = new Matrix4();
+var _target = new Vector3();
+var _position$3 = new Vector3();
+var _scale$2 = new Vector3();
+var _quaternion$2 = new Quaternion();
+var _xAxis = new Vector3(1, 0, 0);
+var _yAxis = new Vector3(0, 1, 0);
+var _zAxis = new Vector3(0, 0, 1);
+var _addedEvent = { type: "added" };
+var _removedEvent = { type: "removed" };
+var _childaddedEvent = { type: "childadded", child: null };
+var _childremovedEvent = { type: "childremoved", child: null };
+var Object3D = class _Object3D extends EventDispatcher {
+ /**
+ * Constructs a new 3D object.
+ */
+ constructor() {
+ super();
+ this.isObject3D = true;
+ Object.defineProperty(this, "id", { value: _object3DId++ });
+ this.uuid = generateUUID();
+ this.name = "";
+ this.type = "Object3D";
+ this.parent = null;
+ this.children = [];
+ this.up = _Object3D.DEFAULT_UP.clone();
+ const position = new Vector3();
+ const rotation = new Euler();
+ const quaternion = new Quaternion();
+ const scale = new Vector3(1, 1, 1);
+ function onRotationChange() {
+ quaternion.setFromEuler(rotation, false);
+ }
+ function onQuaternionChange() {
+ rotation.setFromQuaternion(quaternion, void 0, false);
+ }
+ rotation._onChange(onRotationChange);
+ quaternion._onChange(onQuaternionChange);
+ Object.defineProperties(this, {
+ /**
+ * Represents the object's local position.
+ *
+ * @name Object3D#position
+ * @type {Vector3}
+ * @default (0,0,0)
+ */
+ position: {
+ configurable: true,
+ enumerable: true,
+ value: position
+ },
+ /**
+ * Represents the object's local rotation as Euler angles, in radians.
+ *
+ * @name Object3D#rotation
+ * @type {Euler}
+ * @default (0,0,0)
+ */
+ rotation: {
+ configurable: true,
+ enumerable: true,
+ value: rotation
+ },
+ /**
+ * Represents the object's local rotation as Quaternions.
+ *
+ * @name Object3D#quaternion
+ * @type {Quaternion}
+ */
+ quaternion: {
+ configurable: true,
+ enumerable: true,
+ value: quaternion
+ },
+ /**
+ * Represents the object's local scale.
+ *
+ * @name Object3D#scale
+ * @type {Vector3}
+ * @default (1,1,1)
+ */
+ scale: {
+ configurable: true,
+ enumerable: true,
+ value: scale
+ },
+ /**
+ * Represents the object's model-view matrix.
+ *
+ * @name Object3D#modelViewMatrix
+ * @type {Matrix4}
+ */
+ modelViewMatrix: {
+ value: new Matrix4()
+ },
+ /**
+ * Represents the object's normal matrix.
+ *
+ * @name Object3D#normalMatrix
+ * @type {Matrix3}
+ */
+ normalMatrix: {
+ value: new Matrix3()
+ }
+ });
+ this.matrix = new Matrix4();
+ this.matrixWorld = new Matrix4();
+ this.matrixAutoUpdate = _Object3D.DEFAULT_MATRIX_AUTO_UPDATE;
+ this.matrixWorldAutoUpdate = _Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE;
+ this.matrixWorldNeedsUpdate = false;
+ this.layers = new Layers();
+ this.visible = true;
+ this.castShadow = false;
+ this.receiveShadow = false;
+ this.frustumCulled = true;
+ this.renderOrder = 0;
+ this.animations = [];
+ this.customDepthMaterial = void 0;
+ this.customDistanceMaterial = void 0;
+ this.userData = {};
+ }
+ /**
+ * A callback that is executed immediately before a 3D object is rendered to a shadow map.
+ *
+ * @param {Renderer|WebGLRenderer} renderer - The renderer.
+ * @param {Object3D} object - The 3D object.
+ * @param {Camera} camera - The camera that is used to render the scene.
+ * @param {Camera} shadowCamera - The shadow camera.
+ * @param {BufferGeometry} geometry - The 3D object's geometry.
+ * @param {Material} depthMaterial - The depth material.
+ * @param {Object} group - The geometry group data.
+ */
+ onBeforeShadow() {
+ }
+ /**
+ * A callback that is executed immediately after a 3D object is rendered to a shadow map.
+ *
+ * @param {Renderer|WebGLRenderer} renderer - The renderer.
+ * @param {Object3D} object - The 3D object.
+ * @param {Camera} camera - The camera that is used to render the scene.
+ * @param {Camera} shadowCamera - The shadow camera.
+ * @param {BufferGeometry} geometry - The 3D object's geometry.
+ * @param {Material} depthMaterial - The depth material.
+ * @param {Object} group - The geometry group data.
+ */
+ onAfterShadow() {
+ }
+ /**
+ * A callback that is executed immediately before a 3D object is rendered.
+ *
+ * @param {Renderer|WebGLRenderer} renderer - The renderer.
+ * @param {Object3D} object - The 3D object.
+ * @param {Camera} camera - The camera that is used to render the scene.
+ * @param {BufferGeometry} geometry - The 3D object's geometry.
+ * @param {Material} material - The 3D object's material.
+ * @param {Object} group - The geometry group data.
+ */
+ onBeforeRender() {
+ }
+ /**
+ * A callback that is executed immediately after a 3D object is rendered.
+ *
+ * @param {Renderer|WebGLRenderer} renderer - The renderer.
+ * @param {Object3D} object - The 3D object.
+ * @param {Camera} camera - The camera that is used to render the scene.
+ * @param {BufferGeometry} geometry - The 3D object's geometry.
+ * @param {Material} material - The 3D object's material.
+ * @param {Object} group - The geometry group data.
+ */
+ onAfterRender() {
+ }
+ /**
+ * Applies the given transformation matrix to the object and updates the object's position,
+ * rotation and scale.
+ *
+ * @param {Matrix4} matrix - The transformation matrix.
+ */
+ applyMatrix4(matrix) {
+ if (this.matrixAutoUpdate) this.updateMatrix();
+ this.matrix.premultiply(matrix);
+ this.matrix.decompose(this.position, this.quaternion, this.scale);
+ }
+ /**
+ * Applies a rotation represented by given the quaternion to the 3D object.
+ *
+ * @param {Quaternion} q - The quaternion.
+ * @return {Object3D} A reference to this instance.
+ */
+ applyQuaternion(q) {
+ this.quaternion.premultiply(q);
+ return this;
+ }
+ /**
+ * Sets the given rotation represented as an axis/angle couple to the 3D object.
+ *
+ * @param {Vector3} axis - The (normalized) axis vector.
+ * @param {number} angle - The angle in radians.
+ */
+ setRotationFromAxisAngle(axis, angle) {
+ this.quaternion.setFromAxisAngle(axis, angle);
+ }
+ /**
+ * Sets the given rotation represented as Euler angles to the 3D object.
+ *
+ * @param {Euler} euler - The Euler angles.
+ */
+ setRotationFromEuler(euler) {
+ this.quaternion.setFromEuler(euler, true);
+ }
+ /**
+ * Sets the given rotation represented as rotation matrix to the 3D object.
+ *
+ * @param {Matrix4} m - Although a 4x4 matrix is expected, the upper 3x3 portion must be
+ * a pure rotation matrix (i.e, unscaled).
+ */
+ setRotationFromMatrix(m) {
+ this.quaternion.setFromRotationMatrix(m);
+ }
+ /**
+ * Sets the given rotation represented as a Quaternion to the 3D object.
+ *
+ * @param {Quaternion} q - The Quaternion
+ */
+ setRotationFromQuaternion(q) {
+ this.quaternion.copy(q);
+ }
+ /**
+ * Rotates the 3D object along an axis in local space.
+ *
+ * @param {Vector3} axis - The (normalized) axis vector.
+ * @param {number} angle - The angle in radians.
+ * @return {Object3D} A reference to this instance.
+ */
+ rotateOnAxis(axis, angle) {
+ _q1.setFromAxisAngle(axis, angle);
+ this.quaternion.multiply(_q1);
+ return this;
+ }
+ /**
+ * Rotates the 3D object along an axis in world space.
+ *
+ * @param {Vector3} axis - The (normalized) axis vector.
+ * @param {number} angle - The angle in radians.
+ * @return {Object3D} A reference to this instance.
+ */
+ rotateOnWorldAxis(axis, angle) {
+ _q1.setFromAxisAngle(axis, angle);
+ this.quaternion.premultiply(_q1);
+ return this;
+ }
+ /**
+ * Rotates the 3D object around its X axis in local space.
+ *
+ * @param {number} angle - The angle in radians.
+ * @return {Object3D} A reference to this instance.
+ */
+ rotateX(angle) {
+ return this.rotateOnAxis(_xAxis, angle);
+ }
+ /**
+ * Rotates the 3D object around its Y axis in local space.
+ *
+ * @param {number} angle - The angle in radians.
+ * @return {Object3D} A reference to this instance.
+ */
+ rotateY(angle) {
+ return this.rotateOnAxis(_yAxis, angle);
+ }
+ /**
+ * Rotates the 3D object around its Z axis in local space.
+ *
+ * @param {number} angle - The angle in radians.
+ * @return {Object3D} A reference to this instance.
+ */
+ rotateZ(angle) {
+ return this.rotateOnAxis(_zAxis, angle);
+ }
+ /**
+ * Translate the 3D object by a distance along the given axis in local space.
+ *
+ * @param {Vector3} axis - The (normalized) axis vector.
+ * @param {number} distance - The distance in world units.
+ * @return {Object3D} A reference to this instance.
+ */
+ translateOnAxis(axis, distance) {
+ _v1$4.copy(axis).applyQuaternion(this.quaternion);
+ this.position.add(_v1$4.multiplyScalar(distance));
+ return this;
+ }
+ /**
+ * Translate the 3D object by a distance along its X-axis in local space.
+ *
+ * @param {number} distance - The distance in world units.
+ * @return {Object3D} A reference to this instance.
+ */
+ translateX(distance) {
+ return this.translateOnAxis(_xAxis, distance);
+ }
+ /**
+ * Translate the 3D object by a distance along its Y-axis in local space.
+ *
+ * @param {number} distance - The distance in world units.
+ * @return {Object3D} A reference to this instance.
+ */
+ translateY(distance) {
+ return this.translateOnAxis(_yAxis, distance);
+ }
+ /**
+ * Translate the 3D object by a distance along its Z-axis in local space.
+ *
+ * @param {number} distance - The distance in world units.
+ * @return {Object3D} A reference to this instance.
+ */
+ translateZ(distance) {
+ return this.translateOnAxis(_zAxis, distance);
+ }
+ /**
+ * Converts the given vector from this 3D object's local space to world space.
+ *
+ * @param {Vector3} vector - The vector to convert.
+ * @return {Vector3} The converted vector.
+ */
+ localToWorld(vector) {
+ this.updateWorldMatrix(true, false);
+ return vector.applyMatrix4(this.matrixWorld);
+ }
+ /**
+ * Converts the given vector from this 3D object's word space to local space.
+ *
+ * @param {Vector3} vector - The vector to convert.
+ * @return {Vector3} The converted vector.
+ */
+ worldToLocal(vector) {
+ this.updateWorldMatrix(true, false);
+ return vector.applyMatrix4(_m1$1.copy(this.matrixWorld).invert());
+ }
+ /**
+ * Rotates the object to face a point in world space.
+ *
+ * This method does not support objects having non-uniformly-scaled parent(s).
+ *
+ * @param {number|Vector3} x - The x coordinate in world space. Alternatively, a vector representing a position in world space
+ * @param {number} [y] - The y coordinate in world space.
+ * @param {number} [z] - The z coordinate in world space.
+ */
+ lookAt(x, y, z) {
+ if (x.isVector3) {
+ _target.copy(x);
+ } else {
+ _target.set(x, y, z);
+ }
+ const parent = this.parent;
+ this.updateWorldMatrix(true, false);
+ _position$3.setFromMatrixPosition(this.matrixWorld);
+ if (this.isCamera || this.isLight) {
+ _m1$1.lookAt(_position$3, _target, this.up);
+ } else {
+ _m1$1.lookAt(_target, _position$3, this.up);
+ }
+ this.quaternion.setFromRotationMatrix(_m1$1);
+ if (parent) {
+ _m1$1.extractRotation(parent.matrixWorld);
+ _q1.setFromRotationMatrix(_m1$1);
+ this.quaternion.premultiply(_q1.invert());
+ }
+ }
+ /**
+ * Adds the given 3D object as a child to this 3D object. An arbitrary number of
+ * objects may be added. Any current parent on an object passed in here will be
+ * removed, since an object can have at most one parent.
+ *
+ * @fires Object3D#added
+ * @fires Object3D#childadded
+ * @param {Object3D} object - The 3D object to add.
+ * @return {Object3D} A reference to this instance.
+ */
+ add(object) {
+ if (arguments.length > 1) {
+ for (let i = 0; i < arguments.length; i++) {
+ this.add(arguments[i]);
+ }
+ return this;
+ }
+ if (object === this) {
+ error("Object3D.add: object can't be added as a child of itself.", object);
+ return this;
+ }
+ if (object && object.isObject3D) {
+ object.removeFromParent();
+ object.parent = this;
+ this.children.push(object);
+ object.dispatchEvent(_addedEvent);
+ _childaddedEvent.child = object;
+ this.dispatchEvent(_childaddedEvent);
+ _childaddedEvent.child = null;
+ } else {
+ error("Object3D.add: object not an instance of THREE.Object3D.", object);
+ }
+ return this;
+ }
+ /**
+ * Removes the given 3D object as child from this 3D object.
+ * An arbitrary number of objects may be removed.
+ *
+ * @fires Object3D#removed
+ * @fires Object3D#childremoved
+ * @param {Object3D} object - The 3D object to remove.
+ * @return {Object3D} A reference to this instance.
+ */
+ remove(object) {
+ if (arguments.length > 1) {
+ for (let i = 0; i < arguments.length; i++) {
+ this.remove(arguments[i]);
+ }
+ return this;
+ }
+ const index = this.children.indexOf(object);
+ if (index !== -1) {
+ object.parent = null;
+ this.children.splice(index, 1);
+ object.dispatchEvent(_removedEvent);
+ _childremovedEvent.child = object;
+ this.dispatchEvent(_childremovedEvent);
+ _childremovedEvent.child = null;
+ }
+ return this;
+ }
+ /**
+ * Removes this 3D object from its current parent.
+ *
+ * @fires Object3D#removed
+ * @fires Object3D#childremoved
+ * @return {Object3D} A reference to this instance.
+ */
+ removeFromParent() {
+ const parent = this.parent;
+ if (parent !== null) {
+ parent.remove(this);
+ }
+ return this;
+ }
+ /**
+ * Removes all child objects.
+ *
+ * @fires Object3D#removed
+ * @fires Object3D#childremoved
+ * @return {Object3D} A reference to this instance.
+ */
+ clear() {
+ return this.remove(...this.children);
+ }
+ /**
+ * Adds the given 3D object as a child of this 3D object, while maintaining the object's world
+ * transform. This method does not support scene graphs having non-uniformly-scaled nodes(s).
+ *
+ * @fires Object3D#added
+ * @fires Object3D#childadded
+ * @param {Object3D} object - The 3D object to attach.
+ * @return {Object3D} A reference to this instance.
+ */
+ attach(object) {
+ this.updateWorldMatrix(true, false);
+ _m1$1.copy(this.matrixWorld).invert();
+ if (object.parent !== null) {
+ object.parent.updateWorldMatrix(true, false);
+ _m1$1.multiply(object.parent.matrixWorld);
+ }
+ object.applyMatrix4(_m1$1);
+ object.removeFromParent();
+ object.parent = this;
+ this.children.push(object);
+ object.updateWorldMatrix(false, true);
+ object.dispatchEvent(_addedEvent);
+ _childaddedEvent.child = object;
+ this.dispatchEvent(_childaddedEvent);
+ _childaddedEvent.child = null;
+ return this;
+ }
+ /**
+ * Searches through the 3D object and its children, starting with the 3D object
+ * itself, and returns the first with a matching ID.
+ *
+ * @param {number} id - The id.
+ * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.
+ */
+ getObjectById(id) {
+ return this.getObjectByProperty("id", id);
+ }
+ /**
+ * Searches through the 3D object and its children, starting with the 3D object
+ * itself, and returns the first with a matching name.
+ *
+ * @param {string} name - The name.
+ * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.
+ */
+ getObjectByName(name) {
+ return this.getObjectByProperty("name", name);
+ }
+ /**
+ * Searches through the 3D object and its children, starting with the 3D object
+ * itself, and returns the first with a matching property value.
+ *
+ * @param {string} name - The name of the property.
+ * @param {any} value - The value.
+ * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.
+ */
+ getObjectByProperty(name, value) {
+ if (this[name] === value) return this;
+ for (let i = 0, l = this.children.length; i < l; i++) {
+ const child = this.children[i];
+ const object = child.getObjectByProperty(name, value);
+ if (object !== void 0) {
+ return object;
+ }
+ }
+ return void 0;
+ }
+ /**
+ * Searches through the 3D object and its children, starting with the 3D object
+ * itself, and returns all 3D objects with a matching property value.
+ *
+ * @param {string} name - The name of the property.
+ * @param {any} value - The value.
+ * @param {Array} result - The method stores the result in this array.
+ * @return {Array} The found 3D objects.
+ */
+ getObjectsByProperty(name, value, result = []) {
+ if (this[name] === value) result.push(this);
+ const children = this.children;
+ for (let i = 0, l = children.length; i < l; i++) {
+ children[i].getObjectsByProperty(name, value, result);
+ }
+ return result;
+ }
+ /**
+ * Returns a vector representing the position of the 3D object in world space.
+ *
+ * @param {Vector3} target - The target vector the result is stored to.
+ * @return {Vector3} The 3D object's position in world space.
+ */
+ getWorldPosition(target) {
+ this.updateWorldMatrix(true, false);
+ return target.setFromMatrixPosition(this.matrixWorld);
+ }
+ /**
+ * Returns a Quaternion representing the position of the 3D object in world space.
+ *
+ * @param {Quaternion} target - The target Quaternion the result is stored to.
+ * @return {Quaternion} The 3D object's rotation in world space.
+ */
+ getWorldQuaternion(target) {
+ this.updateWorldMatrix(true, false);
+ this.matrixWorld.decompose(_position$3, target, _scale$2);
+ return target;
+ }
+ /**
+ * Returns a vector representing the scale of the 3D object in world space.
+ *
+ * @param {Vector3} target - The target vector the result is stored to.
+ * @return {Vector3} The 3D object's scale in world space.
+ */
+ getWorldScale(target) {
+ this.updateWorldMatrix(true, false);
+ this.matrixWorld.decompose(_position$3, _quaternion$2, target);
+ return target;
+ }
+ /**
+ * Returns a vector representing the ("look") direction of the 3D object in world space.
+ *
+ * @param {Vector3} target - The target vector the result is stored to.
+ * @return {Vector3} The 3D object's direction in world space.
+ */
+ getWorldDirection(target) {
+ this.updateWorldMatrix(true, false);
+ const e = this.matrixWorld.elements;
+ return target.set(e[8], e[9], e[10]).normalize();
+ }
+ /**
+ * Abstract method to get intersections between a casted ray and this
+ * 3D object. Renderable 3D objects such as {@link Mesh}, {@link Line} or {@link Points}
+ * implement this method in order to use raycasting.
+ *
+ * @abstract
+ * @param {Raycaster} raycaster - The raycaster.
+ * @param {Array