\n `;\n\n const actionBtn = document.createElement('button');\n actionBtn.textContent = 'Update Status';\n actionBtn.style.marginTop = '10px';\n actionBtn.onclick = () => {\n alert('Status updated!');\n };\n\n contentEl.appendChild(infoTitle);\n contentEl.appendChild(infoList);\n contentEl.appendChild(actionBtn);\n\n // 2. 调用父类构造函数,传入特定的配置\n super({\n container: container,\n title: 'dialog.testTitle',\n content: contentEl,\n width: 320,\n height: 'auto',\n position: 'center',\n resizable: true,\n draggable: true,\n // 可以在这里添加特定的 onClose 逻辑\n onClose: () => {\n console.log('Info dialog closed');\n },\n onOpen: () => {\n console.log('Info dialog opened');\n }\n });\n\n // 3. 如果有特定于子类的初始化逻辑,可以在 super() 之后执行\n // 例如:this.element.classList.add('my-special-class');\n }\n\n // 不需要再手动实现 setTheme, destroy, close, init\n // 它们都已从 BimDialog 继承\n}","import { BimDialog } from '../components/dialog';\nimport { BimInfoDialog } from '../components/dialog/bimInfoDialog';\nimport type { DialogOptions } from '../components/dialog/index.type';\nimport type { ThemeConfig } from '../themes/types';\nimport { themeManager } from '../services/theme';\nimport { BimComponent } from '../core/component';\nimport type { BimEngine } from '../bim-engine';\n\n/**\n * 弹窗管理器\n * 负责创建和管理应用中的各类弹窗。\n */\nexport class DialogManager extends BimComponent {\n /** 弹窗挂载的父容器 */\n private container: HTMLElement;\n /** 活跃的弹窗实例列表 */\n private activeDialogs: BimDialog[] = [];\n\n /**\n * 构造函数\n * @param engine 引擎实例\n * @param container 弹窗挂载的目标容器\n */\n constructor(engine: BimEngine, container: HTMLElement) {\n super(engine);\n this.container = container;\n\n // 监听打开弹窗事件\n this.on('ui:open-dialog', (payload) => {\n // 这里可以根据 payload.id 做更复杂的逻辑,目前简单演示\n console.log('[DialogManager] Received open-dialog event:', payload);\n // 示例:如果 payload.id 是 'info',则打开 info dialog\n if (payload.id === 'info') {\n this.showInfoDialog();\n }\n });\n }\n\n /**\n * 创建一个通用弹窗\n * @param options 弹窗配置选项(不需要传 container,自动使用管理器绑定的容器)\n * @returns BimDialog 实例\n */\n public create(options: Omit): BimDialog {\n const dialog = new BimDialog({\n container: this.container,\n ...options,\n onClose: () => {\n // 从活跃列表中移除\n this.activeDialogs = this.activeDialogs.filter(d => d !== dialog);\n if (options.onClose) options.onClose();\n }\n });\n\n // 应用当前主题\n dialog.setTheme(themeManager.getTheme());\n\n this.activeDialogs.push(dialog);\n return dialog;\n }\n\n /**\n * 显示二次封装的模型信息弹窗\n * 演示如何调用特定的业务弹窗组件\n */\n public showInfoDialog() {\n // 最佳实践:所有弹窗应通过 create 统一管理,或者手动加入管理。\n new BimInfoDialog(this.container);\n // 暂时不做主题追踪,作为遗留逻辑保留\n }\n\n /**\n * 响应全局主题变更\n * @param theme 全局主题配置\n */\n public updateTheme(theme: ThemeConfig) {\n this.activeDialogs.forEach(dialog => {\n if (dialog.setTheme) {\n dialog.setTheme(theme);\n }\n });\n }\n\n public destroy() {\n this.activeDialogs.forEach(d => d.destroy());\n this.activeDialogs = [];\n }\n}","const Ni = { ROTATE: 0, DOLLY: 1, PAN: 2 }, Ii = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, Nh = 0, tl = 1, Fh = 2, Dc = 1, Lc = 2, On = 3, En = 0, zt = 1, Wt = 2, Mt = 0, Fi = 1, _r = 2, nl = 3, il = 4, Ic = 5, cn = 100, Oh = 101, Bh = 102, zh = 103, kh = 104, ps = 200, Vh = 201, Gh = 202, Hh = 203, ba = 204, ya = 205, Ta = 206, Wh = 207, Ea = 208, Xh = 209, jh = 210, qh = 211, Yh = 212, Kh = 213, Zh = 214, wa = 0, Aa = 1, Ra = 2, Vi = 3, Ca = 4, Pa = 5, Da = 6, La = 7, So = 0, $h = 1, Jh = 2, Jn = 0, Uc = 1, Nc = 2, Fc = 3, bo = 4, Oc = 5, Bc = 6, zc = 7, sl = \"attached\", Qh = \"detached\", kc = 300, Gi = 301, Hi = 302, vr = 303, Ia = 304, Rr = 306, wn = 1e3, en = 1001, Mr = 1002, Dt = 1003, Vc = 1004, ms = 1005, bt = 1006, ur = 1007, yn = 1008, mn = 1009, Gc = 1010, Hc = 1011, Ss = 1012, yo = 1013, di = 1014, Xt = 1015, xt = 1016, To = 1017, Eo = 1018, Wi = 1020, Wc = 35902, Xc = 35899, jc = 1021, qc = 1022, Zt = 1023, bs = 1026, Xi = 1027, wo = 1028, Ao = 1029, Ro = 1030, Co = 1031, Po = 1033, dr = 33776, fr = 33777, pr = 33778, mr = 33779, Ua = 35840, Na = 35841, Fa = 35842, Oa = 35843, Ba = 36196, za = 37492, ka = 37496, Va = 37808, Ga = 37809, Ha = 37810, Wa = 37811, Xa = 37812, ja = 37813, qa = 37814, Ya = 37815, Ka = 37816, Za = 37817, $a = 37818, Ja = 37819, Qa = 37820, eo = 37821, to = 36492, no = 36494, io = 36495, so = 36283, ro = 36284, ao = 36285, oo = 36286, ys = 2300, Ts = 2301, Ur = 2302, rl = 2400, al = 2401, ol = 2402, eu = 2500, tu = 0, Yc = 1, lo = 2, nu = 3200, Kc = 3201, Cr = 0, iu = 1, Kn = \"\", Rt = \"srgb\", Ut = \"srgb-linear\", Sr = \"linear\", et = \"srgb\", xi = 7680, Nr = 34055, Fr = 34056, su = 517, co = 519, ru = 512, au = 513, ou = 514, Zc = 515, lu = 516, cu = 517, hu = 518, uu = 519, ho = 35044, ll = \"300 es\", Tn = 2e3, br = 2001;\nfunction $c(i) {\n for (let e = i.length - 1; e >= 0; --e)\n if (i[e] >= 65535) return !0;\n return !1;\n}\nfunction Es(i) {\n return document.createElementNS(\"http://www.w3.org/1999/xhtml\", i);\n}\nfunction du() {\n const i = Es(\"canvas\");\n return i.style.display = \"block\", i;\n}\nconst cl = {};\nfunction yr(...i) {\n const e = \"THREE.\" + i.shift();\n console.log(e, ...i);\n}\nfunction Te(...i) {\n const e = \"THREE.\" + i.shift();\n console.warn(e, ...i);\n}\nfunction Xe(...i) {\n const e = \"THREE.\" + i.shift();\n console.error(e, ...i);\n}\nfunction ws(...i) {\n const e = i.join(\" \");\n e in cl || (cl[e] = !0, Te(...i));\n}\nfunction fu(i, e, t) {\n return new Promise(function(n, s) {\n function r() {\n switch (i.clientWaitSync(e, i.SYNC_FLUSH_COMMANDS_BIT, 0)) {\n case i.WAIT_FAILED:\n s();\n break;\n case i.TIMEOUT_EXPIRED:\n setTimeout(r, t);\n break;\n default:\n n();\n }\n }\n setTimeout(r, t);\n });\n}\nclass mi {\n /**\n * Adds the given event listener to the given event type.\n *\n * @param {string} type - The type of event to listen to.\n * @param {Function} listener - The function that gets called when the event is fired.\n */\n addEventListener(e, t) {\n this._listeners === void 0 && (this._listeners = {});\n const n = this._listeners;\n n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t);\n }\n /**\n * Returns `true` if the given event listener has been added to the given event type.\n *\n * @param {string} type - The type of event.\n * @param {Function} listener - The listener to check.\n * @return {boolean} Whether the given event listener has been added to the given event type.\n */\n hasEventListener(e, t) {\n const n = this._listeners;\n return n === void 0 ? !1 : n[e] !== void 0 && n[e].indexOf(t) !== -1;\n }\n /**\n * Removes the given event listener from the given event type.\n *\n * @param {string} type - The type of event.\n * @param {Function} listener - The listener to remove.\n */\n removeEventListener(e, t) {\n const n = this._listeners;\n if (n === void 0) return;\n const s = n[e];\n if (s !== void 0) {\n const r = s.indexOf(t);\n r !== -1 && s.splice(r, 1);\n }\n }\n /**\n * Dispatches an event object.\n *\n * @param {Object} event - The event that gets fired.\n */\n dispatchEvent(e) {\n const t = this._listeners;\n if (t === void 0) return;\n const n = t[e.type];\n if (n !== void 0) {\n e.target = this;\n const s = n.slice(0);\n for (let r = 0, a = s.length; r < a; r++)\n s[r].call(this, e);\n e.target = null;\n }\n }\n}\nconst Lt = [\"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\"];\nlet hl = 1234567;\nconst _s = Math.PI / 180, ji = 180 / Math.PI;\nfunction fn() {\n const i = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0;\n return (Lt[i & 255] + Lt[i >> 8 & 255] + Lt[i >> 16 & 255] + Lt[i >> 24 & 255] + \"-\" + Lt[e & 255] + Lt[e >> 8 & 255] + \"-\" + Lt[e >> 16 & 15 | 64] + Lt[e >> 24 & 255] + \"-\" + Lt[t & 63 | 128] + Lt[t >> 8 & 255] + \"-\" + Lt[t >> 16 & 255] + Lt[t >> 24 & 255] + Lt[n & 255] + Lt[n >> 8 & 255] + Lt[n >> 16 & 255] + Lt[n >> 24 & 255]).toLowerCase();\n}\nfunction He(i, e, t) {\n return Math.max(e, Math.min(t, i));\n}\nfunction Do(i, e) {\n return (i % e + e) % e;\n}\nfunction pu(i, e, t, n, s) {\n return n + (i - e) * (s - n) / (t - e);\n}\nfunction mu(i, e, t) {\n return i !== e ? (t - i) / (e - i) : 0;\n}\nfunction vs(i, e, t) {\n return (1 - t) * i + t * e;\n}\nfunction gu(i, e, t, n) {\n return vs(i, e, 1 - Math.exp(-t * n));\n}\nfunction xu(i, e = 1) {\n return e - Math.abs(Do(i, e * 2) - e);\n}\nfunction _u(i, e, t) {\n return i <= e ? 0 : i >= t ? 1 : (i = (i - e) / (t - e), i * i * (3 - 2 * i));\n}\nfunction vu(i, e, t) {\n return i <= e ? 0 : i >= t ? 1 : (i = (i - e) / (t - e), i * i * i * (i * (i * 6 - 15) + 10));\n}\nfunction Mu(i, e) {\n return i + Math.floor(Math.random() * (e - i + 1));\n}\nfunction Su(i, e) {\n return i + Math.random() * (e - i);\n}\nfunction bu(i) {\n return i * (0.5 - Math.random());\n}\nfunction yu(i) {\n i !== void 0 && (hl = i);\n let e = hl += 1831565813;\n return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;\n}\nfunction Tu(i) {\n return i * _s;\n}\nfunction Eu(i) {\n return i * ji;\n}\nfunction wu(i) {\n return (i & i - 1) === 0 && i !== 0;\n}\nfunction Au(i) {\n return Math.pow(2, Math.ceil(Math.log(i) / Math.LN2));\n}\nfunction Ru(i) {\n return Math.pow(2, Math.floor(Math.log(i) / Math.LN2));\n}\nfunction Cu(i, e, t, n, s) {\n const r = Math.cos, a = Math.sin, o = r(t / 2), l = a(t / 2), c = r((e + n) / 2), h = a((e + n) / 2), u = r((e - n) / 2), d = a((e - n) / 2), p = r((n - e) / 2), g = a((n - e) / 2);\n switch (s) {\n case \"XYX\":\n i.set(o * h, l * u, l * d, o * c);\n break;\n case \"YZY\":\n i.set(l * d, o * h, l * u, o * c);\n break;\n case \"ZXZ\":\n i.set(l * u, l * d, o * h, o * c);\n break;\n case \"XZX\":\n i.set(o * h, l * g, l * p, o * c);\n break;\n case \"YXY\":\n i.set(l * p, o * h, l * g, o * c);\n break;\n case \"ZYZ\":\n i.set(l * g, l * p, o * h, o * c);\n break;\n default:\n Te(\"MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: \" + s);\n }\n}\nfunction hn(i, e) {\n switch (e.constructor) {\n case Float32Array:\n return i;\n case Uint32Array:\n return i / 4294967295;\n case Uint16Array:\n return i / 65535;\n case Uint8Array:\n return i / 255;\n case Int32Array:\n return Math.max(i / 2147483647, -1);\n case Int16Array:\n return Math.max(i / 32767, -1);\n case Int8Array:\n return Math.max(i / 127, -1);\n default:\n throw new Error(\"Invalid component type.\");\n }\n}\nfunction tt(i, e) {\n switch (e.constructor) {\n case Float32Array:\n return i;\n case Uint32Array:\n return Math.round(i * 4294967295);\n case Uint16Array:\n return Math.round(i * 65535);\n case Uint8Array:\n return Math.round(i * 255);\n case Int32Array:\n return Math.round(i * 2147483647);\n case Int16Array:\n return Math.round(i * 32767);\n case Int8Array:\n return Math.round(i * 127);\n default:\n throw new Error(\"Invalid component type.\");\n }\n}\nconst Lo = {\n DEG2RAD: _s,\n RAD2DEG: ji,\n /**\n * Generate a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)\n * (universally unique identifier).\n *\n * @static\n * @method\n * @return {string} The UUID.\n */\n generateUUID: fn,\n /**\n * Clamps the given value between min and max.\n *\n * @static\n * @method\n * @param {number} value - The value to clamp.\n * @param {number} min - The min value.\n * @param {number} max - The max value.\n * @return {number} The clamped value.\n */\n clamp: He,\n /**\n * Computes the Euclidean modulo of the given parameters that\n * is `( ( n % m ) + m ) % m`.\n *\n * @static\n * @method\n * @param {number} n - The first parameter.\n * @param {number} m - The second parameter.\n * @return {number} The Euclidean modulo.\n */\n euclideanModulo: Do,\n /**\n * Performs a linear mapping from range `` to range ``\n * for the given value.\n *\n * @static\n * @method\n * @param {number} x - The value to be mapped.\n * @param {number} a1 - Minimum value for range A.\n * @param {number} a2 - Maximum value for range A.\n * @param {number} b1 - Minimum value for range B.\n * @param {number} b2 - Maximum value for range B.\n * @return {number} The mapped value.\n */\n mapLinear: pu,\n /**\n * Returns the percentage in the closed interval `[0, 1]` of the given value\n * between the start and end point.\n *\n * @static\n * @method\n * @param {number} x - The start point\n * @param {number} y - The end point.\n * @param {number} value - A value between start and end.\n * @return {number} The interpolation factor.\n */\n inverseLerp: mu,\n /**\n * Returns a value linearly interpolated from two known points based on the given interval -\n * `t = 0` will return `x` and `t = 1` will return `y`.\n *\n * @static\n * @method\n * @param {number} x - The start point\n * @param {number} y - The end point.\n * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.\n * @return {number} The interpolated value.\n */\n lerp: vs,\n /**\n * Smoothly interpolate a number from `x` to `y` in a spring-like manner using a delta\n * time to maintain frame rate independent movement. For details, see\n * [Frame rate independent damping using lerp](http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/).\n *\n * @static\n * @method\n * @param {number} x - The current point.\n * @param {number} y - The target point.\n * @param {number} lambda - A higher lambda value will make the movement more sudden,\n * and a lower value will make the movement more gradual.\n * @param {number} dt - Delta time in seconds.\n * @return {number} The interpolated value.\n */\n damp: gu,\n /**\n * Returns a value that alternates between `0` and the given `length` parameter.\n *\n * @static\n * @method\n * @param {number} x - The value to pingpong.\n * @param {number} [length=1] - The positive value the function will pingpong to.\n * @return {number} The alternated value.\n */\n pingpong: xu,\n /**\n * Returns a value in the range `[0,1]` that represents the percentage that `x` has\n * moved between `min` and `max`, but smoothed or slowed down the closer `x` is to\n * the `min` and `max`.\n *\n * See [Smoothstep](http://en.wikipedia.org/wiki/Smoothstep) for more details.\n *\n * @static\n * @method\n * @param {number} x - The value to evaluate based on its position between min and max.\n * @param {number} min - The min value. Any x value below min will be `0`.\n * @param {number} max - The max value. Any x value above max will be `1`.\n * @return {number} The alternated value.\n */\n smoothstep: _u,\n /**\n * A [variation on smoothstep](https://en.wikipedia.org/wiki/Smoothstep#Variations)\n * that has zero 1st and 2nd order derivatives at x=0 and x=1.\n *\n * @static\n * @method\n * @param {number} x - The value to evaluate based on its position between min and max.\n * @param {number} min - The min value. Any x value below min will be `0`.\n * @param {number} max - The max value. Any x value above max will be `1`.\n * @return {number} The alternated value.\n */\n smootherstep: vu,\n /**\n * Returns a random integer from `` interval.\n *\n * @static\n * @method\n * @param {number} low - The lower value boundary.\n * @param {number} high - The upper value boundary\n * @return {number} A random integer.\n */\n randInt: Mu,\n /**\n * Returns a random float from `` interval.\n *\n * @static\n * @method\n * @param {number} low - The lower value boundary.\n * @param {number} high - The upper value boundary\n * @return {number} A random float.\n */\n randFloat: Su,\n /**\n * Returns a random integer from `<-range/2, range/2>` interval.\n *\n * @static\n * @method\n * @param {number} range - Defines the value range.\n * @return {number} A random float.\n */\n randFloatSpread: bu,\n /**\n * Returns a deterministic pseudo-random float in the interval `[0, 1]`.\n *\n * @static\n * @method\n * @param {number} [s] - The integer seed.\n * @return {number} A random float.\n */\n seededRandom: yu,\n /**\n * Converts degrees to radians.\n *\n * @static\n * @method\n * @param {number} degrees - A value in degrees.\n * @return {number} The converted value in radians.\n */\n degToRad: Tu,\n /**\n * Converts radians to degrees.\n *\n * @static\n * @method\n * @param {number} radians - A value in radians.\n * @return {number} The converted value in degrees.\n */\n radToDeg: Eu,\n /**\n * Returns `true` if the given number is a power of two.\n *\n * @static\n * @method\n * @param {number} value - The value to check.\n * @return {boolean} Whether the given number is a power of two or not.\n */\n isPowerOfTwo: wu,\n /**\n * Returns the smallest power of two that is greater than or equal to the given number.\n *\n * @static\n * @method\n * @param {number} value - The value to find a POT for.\n * @return {number} The smallest power of two that is greater than or equal to the given number.\n */\n ceilPowerOfTwo: Au,\n /**\n * Returns the largest power of two that is less than or equal to the given number.\n *\n * @static\n * @method\n * @param {number} value - The value to find a POT for.\n * @return {number} The largest power of two that is less than or equal to the given number.\n */\n floorPowerOfTwo: Ru,\n /**\n * Sets the given quaternion from the [Intrinsic Proper Euler Angles](https://en.wikipedia.org/wiki/Euler_angles)\n * defined by the given angles and order.\n *\n * Rotations are applied to the axes in the order specified by order:\n * rotation by angle `a` is applied first, then by angle `b`, then by angle `c`.\n *\n * @static\n * @method\n * @param {Quaternion} q - The quaternion to set.\n * @param {number} a - The rotation applied to the first axis, in radians.\n * @param {number} b - The rotation applied to the second axis, in radians.\n * @param {number} c - The rotation applied to the third axis, in radians.\n * @param {('XYX'|'XZX'|'YXY'|'YZY'|'ZXZ'|'ZYZ')} order - A string specifying the axes order.\n */\n setQuaternionFromProperEuler: Cu,\n /**\n * Normalizes the given value according to the given typed array.\n *\n * @static\n * @method\n * @param {number} value - The float value in the range `[0,1]` to normalize.\n * @param {TypedArray} array - The typed array that defines the data type of the value.\n * @return {number} The normalize value.\n */\n normalize: tt,\n /**\n * Denormalizes the given value according to the given typed array.\n *\n * @static\n * @method\n * @param {number} value - The value to denormalize.\n * @param {TypedArray} array - The typed array that defines the data type of the value.\n * @return {number} The denormalize (float) value in the range `[0,1]`.\n */\n denormalize: hn\n};\nclass le {\n /**\n * Constructs a new 2D vector.\n *\n * @param {number} [x=0] - The x value of this vector.\n * @param {number} [y=0] - The y value of this vector.\n */\n constructor(e = 0, t = 0) {\n le.prototype.isVector2 = !0, this.x = e, this.y = t;\n }\n /**\n * Alias for {@link Vector2#x}.\n *\n * @type {number}\n */\n get width() {\n return this.x;\n }\n set width(e) {\n this.x = e;\n }\n /**\n * Alias for {@link Vector2#y}.\n *\n * @type {number}\n */\n get height() {\n return this.y;\n }\n set height(e) {\n this.y = e;\n }\n /**\n * Sets the vector components.\n *\n * @param {number} x - The value of the x component.\n * @param {number} y - The value of the y component.\n * @return {Vector2} A reference to this vector.\n */\n set(e, t) {\n return this.x = e, this.y = t, this;\n }\n /**\n * Sets the vector components to the same value.\n *\n * @param {number} scalar - The value to set for all vector components.\n * @return {Vector2} A reference to this vector.\n */\n setScalar(e) {\n return this.x = e, this.y = e, this;\n }\n /**\n * Sets the vector's x component to the given value\n *\n * @param {number} x - The value to set.\n * @return {Vector2} A reference to this vector.\n */\n setX(e) {\n return this.x = e, this;\n }\n /**\n * Sets the vector's y component to the given value\n *\n * @param {number} y - The value to set.\n * @return {Vector2} A reference to this vector.\n */\n setY(e) {\n return this.y = e, this;\n }\n /**\n * Allows to set a vector component with an index.\n *\n * @param {number} index - The component index. `0` equals to x, `1` equals to y.\n * @param {number} value - The value to set.\n * @return {Vector2} A reference to this vector.\n */\n setComponent(e, t) {\n switch (e) {\n case 0:\n this.x = t;\n break;\n case 1:\n this.y = t;\n break;\n default:\n throw new Error(\"index is out of range: \" + e);\n }\n return this;\n }\n /**\n * Returns the value of the vector component which matches the given index.\n *\n * @param {number} index - The component index. `0` equals to x, `1` equals to y.\n * @return {number} A vector component value.\n */\n getComponent(e) {\n switch (e) {\n case 0:\n return this.x;\n case 1:\n return this.y;\n default:\n throw new Error(\"index is out of range: \" + e);\n }\n }\n /**\n * Returns a new vector with copied values from this instance.\n *\n * @return {Vector2} A clone of this instance.\n */\n clone() {\n return new this.constructor(this.x, this.y);\n }\n /**\n * Copies the values of the given vector to this instance.\n *\n * @param {Vector2} v - The vector to copy.\n * @return {Vector2} A reference to this vector.\n */\n copy(e) {\n return this.x = e.x, this.y = e.y, this;\n }\n /**\n * Adds the given vector to this instance.\n *\n * @param {Vector2} v - The vector to add.\n * @return {Vector2} A reference to this vector.\n */\n add(e) {\n return this.x += e.x, this.y += e.y, this;\n }\n /**\n * Adds the given scalar value to all components of this instance.\n *\n * @param {number} s - The scalar to add.\n * @return {Vector2} A reference to this vector.\n */\n addScalar(e) {\n return this.x += e, this.y += e, this;\n }\n /**\n * Adds the given vectors and stores the result in this instance.\n *\n * @param {Vector2} a - The first vector.\n * @param {Vector2} b - The second vector.\n * @return {Vector2} A reference to this vector.\n */\n addVectors(e, t) {\n return this.x = e.x + t.x, this.y = e.y + t.y, this;\n }\n /**\n * Adds the given vector scaled by the given factor to this instance.\n *\n * @param {Vector2} v - The vector.\n * @param {number} s - The factor that scales `v`.\n * @return {Vector2} A reference to this vector.\n */\n addScaledVector(e, t) {\n return this.x += e.x * t, this.y += e.y * t, this;\n }\n /**\n * Subtracts the given vector from this instance.\n *\n * @param {Vector2} v - The vector to subtract.\n * @return {Vector2} A reference to this vector.\n */\n sub(e) {\n return this.x -= e.x, this.y -= e.y, this;\n }\n /**\n * Subtracts the given scalar value from all components of this instance.\n *\n * @param {number} s - The scalar to subtract.\n * @return {Vector2} A reference to this vector.\n */\n subScalar(e) {\n return this.x -= e, this.y -= e, this;\n }\n /**\n * Subtracts the given vectors and stores the result in this instance.\n *\n * @param {Vector2} a - The first vector.\n * @param {Vector2} b - The second vector.\n * @return {Vector2} A reference to this vector.\n */\n subVectors(e, t) {\n return this.x = e.x - t.x, this.y = e.y - t.y, this;\n }\n /**\n * Multiplies the given vector with this instance.\n *\n * @param {Vector2} v - The vector to multiply.\n * @return {Vector2} A reference to this vector.\n */\n multiply(e) {\n return this.x *= e.x, this.y *= e.y, this;\n }\n /**\n * Multiplies the given scalar value with all components of this instance.\n *\n * @param {number} scalar - The scalar to multiply.\n * @return {Vector2} A reference to this vector.\n */\n multiplyScalar(e) {\n return this.x *= e, this.y *= e, this;\n }\n /**\n * Divides this instance by the given vector.\n *\n * @param {Vector2} v - The vector to divide.\n * @return {Vector2} A reference to this vector.\n */\n divide(e) {\n return this.x /= e.x, this.y /= e.y, this;\n }\n /**\n * Divides this vector by the given scalar.\n *\n * @param {number} scalar - The scalar to divide.\n * @return {Vector2} A reference to this vector.\n */\n divideScalar(e) {\n return this.multiplyScalar(1 / e);\n }\n /**\n * Multiplies this vector (with an implicit 1 as the 3rd component) by\n * the given 3x3 matrix.\n *\n * @param {Matrix3} m - The matrix to apply.\n * @return {Vector2} A reference to this vector.\n */\n applyMatrix3(e) {\n const t = this.x, n = this.y, s = e.elements;\n return this.x = s[0] * t + s[3] * n + s[6], this.y = s[1] * t + s[4] * n + s[7], this;\n }\n /**\n * If this vector's x or y value is greater than the given vector's x or y\n * value, replace that value with the corresponding min value.\n *\n * @param {Vector2} v - The vector.\n * @return {Vector2} A reference to this vector.\n */\n min(e) {\n return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this;\n }\n /**\n * If this vector's x or y value is less than the given vector's x or y\n * value, replace that value with the corresponding max value.\n *\n * @param {Vector2} v - The vector.\n * @return {Vector2} A reference to this vector.\n */\n max(e) {\n return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this;\n }\n /**\n * If this vector's x or y value is greater than the max vector's x or y\n * value, it is replaced by the corresponding value.\n * If this vector's x or y value is less than the min vector's x or y value,\n * it is replaced by the corresponding value.\n *\n * @param {Vector2} min - The minimum x and y values.\n * @param {Vector2} max - The maximum x and y values in the desired range.\n * @return {Vector2} A reference to this vector.\n */\n clamp(e, t) {\n return this.x = He(this.x, e.x, t.x), this.y = He(this.y, e.y, t.y), this;\n }\n /**\n * If this vector's x or y values are greater than the max value, they are\n * replaced by the max value.\n * If this vector's x or y values are less than the min value, they are\n * replaced by the min value.\n *\n * @param {number} minVal - The minimum value the components will be clamped to.\n * @param {number} maxVal - The maximum value the components will be clamped to.\n * @return {Vector2} A reference to this vector.\n */\n clampScalar(e, t) {\n return this.x = He(this.x, e, t), this.y = He(this.y, e, t), this;\n }\n /**\n * If this vector's length is greater than the max value, it is replaced by\n * the max value.\n * If this vector's length is less than the min value, it is replaced by the\n * min value.\n *\n * @param {number} min - The minimum value the vector length will be clamped to.\n * @param {number} max - The maximum value the vector length will be clamped to.\n * @return {Vector2} A reference to this vector.\n */\n clampLength(e, t) {\n const n = this.length();\n return this.divideScalar(n || 1).multiplyScalar(He(n, e, t));\n }\n /**\n * The components of this vector are rounded down to the nearest integer value.\n *\n * @return {Vector2} A reference to this vector.\n */\n floor() {\n return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;\n }\n /**\n * The components of this vector are rounded up to the nearest integer value.\n *\n * @return {Vector2} A reference to this vector.\n */\n ceil() {\n return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;\n }\n /**\n * The components of this vector are rounded to the nearest integer value\n *\n * @return {Vector2} A reference to this vector.\n */\n round() {\n return this.x = Math.round(this.x), this.y = Math.round(this.y), this;\n }\n /**\n * The components of this vector are rounded towards zero (up if negative,\n * down if positive) to an integer value.\n *\n * @return {Vector2} A reference to this vector.\n */\n roundToZero() {\n return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;\n }\n /**\n * Inverts this vector - i.e. sets x = -x and y = -y.\n *\n * @return {Vector2} A reference to this vector.\n */\n negate() {\n return this.x = -this.x, this.y = -this.y, this;\n }\n /**\n * Calculates the dot product of the given vector with this instance.\n *\n * @param {Vector2} v - The vector to compute the dot product with.\n * @return {number} The result of the dot product.\n */\n dot(e) {\n return this.x * e.x + this.y * e.y;\n }\n /**\n * Calculates the cross product of the given vector with this instance.\n *\n * @param {Vector2} v - The vector to compute the cross product with.\n * @return {number} The result of the cross product.\n */\n cross(e) {\n return this.x * e.y - this.y * e.x;\n }\n /**\n * Computes the square of the Euclidean length (straight-line length) from\n * (0, 0) to (x, y). If you are comparing the lengths of vectors, you should\n * compare the length squared instead as it is slightly more efficient to calculate.\n *\n * @return {number} The square length of this vector.\n */\n lengthSq() {\n return this.x * this.x + this.y * this.y;\n }\n /**\n * Computes the Euclidean length (straight-line length) from (0, 0) to (x, y).\n *\n * @return {number} The length of this vector.\n */\n length() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n }\n /**\n * Computes the Manhattan length of this vector.\n *\n * @return {number} The length of this vector.\n */\n manhattanLength() {\n return Math.abs(this.x) + Math.abs(this.y);\n }\n /**\n * Converts this vector to a unit vector - that is, sets it equal to a vector\n * with the same direction as this one, but with a vector length of `1`.\n *\n * @return {Vector2} A reference to this vector.\n */\n normalize() {\n return this.divideScalar(this.length() || 1);\n }\n /**\n * Computes the angle in radians of this vector with respect to the positive x-axis.\n *\n * @return {number} The angle in radians.\n */\n angle() {\n return Math.atan2(-this.y, -this.x) + Math.PI;\n }\n /**\n * Returns the angle between the given vector and this instance in radians.\n *\n * @param {Vector2} v - The vector to compute the angle with.\n * @return {number} The angle in radians.\n */\n angleTo(e) {\n const t = Math.sqrt(this.lengthSq() * e.lengthSq());\n if (t === 0) return Math.PI / 2;\n const n = this.dot(e) / t;\n return Math.acos(He(n, -1, 1));\n }\n /**\n * Computes the distance from the given vector to this instance.\n *\n * @param {Vector2} v - The vector to compute the distance to.\n * @return {number} The distance.\n */\n distanceTo(e) {\n return Math.sqrt(this.distanceToSquared(e));\n }\n /**\n * Computes the squared distance from the given vector to this instance.\n * If you are just comparing the distance with another distance, you should compare\n * the distance squared instead as it is slightly more efficient to calculate.\n *\n * @param {Vector2} v - The vector to compute the squared distance to.\n * @return {number} The squared distance.\n */\n distanceToSquared(e) {\n const t = this.x - e.x, n = this.y - e.y;\n return t * t + n * n;\n }\n /**\n * Computes the Manhattan distance from the given vector to this instance.\n *\n * @param {Vector2} v - The vector to compute the Manhattan distance to.\n * @return {number} The Manhattan distance.\n */\n manhattanDistanceTo(e) {\n return Math.abs(this.x - e.x) + Math.abs(this.y - e.y);\n }\n /**\n * Sets this vector to a vector with the same direction as this one, but\n * with the specified length.\n *\n * @param {number} length - The new length of this vector.\n * @return {Vector2} A reference to this vector.\n */\n setLength(e) {\n return this.normalize().multiplyScalar(e);\n }\n /**\n * Linearly interpolates between the given vector and this instance, where\n * alpha is the percent distance along the line - alpha = 0 will be this\n * vector, and alpha = 1 will be the given one.\n *\n * @param {Vector2} v - The vector to interpolate towards.\n * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n * @return {Vector2} A reference to this vector.\n */\n lerp(e, t) {\n return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this;\n }\n /**\n * Linearly interpolates between the given vectors, where alpha is the percent\n * distance along the line - alpha = 0 will be first vector, and alpha = 1 will\n * be the second one. The result is stored in this instance.\n *\n * @param {Vector2} v1 - The first vector.\n * @param {Vector2} v2 - The second vector.\n * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n * @return {Vector2} A reference to this vector.\n */\n lerpVectors(e, t, n) {\n return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this;\n }\n /**\n * Returns `true` if this vector is equal with the given one.\n *\n * @param {Vector2} v - The vector to test for equality.\n * @return {boolean} Whether this vector is equal with the given one.\n */\n equals(e) {\n return e.x === this.x && e.y === this.y;\n }\n /**\n * Sets this vector's x value to be `array[ offset ]` and y\n * value to be `array[ offset + 1 ]`.\n *\n * @param {Array} array - An array holding the vector component values.\n * @param {number} [offset=0] - The offset into the array.\n * @return {Vector2} A reference to this vector.\n */\n fromArray(e, t = 0) {\n return this.x = e[t], this.y = e[t + 1], this;\n }\n /**\n * Writes the components of this vector to the given array. If no array is provided,\n * the method returns a new instance.\n *\n * @param {Array} [array=[]] - The target array holding the vector components.\n * @param {number} [offset=0] - Index of the first element in the array.\n * @return {Array} The vector components.\n */\n toArray(e = [], t = 0) {\n return e[t] = this.x, e[t + 1] = this.y, e;\n }\n /**\n * Sets the components of this vector from the given buffer attribute.\n *\n * @param {BufferAttribute} attribute - The buffer attribute holding vector data.\n * @param {number} index - The index into the attribute.\n * @return {Vector2} A reference to this vector.\n */\n fromBufferAttribute(e, t) {\n return this.x = e.getX(t), this.y = e.getY(t), this;\n }\n /**\n * Rotates this vector around the given center by the given angle.\n *\n * @param {Vector2} center - The point around which to rotate.\n * @param {number} angle - The angle to rotate, in radians.\n * @return {Vector2} A reference to this vector.\n */\n rotateAround(e, t) {\n const n = Math.cos(t), s = Math.sin(t), r = this.x - e.x, a = this.y - e.y;\n return this.x = r * n - a * s + e.x, this.y = r * s + a * n + e.y, this;\n }\n /**\n * Sets each component of this vector to a pseudo-random value between `0` and\n * `1`, excluding `1`.\n *\n * @return {Vector2} A reference to this vector.\n */\n random() {\n return this.x = Math.random(), this.y = Math.random(), this;\n }\n *[Symbol.iterator]() {\n yield this.x, yield this.y;\n }\n}\nclass gn {\n /**\n * Constructs a new quaternion.\n *\n * @param {number} [x=0] - The x value of this quaternion.\n * @param {number} [y=0] - The y value of this quaternion.\n * @param {number} [z=0] - The z value of this quaternion.\n * @param {number} [w=1] - The w value of this quaternion.\n */\n constructor(e = 0, t = 0, n = 0, s = 1) {\n this.isQuaternion = !0, this._x = e, this._y = t, this._z = n, this._w = s;\n }\n /**\n * Interpolates between two quaternions via SLERP. This implementation assumes the\n * quaternion data are managed in flat arrays.\n *\n * @param {Array} dst - The destination array.\n * @param {number} dstOffset - An offset into the destination array.\n * @param {Array} src0 - The source array of the first quaternion.\n * @param {number} srcOffset0 - An offset into the first source array.\n * @param {Array} src1 - The source array of the second quaternion.\n * @param {number} srcOffset1 - An offset into the second source array.\n * @param {number} t - The interpolation factor in the range `[0,1]`.\n * @see {@link Quaternion#slerp}\n */\n static slerpFlat(e, t, n, s, r, a, o) {\n let l = n[s + 0], c = n[s + 1], h = n[s + 2], u = n[s + 3], d = r[a + 0], p = r[a + 1], g = r[a + 2], x = r[a + 3];\n if (o <= 0) {\n e[t + 0] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u;\n return;\n }\n if (o >= 1) {\n e[t + 0] = d, e[t + 1] = p, e[t + 2] = g, e[t + 3] = x;\n return;\n }\n if (u !== x || l !== d || c !== p || h !== g) {\n let m = l * d + c * p + h * g + u * x;\n m < 0 && (d = -d, p = -p, g = -g, x = -x, m = -m);\n let f = 1 - o;\n if (m < 0.9995) {\n const y = Math.acos(m), v = Math.sin(y);\n f = Math.sin(f * y) / v, o = Math.sin(o * y) / v, l = l * f + d * o, c = c * f + p * o, h = h * f + g * o, u = u * f + x * o;\n } else {\n l = l * f + d * o, c = c * f + p * o, h = h * f + g * o, u = u * f + x * o;\n const y = 1 / Math.sqrt(l * l + c * c + h * h + u * u);\n l *= y, c *= y, h *= y, u *= y;\n }\n }\n e[t] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u;\n }\n /**\n * Multiplies two quaternions. This implementation assumes the quaternion data are managed\n * in flat arrays.\n *\n * @param {Array} dst - The destination array.\n * @param {number} dstOffset - An offset into the destination array.\n * @param {Array} src0 - The source array of the first quaternion.\n * @param {number} srcOffset0 - An offset into the first source array.\n * @param {Array} src1 - The source array of the second quaternion.\n * @param {number} srcOffset1 - An offset into the second source array.\n * @return {Array} The destination array.\n * @see {@link Quaternion#multiplyQuaternions}.\n */\n static multiplyQuaternionsFlat(e, t, n, s, r, a) {\n const o = n[s], l = n[s + 1], c = n[s + 2], h = n[s + 3], u = r[a], d = r[a + 1], p = r[a + 2], g = r[a + 3];\n return e[t] = o * g + h * u + l * p - c * d, e[t + 1] = l * g + h * d + c * u - o * p, e[t + 2] = c * g + h * p + o * d - l * u, e[t + 3] = h * g - o * u - l * d - c * p, e;\n }\n /**\n * The x value of this quaternion.\n *\n * @type {number}\n * @default 0\n */\n get x() {\n return this._x;\n }\n set x(e) {\n this._x = e, this._onChangeCallback();\n }\n /**\n * The y value of this quaternion.\n *\n * @type {number}\n * @default 0\n */\n get y() {\n return this._y;\n }\n set y(e) {\n this._y = e, this._onChangeCallback();\n }\n /**\n * The z value of this quaternion.\n *\n * @type {number}\n * @default 0\n */\n get z() {\n return this._z;\n }\n set z(e) {\n this._z = e, this._onChangeCallback();\n }\n /**\n * The w value of this quaternion.\n *\n * @type {number}\n * @default 1\n */\n get w() {\n return this._w;\n }\n set w(e) {\n this._w = e, this._onChangeCallback();\n }\n /**\n * Sets the quaternion components.\n *\n * @param {number} x - The x value of this quaternion.\n * @param {number} y - The y value of this quaternion.\n * @param {number} z - The z value of this quaternion.\n * @param {number} w - The w value of this quaternion.\n * @return {Quaternion} A reference to this quaternion.\n */\n set(e, t, n, s) {\n return this._x = e, this._y = t, this._z = n, this._w = s, this._onChangeCallback(), this;\n }\n /**\n * Returns a new quaternion with copied values from this instance.\n *\n * @return {Quaternion} A clone of this instance.\n */\n clone() {\n return new this.constructor(this._x, this._y, this._z, this._w);\n }\n /**\n * Copies the values of the given quaternion to this instance.\n *\n * @param {Quaternion} quaternion - The quaternion to copy.\n * @return {Quaternion} A reference to this quaternion.\n */\n copy(e) {\n return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this;\n }\n /**\n * Sets this quaternion from the rotation specified by the given\n * Euler angles.\n *\n * @param {Euler} euler - The Euler angles.\n * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.\n * @return {Quaternion} A reference to this quaternion.\n */\n setFromEuler(e, t = !0) {\n const n = e._x, s = e._y, r = e._z, a = e._order, o = Math.cos, l = Math.sin, c = o(n / 2), h = o(s / 2), u = o(r / 2), d = l(n / 2), p = l(s / 2), g = l(r / 2);\n switch (a) {\n case \"XYZ\":\n this._x = d * h * u + c * p * g, this._y = c * p * u - d * h * g, this._z = c * h * g + d * p * u, this._w = c * h * u - d * p * g;\n break;\n case \"YXZ\":\n this._x = d * h * u + c * p * g, this._y = c * p * u - d * h * g, this._z = c * h * g - d * p * u, this._w = c * h * u + d * p * g;\n break;\n case \"ZXY\":\n this._x = d * h * u - c * p * g, this._y = c * p * u + d * h * g, this._z = c * h * g + d * p * u, this._w = c * h * u - d * p * g;\n break;\n case \"ZYX\":\n this._x = d * h * u - c * p * g, this._y = c * p * u + d * h * g, this._z = c * h * g - d * p * u, this._w = c * h * u + d * p * g;\n break;\n case \"YZX\":\n this._x = d * h * u + c * p * g, this._y = c * p * u + d * h * g, this._z = c * h * g - d * p * u, this._w = c * h * u - d * p * g;\n break;\n case \"XZY\":\n this._x = d * h * u - c * p * g, this._y = c * p * u - d * h * g, this._z = c * h * g + d * p * u, this._w = c * h * u + d * p * g;\n break;\n default:\n Te(\"Quaternion: .setFromEuler() encountered an unknown order: \" + a);\n }\n return t === !0 && this._onChangeCallback(), this;\n }\n /**\n * Sets this quaternion from the given axis and angle.\n *\n * @param {Vector3} axis - The normalized axis.\n * @param {number} angle - The angle in radians.\n * @return {Quaternion} A reference to this quaternion.\n */\n setFromAxisAngle(e, t) {\n const n = t / 2, s = Math.sin(n);\n return this._x = e.x * s, this._y = e.y * s, this._z = e.z * s, this._w = Math.cos(n), this._onChangeCallback(), this;\n }\n /**\n * Sets this quaternion from the given rotation matrix.\n *\n * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).\n * @return {Quaternion} A reference to this quaternion.\n */\n setFromRotationMatrix(e) {\n const t = e.elements, n = t[0], s = t[4], r = t[8], a = t[1], o = t[5], l = t[9], c = t[2], h = t[6], u = t[10], d = n + o + u;\n if (d > 0) {\n const p = 0.5 / Math.sqrt(d + 1);\n this._w = 0.25 / p, this._x = (h - l) * p, this._y = (r - c) * p, this._z = (a - s) * p;\n } else if (n > o && n > u) {\n const p = 2 * Math.sqrt(1 + n - o - u);\n this._w = (h - l) / p, this._x = 0.25 * p, this._y = (s + a) / p, this._z = (r + c) / p;\n } else if (o > u) {\n const p = 2 * Math.sqrt(1 + o - n - u);\n this._w = (r - c) / p, this._x = (s + a) / p, this._y = 0.25 * p, this._z = (l + h) / p;\n } else {\n const p = 2 * Math.sqrt(1 + u - n - o);\n this._w = (a - s) / p, this._x = (r + c) / p, this._y = (l + h) / p, this._z = 0.25 * p;\n }\n return this._onChangeCallback(), this;\n }\n /**\n * Sets this quaternion to the rotation required to rotate the direction vector\n * `vFrom` to the direction vector `vTo`.\n *\n * @param {Vector3} vFrom - The first (normalized) direction vector.\n * @param {Vector3} vTo - The second (normalized) direction vector.\n * @return {Quaternion} A reference to this quaternion.\n */\n setFromUnitVectors(e, t) {\n let n = e.dot(t) + 1;\n return n < 1e-8 ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize();\n }\n /**\n * Returns the angle between this quaternion and the given one in radians.\n *\n * @param {Quaternion} q - The quaternion to compute the angle with.\n * @return {number} The angle in radians.\n */\n angleTo(e) {\n return 2 * Math.acos(Math.abs(He(this.dot(e), -1, 1)));\n }\n /**\n * Rotates this quaternion by a given angular step to the given quaternion.\n * The method ensures that the final quaternion will not overshoot `q`.\n *\n * @param {Quaternion} q - The target quaternion.\n * @param {number} step - The angular step in radians.\n * @return {Quaternion} A reference to this quaternion.\n */\n rotateTowards(e, t) {\n const n = this.angleTo(e);\n if (n === 0) return this;\n const s = Math.min(1, t / n);\n return this.slerp(e, s), this;\n }\n /**\n * Sets this quaternion to the identity quaternion; that is, to the\n * quaternion that represents \"no rotation\".\n *\n * @return {Quaternion} A reference to this quaternion.\n */\n identity() {\n return this.set(0, 0, 0, 1);\n }\n /**\n * Inverts this quaternion via {@link Quaternion#conjugate}. The\n * quaternion is assumed to have unit length.\n *\n * @return {Quaternion} A reference to this quaternion.\n */\n invert() {\n return this.conjugate();\n }\n /**\n * Returns the rotational conjugate of this quaternion. The conjugate of a\n * quaternion represents the same rotation in the opposite direction about\n * the rotational axis.\n *\n * @return {Quaternion} A reference to this quaternion.\n */\n conjugate() {\n return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;\n }\n /**\n * Calculates the dot product of this quaternion and the given one.\n *\n * @param {Quaternion} v - The quaternion to compute the dot product with.\n * @return {number} The result of the dot product.\n */\n dot(e) {\n return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;\n }\n /**\n * Computes the squared Euclidean length (straight-line length) of this quaternion,\n * considered as a 4 dimensional vector. This can be useful if you are comparing the\n * lengths of two quaternions, as this is a slightly more efficient calculation than\n * {@link Quaternion#length}.\n *\n * @return {number} The squared Euclidean length.\n */\n lengthSq() {\n return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;\n }\n /**\n * Computes the Euclidean length (straight-line length) of this quaternion,\n * considered as a 4 dimensional vector.\n *\n * @return {number} The Euclidean length.\n */\n length() {\n return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);\n }\n /**\n * Normalizes this quaternion - that is, calculated the quaternion that performs\n * the same rotation as this one, but has a length equal to `1`.\n *\n * @return {Quaternion} A reference to this quaternion.\n */\n normalize() {\n let e = this.length();\n return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this;\n }\n /**\n * Multiplies this quaternion by the given one.\n *\n * @param {Quaternion} q - The quaternion.\n * @return {Quaternion} A reference to this quaternion.\n */\n multiply(e) {\n return this.multiplyQuaternions(this, e);\n }\n /**\n * Pre-multiplies this quaternion by the given one.\n *\n * @param {Quaternion} q - The quaternion.\n * @return {Quaternion} A reference to this quaternion.\n */\n premultiply(e) {\n return this.multiplyQuaternions(e, this);\n }\n /**\n * Multiplies the given quaternions and stores the result in this instance.\n *\n * @param {Quaternion} a - The first quaternion.\n * @param {Quaternion} b - The second quaternion.\n * @return {Quaternion} A reference to this quaternion.\n */\n multiplyQuaternions(e, t) {\n const n = e._x, s = e._y, r = e._z, a = e._w, o = t._x, l = t._y, c = t._z, h = t._w;\n return this._x = n * h + a * o + s * c - r * l, this._y = s * h + a * l + r * o - n * c, this._z = r * h + a * c + n * l - s * o, this._w = a * h - n * o - s * l - r * c, this._onChangeCallback(), this;\n }\n /**\n * Performs a spherical linear interpolation between quaternions.\n *\n * @param {Quaternion} qb - The target quaternion.\n * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.\n * @return {Quaternion} A reference to this quaternion.\n */\n slerp(e, t) {\n if (t <= 0) return this;\n if (t >= 1) return this.copy(e);\n let n = e._x, s = e._y, r = e._z, a = e._w, o = this.dot(e);\n o < 0 && (n = -n, s = -s, r = -r, a = -a, o = -o);\n let l = 1 - t;\n if (o < 0.9995) {\n const c = Math.acos(o), h = Math.sin(c);\n l = Math.sin(l * c) / h, t = Math.sin(t * c) / h, this._x = this._x * l + n * t, this._y = this._y * l + s * t, this._z = this._z * l + r * t, this._w = this._w * l + a * t, this._onChangeCallback();\n } else\n this._x = this._x * l + n * t, this._y = this._y * l + s * t, this._z = this._z * l + r * t, this._w = this._w * l + a * t, this.normalize();\n return this;\n }\n /**\n * Performs a spherical linear interpolation between the given quaternions\n * and stores the result in this quaternion.\n *\n * @param {Quaternion} qa - The source quaternion.\n * @param {Quaternion} qb - The target quaternion.\n * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.\n * @return {Quaternion} A reference to this quaternion.\n */\n slerpQuaternions(e, t, n) {\n return this.copy(e).slerp(t, n);\n }\n /**\n * Sets this quaternion to a uniformly random, normalized quaternion.\n *\n * @return {Quaternion} A reference to this quaternion.\n */\n random() {\n const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), n = Math.random(), s = Math.sqrt(1 - n), r = Math.sqrt(n);\n return this.set(\n s * Math.sin(e),\n s * Math.cos(e),\n r * Math.sin(t),\n r * Math.cos(t)\n );\n }\n /**\n * Returns `true` if this quaternion is equal with the given one.\n *\n * @param {Quaternion} quaternion - The quaternion to test for equality.\n * @return {boolean} Whether this quaternion is equal with the given one.\n */\n equals(e) {\n return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;\n }\n /**\n * Sets this quaternion's components from the given array.\n *\n * @param {Array} array - An array holding the quaternion component values.\n * @param {number} [offset=0] - The offset into the array.\n * @return {Quaternion} A reference to this quaternion.\n */\n fromArray(e, t = 0) {\n return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this;\n }\n /**\n * Writes the components of this quaternion to the given array. If no array is provided,\n * the method returns a new instance.\n *\n * @param {Array} [array=[]] - The target array holding the quaternion components.\n * @param {number} [offset=0] - Index of the first element in the array.\n * @return {Array} The quaternion components.\n */\n toArray(e = [], t = 0) {\n return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e;\n }\n /**\n * Sets the components of this quaternion from the given buffer attribute.\n *\n * @param {BufferAttribute} attribute - The buffer attribute holding quaternion data.\n * @param {number} index - The index into the attribute.\n * @return {Quaternion} A reference to this quaternion.\n */\n fromBufferAttribute(e, t) {\n return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this._onChangeCallback(), this;\n }\n /**\n * This methods defines the serialization result of this class. Returns the\n * numerical elements of this quaternion in an array of format `[x, y, z, w]`.\n *\n * @return {Array} The serialized quaternion.\n */\n toJSON() {\n return this.toArray();\n }\n _onChange(e) {\n return this._onChangeCallback = e, this;\n }\n _onChangeCallback() {\n }\n *[Symbol.iterator]() {\n yield this._x, yield this._y, yield this._z, yield this._w;\n }\n}\nclass w {\n /**\n * Constructs a new 3D vector.\n *\n * @param {number} [x=0] - The x value of this vector.\n * @param {number} [y=0] - The y value of this vector.\n * @param {number} [z=0] - The z value of this vector.\n */\n constructor(e = 0, t = 0, n = 0) {\n w.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = n;\n }\n /**\n * Sets the vector components.\n *\n * @param {number} x - The value of the x component.\n * @param {number} y - The value of the y component.\n * @param {number} z - The value of the z component.\n * @return {Vector3} A reference to this vector.\n */\n set(e, t, n) {\n return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this;\n }\n /**\n * Sets the vector components to the same value.\n *\n * @param {number} scalar - The value to set for all vector components.\n * @return {Vector3} A reference to this vector.\n */\n setScalar(e) {\n return this.x = e, this.y = e, this.z = e, this;\n }\n /**\n * Sets the vector's x component to the given value\n *\n * @param {number} x - The value to set.\n * @return {Vector3} A reference to this vector.\n */\n setX(e) {\n return this.x = e, this;\n }\n /**\n * Sets the vector's y component to the given value\n *\n * @param {number} y - The value to set.\n * @return {Vector3} A reference to this vector.\n */\n setY(e) {\n return this.y = e, this;\n }\n /**\n * Sets the vector's z component to the given value\n *\n * @param {number} z - The value to set.\n * @return {Vector3} A reference to this vector.\n */\n setZ(e) {\n return this.z = e, this;\n }\n /**\n * Allows to set a vector component with an index.\n *\n * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.\n * @param {number} value - The value to set.\n * @return {Vector3} A reference to this vector.\n */\n setComponent(e, t) {\n switch (e) {\n case 0:\n this.x = t;\n break;\n case 1:\n this.y = t;\n break;\n case 2:\n this.z = t;\n break;\n default:\n throw new Error(\"index is out of range: \" + e);\n }\n return this;\n }\n /**\n * Returns the value of the vector component which matches the given index.\n *\n * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.\n * @return {number} A vector component value.\n */\n getComponent(e) {\n switch (e) {\n case 0:\n return this.x;\n case 1:\n return this.y;\n case 2:\n return this.z;\n default:\n throw new Error(\"index is out of range: \" + e);\n }\n }\n /**\n * Returns a new vector with copied values from this instance.\n *\n * @return {Vector3} A clone of this instance.\n */\n clone() {\n return new this.constructor(this.x, this.y, this.z);\n }\n /**\n * Copies the values of the given vector to this instance.\n *\n * @param {Vector3} v - The vector to copy.\n * @return {Vector3} A reference to this vector.\n */\n copy(e) {\n return this.x = e.x, this.y = e.y, this.z = e.z, this;\n }\n /**\n * Adds the given vector to this instance.\n *\n * @param {Vector3} v - The vector to add.\n * @return {Vector3} A reference to this vector.\n */\n add(e) {\n return this.x += e.x, this.y += e.y, this.z += e.z, this;\n }\n /**\n * Adds the given scalar value to all components of this instance.\n *\n * @param {number} s - The scalar to add.\n * @return {Vector3} A reference to this vector.\n */\n addScalar(e) {\n return this.x += e, this.y += e, this.z += e, this;\n }\n /**\n * Adds the given vectors and stores the result in this instance.\n *\n * @param {Vector3} a - The first vector.\n * @param {Vector3} b - The second vector.\n * @return {Vector3} A reference to this vector.\n */\n addVectors(e, t) {\n return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this;\n }\n /**\n * Adds the given vector scaled by the given factor to this instance.\n *\n * @param {Vector3|Vector4} v - The vector.\n * @param {number} s - The factor that scales `v`.\n * @return {Vector3} A reference to this vector.\n */\n addScaledVector(e, t) {\n return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this;\n }\n /**\n * Subtracts the given vector from this instance.\n *\n * @param {Vector3} v - The vector to subtract.\n * @return {Vector3} A reference to this vector.\n */\n sub(e) {\n return this.x -= e.x, this.y -= e.y, this.z -= e.z, this;\n }\n /**\n * Subtracts the given scalar value from all components of this instance.\n *\n * @param {number} s - The scalar to subtract.\n * @return {Vector3} A reference to this vector.\n */\n subScalar(e) {\n return this.x -= e, this.y -= e, this.z -= e, this;\n }\n /**\n * Subtracts the given vectors and stores the result in this instance.\n *\n * @param {Vector3} a - The first vector.\n * @param {Vector3} b - The second vector.\n * @return {Vector3} A reference to this vector.\n */\n subVectors(e, t) {\n return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this;\n }\n /**\n * Multiplies the given vector with this instance.\n *\n * @param {Vector3} v - The vector to multiply.\n * @return {Vector3} A reference to this vector.\n */\n multiply(e) {\n return this.x *= e.x, this.y *= e.y, this.z *= e.z, this;\n }\n /**\n * Multiplies the given scalar value with all components of this instance.\n *\n * @param {number} scalar - The scalar to multiply.\n * @return {Vector3} A reference to this vector.\n */\n multiplyScalar(e) {\n return this.x *= e, this.y *= e, this.z *= e, this;\n }\n /**\n * Multiplies the given vectors and stores the result in this instance.\n *\n * @param {Vector3} a - The first vector.\n * @param {Vector3} b - The second vector.\n * @return {Vector3} A reference to this vector.\n */\n multiplyVectors(e, t) {\n return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this;\n }\n /**\n * Applies the given Euler rotation to this vector.\n *\n * @param {Euler} euler - The Euler angles.\n * @return {Vector3} A reference to this vector.\n */\n applyEuler(e) {\n return this.applyQuaternion(ul.setFromEuler(e));\n }\n /**\n * Applies a rotation specified by an axis and an angle to this vector.\n *\n * @param {Vector3} axis - A normalized vector representing the rotation axis.\n * @param {number} angle - The angle in radians.\n * @return {Vector3} A reference to this vector.\n */\n applyAxisAngle(e, t) {\n return this.applyQuaternion(ul.setFromAxisAngle(e, t));\n }\n /**\n * Multiplies this vector with the given 3x3 matrix.\n *\n * @param {Matrix3} m - The 3x3 matrix.\n * @return {Vector3} A reference to this vector.\n */\n applyMatrix3(e) {\n const t = this.x, n = this.y, s = this.z, r = e.elements;\n return this.x = r[0] * t + r[3] * n + r[6] * s, this.y = r[1] * t + r[4] * n + r[7] * s, this.z = r[2] * t + r[5] * n + r[8] * s, this;\n }\n /**\n * Multiplies this vector by the given normal matrix and normalizes\n * the result.\n *\n * @param {Matrix3} m - The normal matrix.\n * @return {Vector3} A reference to this vector.\n */\n applyNormalMatrix(e) {\n return this.applyMatrix3(e).normalize();\n }\n /**\n * Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and\n * divides by perspective.\n *\n * @param {Matrix4} m - The matrix to apply.\n * @return {Vector3} A reference to this vector.\n */\n applyMatrix4(e) {\n const t = this.x, n = this.y, s = this.z, r = e.elements, a = 1 / (r[3] * t + r[7] * n + r[11] * s + r[15]);\n return this.x = (r[0] * t + r[4] * n + r[8] * s + r[12]) * a, this.y = (r[1] * t + r[5] * n + r[9] * s + r[13]) * a, this.z = (r[2] * t + r[6] * n + r[10] * s + r[14]) * a, this;\n }\n /**\n * Applies the given Quaternion to this vector.\n *\n * @param {Quaternion} q - The Quaternion.\n * @return {Vector3} A reference to this vector.\n */\n applyQuaternion(e) {\n const t = this.x, n = this.y, s = this.z, r = e.x, a = e.y, o = e.z, l = e.w, c = 2 * (a * s - o * n), h = 2 * (o * t - r * s), u = 2 * (r * n - a * t);\n return this.x = t + l * c + a * u - o * h, this.y = n + l * h + o * c - r * u, this.z = s + l * u + r * h - a * c, this;\n }\n /**\n * Projects this vector from world space into the camera's normalized\n * device coordinate (NDC) space.\n *\n * @param {Camera} camera - The camera.\n * @return {Vector3} A reference to this vector.\n */\n project(e) {\n return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);\n }\n /**\n * Unprojects this vector from the camera's normalized device coordinate (NDC)\n * space into world space.\n *\n * @param {Camera} camera - The camera.\n * @return {Vector3} A reference to this vector.\n */\n unproject(e) {\n return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);\n }\n /**\n * Transforms the direction of this vector by a matrix (the upper left 3 x 3\n * subset of the given 4x4 matrix and then normalizes the result.\n *\n * @param {Matrix4} m - The matrix.\n * @return {Vector3} A reference to this vector.\n */\n transformDirection(e) {\n const t = this.x, n = this.y, s = this.z, r = e.elements;\n return this.x = r[0] * t + r[4] * n + r[8] * s, this.y = r[1] * t + r[5] * n + r[9] * s, this.z = r[2] * t + r[6] * n + r[10] * s, this.normalize();\n }\n /**\n * Divides this instance by the given vector.\n *\n * @param {Vector3} v - The vector to divide.\n * @return {Vector3} A reference to this vector.\n */\n divide(e) {\n return this.x /= e.x, this.y /= e.y, this.z /= e.z, this;\n }\n /**\n * Divides this vector by the given scalar.\n *\n * @param {number} scalar - The scalar to divide.\n * @return {Vector3} A reference to this vector.\n */\n divideScalar(e) {\n return this.multiplyScalar(1 / e);\n }\n /**\n * If this vector's x, y or z value is greater than the given vector's x, y or z\n * value, replace that value with the corresponding min value.\n *\n * @param {Vector3} v - The vector.\n * @return {Vector3} A reference to this vector.\n */\n min(e) {\n return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this;\n }\n /**\n * If this vector's x, y or z value is less than the given vector's x, y or z\n * value, replace that value with the corresponding max value.\n *\n * @param {Vector3} v - The vector.\n * @return {Vector3} A reference to this vector.\n */\n max(e) {\n return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this;\n }\n /**\n * If this vector's x, y or z value is greater than the max vector's x, y or z\n * value, it is replaced by the corresponding value.\n * If this vector's x, y or z value is less than the min vector's x, y or z value,\n * it is replaced by the corresponding value.\n *\n * @param {Vector3} min - The minimum x, y and z values.\n * @param {Vector3} max - The maximum x, y and z values in the desired range.\n * @return {Vector3} A reference to this vector.\n */\n clamp(e, t) {\n return this.x = He(this.x, e.x, t.x), this.y = He(this.y, e.y, t.y), this.z = He(this.z, e.z, t.z), this;\n }\n /**\n * If this vector's x, y or z values are greater than the max value, they are\n * replaced by the max value.\n * If this vector's x, y or z values are less than the min value, they are\n * replaced by the min value.\n *\n * @param {number} minVal - The minimum value the components will be clamped to.\n * @param {number} maxVal - The maximum value the components will be clamped to.\n * @return {Vector3} A reference to this vector.\n */\n clampScalar(e, t) {\n return this.x = He(this.x, e, t), this.y = He(this.y, e, t), this.z = He(this.z, e, t), this;\n }\n /**\n * If this vector's length is greater than the max value, it is replaced by\n * the max value.\n * If this vector's length is less than the min value, it is replaced by the\n * min value.\n *\n * @param {number} min - The minimum value the vector length will be clamped to.\n * @param {number} max - The maximum value the vector length will be clamped to.\n * @return {Vector3} A reference to this vector.\n */\n clampLength(e, t) {\n const n = this.length();\n return this.divideScalar(n || 1).multiplyScalar(He(n, e, t));\n }\n /**\n * The components of this vector are rounded down to the nearest integer value.\n *\n * @return {Vector3} A reference to this vector.\n */\n floor() {\n return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;\n }\n /**\n * The components of this vector are rounded up to the nearest integer value.\n *\n * @return {Vector3} A reference to this vector.\n */\n ceil() {\n return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;\n }\n /**\n * The components of this vector are rounded to the nearest integer value\n *\n * @return {Vector3} A reference to this vector.\n */\n round() {\n return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;\n }\n /**\n * The components of this vector are rounded towards zero (up if negative,\n * down if positive) to an integer value.\n *\n * @return {Vector3} A reference to this vector.\n */\n roundToZero() {\n return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;\n }\n /**\n * Inverts this vector - i.e. sets x = -x, y = -y and z = -z.\n *\n * @return {Vector3} A reference to this vector.\n */\n negate() {\n return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;\n }\n /**\n * Calculates the dot product of the given vector with this instance.\n *\n * @param {Vector3} v - The vector to compute the dot product with.\n * @return {number} The result of the dot product.\n */\n dot(e) {\n return this.x * e.x + this.y * e.y + this.z * e.z;\n }\n // TODO lengthSquared?\n /**\n * Computes the square of the Euclidean length (straight-line length) from\n * (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should\n * compare the length squared instead as it is slightly more efficient to calculate.\n *\n * @return {number} The square length of this vector.\n */\n lengthSq() {\n return this.x * this.x + this.y * this.y + this.z * this.z;\n }\n /**\n * Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).\n *\n * @return {number} The length of this vector.\n */\n length() {\n return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);\n }\n /**\n * Computes the Manhattan length of this vector.\n *\n * @return {number} The length of this vector.\n */\n manhattanLength() {\n return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);\n }\n /**\n * Converts this vector to a unit vector - that is, sets it equal to a vector\n * with the same direction as this one, but with a vector length of `1`.\n *\n * @return {Vector3} A reference to this vector.\n */\n normalize() {\n return this.divideScalar(this.length() || 1);\n }\n /**\n * Sets this vector to a vector with the same direction as this one, but\n * with the specified length.\n *\n * @param {number} length - The new length of this vector.\n * @return {Vector3} A reference to this vector.\n */\n setLength(e) {\n return this.normalize().multiplyScalar(e);\n }\n /**\n * Linearly interpolates between the given vector and this instance, where\n * alpha is the percent distance along the line - alpha = 0 will be this\n * vector, and alpha = 1 will be the given one.\n *\n * @param {Vector3} v - The vector to interpolate towards.\n * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n * @return {Vector3} A reference to this vector.\n */\n lerp(e, t) {\n return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this;\n }\n /**\n * Linearly interpolates between the given vectors, where alpha is the percent\n * distance along the line - alpha = 0 will be first vector, and alpha = 1 will\n * be the second one. The result is stored in this instance.\n *\n * @param {Vector3} v1 - The first vector.\n * @param {Vector3} v2 - The second vector.\n * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n * @return {Vector3} A reference to this vector.\n */\n lerpVectors(e, t, n) {\n return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this;\n }\n /**\n * Calculates the cross product of the given vector with this instance.\n *\n * @param {Vector3} v - The vector to compute the cross product with.\n * @return {Vector3} The result of the cross product.\n */\n cross(e) {\n return this.crossVectors(this, e);\n }\n /**\n * Calculates the cross product of the given vectors and stores the result\n * in this instance.\n *\n * @param {Vector3} a - The first vector.\n * @param {Vector3} b - The second vector.\n * @return {Vector3} A reference to this vector.\n */\n crossVectors(e, t) {\n const n = e.x, s = e.y, r = e.z, a = t.x, o = t.y, l = t.z;\n return this.x = s * l - r * o, this.y = r * a - n * l, this.z = n * o - s * a, this;\n }\n /**\n * Projects this vector onto the given one.\n *\n * @param {Vector3} v - The vector to project to.\n * @return {Vector3} A reference to this vector.\n */\n projectOnVector(e) {\n const t = e.lengthSq();\n if (t === 0) return this.set(0, 0, 0);\n const n = e.dot(this) / t;\n return this.copy(e).multiplyScalar(n);\n }\n /**\n * Projects this vector onto a plane by subtracting this\n * vector projected onto the plane's normal from this vector.\n *\n * @param {Vector3} planeNormal - The plane normal.\n * @return {Vector3} A reference to this vector.\n */\n projectOnPlane(e) {\n return Or.copy(this).projectOnVector(e), this.sub(Or);\n }\n /**\n * Reflects this vector off a plane orthogonal to the given normal vector.\n *\n * @param {Vector3} normal - The (normalized) normal vector.\n * @return {Vector3} A reference to this vector.\n */\n reflect(e) {\n return this.sub(Or.copy(e).multiplyScalar(2 * this.dot(e)));\n }\n /**\n * Returns the angle between the given vector and this instance in radians.\n *\n * @param {Vector3} v - The vector to compute the angle with.\n * @return {number} The angle in radians.\n */\n angleTo(e) {\n const t = Math.sqrt(this.lengthSq() * e.lengthSq());\n if (t === 0) return Math.PI / 2;\n const n = this.dot(e) / t;\n return Math.acos(He(n, -1, 1));\n }\n /**\n * Computes the distance from the given vector to this instance.\n *\n * @param {Vector3} v - The vector to compute the distance to.\n * @return {number} The distance.\n */\n distanceTo(e) {\n return Math.sqrt(this.distanceToSquared(e));\n }\n /**\n * Computes the squared distance from the given vector to this instance.\n * If you are just comparing the distance with another distance, you should compare\n * the distance squared instead as it is slightly more efficient to calculate.\n *\n * @param {Vector3} v - The vector to compute the squared distance to.\n * @return {number} The squared distance.\n */\n distanceToSquared(e) {\n const t = this.x - e.x, n = this.y - e.y, s = this.z - e.z;\n return t * t + n * n + s * s;\n }\n /**\n * Computes the Manhattan distance from the given vector to this instance.\n *\n * @param {Vector3} v - The vector to compute the Manhattan distance to.\n * @return {number} The Manhattan distance.\n */\n manhattanDistanceTo(e) {\n return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z);\n }\n /**\n * Sets the vector components from the given spherical coordinates.\n *\n * @param {Spherical} s - The spherical coordinates.\n * @return {Vector3} A reference to this vector.\n */\n setFromSpherical(e) {\n return this.setFromSphericalCoords(e.radius, e.phi, e.theta);\n }\n /**\n * Sets the vector components from the given spherical coordinates.\n *\n * @param {number} radius - The radius.\n * @param {number} phi - The phi angle in radians.\n * @param {number} theta - The theta angle in radians.\n * @return {Vector3} A reference to this vector.\n */\n setFromSphericalCoords(e, t, n) {\n const s = Math.sin(t) * e;\n return this.x = s * Math.sin(n), this.y = Math.cos(t) * e, this.z = s * Math.cos(n), this;\n }\n /**\n * Sets the vector components from the given cylindrical coordinates.\n *\n * @param {Cylindrical} c - The cylindrical coordinates.\n * @return {Vector3} A reference to this vector.\n */\n setFromCylindrical(e) {\n return this.setFromCylindricalCoords(e.radius, e.theta, e.y);\n }\n /**\n * Sets the vector components from the given cylindrical coordinates.\n *\n * @param {number} radius - The radius.\n * @param {number} theta - The theta angle in radians.\n * @param {number} y - The y value.\n * @return {Vector3} A reference to this vector.\n */\n setFromCylindricalCoords(e, t, n) {\n return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this;\n }\n /**\n * Sets the vector components to the position elements of the\n * given transformation matrix.\n *\n * @param {Matrix4} m - The 4x4 matrix.\n * @return {Vector3} A reference to this vector.\n */\n setFromMatrixPosition(e) {\n const t = e.elements;\n return this.x = t[12], this.y = t[13], this.z = t[14], this;\n }\n /**\n * Sets the vector components to the scale elements of the\n * given transformation matrix.\n *\n * @param {Matrix4} m - The 4x4 matrix.\n * @return {Vector3} A reference to this vector.\n */\n setFromMatrixScale(e) {\n const t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), s = this.setFromMatrixColumn(e, 2).length();\n return this.x = t, this.y = n, this.z = s, this;\n }\n /**\n * Sets the vector components from the specified matrix column.\n *\n * @param {Matrix4} m - The 4x4 matrix.\n * @param {number} index - The column index.\n * @return {Vector3} A reference to this vector.\n */\n setFromMatrixColumn(e, t) {\n return this.fromArray(e.elements, t * 4);\n }\n /**\n * Sets the vector components from the specified matrix column.\n *\n * @param {Matrix3} m - The 3x3 matrix.\n * @param {number} index - The column index.\n * @return {Vector3} A reference to this vector.\n */\n setFromMatrix3Column(e, t) {\n return this.fromArray(e.elements, t * 3);\n }\n /**\n * Sets the vector components from the given Euler angles.\n *\n * @param {Euler} e - The Euler angles to set.\n * @return {Vector3} A reference to this vector.\n */\n setFromEuler(e) {\n return this.x = e._x, this.y = e._y, this.z = e._z, this;\n }\n /**\n * Sets the vector components from the RGB components of the\n * given color.\n *\n * @param {Color} c - The color to set.\n * @return {Vector3} A reference to this vector.\n */\n setFromColor(e) {\n return this.x = e.r, this.y = e.g, this.z = e.b, this;\n }\n /**\n * Returns `true` if this vector is equal with the given one.\n *\n * @param {Vector3} v - The vector to test for equality.\n * @return {boolean} Whether this vector is equal with the given one.\n */\n equals(e) {\n return e.x === this.x && e.y === this.y && e.z === this.z;\n }\n /**\n * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`\n * and z value to be `array[ offset + 2 ]`.\n *\n * @param {Array} array - An array holding the vector component values.\n * @param {number} [offset=0] - The offset into the array.\n * @return {Vector3} A reference to this vector.\n */\n fromArray(e, t = 0) {\n return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this;\n }\n /**\n * Writes the components of this vector to the given array. If no array is provided,\n * the method returns a new instance.\n *\n * @param {Array} [array=[]] - The target array holding the vector components.\n * @param {number} [offset=0] - Index of the first element in the array.\n * @return {Array} The vector components.\n */\n toArray(e = [], t = 0) {\n return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e;\n }\n /**\n * Sets the components of this vector from the given buffer attribute.\n *\n * @param {BufferAttribute} attribute - The buffer attribute holding vector data.\n * @param {number} index - The index into the attribute.\n * @return {Vector3} A reference to this vector.\n */\n fromBufferAttribute(e, t) {\n return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this;\n }\n /**\n * Sets each component of this vector to a pseudo-random value between `0` and\n * `1`, excluding `1`.\n *\n * @return {Vector3} A reference to this vector.\n */\n random() {\n return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;\n }\n /**\n * Sets this vector to a uniformly random point on a unit sphere.\n *\n * @return {Vector3} A reference to this vector.\n */\n randomDirection() {\n const e = Math.random() * Math.PI * 2, t = Math.random() * 2 - 1, n = Math.sqrt(1 - t * t);\n return this.x = n * Math.cos(e), this.y = t, this.z = n * Math.sin(e), this;\n }\n *[Symbol.iterator]() {\n yield this.x, yield this.y, yield this.z;\n }\n}\nconst Or = /* @__PURE__ */ new w(), ul = /* @__PURE__ */ new gn();\nclass ze {\n /**\n * Constructs a new 3x3 matrix. The arguments are supposed to be\n * in row-major order. If no arguments are provided, the constructor\n * initializes the matrix as an identity matrix.\n *\n * @param {number} [n11] - 1-1 matrix element.\n * @param {number} [n12] - 1-2 matrix element.\n * @param {number} [n13] - 1-3 matrix element.\n * @param {number} [n21] - 2-1 matrix element.\n * @param {number} [n22] - 2-2 matrix element.\n * @param {number} [n23] - 2-3 matrix element.\n * @param {number} [n31] - 3-1 matrix element.\n * @param {number} [n32] - 3-2 matrix element.\n * @param {number} [n33] - 3-3 matrix element.\n */\n constructor(e, t, n, s, r, a, o, l, c) {\n ze.prototype.isMatrix3 = !0, this.elements = [\n 1,\n 0,\n 0,\n 0,\n 1,\n 0,\n 0,\n 0,\n 1\n ], e !== void 0 && this.set(e, t, n, s, r, a, o, l, c);\n }\n /**\n * Sets the elements of the matrix.The arguments are supposed to be\n * in row-major order.\n *\n * @param {number} [n11] - 1-1 matrix element.\n * @param {number} [n12] - 1-2 matrix element.\n * @param {number} [n13] - 1-3 matrix element.\n * @param {number} [n21] - 2-1 matrix element.\n * @param {number} [n22] - 2-2 matrix element.\n * @param {number} [n23] - 2-3 matrix element.\n * @param {number} [n31] - 3-1 matrix element.\n * @param {number} [n32] - 3-2 matrix element.\n * @param {number} [n33] - 3-3 matrix element.\n * @return {Matrix3} A reference to this matrix.\n */\n set(e, t, n, s, r, a, o, l, c) {\n const h = this.elements;\n return h[0] = e, h[1] = s, h[2] = o, h[3] = t, h[4] = r, h[5] = l, h[6] = n, h[7] = a, h[8] = c, this;\n }\n /**\n * Sets this matrix to the 3x3 identity matrix.\n *\n * @return {Matrix3} A reference to this matrix.\n */\n identity() {\n return this.set(\n 1,\n 0,\n 0,\n 0,\n 1,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Copies the values of the given matrix to this instance.\n *\n * @param {Matrix3} m - The matrix to copy.\n * @return {Matrix3} A reference to this matrix.\n */\n copy(e) {\n const t = this.elements, n = e.elements;\n return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], this;\n }\n /**\n * Extracts the basis of this matrix into the three axis vectors provided.\n *\n * @param {Vector3} xAxis - The basis's x axis.\n * @param {Vector3} yAxis - The basis's y axis.\n * @param {Vector3} zAxis - The basis's z axis.\n * @return {Matrix3} A reference to this matrix.\n */\n extractBasis(e, t, n) {\n return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this;\n }\n /**\n * Set this matrix to the upper 3x3 matrix of the given 4x4 matrix.\n *\n * @param {Matrix4} m - The 4x4 matrix.\n * @return {Matrix3} A reference to this matrix.\n */\n setFromMatrix4(e) {\n const t = e.elements;\n return this.set(\n t[0],\n t[4],\n t[8],\n t[1],\n t[5],\n t[9],\n t[2],\n t[6],\n t[10]\n ), this;\n }\n /**\n * Post-multiplies this matrix by the given 3x3 matrix.\n *\n * @param {Matrix3} m - The matrix to multiply with.\n * @return {Matrix3} A reference to this matrix.\n */\n multiply(e) {\n return this.multiplyMatrices(this, e);\n }\n /**\n * Pre-multiplies this matrix by the given 3x3 matrix.\n *\n * @param {Matrix3} m - The matrix to multiply with.\n * @return {Matrix3} A reference to this matrix.\n */\n premultiply(e) {\n return this.multiplyMatrices(e, this);\n }\n /**\n * Multiples the given 3x3 matrices and stores the result\n * in this matrix.\n *\n * @param {Matrix3} a - The first matrix.\n * @param {Matrix3} b - The second matrix.\n * @return {Matrix3} A reference to this matrix.\n */\n multiplyMatrices(e, t) {\n const n = e.elements, s = t.elements, r = this.elements, a = n[0], o = n[3], l = n[6], c = n[1], h = n[4], u = n[7], d = n[2], p = n[5], g = n[8], x = s[0], m = s[3], f = s[6], y = s[1], v = s[4], T = s[7], R = s[2], E = s[5], P = s[8];\n return r[0] = a * x + o * y + l * R, r[3] = a * m + o * v + l * E, r[6] = a * f + o * T + l * P, r[1] = c * x + h * y + u * R, r[4] = c * m + h * v + u * E, r[7] = c * f + h * T + u * P, r[2] = d * x + p * y + g * R, r[5] = d * m + p * v + g * E, r[8] = d * f + p * T + g * P, this;\n }\n /**\n * Multiplies every component of the matrix by the given scalar.\n *\n * @param {number} s - The scalar.\n * @return {Matrix3} A reference to this matrix.\n */\n multiplyScalar(e) {\n const t = this.elements;\n return t[0] *= e, t[3] *= e, t[6] *= e, t[1] *= e, t[4] *= e, t[7] *= e, t[2] *= e, t[5] *= e, t[8] *= e, this;\n }\n /**\n * Computes and returns the determinant of this matrix.\n *\n * @return {number} The determinant.\n */\n determinant() {\n const e = this.elements, t = e[0], n = e[1], s = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8];\n return t * a * h - t * o * c - n * r * h + n * o * l + s * r * c - s * a * l;\n }\n /**\n * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).\n * You can not invert with a determinant of zero. If you attempt this, the method produces\n * a zero matrix instead.\n *\n * @return {Matrix3} A reference to this matrix.\n */\n invert() {\n const e = this.elements, t = e[0], n = e[1], s = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8], u = h * a - o * c, d = o * l - h * r, p = c * r - a * l, g = t * u + n * d + s * p;\n if (g === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);\n const x = 1 / g;\n return e[0] = u * x, e[1] = (s * c - h * n) * x, e[2] = (o * n - s * a) * x, e[3] = d * x, e[4] = (h * t - s * l) * x, e[5] = (s * r - o * t) * x, e[6] = p * x, e[7] = (n * l - c * t) * x, e[8] = (a * t - n * r) * x, this;\n }\n /**\n * Transposes this matrix in place.\n *\n * @return {Matrix3} A reference to this matrix.\n */\n transpose() {\n let e;\n const t = this.elements;\n return e = t[1], t[1] = t[3], t[3] = e, e = t[2], t[2] = t[6], t[6] = e, e = t[5], t[5] = t[7], t[7] = e, this;\n }\n /**\n * Computes the normal matrix which is the inverse transpose of the upper\n * left 3x3 portion of the given 4x4 matrix.\n *\n * @param {Matrix4} matrix4 - The 4x4 matrix.\n * @return {Matrix3} A reference to this matrix.\n */\n getNormalMatrix(e) {\n return this.setFromMatrix4(e).invert().transpose();\n }\n /**\n * Transposes this matrix into the supplied array, and returns itself unchanged.\n *\n * @param {Array} r - An array to store the transposed matrix elements.\n * @return {Matrix3} A reference to this matrix.\n */\n transposeIntoArray(e) {\n const t = this.elements;\n return e[0] = t[0], e[1] = t[3], e[2] = t[6], e[3] = t[1], e[4] = t[4], e[5] = t[7], e[6] = t[2], e[7] = t[5], e[8] = t[8], this;\n }\n /**\n * Sets the UV transform matrix from offset, repeat, rotation, and center.\n *\n * @param {number} tx - Offset x.\n * @param {number} ty - Offset y.\n * @param {number} sx - Repeat x.\n * @param {number} sy - Repeat y.\n * @param {number} rotation - Rotation, in radians. Positive values rotate counterclockwise.\n * @param {number} cx - Center x of rotation.\n * @param {number} cy - Center y of rotation\n * @return {Matrix3} A reference to this matrix.\n */\n setUvTransform(e, t, n, s, r, a, o) {\n const l = Math.cos(r), c = Math.sin(r);\n return this.set(\n n * l,\n n * c,\n -n * (l * a + c * o) + a + e,\n -s * c,\n s * l,\n -s * (-c * a + l * o) + o + t,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Scales this matrix with the given scalar values.\n *\n * @param {number} sx - The amount to scale in the X axis.\n * @param {number} sy - The amount to scale in the Y axis.\n * @return {Matrix3} A reference to this matrix.\n */\n scale(e, t) {\n return this.premultiply(Br.makeScale(e, t)), this;\n }\n /**\n * Rotates this matrix by the given angle.\n *\n * @param {number} theta - The rotation in radians.\n * @return {Matrix3} A reference to this matrix.\n */\n rotate(e) {\n return this.premultiply(Br.makeRotation(-e)), this;\n }\n /**\n * Translates this matrix by the given scalar values.\n *\n * @param {number} tx - The amount to translate in the X axis.\n * @param {number} ty - The amount to translate in the Y axis.\n * @return {Matrix3} A reference to this matrix.\n */\n translate(e, t) {\n return this.premultiply(Br.makeTranslation(e, t)), this;\n }\n // for 2D Transforms\n /**\n * Sets this matrix as a 2D translation transform.\n *\n * @param {number|Vector2} x - The amount to translate in the X axis or alternatively a translation vector.\n * @param {number} y - The amount to translate in the Y axis.\n * @return {Matrix3} A reference to this matrix.\n */\n makeTranslation(e, t) {\n return e.isVector2 ? this.set(\n 1,\n 0,\n e.x,\n 0,\n 1,\n e.y,\n 0,\n 0,\n 1\n ) : this.set(\n 1,\n 0,\n e,\n 0,\n 1,\n t,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Sets this matrix as a 2D rotational transformation.\n *\n * @param {number} theta - The rotation in radians.\n * @return {Matrix3} A reference to this matrix.\n */\n makeRotation(e) {\n const t = Math.cos(e), n = Math.sin(e);\n return this.set(\n t,\n -n,\n 0,\n n,\n t,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Sets this matrix as a 2D scale transform.\n *\n * @param {number} x - The amount to scale in the X axis.\n * @param {number} y - The amount to scale in the Y axis.\n * @return {Matrix3} A reference to this matrix.\n */\n makeScale(e, t) {\n return this.set(\n e,\n 0,\n 0,\n 0,\n t,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Returns `true` if this matrix is equal with the given one.\n *\n * @param {Matrix3} matrix - The matrix to test for equality.\n * @return {boolean} Whether this matrix is equal with the given one.\n */\n equals(e) {\n const t = this.elements, n = e.elements;\n for (let s = 0; s < 9; s++)\n if (t[s] !== n[s]) return !1;\n return !0;\n }\n /**\n * Sets the elements of the matrix from the given array.\n *\n * @param {Array} array - The matrix elements in column-major order.\n * @param {number} [offset=0] - Index of the first element in the array.\n * @return {Matrix3} A reference to this matrix.\n */\n fromArray(e, t = 0) {\n for (let n = 0; n < 9; n++)\n this.elements[n] = e[n + t];\n return this;\n }\n /**\n * Writes the elements of this matrix to the given array. If no array is provided,\n * the method returns a new instance.\n *\n * @param {Array} [array=[]] - The target array holding the matrix elements in column-major order.\n * @param {number} [offset=0] - Index of the first element in the array.\n * @return {Array} The matrix elements in column-major order.\n */\n toArray(e = [], t = 0) {\n const n = this.elements;\n return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e;\n }\n /**\n * Returns a matrix with copied values from this instance.\n *\n * @return {Matrix3} A clone of this instance.\n */\n clone() {\n return new this.constructor().fromArray(this.elements);\n }\n}\nconst Br = /* @__PURE__ */ new ze(), dl = /* @__PURE__ */ new ze().set(\n 0.4123908,\n 0.3575843,\n 0.1804808,\n 0.212639,\n 0.7151687,\n 0.0721923,\n 0.0193308,\n 0.1191948,\n 0.9505322\n), fl = /* @__PURE__ */ new ze().set(\n 3.2409699,\n -1.5373832,\n -0.4986108,\n -0.9692436,\n 1.8759675,\n 0.0415551,\n 0.0556301,\n -0.203977,\n 1.0569715\n);\nfunction Pu() {\n const i = {\n enabled: !0,\n workingColorSpace: Ut,\n /**\n * Implementations of supported color spaces.\n *\n * Required:\n *\t- primaries: chromaticity coordinates [ rx ry gx gy bx by ]\n *\t- whitePoint: reference white [ x y ]\n *\t- transfer: transfer function (pre-defined)\n *\t- toXYZ: Matrix3 RGB to XYZ transform\n *\t- fromXYZ: Matrix3 XYZ to RGB transform\n *\t- luminanceCoefficients: RGB luminance coefficients\n *\n * Optional:\n * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' }\n * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }\n *\n * Reference:\n * - https://www.russellcottrell.com/photo/matrixCalculator.htm\n */\n spaces: {},\n convert: function(s, r, a) {\n return this.enabled === !1 || r === a || !r || !a || (this.spaces[r].transfer === et && (s.r = Vn(s.r), s.g = Vn(s.g), s.b = Vn(s.b)), this.spaces[r].primaries !== this.spaces[a].primaries && (s.applyMatrix3(this.spaces[r].toXYZ), s.applyMatrix3(this.spaces[a].fromXYZ)), this.spaces[a].transfer === et && (s.r = Oi(s.r), s.g = Oi(s.g), s.b = Oi(s.b))), s;\n },\n workingToColorSpace: function(s, r) {\n return this.convert(s, this.workingColorSpace, r);\n },\n colorSpaceToWorking: function(s, r) {\n return this.convert(s, r, this.workingColorSpace);\n },\n getPrimaries: function(s) {\n return this.spaces[s].primaries;\n },\n getTransfer: function(s) {\n return s === Kn ? Sr : this.spaces[s].transfer;\n },\n getToneMappingMode: function(s) {\n return this.spaces[s].outputColorSpaceConfig.toneMappingMode || \"standard\";\n },\n getLuminanceCoefficients: function(s, r = this.workingColorSpace) {\n return s.fromArray(this.spaces[r].luminanceCoefficients);\n },\n define: function(s) {\n Object.assign(this.spaces, s);\n },\n // Internal APIs\n _getMatrix: function(s, r, a) {\n return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ);\n },\n _getDrawingBufferColorSpace: function(s) {\n return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace;\n },\n _getUnpackColorSpace: function(s = this.workingColorSpace) {\n return this.spaces[s].workingColorSpaceConfig.unpackColorSpace;\n },\n // Deprecated\n fromWorkingColorSpace: function(s, r) {\n return ws(\"ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().\"), i.workingToColorSpace(s, r);\n },\n toWorkingColorSpace: function(s, r) {\n return ws(\"ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().\"), i.colorSpaceToWorking(s, r);\n }\n }, e = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], t = [0.2126, 0.7152, 0.0722], n = [0.3127, 0.329];\n return i.define({\n [Ut]: {\n primaries: e,\n whitePoint: n,\n transfer: Sr,\n toXYZ: dl,\n fromXYZ: fl,\n luminanceCoefficients: t,\n workingColorSpaceConfig: { unpackColorSpace: Rt },\n outputColorSpaceConfig: { drawingBufferColorSpace: Rt }\n },\n [Rt]: {\n primaries: e,\n whitePoint: n,\n transfer: et,\n toXYZ: dl,\n fromXYZ: fl,\n luminanceCoefficients: t,\n outputColorSpaceConfig: { drawingBufferColorSpace: Rt }\n }\n }), i;\n}\nconst Ye = /* @__PURE__ */ Pu();\nfunction Vn(i) {\n return i < 0.04045 ? i * 0.0773993808 : Math.pow(i * 0.9478672986 + 0.0521327014, 2.4);\n}\nfunction Oi(i) {\n return i < 31308e-7 ? i * 12.92 : 1.055 * Math.pow(i, 0.41666) - 0.055;\n}\nlet _i;\nclass Du {\n /**\n * Returns a data URI containing a representation of the given image.\n *\n * @param {(HTMLImageElement|HTMLCanvasElement)} image - The image object.\n * @param {string} [type='image/png'] - Indicates the image format.\n * @return {string} The data URI.\n */\n static getDataURL(e, t = \"image/png\") {\n if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > \"u\")\n return e.src;\n let n;\n if (e instanceof HTMLCanvasElement)\n n = e;\n else {\n _i === void 0 && (_i = Es(\"canvas\")), _i.width = e.width, _i.height = e.height;\n const s = _i.getContext(\"2d\");\n e instanceof ImageData ? s.putImageData(e, 0, 0) : s.drawImage(e, 0, 0, e.width, e.height), n = _i;\n }\n return n.toDataURL(t);\n }\n /**\n * Converts the given sRGB image data to linear color space.\n *\n * @param {(HTMLImageElement|HTMLCanvasElement|ImageBitmap|Object)} image - The image object.\n * @return {HTMLCanvasElement|Object} The converted image.\n */\n static sRGBToLinear(e) {\n if (typeof HTMLImageElement < \"u\" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < \"u\" && e instanceof HTMLCanvasElement || typeof ImageBitmap < \"u\" && e instanceof ImageBitmap) {\n const t = Es(\"canvas\");\n t.width = e.width, t.height = e.height;\n const n = t.getContext(\"2d\");\n n.drawImage(e, 0, 0, e.width, e.height);\n const s = n.getImageData(0, 0, e.width, e.height), r = s.data;\n for (let a = 0; a < r.length; a++)\n r[a] = Vn(r[a] / 255) * 255;\n return n.putImageData(s, 0, 0), t;\n } else if (e.data) {\n const t = e.data.slice(0);\n for (let n = 0; n < t.length; n++)\n t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[n] = Math.floor(Vn(t[n] / 255) * 255) : t[n] = Vn(t[n]);\n return {\n data: t,\n width: e.width,\n height: e.height\n };\n } else\n return Te(\"ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.\"), e;\n }\n}\nlet Lu = 0;\nclass Io {\n /**\n * Constructs a new video texture.\n *\n * @param {any} [data=null] - The data definition of a texture.\n */\n constructor(e = null) {\n this.isSource = !0, Object.defineProperty(this, \"id\", { value: Lu++ }), this.uuid = fn(), this.data = e, this.dataReady = !0, this.version = 0;\n }\n /**\n * Returns the dimensions of the source into the given target vector.\n *\n * @param {(Vector2|Vector3)} target - The target object the result is written into.\n * @return {(Vector2|Vector3)} The dimensions of the source.\n */\n getSize(e) {\n const t = this.data;\n return typeof HTMLVideoElement < \"u\" && t instanceof HTMLVideoElement ? e.set(t.videoWidth, t.videoHeight, 0) : t instanceof VideoFrame ? e.set(t.displayHeight, t.displayWidth, 0) : t !== null ? e.set(t.width, t.height, t.depth || 0) : e.set(0, 0, 0), e;\n }\n /**\n * When the property is set to `true`, the engine allocates the memory\n * for the texture (if necessary) and triggers the actual texture upload\n * to the GPU next time the source is used.\n *\n * @type {boolean}\n * @default false\n * @param {boolean} value\n */\n set needsUpdate(e) {\n e === !0 && this.version++;\n }\n /**\n * Serializes the source into JSON.\n *\n * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.\n * @return {Object} A JSON object representing the serialized source.\n * @see {@link ObjectLoader#parse}\n */\n toJSON(e) {\n const t = e === void 0 || typeof e == \"string\";\n if (!t && e.images[this.uuid] !== void 0)\n return e.images[this.uuid];\n const n = {\n uuid: this.uuid,\n url: \"\"\n }, s = this.data;\n if (s !== null) {\n let r;\n if (Array.isArray(s)) {\n r = [];\n for (let a = 0, o = s.length; a < o; a++)\n s[a].isDataTexture ? r.push(zr(s[a].image)) : r.push(zr(s[a]));\n } else\n r = zr(s);\n n.url = r;\n }\n return t || (e.images[this.uuid] = n), n;\n }\n}\nfunction zr(i) {\n return typeof HTMLImageElement < \"u\" && i instanceof HTMLImageElement || typeof HTMLCanvasElement < \"u\" && i instanceof HTMLCanvasElement || typeof ImageBitmap < \"u\" && i instanceof ImageBitmap ? Du.getDataURL(i) : i.data ? {\n data: Array.from(i.data),\n width: i.width,\n height: i.height,\n type: i.data.constructor.name\n } : (Te(\"Texture: Unable to serialize Texture.\"), {});\n}\nlet Iu = 0;\nconst kr = /* @__PURE__ */ new w();\nclass Ct extends mi {\n /**\n * Constructs a new texture.\n *\n * @param {?Object} [image=Texture.DEFAULT_IMAGE] - The image holding the texture data.\n * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.\n * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.\n * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.\n * @param {number} [magFilter=LinearFilter] - The mag filter value.\n * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.\n * @param {number} [format=RGBAFormat] - The texture format.\n * @param {number} [type=UnsignedByteType] - The texture type.\n * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.\n * @param {string} [colorSpace=NoColorSpace] - The color space.\n */\n constructor(e = Ct.DEFAULT_IMAGE, t = Ct.DEFAULT_MAPPING, n = en, s = en, r = bt, a = yn, o = Zt, l = mn, c = Ct.DEFAULT_ANISOTROPY, h = Kn) {\n super(), this.isTexture = !0, Object.defineProperty(this, \"id\", { value: Iu++ }), this.uuid = fn(), this.name = \"\", this.source = new Io(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = n, this.wrapT = s, this.magFilter = r, this.minFilter = a, this.anisotropy = c, this.format = o, this.internalFormat = null, this.type = l, this.offset = new le(0, 0), this.repeat = new le(1, 1), this.center = new le(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new ze(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = h, this.userData = {}, this.updateRanges = [], this.version = 0, this.onUpdate = null, this.renderTarget = null, this.isRenderTargetTexture = !1, this.isArrayTexture = !!(e && e.depth && e.depth > 1), this.pmremVersion = 0;\n }\n /**\n * The width of the texture in pixels.\n */\n get width() {\n return this.source.getSize(kr).x;\n }\n /**\n * The height of the texture in pixels.\n */\n get height() {\n return this.source.getSize(kr).y;\n }\n /**\n * The depth of the texture in pixels.\n */\n get depth() {\n return this.source.getSize(kr).z;\n }\n /**\n * The image object holding the texture data.\n *\n * @type {?Object}\n */\n get image() {\n return this.source.data;\n }\n set image(e = null) {\n this.source.data = e;\n }\n /**\n * Updates the texture transformation matrix from the from the properties {@link Texture#offset},\n * {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.\n */\n updateMatrix() {\n this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);\n }\n /**\n * Adds a range of data in the data texture to be updated on the GPU.\n *\n * @param {number} start - Position at which to start update.\n * @param {number} count - The number of components to update.\n */\n addUpdateRange(e, t) {\n this.updateRanges.push({ start: e, count: t });\n }\n /**\n * Clears the update ranges.\n */\n clearUpdateRanges() {\n this.updateRanges.length = 0;\n }\n /**\n * Returns a new texture with copied values from this instance.\n *\n * @return {Texture} A clone of this instance.\n */\n clone() {\n return new this.constructor().copy(this);\n }\n /**\n * Copies the values of the given texture to this instance.\n *\n * @param {Texture} source - The texture to copy.\n * @return {Texture} A reference to this instance.\n */\n copy(e) {\n return this.name = e.name, this.source = e.source, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.channel = e.channel, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.colorSpace = e.colorSpace, this.renderTarget = e.renderTarget, this.isRenderTargetTexture = e.isRenderTargetTexture, this.isArrayTexture = e.isArrayTexture, this.userData = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this;\n }\n /**\n * Sets this texture's properties based on `values`.\n * @param {Object} values - A container with texture parameters.\n */\n setValues(e) {\n for (const t in e) {\n const n = e[t];\n if (n === void 0) {\n Te(`Texture.setValues(): parameter '${t}' has value of undefined.`);\n continue;\n }\n const s = this[t];\n if (s === void 0) {\n Te(`Texture.setValues(): property '${t}' does not exist.`);\n continue;\n }\n s && n && s.isVector2 && n.isVector2 || s && n && s.isVector3 && n.isVector3 || s && n && s.isMatrix3 && n.isMatrix3 ? s.copy(n) : this[t] = n;\n }\n }\n /**\n * Serializes the texture into JSON.\n *\n * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.\n * @return {Object} A JSON object representing the serialized texture.\n * @see {@link ObjectLoader#parse}\n */\n toJSON(e) {\n const t = e === void 0 || typeof e == \"string\";\n if (!t && e.textures[this.uuid] !== void 0)\n return e.textures[this.uuid];\n const n = {\n metadata: {\n version: 4.7,\n type: \"Texture\",\n generator: \"Texture.toJSON\"\n },\n uuid: this.uuid,\n name: this.name,\n image: this.source.toJSON(e).uuid,\n mapping: this.mapping,\n channel: this.channel,\n repeat: [this.repeat.x, this.repeat.y],\n offset: [this.offset.x, this.offset.y],\n center: [this.center.x, this.center.y],\n rotation: this.rotation,\n wrap: [this.wrapS, this.wrapT],\n format: this.format,\n internalFormat: this.internalFormat,\n type: this.type,\n colorSpace: this.colorSpace,\n minFilter: this.minFilter,\n magFilter: this.magFilter,\n anisotropy: this.anisotropy,\n flipY: this.flipY,\n generateMipmaps: this.generateMipmaps,\n premultiplyAlpha: this.premultiplyAlpha,\n unpackAlignment: this.unpackAlignment\n };\n return Object.keys(this.userData).length > 0 && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n;\n }\n /**\n * Frees the GPU-related resources allocated by this instance. Call this\n * method whenever this instance is no longer used in your app.\n *\n * @fires Texture#dispose\n */\n dispose() {\n this.dispatchEvent({ type: \"dispose\" });\n }\n /**\n * Transforms the given uv vector with the textures uv transformation matrix.\n *\n * @param {Vector2} uv - The uv vector.\n * @return {Vector2} The transformed uv vector.\n */\n transformUv(e) {\n if (this.mapping !== kc) return e;\n if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1)\n switch (this.wrapS) {\n case wn:\n e.x = e.x - Math.floor(e.x);\n break;\n case en:\n e.x = e.x < 0 ? 0 : 1;\n break;\n case Mr:\n Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x);\n break;\n }\n if (e.y < 0 || e.y > 1)\n switch (this.wrapT) {\n case wn:\n e.y = e.y - Math.floor(e.y);\n break;\n case en:\n e.y = e.y < 0 ? 0 : 1;\n break;\n case Mr:\n Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y);\n break;\n }\n return this.flipY && (e.y = 1 - e.y), e;\n }\n /**\n * Setting this property to `true` indicates the engine the texture\n * must be updated in the next render. This triggers a texture upload\n * to the GPU and ensures correct texture parameter configuration.\n *\n * @type {boolean}\n * @default false\n * @param {boolean} value\n */\n set needsUpdate(e) {\n e === !0 && (this.version++, this.source.needsUpdate = !0);\n }\n /**\n * Setting this property to `true` indicates the engine the PMREM\n * must be regenerated.\n *\n * @type {boolean}\n * @default false\n * @param {boolean} value\n */\n set needsPMREMUpdate(e) {\n e === !0 && this.pmremVersion++;\n }\n}\nCt.DEFAULT_IMAGE = null;\nCt.DEFAULT_MAPPING = kc;\nCt.DEFAULT_ANISOTROPY = 1;\nclass Je {\n /**\n * Constructs a new 4D vector.\n *\n * @param {number} [x=0] - The x value of this vector.\n * @param {number} [y=0] - The y value of this vector.\n * @param {number} [z=0] - The z value of this vector.\n * @param {number} [w=1] - The w value of this vector.\n */\n constructor(e = 0, t = 0, n = 0, s = 1) {\n Je.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = n, this.w = s;\n }\n /**\n * Alias for {@link Vector4#z}.\n *\n * @type {number}\n */\n get width() {\n return this.z;\n }\n set width(e) {\n this.z = e;\n }\n /**\n * Alias for {@link Vector4#w}.\n *\n * @type {number}\n */\n get height() {\n return this.w;\n }\n set height(e) {\n this.w = e;\n }\n /**\n * Sets the vector components.\n *\n * @param {number} x - The value of the x component.\n * @param {number} y - The value of the y component.\n * @param {number} z - The value of the z component.\n * @param {number} w - The value of the w component.\n * @return {Vector4} A reference to this vector.\n */\n set(e, t, n, s) {\n return this.x = e, this.y = t, this.z = n, this.w = s, this;\n }\n /**\n * Sets the vector components to the same value.\n *\n * @param {number} scalar - The value to set for all vector components.\n * @return {Vector4} A reference to this vector.\n */\n setScalar(e) {\n return this.x = e, this.y = e, this.z = e, this.w = e, this;\n }\n /**\n * Sets the vector's x component to the given value\n *\n * @param {number} x - The value to set.\n * @return {Vector4} A reference to this vector.\n */\n setX(e) {\n return this.x = e, this;\n }\n /**\n * Sets the vector's y component to the given value\n *\n * @param {number} y - The value to set.\n * @return {Vector4} A reference to this vector.\n */\n setY(e) {\n return this.y = e, this;\n }\n /**\n * Sets the vector's z component to the given value\n *\n * @param {number} z - The value to set.\n * @return {Vector4} A reference to this vector.\n */\n setZ(e) {\n return this.z = e, this;\n }\n /**\n * Sets the vector's w component to the given value\n *\n * @param {number} w - The value to set.\n * @return {Vector4} A reference to this vector.\n */\n setW(e) {\n return this.w = e, this;\n }\n /**\n * Allows to set a vector component with an index.\n *\n * @param {number} index - The component index. `0` equals to x, `1` equals to y,\n * `2` equals to z, `3` equals to w.\n * @param {number} value - The value to set.\n * @return {Vector4} A reference to this vector.\n */\n setComponent(e, t) {\n switch (e) {\n case 0:\n this.x = t;\n break;\n case 1:\n this.y = t;\n break;\n case 2:\n this.z = t;\n break;\n case 3:\n this.w = t;\n break;\n default:\n throw new Error(\"index is out of range: \" + e);\n }\n return this;\n }\n /**\n * Returns the value of the vector component which matches the given index.\n *\n * @param {number} index - The component index. `0` equals to x, `1` equals to y,\n * `2` equals to z, `3` equals to w.\n * @return {number} A vector component value.\n */\n getComponent(e) {\n switch (e) {\n case 0:\n return this.x;\n case 1:\n return this.y;\n case 2:\n return this.z;\n case 3:\n return this.w;\n default:\n throw new Error(\"index is out of range: \" + e);\n }\n }\n /**\n * Returns a new vector with copied values from this instance.\n *\n * @return {Vector4} A clone of this instance.\n */\n clone() {\n return new this.constructor(this.x, this.y, this.z, this.w);\n }\n /**\n * Copies the values of the given vector to this instance.\n *\n * @param {Vector3|Vector4} v - The vector to copy.\n * @return {Vector4} A reference to this vector.\n */\n copy(e) {\n return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this;\n }\n /**\n * Adds the given vector to this instance.\n *\n * @param {Vector4} v - The vector to add.\n * @return {Vector4} A reference to this vector.\n */\n add(e) {\n return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this;\n }\n /**\n * Adds the given scalar value to all components of this instance.\n *\n * @param {number} s - The scalar to add.\n * @return {Vector4} A reference to this vector.\n */\n addScalar(e) {\n return this.x += e, this.y += e, this.z += e, this.w += e, this;\n }\n /**\n * Adds the given vectors and stores the result in this instance.\n *\n * @param {Vector4} a - The first vector.\n * @param {Vector4} b - The second vector.\n * @return {Vector4} A reference to this vector.\n */\n addVectors(e, t) {\n return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this.w = e.w + t.w, this;\n }\n /**\n * Adds the given vector scaled by the given factor to this instance.\n *\n * @param {Vector4} v - The vector.\n * @param {number} s - The factor that scales `v`.\n * @return {Vector4} A reference to this vector.\n */\n addScaledVector(e, t) {\n return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this;\n }\n /**\n * Subtracts the given vector from this instance.\n *\n * @param {Vector4} v - The vector to subtract.\n * @return {Vector4} A reference to this vector.\n */\n sub(e) {\n return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this;\n }\n /**\n * Subtracts the given scalar value from all components of this instance.\n *\n * @param {number} s - The scalar to subtract.\n * @return {Vector4} A reference to this vector.\n */\n subScalar(e) {\n return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this;\n }\n /**\n * Subtracts the given vectors and stores the result in this instance.\n *\n * @param {Vector4} a - The first vector.\n * @param {Vector4} b - The second vector.\n * @return {Vector4} A reference to this vector.\n */\n subVectors(e, t) {\n return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this.w = e.w - t.w, this;\n }\n /**\n * Multiplies the given vector with this instance.\n *\n * @param {Vector4} v - The vector to multiply.\n * @return {Vector4} A reference to this vector.\n */\n multiply(e) {\n return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this;\n }\n /**\n * Multiplies the given scalar value with all components of this instance.\n *\n * @param {number} scalar - The scalar to multiply.\n * @return {Vector4} A reference to this vector.\n */\n multiplyScalar(e) {\n return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this;\n }\n /**\n * Multiplies this vector with the given 4x4 matrix.\n *\n * @param {Matrix4} m - The 4x4 matrix.\n * @return {Vector4} A reference to this vector.\n */\n applyMatrix4(e) {\n const t = this.x, n = this.y, s = this.z, r = this.w, a = e.elements;\n return this.x = a[0] * t + a[4] * n + a[8] * s + a[12] * r, this.y = a[1] * t + a[5] * n + a[9] * s + a[13] * r, this.z = a[2] * t + a[6] * n + a[10] * s + a[14] * r, this.w = a[3] * t + a[7] * n + a[11] * s + a[15] * r, this;\n }\n /**\n * Divides this instance by the given vector.\n *\n * @param {Vector4} v - The vector to divide.\n * @return {Vector4} A reference to this vector.\n */\n divide(e) {\n return this.x /= e.x, this.y /= e.y, this.z /= e.z, this.w /= e.w, this;\n }\n /**\n * Divides this vector by the given scalar.\n *\n * @param {number} scalar - The scalar to divide.\n * @return {Vector4} A reference to this vector.\n */\n divideScalar(e) {\n return this.multiplyScalar(1 / e);\n }\n /**\n * Sets the x, y and z components of this\n * vector to the quaternion's axis and w to the angle.\n *\n * @param {Quaternion} q - The Quaternion to set.\n * @return {Vector4} A reference to this vector.\n */\n setAxisAngleFromQuaternion(e) {\n this.w = 2 * Math.acos(e.w);\n const t = Math.sqrt(1 - e.w * e.w);\n return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this;\n }\n /**\n * Sets the x, y and z components of this\n * vector to the axis of rotation and w to the angle.\n *\n * @param {Matrix4} m - A 4x4 matrix of which the upper left 3x3 matrix is a pure rotation matrix.\n * @return {Vector4} A reference to this vector.\n */\n setAxisAngleFromRotationMatrix(e) {\n let t, n, s, r;\n const l = e.elements, c = l[0], h = l[4], u = l[8], d = l[1], p = l[5], g = l[9], x = l[2], m = l[6], f = l[10];\n if (Math.abs(h - d) < 0.01 && Math.abs(u - x) < 0.01 && Math.abs(g - m) < 0.01) {\n if (Math.abs(h + d) < 0.1 && Math.abs(u + x) < 0.1 && Math.abs(g + m) < 0.1 && Math.abs(c + p + f - 3) < 0.1)\n return this.set(1, 0, 0, 0), this;\n t = Math.PI;\n const v = (c + 1) / 2, T = (p + 1) / 2, R = (f + 1) / 2, E = (h + d) / 4, P = (u + x) / 4, I = (g + m) / 4;\n return v > T && v > R ? v < 0.01 ? (n = 0, s = 0.707106781, r = 0.707106781) : (n = Math.sqrt(v), s = E / n, r = P / n) : T > R ? T < 0.01 ? (n = 0.707106781, s = 0, r = 0.707106781) : (s = Math.sqrt(T), n = E / s, r = I / s) : R < 0.01 ? (n = 0.707106781, s = 0.707106781, r = 0) : (r = Math.sqrt(R), n = P / r, s = I / r), this.set(n, s, r, t), this;\n }\n let y = Math.sqrt((m - g) * (m - g) + (u - x) * (u - x) + (d - h) * (d - h));\n return Math.abs(y) < 1e-3 && (y = 1), this.x = (m - g) / y, this.y = (u - x) / y, this.z = (d - h) / y, this.w = Math.acos((c + p + f - 1) / 2), this;\n }\n /**\n * Sets the vector components to the position elements of the\n * given transformation matrix.\n *\n * @param {Matrix4} m - The 4x4 matrix.\n * @return {Vector4} A reference to this vector.\n */\n setFromMatrixPosition(e) {\n const t = e.elements;\n return this.x = t[12], this.y = t[13], this.z = t[14], this.w = t[15], this;\n }\n /**\n * If this vector's x, y, z or w value is greater than the given vector's x, y, z or w\n * value, replace that value with the corresponding min value.\n *\n * @param {Vector4} v - The vector.\n * @return {Vector4} A reference to this vector.\n */\n min(e) {\n return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this.w = Math.min(this.w, e.w), this;\n }\n /**\n * If this vector's x, y, z or w value is less than the given vector's x, y, z or w\n * value, replace that value with the corresponding max value.\n *\n * @param {Vector4} v - The vector.\n * @return {Vector4} A reference to this vector.\n */\n max(e) {\n return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this.w = Math.max(this.w, e.w), this;\n }\n /**\n * If this vector's x, y, z or w value is greater than the max vector's x, y, z or w\n * value, it is replaced by the corresponding value.\n * If this vector's x, y, z or w value is less than the min vector's x, y, z or w value,\n * it is replaced by the corresponding value.\n *\n * @param {Vector4} min - The minimum x, y and z values.\n * @param {Vector4} max - The maximum x, y and z values in the desired range.\n * @return {Vector4} A reference to this vector.\n */\n clamp(e, t) {\n return this.x = He(this.x, e.x, t.x), this.y = He(this.y, e.y, t.y), this.z = He(this.z, e.z, t.z), this.w = He(this.w, e.w, t.w), this;\n }\n /**\n * If this vector's x, y, z or w values are greater than the max value, they are\n * replaced by the max value.\n * If this vector's x, y, z or w values are less than the min value, they are\n * replaced by the min value.\n *\n * @param {number} minVal - The minimum value the components will be clamped to.\n * @param {number} maxVal - The maximum value the components will be clamped to.\n * @return {Vector4} A reference to this vector.\n */\n clampScalar(e, t) {\n return this.x = He(this.x, e, t), this.y = He(this.y, e, t), this.z = He(this.z, e, t), this.w = He(this.w, e, t), this;\n }\n /**\n * If this vector's length is greater than the max value, it is replaced by\n * the max value.\n * If this vector's length is less than the min value, it is replaced by the\n * min value.\n *\n * @param {number} min - The minimum value the vector length will be clamped to.\n * @param {number} max - The maximum value the vector length will be clamped to.\n * @return {Vector4} A reference to this vector.\n */\n clampLength(e, t) {\n const n = this.length();\n return this.divideScalar(n || 1).multiplyScalar(He(n, e, t));\n }\n /**\n * The components of this vector are rounded down to the nearest integer value.\n *\n * @return {Vector4} A reference to this vector.\n */\n floor() {\n return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this.w = Math.floor(this.w), this;\n }\n /**\n * The components of this vector are rounded up to the nearest integer value.\n *\n * @return {Vector4} A reference to this vector.\n */\n ceil() {\n return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this.w = Math.ceil(this.w), this;\n }\n /**\n * The components of this vector are rounded to the nearest integer value\n *\n * @return {Vector4} A reference to this vector.\n */\n round() {\n return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this.w = Math.round(this.w), this;\n }\n /**\n * The components of this vector are rounded towards zero (up if negative,\n * down if positive) to an integer value.\n *\n * @return {Vector4} A reference to this vector.\n */\n roundToZero() {\n return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this.w = Math.trunc(this.w), this;\n }\n /**\n * Inverts this vector - i.e. sets x = -x, y = -y, z = -z, w = -w.\n *\n * @return {Vector4} A reference to this vector.\n */\n negate() {\n return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this;\n }\n /**\n * Calculates the dot product of the given vector with this instance.\n *\n * @param {Vector4} v - The vector to compute the dot product with.\n * @return {number} The result of the dot product.\n */\n dot(e) {\n return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w;\n }\n /**\n * Computes the square of the Euclidean length (straight-line length) from\n * (0, 0, 0, 0) to (x, y, z, w). If you are comparing the lengths of vectors, you should\n * compare the length squared instead as it is slightly more efficient to calculate.\n *\n * @return {number} The square length of this vector.\n */\n lengthSq() {\n return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;\n }\n /**\n * Computes the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w).\n *\n * @return {number} The length of this vector.\n */\n length() {\n return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);\n }\n /**\n * Computes the Manhattan length of this vector.\n *\n * @return {number} The length of this vector.\n */\n manhattanLength() {\n return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);\n }\n /**\n * Converts this vector to a unit vector - that is, sets it equal to a vector\n * with the same direction as this one, but with a vector length of `1`.\n *\n * @return {Vector4} A reference to this vector.\n */\n normalize() {\n return this.divideScalar(this.length() || 1);\n }\n /**\n * Sets this vector to a vector with the same direction as this one, but\n * with the specified length.\n *\n * @param {number} length - The new length of this vector.\n * @return {Vector4} A reference to this vector.\n */\n setLength(e) {\n return this.normalize().multiplyScalar(e);\n }\n /**\n * Linearly interpolates between the given vector and this instance, where\n * alpha is the percent distance along the line - alpha = 0 will be this\n * vector, and alpha = 1 will be the given one.\n *\n * @param {Vector4} v - The vector to interpolate towards.\n * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n * @return {Vector4} A reference to this vector.\n */\n lerp(e, t) {\n return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this.w += (e.w - this.w) * t, this;\n }\n /**\n * Linearly interpolates between the given vectors, where alpha is the percent\n * distance along the line - alpha = 0 will be first vector, and alpha = 1 will\n * be the second one. The result is stored in this instance.\n *\n * @param {Vector4} v1 - The first vector.\n * @param {Vector4} v2 - The second vector.\n * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n * @return {Vector4} A reference to this vector.\n */\n lerpVectors(e, t, n) {\n return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, this;\n }\n /**\n * Returns `true` if this vector is equal with the given one.\n *\n * @param {Vector4} v - The vector to test for equality.\n * @return {boolean} Whether this vector is equal with the given one.\n */\n equals(e) {\n return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w;\n }\n /**\n * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`,\n * z value to be `array[ offset + 2 ]`, w value to be `array[ offset + 3 ]`.\n *\n * @param {Array} array - An array holding the vector component values.\n * @param {number} [offset=0] - The offset into the array.\n * @return {Vector4} A reference to this vector.\n */\n fromArray(e, t = 0) {\n return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this;\n }\n /**\n * Writes the components of this vector to the given array. If no array is provided,\n * the method returns a new instance.\n *\n * @param {Array} [array=[]] - The target array holding the vector components.\n * @param {number} [offset=0] - Index of the first element in the array.\n * @return {Array} The vector components.\n */\n toArray(e = [], t = 0) {\n return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e;\n }\n /**\n * Sets the components of this vector from the given buffer attribute.\n *\n * @param {BufferAttribute} attribute - The buffer attribute holding vector data.\n * @param {number} index - The index into the attribute.\n * @return {Vector4} A reference to this vector.\n */\n fromBufferAttribute(e, t) {\n return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), this;\n }\n /**\n * Sets each component of this vector to a pseudo-random value between `0` and\n * `1`, excluding `1`.\n *\n * @return {Vector4} A reference to this vector.\n */\n random() {\n return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this;\n }\n *[Symbol.iterator]() {\n yield this.x, yield this.y, yield this.z, yield this.w;\n }\n}\nclass Uu extends mi {\n /**\n * Render target options.\n *\n * @typedef {Object} RenderTarget~Options\n * @property {boolean} [generateMipmaps=false] - Whether to generate mipmaps or not.\n * @property {number} [magFilter=LinearFilter] - The mag filter.\n * @property {number} [minFilter=LinearFilter] - The min filter.\n * @property {number} [format=RGBAFormat] - The texture format.\n * @property {number} [type=UnsignedByteType] - The texture type.\n * @property {?string} [internalFormat=null] - The texture's internal format.\n * @property {number} [wrapS=ClampToEdgeWrapping] - The texture's uv wrapping mode.\n * @property {number} [wrapT=ClampToEdgeWrapping] - The texture's uv wrapping mode.\n * @property {number} [anisotropy=1] - The texture's anisotropy value.\n * @property {string} [colorSpace=NoColorSpace] - The texture's color space.\n * @property {boolean} [depthBuffer=true] - Whether to allocate a depth buffer or not.\n * @property {boolean} [stencilBuffer=false] - Whether to allocate a stencil buffer or not.\n * @property {boolean} [resolveDepthBuffer=true] - Whether to resolve the depth buffer or not.\n * @property {boolean} [resolveStencilBuffer=true] - Whether to resolve the stencil buffer or not.\n * @property {?Texture} [depthTexture=null] - Reference to a depth texture.\n * @property {number} [samples=0] - The MSAA samples count.\n * @property {number} [count=1] - Defines the number of color attachments . Must be at least `1`.\n * @property {number} [depth=1] - The texture depth.\n * @property {boolean} [multiview=false] - Whether this target is used for multiview rendering.\n */\n /**\n * Constructs a new render target.\n *\n * @param {number} [width=1] - The width of the render target.\n * @param {number} [height=1] - The height of the render target.\n * @param {RenderTarget~Options} [options] - The configuration object.\n */\n constructor(e = 1, t = 1, n = {}) {\n super(), n = Object.assign({\n generateMipmaps: !1,\n internalFormat: null,\n minFilter: bt,\n depthBuffer: !0,\n stencilBuffer: !1,\n resolveDepthBuffer: !0,\n resolveStencilBuffer: !0,\n depthTexture: null,\n samples: 0,\n count: 1,\n depth: 1,\n multiview: !1\n }, n), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = n.depth, this.scissor = new Je(0, 0, e, t), this.scissorTest = !1, this.viewport = new Je(0, 0, e, t);\n const s = { width: e, height: t, depth: n.depth }, r = new Ct(s);\n this.textures = [];\n const a = n.count;\n for (let o = 0; o < a; o++)\n this.textures[o] = r.clone(), this.textures[o].isRenderTargetTexture = !0, this.textures[o].renderTarget = this;\n this._setTextureOptions(n), this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.resolveDepthBuffer = n.resolveDepthBuffer, this.resolveStencilBuffer = n.resolveStencilBuffer, this._depthTexture = null, this.depthTexture = n.depthTexture, this.samples = n.samples, this.multiview = n.multiview;\n }\n _setTextureOptions(e = {}) {\n const t = {\n minFilter: bt,\n generateMipmaps: !1,\n flipY: !1,\n internalFormat: null\n };\n e.mapping !== void 0 && (t.mapping = e.mapping), e.wrapS !== void 0 && (t.wrapS = e.wrapS), e.wrapT !== void 0 && (t.wrapT = e.wrapT), e.wrapR !== void 0 && (t.wrapR = e.wrapR), e.magFilter !== void 0 && (t.magFilter = e.magFilter), e.minFilter !== void 0 && (t.minFilter = e.minFilter), e.format !== void 0 && (t.format = e.format), e.type !== void 0 && (t.type = e.type), e.anisotropy !== void 0 && (t.anisotropy = e.anisotropy), e.colorSpace !== void 0 && (t.colorSpace = e.colorSpace), e.flipY !== void 0 && (t.flipY = e.flipY), e.generateMipmaps !== void 0 && (t.generateMipmaps = e.generateMipmaps), e.internalFormat !== void 0 && (t.internalFormat = e.internalFormat);\n for (let n = 0; n < this.textures.length; n++)\n this.textures[n].setValues(t);\n }\n /**\n * The texture representing the default color attachment.\n *\n * @type {Texture}\n */\n get texture() {\n return this.textures[0];\n }\n set texture(e) {\n this.textures[0] = e;\n }\n set depthTexture(e) {\n this._depthTexture !== null && (this._depthTexture.renderTarget = null), e !== null && (e.renderTarget = this), this._depthTexture = e;\n }\n /**\n * Instead of saving the depth in a renderbuffer, a texture\n * can be used instead which is useful for further processing\n * e.g. in context of post-processing.\n *\n * @type {?DepthTexture}\n * @default null\n */\n get depthTexture() {\n return this._depthTexture;\n }\n /**\n * Sets the size of this render target.\n *\n * @param {number} width - The width.\n * @param {number} height - The height.\n * @param {number} [depth=1] - The depth.\n */\n setSize(e, t, n = 1) {\n if (this.width !== e || this.height !== t || this.depth !== n) {\n this.width = e, this.height = t, this.depth = n;\n for (let s = 0, r = this.textures.length; s < r; s++)\n this.textures[s].image.width = e, this.textures[s].image.height = t, this.textures[s].image.depth = n, this.textures[s].isData3DTexture !== !0 && (this.textures[s].isArrayTexture = this.textures[s].image.depth > 1);\n this.dispose();\n }\n this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t);\n }\n /**\n * Returns a new render target with copied values from this instance.\n *\n * @return {RenderTarget} A clone of this instance.\n */\n clone() {\n return new this.constructor().copy(this);\n }\n /**\n * Copies the settings of the given render target. This is a structural copy so\n * no resources are shared between render targets after the copy. That includes\n * all MRT textures and the depth texture.\n *\n * @param {RenderTarget} source - The render target to copy.\n * @return {RenderTarget} A reference to this instance.\n */\n copy(e) {\n this.width = e.width, this.height = e.height, this.depth = e.depth, this.scissor.copy(e.scissor), this.scissorTest = e.scissorTest, this.viewport.copy(e.viewport), this.textures.length = 0;\n for (let t = 0, n = e.textures.length; t < n; t++) {\n this.textures[t] = e.textures[t].clone(), this.textures[t].isRenderTargetTexture = !0, this.textures[t].renderTarget = this;\n const s = Object.assign({}, e.textures[t].image);\n this.textures[t].source = new Io(s);\n }\n return this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.resolveDepthBuffer = e.resolveDepthBuffer, this.resolveStencilBuffer = e.resolveStencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this;\n }\n /**\n * Frees the GPU-related resources allocated by this instance. Call this\n * method whenever this instance is no longer used in your app.\n *\n * @fires RenderTarget#dispose\n */\n dispose() {\n this.dispatchEvent({ type: \"dispose\" });\n }\n}\nclass St extends Uu {\n /**\n * Constructs a new 3D render target.\n *\n * @param {number} [width=1] - The width of the render target.\n * @param {number} [height=1] - The height of the render target.\n * @param {RenderTarget~Options} [options] - The configuration object.\n */\n constructor(e = 1, t = 1, n = {}) {\n super(e, t, n), this.isWebGLRenderTarget = !0;\n }\n}\nclass Jc extends Ct {\n /**\n * Constructs a new data array texture.\n *\n * @param {?TypedArray} [data=null] - The buffer data.\n * @param {number} [width=1] - The width of the texture.\n * @param {number} [height=1] - The height of the texture.\n * @param {number} [depth=1] - The depth of the texture.\n */\n constructor(e = null, t = 1, n = 1, s = 1) {\n super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: n, depth: s }, this.magFilter = Dt, this.minFilter = Dt, this.wrapR = en, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set();\n }\n /**\n * Describes that a specific layer of the texture needs to be updated.\n * Normally when {@link Texture#needsUpdate} is set to `true`, the\n * entire data texture array is sent to the GPU. Marking specific\n * layers will only transmit subsets of all mipmaps associated with a\n * specific depth in the array which is often much more performant.\n *\n * @param {number} layerIndex - The layer index that should be updated.\n */\n addLayerUpdate(e) {\n this.layerUpdates.add(e);\n }\n /**\n * Resets the layer updates registry.\n */\n clearLayerUpdates() {\n this.layerUpdates.clear();\n }\n}\nclass Nu extends Ct {\n /**\n * Constructs a new data array texture.\n *\n * @param {?TypedArray} [data=null] - The buffer data.\n * @param {number} [width=1] - The width of the texture.\n * @param {number} [height=1] - The height of the texture.\n * @param {number} [depth=1] - The depth of the texture.\n */\n constructor(e = null, t = 1, n = 1, s = 1) {\n super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: n, depth: s }, this.magFilter = Dt, this.minFilter = Dt, this.wrapR = en, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;\n }\n}\nclass Pt {\n /**\n * Constructs a new bounding box.\n *\n * @param {Vector3} [min=(Infinity,Infinity,Infinity)] - A vector representing the lower boundary of the box.\n * @param {Vector3} [max=(-Infinity,-Infinity,-Infinity)] - A vector representing the upper boundary of the box.\n */\n constructor(e = new w(1 / 0, 1 / 0, 1 / 0), t = new w(-1 / 0, -1 / 0, -1 / 0)) {\n this.isBox3 = !0, this.min = e, this.max = t;\n }\n /**\n * Sets the lower and upper boundaries of this box.\n * Please note that this method only copies the values from the given objects.\n *\n * @param {Vector3} min - The lower boundary of the box.\n * @param {Vector3} max - The upper boundary of the box.\n * @return {Box3} A reference to this bounding box.\n */\n set(e, t) {\n return this.min.copy(e), this.max.copy(t), this;\n }\n /**\n * Sets the upper and lower bounds of this box so it encloses the position data\n * in the given array.\n *\n * @param {Array} array - An array holding 3D position data.\n * @return {Box3} A reference to this bounding box.\n */\n setFromArray(e) {\n this.makeEmpty();\n for (let t = 0, n = e.length; t < n; t += 3)\n this.expandByPoint(rn.fromArray(e, t));\n return this;\n }\n /**\n * Sets the upper and lower bounds of this box so it encloses the position data\n * in the given buffer attribute.\n *\n * @param {BufferAttribute} attribute - A buffer attribute holding 3D position data.\n * @return {Box3} A reference to this bounding box.\n */\n setFromBufferAttribute(e) {\n this.makeEmpty();\n for (let t = 0, n = e.count; t < n; t++)\n this.expandByPoint(rn.fromBufferAttribute(e, t));\n return this;\n }\n /**\n * Sets the upper and lower bounds of this box so it encloses the position data\n * in the given array.\n *\n * @param {Array} points - An array holding 3D position data as instances of {@link Vector3}.\n * @return {Box3} A reference to this bounding box.\n */\n setFromPoints(e) {\n this.makeEmpty();\n for (let t = 0, n = e.length; t < n; t++)\n this.expandByPoint(e[t]);\n return this;\n }\n /**\n * Centers this box on the given center vector and sets this box's width, height and\n * depth to the given size values.\n *\n * @param {Vector3} center - The center of the box.\n * @param {Vector3} size - The x, y and z dimensions of the box.\n * @return {Box3} A reference to this bounding box.\n */\n setFromCenterAndSize(e, t) {\n const n = rn.copy(t).multiplyScalar(0.5);\n return this.min.copy(e).sub(n), this.max.copy(e).add(n), this;\n }\n /**\n * Computes the world-axis-aligned bounding box for the given 3D object\n * (including its children), accounting for the object's, and children's,\n * world transforms. The function may result in a larger box than strictly necessary.\n *\n * @param {Object3D} object - The 3D object to compute the bounding box for.\n * @param {boolean} [precise=false] - If set to `true`, the method computes the smallest\n * world-axis-aligned bounding box at the expense of more computation.\n * @return {Box3} A reference to this bounding box.\n */\n setFromObject(e, t = !1) {\n return this.makeEmpty(), this.expandByObject(e, t);\n }\n /**\n * Returns a new box with copied values from this instance.\n *\n * @return {Box3} A clone of this instance.\n */\n clone() {\n return new this.constructor().copy(this);\n }\n /**\n * Copies the values of the given box to this instance.\n *\n * @param {Box3} box - The box to copy.\n * @return {Box3} A reference to this bounding box.\n */\n copy(e) {\n return this.min.copy(e.min), this.max.copy(e.max), this;\n }\n /**\n * Makes this box empty which means in encloses a zero space in 3D.\n *\n * @return {Box3} A reference to this bounding box.\n */\n makeEmpty() {\n return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this;\n }\n /**\n * Returns true if this box includes zero points within its bounds.\n * Note that a box with equal lower and upper bounds still includes one\n * point, the one both bounds share.\n *\n * @return {boolean} Whether this box is empty or not.\n */\n isEmpty() {\n return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;\n }\n /**\n * Returns the center point of this box.\n *\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {Vector3} The center point.\n */\n getCenter(e) {\n return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5);\n }\n /**\n * Returns the dimensions of this box.\n *\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {Vector3} The size.\n */\n getSize(e) {\n return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min);\n }\n /**\n * Expands the boundaries of this box to include the given point.\n *\n * @param {Vector3} point - The point that should be included by the bounding box.\n * @return {Box3} A reference to this bounding box.\n */\n expandByPoint(e) {\n return this.min.min(e), this.max.max(e), this;\n }\n /**\n * Expands this box equilaterally by the given vector. The width of this\n * box will be expanded by the x component of the vector in both\n * directions. The height of this box will be expanded by the y component of\n * the vector in both directions. The depth of this box will be\n * expanded by the z component of the vector in both directions.\n *\n * @param {Vector3} vector - The vector that should expand the bounding box.\n * @return {Box3} A reference to this bounding box.\n */\n expandByVector(e) {\n return this.min.sub(e), this.max.add(e), this;\n }\n /**\n * Expands each dimension of the box by the given scalar. If negative, the\n * dimensions of the box will be contracted.\n *\n * @param {number} scalar - The scalar value that should expand the bounding box.\n * @return {Box3} A reference to this bounding box.\n */\n expandByScalar(e) {\n return this.min.addScalar(-e), this.max.addScalar(e), this;\n }\n /**\n * Expands the boundaries of this box to include the given 3D object and\n * its children, accounting for the object's, and children's, world\n * transforms. The function may result in a larger box than strictly\n * necessary (unless the precise parameter is set to true).\n *\n * @param {Object3D} object - The 3D object that should expand the bounding box.\n * @param {boolean} precise - If set to `true`, the method expands the bounding box\n * as little as necessary at the expense of more computation.\n * @return {Box3} A reference to this bounding box.\n */\n expandByObject(e, t = !1) {\n e.updateWorldMatrix(!1, !1);\n const n = e.geometry;\n if (n !== void 0) {\n const r = n.getAttribute(\"position\");\n if (t === !0 && r !== void 0 && e.isInstancedMesh !== !0)\n for (let a = 0, o = r.count; a < o; a++)\n e.isMesh === !0 ? e.getVertexPosition(a, rn) : rn.fromBufferAttribute(r, a), rn.applyMatrix4(e.matrixWorld), this.expandByPoint(rn);\n else\n e.boundingBox !== void 0 ? (e.boundingBox === null && e.computeBoundingBox(), Is.copy(e.boundingBox)) : (n.boundingBox === null && n.computeBoundingBox(), Is.copy(n.boundingBox)), Is.applyMatrix4(e.matrixWorld), this.union(Is);\n }\n const s = e.children;\n for (let r = 0, a = s.length; r < a; r++)\n this.expandByObject(s[r], t);\n return this;\n }\n /**\n * Returns `true` if the given point lies within or on the boundaries of this box.\n *\n * @param {Vector3} point - The point to test.\n * @return {boolean} Whether the bounding box contains the given point or not.\n */\n containsPoint(e) {\n return e.x >= this.min.x && e.x <= this.max.x && e.y >= this.min.y && e.y <= this.max.y && e.z >= this.min.z && e.z <= this.max.z;\n }\n /**\n * Returns `true` if this bounding box includes the entirety of the given bounding box.\n * If this box and the given one are identical, this function also returns `true`.\n *\n * @param {Box3} box - The bounding box to test.\n * @return {boolean} Whether the bounding box contains the given bounding box or not.\n */\n containsBox(e) {\n return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z;\n }\n /**\n * Returns a point as a proportion of this box's width, height and depth.\n *\n * @param {Vector3} point - A point in 3D space.\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {Vector3} A point as a proportion of this box's width, height and depth.\n */\n getParameter(e, t) {\n return t.set(\n (e.x - this.min.x) / (this.max.x - this.min.x),\n (e.y - this.min.y) / (this.max.y - this.min.y),\n (e.z - this.min.z) / (this.max.z - this.min.z)\n );\n }\n /**\n * Returns `true` if the given bounding box intersects with this bounding box.\n *\n * @param {Box3} box - The bounding box to test.\n * @return {boolean} Whether the given bounding box intersects with this bounding box.\n */\n intersectsBox(e) {\n return e.max.x >= this.min.x && e.min.x <= this.max.x && e.max.y >= this.min.y && e.min.y <= this.max.y && e.max.z >= this.min.z && e.min.z <= this.max.z;\n }\n /**\n * Returns `true` if the given bounding sphere intersects with this bounding box.\n *\n * @param {Sphere} sphere - The bounding sphere to test.\n * @return {boolean} Whether the given bounding sphere intersects with this bounding box.\n */\n intersectsSphere(e) {\n return this.clampPoint(e.center, rn), rn.distanceToSquared(e.center) <= e.radius * e.radius;\n }\n /**\n * Returns `true` if the given plane intersects with this bounding box.\n *\n * @param {Plane} plane - The plane to test.\n * @return {boolean} Whether the given plane intersects with this bounding box.\n */\n intersectsPlane(e) {\n let t, n;\n return e.normal.x > 0 ? (t = e.normal.x * this.min.x, n = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, n = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, n += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, n += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, n += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, n += e.normal.z * this.min.z), t <= -e.constant && n >= -e.constant;\n }\n /**\n * Returns `true` if the given triangle intersects with this bounding box.\n *\n * @param {Triangle} triangle - The triangle to test.\n * @return {boolean} Whether the given triangle intersects with this bounding box.\n */\n intersectsTriangle(e) {\n if (this.isEmpty())\n return !1;\n this.getCenter(ss), Us.subVectors(this.max, ss), vi.subVectors(e.a, ss), Mi.subVectors(e.b, ss), Si.subVectors(e.c, ss), Gn.subVectors(Mi, vi), Hn.subVectors(Si, Mi), si.subVectors(vi, Si);\n let t = [\n 0,\n -Gn.z,\n Gn.y,\n 0,\n -Hn.z,\n Hn.y,\n 0,\n -si.z,\n si.y,\n Gn.z,\n 0,\n -Gn.x,\n Hn.z,\n 0,\n -Hn.x,\n si.z,\n 0,\n -si.x,\n -Gn.y,\n Gn.x,\n 0,\n -Hn.y,\n Hn.x,\n 0,\n -si.y,\n si.x,\n 0\n ];\n return !Vr(t, vi, Mi, Si, Us) || (t = [1, 0, 0, 0, 1, 0, 0, 0, 1], !Vr(t, vi, Mi, Si, Us)) ? !1 : (Ns.crossVectors(Gn, Hn), t = [Ns.x, Ns.y, Ns.z], Vr(t, vi, Mi, Si, Us));\n }\n /**\n * Clamps the given point within the bounds of this box.\n *\n * @param {Vector3} point - The point to clamp.\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {Vector3} The clamped point.\n */\n clampPoint(e, t) {\n return t.copy(e).clamp(this.min, this.max);\n }\n /**\n * Returns the euclidean distance from any edge of this box to the specified point. If\n * the given point lies inside of this box, the distance will be `0`.\n *\n * @param {Vector3} point - The point to compute the distance to.\n * @return {number} The euclidean distance.\n */\n distanceToPoint(e) {\n return this.clampPoint(e, rn).distanceTo(e);\n }\n /**\n * Returns a bounding sphere that encloses this bounding box.\n *\n * @param {Sphere} target - The target sphere that is used to store the method's result.\n * @return {Sphere} The bounding sphere that encloses this bounding box.\n */\n getBoundingSphere(e) {\n return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(rn).length() * 0.5), e;\n }\n /**\n * Computes the intersection of this bounding box and the given one, setting the upper\n * bound of this box to the lesser of the two boxes' upper bounds and the\n * lower bound of this box to the greater of the two boxes' lower bounds. If\n * there's no overlap, makes this box empty.\n *\n * @param {Box3} box - The bounding box to intersect with.\n * @return {Box3} A reference to this bounding box.\n */\n intersect(e) {\n return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this;\n }\n /**\n * Computes the union of this box and another and the given one, setting the upper\n * bound of this box to the greater of the two boxes' upper bounds and the\n * lower bound of this box to the lesser of the two boxes' lower bounds.\n *\n * @param {Box3} box - The bounding box that will be unioned with this instance.\n * @return {Box3} A reference to this bounding box.\n */\n union(e) {\n return this.min.min(e.min), this.max.max(e.max), this;\n }\n /**\n * Transforms this bounding box by the given 4x4 transformation matrix.\n *\n * @param {Matrix4} matrix - The transformation matrix.\n * @return {Box3} A reference to this bounding box.\n */\n applyMatrix4(e) {\n return this.isEmpty() ? this : (Pn[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), Pn[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), Pn[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), Pn[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), Pn[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), Pn[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), Pn[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), Pn[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(Pn), this);\n }\n /**\n * Adds the given offset to both the upper and lower bounds of this bounding box,\n * effectively moving it in 3D space.\n *\n * @param {Vector3} offset - The offset that should be used to translate the bounding box.\n * @return {Box3} A reference to this bounding box.\n */\n translate(e) {\n return this.min.add(e), this.max.add(e), this;\n }\n /**\n * Returns `true` if this bounding box is equal with the given one.\n *\n * @param {Box3} box - The box to test for equality.\n * @return {boolean} Whether this bounding box is equal with the given one.\n */\n equals(e) {\n return e.min.equals(this.min) && e.max.equals(this.max);\n }\n /**\n * Returns a serialized structure of the bounding box.\n *\n * @return {Object} Serialized structure with fields representing the object state.\n */\n toJSON() {\n return {\n min: this.min.toArray(),\n max: this.max.toArray()\n };\n }\n /**\n * Returns a serialized structure of the bounding box.\n *\n * @param {Object} json - The serialized json to set the box from.\n * @return {Box3} A reference to this bounding box.\n */\n fromJSON(e) {\n return this.min.fromArray(e.min), this.max.fromArray(e.max), this;\n }\n}\nconst Pn = [\n /* @__PURE__ */ new w(),\n /* @__PURE__ */ new w(),\n /* @__PURE__ */ new w(),\n /* @__PURE__ */ new w(),\n /* @__PURE__ */ new w(),\n /* @__PURE__ */ new w(),\n /* @__PURE__ */ new w(),\n /* @__PURE__ */ new w()\n], rn = /* @__PURE__ */ new w(), Is = /* @__PURE__ */ new Pt(), vi = /* @__PURE__ */ new w(), Mi = /* @__PURE__ */ new w(), Si = /* @__PURE__ */ new w(), Gn = /* @__PURE__ */ new w(), Hn = /* @__PURE__ */ new w(), si = /* @__PURE__ */ new w(), ss = /* @__PURE__ */ new w(), Us = /* @__PURE__ */ new w(), Ns = /* @__PURE__ */ new w(), ri = /* @__PURE__ */ new w();\nfunction Vr(i, e, t, n, s) {\n for (let r = 0, a = i.length - 3; r <= a; r += 3) {\n ri.fromArray(i, r);\n const o = s.x * Math.abs(ri.x) + s.y * Math.abs(ri.y) + s.z * Math.abs(ri.z), l = e.dot(ri), c = t.dot(ri), h = n.dot(ri);\n if (Math.max(-Math.max(l, c, h), Math.min(l, c, h)) > o)\n return !1;\n }\n return !0;\n}\nconst Fu = /* @__PURE__ */ new Pt(), rs = /* @__PURE__ */ new w(), Gr = /* @__PURE__ */ new w();\nclass Rn {\n /**\n * Constructs a new sphere.\n *\n * @param {Vector3} [center=(0,0,0)] - The center of the sphere\n * @param {number} [radius=-1] - The radius of the sphere.\n */\n constructor(e = new w(), t = -1) {\n this.isSphere = !0, this.center = e, this.radius = t;\n }\n /**\n * Sets the sphere's components by copying the given values.\n *\n * @param {Vector3} center - The center.\n * @param {number} radius - The radius.\n * @return {Sphere} A reference to this sphere.\n */\n set(e, t) {\n return this.center.copy(e), this.radius = t, this;\n }\n /**\n * Computes the minimum bounding sphere for list of points.\n * If the optional center point is given, it is used as the sphere's\n * center. Otherwise, the center of the axis-aligned bounding box\n * encompassing the points is calculated.\n *\n * @param {Array} points - A list of points in 3D space.\n * @param {Vector3} [optionalCenter] - The center of the sphere.\n * @return {Sphere} A reference to this sphere.\n */\n setFromPoints(e, t) {\n const n = this.center;\n t !== void 0 ? n.copy(t) : Fu.setFromPoints(e).getCenter(n);\n let s = 0;\n for (let r = 0, a = e.length; r < a; r++)\n s = Math.max(s, n.distanceToSquared(e[r]));\n return this.radius = Math.sqrt(s), this;\n }\n /**\n * Copies the values of the given sphere to this instance.\n *\n * @param {Sphere} sphere - The sphere to copy.\n * @return {Sphere} A reference to this sphere.\n */\n copy(e) {\n return this.center.copy(e.center), this.radius = e.radius, this;\n }\n /**\n * Returns `true` if the sphere is empty (the radius set to a negative number).\n *\n * Spheres with a radius of `0` contain only their center point and are not\n * considered to be empty.\n *\n * @return {boolean} Whether this sphere is empty or not.\n */\n isEmpty() {\n return this.radius < 0;\n }\n /**\n * Makes this sphere empty which means in encloses a zero space in 3D.\n *\n * @return {Sphere} A reference to this sphere.\n */\n makeEmpty() {\n return this.center.set(0, 0, 0), this.radius = -1, this;\n }\n /**\n * Returns `true` if this sphere contains the given point inclusive of\n * the surface of the sphere.\n *\n * @param {Vector3} point - The point to check.\n * @return {boolean} Whether this sphere contains the given point or not.\n */\n containsPoint(e) {\n return e.distanceToSquared(this.center) <= this.radius * this.radius;\n }\n /**\n * Returns the closest distance from the boundary of the sphere to the\n * given point. If the sphere contains the point, the distance will\n * be negative.\n *\n * @param {Vector3} point - The point to compute the distance to.\n * @return {number} The distance to the point.\n */\n distanceToPoint(e) {\n return e.distanceTo(this.center) - this.radius;\n }\n /**\n * Returns `true` if this sphere intersects with the given one.\n *\n * @param {Sphere} sphere - The sphere to test.\n * @return {boolean} Whether this sphere intersects with the given one or not.\n */\n intersectsSphere(e) {\n const t = this.radius + e.radius;\n return e.center.distanceToSquared(this.center) <= t * t;\n }\n /**\n * Returns `true` if this sphere intersects with the given box.\n *\n * @param {Box3} box - The box to test.\n * @return {boolean} Whether this sphere intersects with the given box or not.\n */\n intersectsBox(e) {\n return e.intersectsSphere(this);\n }\n /**\n * Returns `true` if this sphere intersects with the given plane.\n *\n * @param {Plane} plane - The plane to test.\n * @return {boolean} Whether this sphere intersects with the given plane or not.\n */\n intersectsPlane(e) {\n return Math.abs(e.distanceToPoint(this.center)) <= this.radius;\n }\n /**\n * Clamps a point within the sphere. If the point is outside the sphere, it\n * will clamp it to the closest point on the edge of the sphere. Points\n * already inside the sphere will not be affected.\n *\n * @param {Vector3} point - The plane to clamp.\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {Vector3} The clamped point.\n */\n clampPoint(e, t) {\n const n = this.center.distanceToSquared(e);\n return t.copy(e), n > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t;\n }\n /**\n * Returns a bounding box that encloses this sphere.\n *\n * @param {Box3} target - The target box that is used to store the method's result.\n * @return {Box3} The bounding box that encloses this sphere.\n */\n getBoundingBox(e) {\n return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e);\n }\n /**\n * Transforms this sphere with the given 4x4 transformation matrix.\n *\n * @param {Matrix4} matrix - The transformation matrix.\n * @return {Sphere} A reference to this sphere.\n */\n applyMatrix4(e) {\n return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this;\n }\n /**\n * Translates the sphere's center by the given offset.\n *\n * @param {Vector3} offset - The offset.\n * @return {Sphere} A reference to this sphere.\n */\n translate(e) {\n return this.center.add(e), this;\n }\n /**\n * Expands the boundaries of this sphere to include the given point.\n *\n * @param {Vector3} point - The point to include.\n * @return {Sphere} A reference to this sphere.\n */\n expandByPoint(e) {\n if (this.isEmpty())\n return this.center.copy(e), this.radius = 0, this;\n rs.subVectors(e, this.center);\n const t = rs.lengthSq();\n if (t > this.radius * this.radius) {\n const n = Math.sqrt(t), s = (n - this.radius) * 0.5;\n this.center.addScaledVector(rs, s / n), this.radius += s;\n }\n return this;\n }\n /**\n * Expands this sphere to enclose both the original sphere and the given sphere.\n *\n * @param {Sphere} sphere - The sphere to include.\n * @return {Sphere} A reference to this sphere.\n */\n union(e) {\n return e.isEmpty() ? this : this.isEmpty() ? (this.copy(e), this) : (this.center.equals(e.center) === !0 ? this.radius = Math.max(this.radius, e.radius) : (Gr.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(rs.copy(e.center).add(Gr)), this.expandByPoint(rs.copy(e.center).sub(Gr))), this);\n }\n /**\n * Returns `true` if this sphere is equal with the given one.\n *\n * @param {Sphere} sphere - The sphere to test for equality.\n * @return {boolean} Whether this bounding sphere is equal with the given one.\n */\n equals(e) {\n return e.center.equals(this.center) && e.radius === this.radius;\n }\n /**\n * Returns a new sphere with copied values from this instance.\n *\n * @return {Sphere} A clone of this instance.\n */\n clone() {\n return new this.constructor().copy(this);\n }\n /**\n * Returns a serialized structure of the bounding sphere.\n *\n * @return {Object} Serialized structure with fields representing the object state.\n */\n toJSON() {\n return {\n radius: this.radius,\n center: this.center.toArray()\n };\n }\n /**\n * Returns a serialized structure of the bounding sphere.\n *\n * @param {Object} json - The serialized json to set the sphere from.\n * @return {Box3} A reference to this bounding sphere.\n */\n fromJSON(e) {\n return this.radius = e.radius, this.center.fromArray(e.center), this;\n }\n}\nconst Dn = /* @__PURE__ */ new w(), Hr = /* @__PURE__ */ new w(), Fs = /* @__PURE__ */ new w(), Wn = /* @__PURE__ */ new w(), Wr = /* @__PURE__ */ new w(), Os = /* @__PURE__ */ new w(), Xr = /* @__PURE__ */ new w();\nclass Ji {\n /**\n * Constructs a new ray.\n *\n * @param {Vector3} [origin=(0,0,0)] - The origin of the ray.\n * @param {Vector3} [direction=(0,0,-1)] - The (normalized) direction of the ray.\n */\n constructor(e = new w(), t = new w(0, 0, -1)) {\n this.origin = e, this.direction = t;\n }\n /**\n * Sets the ray's components by copying the given values.\n *\n * @param {Vector3} origin - The origin.\n * @param {Vector3} direction - The direction.\n * @return {Ray} A reference to this ray.\n */\n set(e, t) {\n return this.origin.copy(e), this.direction.copy(t), this;\n }\n /**\n * Copies the values of the given ray to this instance.\n *\n * @param {Ray} ray - The ray to copy.\n * @return {Ray} A reference to this ray.\n */\n copy(e) {\n return this.origin.copy(e.origin), this.direction.copy(e.direction), this;\n }\n /**\n * Returns a vector that is located at a given distance along this ray.\n *\n * @param {number} t - The distance along the ray to retrieve a position for.\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {Vector3} A position on the ray.\n */\n at(e, t) {\n return t.copy(this.origin).addScaledVector(this.direction, e);\n }\n /**\n * Adjusts the direction of the ray to point at the given vector in world space.\n *\n * @param {Vector3} v - The target position.\n * @return {Ray} A reference to this ray.\n */\n lookAt(e) {\n return this.direction.copy(e).sub(this.origin).normalize(), this;\n }\n /**\n * Shift the origin of this ray along its direction by the given distance.\n *\n * @param {number} t - The distance along the ray to interpolate.\n * @return {Ray} A reference to this ray.\n */\n recast(e) {\n return this.origin.copy(this.at(e, Dn)), this;\n }\n /**\n * Returns the point along this ray that is closest to the given point.\n *\n * @param {Vector3} point - A point in 3D space to get the closet location on the ray for.\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {Vector3} The closest point on this ray.\n */\n closestPointToPoint(e, t) {\n t.subVectors(e, this.origin);\n const n = t.dot(this.direction);\n return n < 0 ? t.copy(this.origin) : t.copy(this.origin).addScaledVector(this.direction, n);\n }\n /**\n * Returns the distance of the closest approach between this ray and the given point.\n *\n * @param {Vector3} point - A point in 3D space to compute the distance to.\n * @return {number} The distance.\n */\n distanceToPoint(e) {\n return Math.sqrt(this.distanceSqToPoint(e));\n }\n /**\n * Returns the squared distance of the closest approach between this ray and the given point.\n *\n * @param {Vector3} point - A point in 3D space to compute the distance to.\n * @return {number} The squared distance.\n */\n distanceSqToPoint(e) {\n const t = Dn.subVectors(e, this.origin).dot(this.direction);\n return t < 0 ? this.origin.distanceToSquared(e) : (Dn.copy(this.origin).addScaledVector(this.direction, t), Dn.distanceToSquared(e));\n }\n /**\n * Returns the squared distance between this ray and the given line segment.\n *\n * @param {Vector3} v0 - The start point of the line segment.\n * @param {Vector3} v1 - The end point of the line segment.\n * @param {Vector3} [optionalPointOnRay] - When provided, it receives the point on this ray that is closest to the segment.\n * @param {Vector3} [optionalPointOnSegment] - When provided, it receives the point on the line segment that is closest to this ray.\n * @return {number} The squared distance.\n */\n distanceSqToSegment(e, t, n, s) {\n Hr.copy(e).add(t).multiplyScalar(0.5), Fs.copy(t).sub(e).normalize(), Wn.copy(this.origin).sub(Hr);\n const r = e.distanceTo(t) * 0.5, a = -this.direction.dot(Fs), o = Wn.dot(this.direction), l = -Wn.dot(Fs), c = Wn.lengthSq(), h = Math.abs(1 - a * a);\n let u, d, p, g;\n if (h > 0)\n if (u = a * l - o, d = a * o - l, g = r * h, u >= 0)\n if (d >= -g)\n if (d <= g) {\n const x = 1 / h;\n u *= x, d *= x, p = u * (u + a * d + 2 * o) + d * (a * u + d + 2 * l) + c;\n } else\n d = r, u = Math.max(0, -(a * d + o)), p = -u * u + d * (d + 2 * l) + c;\n else\n d = -r, u = Math.max(0, -(a * d + o)), p = -u * u + d * (d + 2 * l) + c;\n else\n d <= -g ? (u = Math.max(0, -(-a * r + o)), d = u > 0 ? -r : Math.min(Math.max(-r, -l), r), p = -u * u + d * (d + 2 * l) + c) : d <= g ? (u = 0, d = Math.min(Math.max(-r, -l), r), p = d * (d + 2 * l) + c) : (u = Math.max(0, -(a * r + o)), d = u > 0 ? r : Math.min(Math.max(-r, -l), r), p = -u * u + d * (d + 2 * l) + c);\n else\n d = a > 0 ? -r : r, u = Math.max(0, -(a * d + o)), p = -u * u + d * (d + 2 * l) + c;\n return n && n.copy(this.origin).addScaledVector(this.direction, u), s && s.copy(Hr).addScaledVector(Fs, d), p;\n }\n /**\n * Intersects this ray with the given sphere, returning the intersection\n * point or `null` if there is no intersection.\n *\n * @param {Sphere} sphere - The sphere to intersect.\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {?Vector3} The intersection point.\n */\n intersectSphere(e, t) {\n Dn.subVectors(e.center, this.origin);\n const n = Dn.dot(this.direction), s = Dn.dot(Dn) - n * n, r = e.radius * e.radius;\n if (s > r) return null;\n const a = Math.sqrt(r - s), o = n - a, l = n + a;\n return l < 0 ? null : o < 0 ? this.at(l, t) : this.at(o, t);\n }\n /**\n * Returns `true` if this ray intersects with the given sphere.\n *\n * @param {Sphere} sphere - The sphere to intersect.\n * @return {boolean} Whether this ray intersects with the given sphere or not.\n */\n intersectsSphere(e) {\n return e.radius < 0 ? !1 : this.distanceSqToPoint(e.center) <= e.radius * e.radius;\n }\n /**\n * Computes the distance from the ray's origin to the given plane. Returns `null` if the ray\n * does not intersect with the plane.\n *\n * @param {Plane} plane - The plane to compute the distance to.\n * @return {?number} Whether this ray intersects with the given sphere or not.\n */\n distanceToPlane(e) {\n const t = e.normal.dot(this.direction);\n if (t === 0)\n return e.distanceToPoint(this.origin) === 0 ? 0 : null;\n const n = -(this.origin.dot(e.normal) + e.constant) / t;\n return n >= 0 ? n : null;\n }\n /**\n * Intersects this ray with the given plane, returning the intersection\n * point or `null` if there is no intersection.\n *\n * @param {Plane} plane - The plane to intersect.\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {?Vector3} The intersection point.\n */\n intersectPlane(e, t) {\n const n = this.distanceToPlane(e);\n return n === null ? null : this.at(n, t);\n }\n /**\n * Returns `true` if this ray intersects with the given plane.\n *\n * @param {Plane} plane - The plane to intersect.\n * @return {boolean} Whether this ray intersects with the given plane or not.\n */\n intersectsPlane(e) {\n const t = e.distanceToPoint(this.origin);\n return t === 0 || e.normal.dot(this.direction) * t < 0;\n }\n /**\n * Intersects this ray with the given bounding box, returning the intersection\n * point or `null` if there is no intersection.\n *\n * @param {Box3} box - The box to intersect.\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {?Vector3} The intersection point.\n */\n intersectBox(e, t) {\n let n, s, r, a, o, l;\n const c = 1 / this.direction.x, h = 1 / this.direction.y, u = 1 / this.direction.z, d = this.origin;\n return c >= 0 ? (n = (e.min.x - d.x) * c, s = (e.max.x - d.x) * c) : (n = (e.max.x - d.x) * c, s = (e.min.x - d.x) * c), h >= 0 ? (r = (e.min.y - d.y) * h, a = (e.max.y - d.y) * h) : (r = (e.max.y - d.y) * h, a = (e.min.y - d.y) * h), n > a || r > s || ((r > n || isNaN(n)) && (n = r), (a < s || isNaN(s)) && (s = a), u >= 0 ? (o = (e.min.z - d.z) * u, l = (e.max.z - d.z) * u) : (o = (e.max.z - d.z) * u, l = (e.min.z - d.z) * u), n > l || o > s) || ((o > n || n !== n) && (n = o), (l < s || s !== s) && (s = l), s < 0) ? null : this.at(n >= 0 ? n : s, t);\n }\n /**\n * Returns `true` if this ray intersects with the given box.\n *\n * @param {Box3} box - The box to intersect.\n * @return {boolean} Whether this ray intersects with the given box or not.\n */\n intersectsBox(e) {\n return this.intersectBox(e, Dn) !== null;\n }\n /**\n * Intersects this ray with the given triangle, returning the intersection\n * point or `null` if there is no intersection.\n *\n * @param {Vector3} a - The first vertex of the triangle.\n * @param {Vector3} b - The second vertex of the triangle.\n * @param {Vector3} c - The third vertex of the triangle.\n * @param {boolean} backfaceCulling - Whether to use backface culling or not.\n * @param {Vector3} target - The target vector that is used to store the method's result.\n * @return {?Vector3} The intersection point.\n */\n intersectTriangle(e, t, n, s, r) {\n Wr.subVectors(t, e), Os.subVectors(n, e), Xr.crossVectors(Wr, Os);\n let a = this.direction.dot(Xr), o;\n if (a > 0) {\n if (s) return null;\n o = 1;\n } else if (a < 0)\n o = -1, a = -a;\n else\n return null;\n Wn.subVectors(this.origin, e);\n const l = o * this.direction.dot(Os.crossVectors(Wn, Os));\n if (l < 0)\n return null;\n const c = o * this.direction.dot(Wr.cross(Wn));\n if (c < 0 || l + c > a)\n return null;\n const h = -o * Wn.dot(Xr);\n return h < 0 ? null : this.at(h / a, r);\n }\n /**\n * Transforms this ray with the given 4x4 transformation matrix.\n *\n * @param {Matrix4} matrix4 - The transformation matrix.\n * @return {Ray} A reference to this ray.\n */\n applyMatrix4(e) {\n return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this;\n }\n /**\n * Returns `true` if this ray is equal with the given one.\n *\n * @param {Ray} ray - The ray to test for equality.\n * @return {boolean} Whether this ray is equal with the given one.\n */\n equals(e) {\n return e.origin.equals(this.origin) && e.direction.equals(this.direction);\n }\n /**\n * Returns a new ray with copied values from this instance.\n *\n * @return {Ray} A clone of this instance.\n */\n clone() {\n return new this.constructor().copy(this);\n }\n}\nclass Ne {\n /**\n * Constructs a new 4x4 matrix. The arguments are supposed to be\n * in row-major order. If no arguments are provided, the constructor\n * initializes the matrix as an identity matrix.\n *\n * @param {number} [n11] - 1-1 matrix element.\n * @param {number} [n12] - 1-2 matrix element.\n * @param {number} [n13] - 1-3 matrix element.\n * @param {number} [n14] - 1-4 matrix element.\n * @param {number} [n21] - 2-1 matrix element.\n * @param {number} [n22] - 2-2 matrix element.\n * @param {number} [n23] - 2-3 matrix element.\n * @param {number} [n24] - 2-4 matrix element.\n * @param {number} [n31] - 3-1 matrix element.\n * @param {number} [n32] - 3-2 matrix element.\n * @param {number} [n33] - 3-3 matrix element.\n * @param {number} [n34] - 3-4 matrix element.\n * @param {number} [n41] - 4-1 matrix element.\n * @param {number} [n42] - 4-2 matrix element.\n * @param {number} [n43] - 4-3 matrix element.\n * @param {number} [n44] - 4-4 matrix element.\n */\n constructor(e, t, n, s, r, a, o, l, c, h, u, d, p, g, x, m) {\n Ne.prototype.isMatrix4 = !0, this.elements = [\n 1,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n 0,\n 0,\n 0,\n 1\n ], e !== void 0 && this.set(e, t, n, s, r, a, o, l, c, h, u, d, p, g, x, m);\n }\n /**\n * Sets the elements of the matrix.The arguments are supposed to be\n * in row-major order.\n *\n * @param {number} [n11] - 1-1 matrix element.\n * @param {number} [n12] - 1-2 matrix element.\n * @param {number} [n13] - 1-3 matrix element.\n * @param {number} [n14] - 1-4 matrix element.\n * @param {number} [n21] - 2-1 matrix element.\n * @param {number} [n22] - 2-2 matrix element.\n * @param {number} [n23] - 2-3 matrix element.\n * @param {number} [n24] - 2-4 matrix element.\n * @param {number} [n31] - 3-1 matrix element.\n * @param {number} [n32] - 3-2 matrix element.\n * @param {number} [n33] - 3-3 matrix element.\n * @param {number} [n34] - 3-4 matrix element.\n * @param {number} [n41] - 4-1 matrix element.\n * @param {number} [n42] - 4-2 matrix element.\n * @param {number} [n43] - 4-3 matrix element.\n * @param {number} [n44] - 4-4 matrix element.\n * @return {Matrix4} A reference to this matrix.\n */\n set(e, t, n, s, r, a, o, l, c, h, u, d, p, g, x, m) {\n const f = this.elements;\n return f[0] = e, f[4] = t, f[8] = n, f[12] = s, f[1] = r, f[5] = a, f[9] = o, f[13] = l, f[2] = c, f[6] = h, f[10] = u, f[14] = d, f[3] = p, f[7] = g, f[11] = x, f[15] = m, this;\n }\n /**\n * Sets this matrix to the 4x4 identity matrix.\n *\n * @return {Matrix4} A reference to this matrix.\n */\n identity() {\n return this.set(\n 1,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Returns a matrix with copied values from this instance.\n *\n * @return {Matrix4} A clone of this instance.\n */\n clone() {\n return new Ne().fromArray(this.elements);\n }\n /**\n * Copies the values of the given matrix to this instance.\n *\n * @param {Matrix4} m - The matrix to copy.\n * @return {Matrix4} A reference to this matrix.\n */\n copy(e) {\n const t = this.elements, n = e.elements;\n return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], t[9] = n[9], t[10] = n[10], t[11] = n[11], t[12] = n[12], t[13] = n[13], t[14] = n[14], t[15] = n[15], this;\n }\n /**\n * Copies the translation component of the given matrix\n * into this matrix's translation component.\n *\n * @param {Matrix4} m - The matrix to copy the translation component.\n * @return {Matrix4} A reference to this matrix.\n */\n copyPosition(e) {\n const t = this.elements, n = e.elements;\n return t[12] = n[12], t[13] = n[13], t[14] = n[14], this;\n }\n /**\n * Set the upper 3x3 elements of this matrix to the values of given 3x3 matrix.\n *\n * @param {Matrix3} m - The 3x3 matrix.\n * @return {Matrix4} A reference to this matrix.\n */\n setFromMatrix3(e) {\n const t = e.elements;\n return this.set(\n t[0],\n t[3],\n t[6],\n 0,\n t[1],\n t[4],\n t[7],\n 0,\n t[2],\n t[5],\n t[8],\n 0,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Extracts the basis of this matrix into the three axis vectors provided.\n *\n * @param {Vector3} xAxis - The basis's x axis.\n * @param {Vector3} yAxis - The basis's y axis.\n * @param {Vector3} zAxis - The basis's z axis.\n * @return {Matrix4} A reference to this matrix.\n */\n extractBasis(e, t, n) {\n return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this;\n }\n /**\n * Sets the given basis vectors to this matrix.\n *\n * @param {Vector3} xAxis - The basis's x axis.\n * @param {Vector3} yAxis - The basis's y axis.\n * @param {Vector3} zAxis - The basis's z axis.\n * @return {Matrix4} A reference to this matrix.\n */\n makeBasis(e, t, n) {\n return this.set(\n e.x,\n t.x,\n n.x,\n 0,\n e.y,\n t.y,\n n.y,\n 0,\n e.z,\n t.z,\n n.z,\n 0,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Extracts the rotation component of the given matrix\n * into this matrix's rotation component.\n *\n * Note: This method does not support reflection matrices.\n *\n * @param {Matrix4} m - The matrix.\n * @return {Matrix4} A reference to this matrix.\n */\n extractRotation(e) {\n const t = this.elements, n = e.elements, s = 1 / bi.setFromMatrixColumn(e, 0).length(), r = 1 / bi.setFromMatrixColumn(e, 1).length(), a = 1 / bi.setFromMatrixColumn(e, 2).length();\n return t[0] = n[0] * s, t[1] = n[1] * s, t[2] = n[2] * s, t[3] = 0, t[4] = n[4] * r, t[5] = n[5] * r, t[6] = n[6] * r, t[7] = 0, t[8] = n[8] * a, t[9] = n[9] * a, t[10] = n[10] * a, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;\n }\n /**\n * Sets the rotation component (the upper left 3x3 matrix) of this matrix to\n * the rotation specified by the given Euler angles. The rest of\n * the matrix is set to the identity. Depending on the {@link Euler#order},\n * there are six possible outcomes. See [this page](https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix)\n * for a complete list.\n *\n * @param {Euler} euler - The Euler angles.\n * @return {Matrix4} A reference to this matrix.\n */\n makeRotationFromEuler(e) {\n const t = this.elements, n = e.x, s = e.y, r = e.z, a = Math.cos(n), o = Math.sin(n), l = Math.cos(s), c = Math.sin(s), h = Math.cos(r), u = Math.sin(r);\n if (e.order === \"XYZ\") {\n const d = a * h, p = a * u, g = o * h, x = o * u;\n t[0] = l * h, t[4] = -l * u, t[8] = c, t[1] = p + g * c, t[5] = d - x * c, t[9] = -o * l, t[2] = x - d * c, t[6] = g + p * c, t[10] = a * l;\n } else if (e.order === \"YXZ\") {\n const d = l * h, p = l * u, g = c * h, x = c * u;\n t[0] = d + x * o, t[4] = g * o - p, t[8] = a * c, t[1] = a * u, t[5] = a * h, t[9] = -o, t[2] = p * o - g, t[6] = x + d * o, t[10] = a * l;\n } else if (e.order === \"ZXY\") {\n const d = l * h, p = l * u, g = c * h, x = c * u;\n t[0] = d - x * o, t[4] = -a * u, t[8] = g + p * o, t[1] = p + g * o, t[5] = a * h, t[9] = x - d * o, t[2] = -a * c, t[6] = o, t[10] = a * l;\n } else if (e.order === \"ZYX\") {\n const d = a * h, p = a * u, g = o * h, x = o * u;\n t[0] = l * h, t[4] = g * c - p, t[8] = d * c + x, t[1] = l * u, t[5] = x * c + d, t[9] = p * c - g, t[2] = -c, t[6] = o * l, t[10] = a * l;\n } else if (e.order === \"YZX\") {\n const d = a * l, p = a * c, g = o * l, x = o * c;\n t[0] = l * h, t[4] = x - d * u, t[8] = g * u + p, t[1] = u, t[5] = a * h, t[9] = -o * h, t[2] = -c * h, t[6] = p * u + g, t[10] = d - x * u;\n } else if (e.order === \"XZY\") {\n const d = a * l, p = a * c, g = o * l, x = o * c;\n t[0] = l * h, t[4] = -u, t[8] = c * h, t[1] = d * u + x, t[5] = a * h, t[9] = p * u - g, t[2] = g * u - p, t[6] = o * h, t[10] = x * u + d;\n }\n return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;\n }\n /**\n * Sets the rotation component of this matrix to the rotation specified by\n * the given Quaternion as outlined [here](https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion)\n * The rest of the matrix is set to the identity.\n *\n * @param {Quaternion} q - The Quaternion.\n * @return {Matrix4} A reference to this matrix.\n */\n makeRotationFromQuaternion(e) {\n return this.compose(Ou, e, Bu);\n }\n /**\n * Sets the rotation component of the transformation matrix, looking from `eye` towards\n * `target`, and oriented by the up-direction.\n *\n * @param {Vector3} eye - The eye vector.\n * @param {Vector3} target - The target vector.\n * @param {Vector3} up - The up vector.\n * @return {Matrix4} A reference to this matrix.\n */\n lookAt(e, t, n) {\n const s = this.elements;\n return Yt.subVectors(e, t), Yt.lengthSq() === 0 && (Yt.z = 1), Yt.normalize(), Xn.crossVectors(n, Yt), Xn.lengthSq() === 0 && (Math.abs(n.z) === 1 ? Yt.x += 1e-4 : Yt.z += 1e-4, Yt.normalize(), Xn.crossVectors(n, Yt)), Xn.normalize(), Bs.crossVectors(Yt, Xn), s[0] = Xn.x, s[4] = Bs.x, s[8] = Yt.x, s[1] = Xn.y, s[5] = Bs.y, s[9] = Yt.y, s[2] = Xn.z, s[6] = Bs.z, s[10] = Yt.z, this;\n }\n /**\n * Post-multiplies this matrix by the given 4x4 matrix.\n *\n * @param {Matrix4} m - The matrix to multiply with.\n * @return {Matrix4} A reference to this matrix.\n */\n multiply(e) {\n return this.multiplyMatrices(this, e);\n }\n /**\n * Pre-multiplies this matrix by the given 4x4 matrix.\n *\n * @param {Matrix4} m - The matrix to multiply with.\n * @return {Matrix4} A reference to this matrix.\n */\n premultiply(e) {\n return this.multiplyMatrices(e, this);\n }\n /**\n * Multiples the given 4x4 matrices and stores the result\n * in this matrix.\n *\n * @param {Matrix4} a - The first matrix.\n * @param {Matrix4} b - The second matrix.\n * @return {Matrix4} A reference to this matrix.\n */\n multiplyMatrices(e, t) {\n const n = e.elements, s = t.elements, r = this.elements, a = n[0], o = n[4], l = n[8], c = n[12], h = n[1], u = n[5], d = n[9], p = n[13], g = n[2], x = n[6], m = n[10], f = n[14], y = n[3], v = n[7], T = n[11], R = n[15], E = s[0], P = s[4], I = s[8], S = s[12], M = s[1], C = s[5], U = s[9], B = s[13], z = s[2], W = s[6], k = s[10], ee = s[14], X = s[3], $ = s[7], Q = s[11], ge = s[15];\n return r[0] = a * E + o * M + l * z + c * X, r[4] = a * P + o * C + l * W + c * $, r[8] = a * I + o * U + l * k + c * Q, r[12] = a * S + o * B + l * ee + c * ge, r[1] = h * E + u * M + d * z + p * X, r[5] = h * P + u * C + d * W + p * $, r[9] = h * I + u * U + d * k + p * Q, r[13] = h * S + u * B + d * ee + p * ge, r[2] = g * E + x * M + m * z + f * X, r[6] = g * P + x * C + m * W + f * $, r[10] = g * I + x * U + m * k + f * Q, r[14] = g * S + x * B + m * ee + f * ge, r[3] = y * E + v * M + T * z + R * X, r[7] = y * P + v * C + T * W + R * $, r[11] = y * I + v * U + T * k + R * Q, r[15] = y * S + v * B + T * ee + R * ge, this;\n }\n /**\n * Multiplies every component of the matrix by the given scalar.\n *\n * @param {number} s - The scalar.\n * @return {Matrix4} A reference to this matrix.\n */\n multiplyScalar(e) {\n const t = this.elements;\n return t[0] *= e, t[4] *= e, t[8] *= e, t[12] *= e, t[1] *= e, t[5] *= e, t[9] *= e, t[13] *= e, t[2] *= e, t[6] *= e, t[10] *= e, t[14] *= e, t[3] *= e, t[7] *= e, t[11] *= e, t[15] *= e, this;\n }\n /**\n * Computes and returns the determinant of this matrix.\n *\n * Based on the method outlined [here](http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html).\n *\n * @return {number} The determinant.\n */\n determinant() {\n const e = this.elements, t = e[0], n = e[4], s = e[8], r = e[12], a = e[1], o = e[5], l = e[9], c = e[13], h = e[2], u = e[6], d = e[10], p = e[14], g = e[3], x = e[7], m = e[11], f = e[15];\n return g * (+r * l * u - s * c * u - r * o * d + n * c * d + s * o * p - n * l * p) + x * (+t * l * p - t * c * d + r * a * d - s * a * p + s * c * h - r * l * h) + m * (+t * c * u - t * o * p - r * a * u + n * a * p + r * o * h - n * c * h) + f * (-s * o * h - t * l * u + t * o * d + s * a * u - n * a * d + n * l * h);\n }\n /**\n * Transposes this matrix in place.\n *\n * @return {Matrix4} A reference to this matrix.\n */\n transpose() {\n const e = this.elements;\n let t;\n return t = e[1], e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this;\n }\n /**\n * Sets the position component for this matrix from the given vector,\n * without affecting the rest of the matrix.\n *\n * @param {number|Vector3} x - The x component of the vector or alternatively the vector object.\n * @param {number} y - The y component of the vector.\n * @param {number} z - The z component of the vector.\n * @return {Matrix4} A reference to this matrix.\n */\n setPosition(e, t, n) {\n const s = this.elements;\n return e.isVector3 ? (s[12] = e.x, s[13] = e.y, s[14] = e.z) : (s[12] = e, s[13] = t, s[14] = n), this;\n }\n /**\n * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).\n * You can not invert with a determinant of zero. If you attempt this, the method produces\n * a zero matrix instead.\n *\n * @return {Matrix4} A reference to this matrix.\n */\n invert() {\n const e = this.elements, t = e[0], n = e[1], s = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8], u = e[9], d = e[10], p = e[11], g = e[12], x = e[13], m = e[14], f = e[15], y = u * m * c - x * d * c + x * l * p - o * m * p - u * l * f + o * d * f, v = g * d * c - h * m * c - g * l * p + a * m * p + h * l * f - a * d * f, T = h * x * c - g * u * c + g * o * p - a * x * p - h * o * f + a * u * f, R = g * u * l - h * x * l - g * o * d + a * x * d + h * o * m - a * u * m, E = t * y + n * v + s * T + r * R;\n if (E === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n const P = 1 / E;\n return e[0] = y * P, e[1] = (x * d * r - u * m * r - x * s * p + n * m * p + u * s * f - n * d * f) * P, e[2] = (o * m * r - x * l * r + x * s * c - n * m * c - o * s * f + n * l * f) * P, e[3] = (u * l * r - o * d * r - u * s * c + n * d * c + o * s * p - n * l * p) * P, e[4] = v * P, e[5] = (h * m * r - g * d * r + g * s * p - t * m * p - h * s * f + t * d * f) * P, e[6] = (g * l * r - a * m * r - g * s * c + t * m * c + a * s * f - t * l * f) * P, e[7] = (a * d * r - h * l * r + h * s * c - t * d * c - a * s * p + t * l * p) * P, e[8] = T * P, e[9] = (g * u * r - h * x * r - g * n * p + t * x * p + h * n * f - t * u * f) * P, e[10] = (a * x * r - g * o * r + g * n * c - t * x * c - a * n * f + t * o * f) * P, e[11] = (h * o * r - a * u * r - h * n * c + t * u * c + a * n * p - t * o * p) * P, e[12] = R * P, e[13] = (h * x * s - g * u * s + g * n * d - t * x * d - h * n * m + t * u * m) * P, e[14] = (g * o * s - a * x * s - g * n * l + t * x * l + a * n * m - t * o * m) * P, e[15] = (a * u * s - h * o * s + h * n * l - t * u * l - a * n * d + t * o * d) * P, this;\n }\n /**\n * Multiplies the columns of this matrix by the given vector.\n *\n * @param {Vector3} v - The scale vector.\n * @return {Matrix4} A reference to this matrix.\n */\n scale(e) {\n const t = this.elements, n = e.x, s = e.y, r = e.z;\n return t[0] *= n, t[4] *= s, t[8] *= r, t[1] *= n, t[5] *= s, t[9] *= r, t[2] *= n, t[6] *= s, t[10] *= r, t[3] *= n, t[7] *= s, t[11] *= r, this;\n }\n /**\n * Gets the maximum scale value of the three axes.\n *\n * @return {number} The maximum scale.\n */\n getMaxScaleOnAxis() {\n const e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], s = e[8] * e[8] + e[9] * e[9] + e[10] * e[10];\n return Math.sqrt(Math.max(t, n, s));\n }\n /**\n * Sets this matrix as a translation transform from the given vector.\n *\n * @param {number|Vector3} x - The amount to translate in the X axis or alternatively a translation vector.\n * @param {number} y - The amount to translate in the Y axis.\n * @param {number} z - The amount to translate in the z axis.\n * @return {Matrix4} A reference to this matrix.\n */\n makeTranslation(e, t, n) {\n return e.isVector3 ? this.set(\n 1,\n 0,\n 0,\n e.x,\n 0,\n 1,\n 0,\n e.y,\n 0,\n 0,\n 1,\n e.z,\n 0,\n 0,\n 0,\n 1\n ) : this.set(\n 1,\n 0,\n 0,\n e,\n 0,\n 1,\n 0,\n t,\n 0,\n 0,\n 1,\n n,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Sets this matrix as a rotational transformation around the X axis by\n * the given angle.\n *\n * @param {number} theta - The rotation in radians.\n * @return {Matrix4} A reference to this matrix.\n */\n makeRotationX(e) {\n const t = Math.cos(e), n = Math.sin(e);\n return this.set(\n 1,\n 0,\n 0,\n 0,\n 0,\n t,\n -n,\n 0,\n 0,\n n,\n t,\n 0,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Sets this matrix as a rotational transformation around the Y axis by\n * the given angle.\n *\n * @param {number} theta - The rotation in radians.\n * @return {Matrix4} A reference to this matrix.\n */\n makeRotationY(e) {\n const t = Math.cos(e), n = Math.sin(e);\n return this.set(\n t,\n 0,\n n,\n 0,\n 0,\n 1,\n 0,\n 0,\n -n,\n 0,\n t,\n 0,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Sets this matrix as a rotational transformation around the Z axis by\n * the given angle.\n *\n * @param {number} theta - The rotation in radians.\n * @return {Matrix4} A reference to this matrix.\n */\n makeRotationZ(e) {\n const t = Math.cos(e), n = Math.sin(e);\n return this.set(\n t,\n -n,\n 0,\n 0,\n n,\n t,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Sets this matrix as a rotational transformation around the given axis by\n * the given angle.\n *\n * This is a somewhat controversial but mathematically sound alternative to\n * rotating via Quaternions. See the discussion [here](https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199).\n *\n * @param {Vector3} axis - The normalized rotation axis.\n * @param {number} angle - The rotation in radians.\n * @return {Matrix4} A reference to this matrix.\n */\n makeRotationAxis(e, t) {\n const n = Math.cos(t), s = Math.sin(t), r = 1 - n, a = e.x, o = e.y, l = e.z, c = r * a, h = r * o;\n return this.set(\n c * a + n,\n c * o - s * l,\n c * l + s * o,\n 0,\n c * o + s * l,\n h * o + n,\n h * l - s * a,\n 0,\n c * l - s * o,\n h * l + s * a,\n r * l * l + n,\n 0,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Sets this matrix as a scale transformation.\n *\n * @param {number} x - The amount to scale in the X axis.\n * @param {number} y - The amount to scale in the Y axis.\n * @param {number} z - The amount to scale in the Z axis.\n * @return {Matrix4} A reference to this matrix.\n */\n makeScale(e, t, n) {\n return this.set(\n e,\n 0,\n 0,\n 0,\n 0,\n t,\n 0,\n 0,\n 0,\n 0,\n n,\n 0,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Sets this matrix as a shear transformation.\n *\n * @param {number} xy - The amount to shear X by Y.\n * @param {number} xz - The amount to shear X by Z.\n * @param {number} yx - The amount to shear Y by X.\n * @param {number} yz - The amount to shear Y by Z.\n * @param {number} zx - The amount to shear Z by X.\n * @param {number} zy - The amount to shear Z by Y.\n * @return {Matrix4} A reference to this matrix.\n */\n makeShear(e, t, n, s, r, a) {\n return this.set(\n 1,\n n,\n r,\n 0,\n e,\n 1,\n a,\n 0,\n t,\n s,\n 1,\n 0,\n 0,\n 0,\n 0,\n 1\n ), this;\n }\n /**\n * Sets this matrix to the transformation composed of the given position,\n * rotation (Quaternion) and scale.\n *\n * @param {Vector3} position - The position vector.\n * @param {Quaternion} quaternion - The rotation as a Quaternion.\n * @param {Vector3} scale - The scale vector.\n * @return {Matrix4} A reference to this matrix.\n */\n compose(e, t, n) {\n const s = this.elements, r = t._x, a = t._y, o = t._z, l = t._w, c = r + r, h = a + a, u = o + o, d = r * c, p = r * h, g = r * u, x = a * h, m = a * u, f = o * u, y = l * c, v = l * h, T = l * u, R = n.x, E = n.y, P = n.z;\n return s[0] = (1 - (x + f)) * R, s[1] = (p + T) * R, s[2] = (g - v) * R, s[3] = 0, s[4] = (p - T) * E, s[5] = (1 - (d + f)) * E, s[6] = (m + y) * E, s[7] = 0, s[8] = (g + v) * P, s[9] = (m - y) * P, s[10] = (1 - (d + x)) * P, s[11] = 0, s[12] = e.x, s[13] = e.y, s[14] = e.z, s[15] = 1, this;\n }\n /**\n * Decomposes this matrix into its position, rotation and scale components\n * and provides the result in the given objects.\n *\n * Note: Not all matrices are decomposable in this way. For example, if an\n * object has a non-uniformly scaled parent, then the object's world matrix\n * may not be decomposable, and this method may not be appropriate.\n *\n * @param {Vector3} position - The position vector.\n * @param {Quaternion} quaternion - The rotation as a Quaternion.\n * @param {Vector3} scale - The scale vector.\n * @return {Matrix4} A reference to this matrix.\n */\n decompose(e, t, n) {\n const s = this.elements;\n let r = bi.set(s[0], s[1], s[2]).length();\n const a = bi.set(s[4], s[5], s[6]).length(), o = bi.set(s[8], s[9], s[10]).length();\n this.determinant() < 0 && (r = -r), e.x = s[12], e.y = s[13], e.z = s[14], an.copy(this);\n const c = 1 / r, h = 1 / a, u = 1 / o;\n return an.elements[0] *= c, an.elements[1] *= c, an.elements[2] *= c, an.elements[4] *= h, an.elements[5] *= h, an.elements[6] *= h, an.elements[8] *= u, an.elements[9] *= u, an.elements[10] *= u, t.setFromRotationMatrix(an), n.x = r, n.y = a, n.z = o, this;\n }\n /**\n \t * Creates a perspective projection matrix. This is used internally by\n \t * {@link PerspectiveCamera#updateProjectionMatrix}.\n \n \t * @param {number} left - Left boundary of the viewing frustum at the near plane.\n \t * @param {number} right - Right boundary of the viewing frustum at the near plane.\n \t * @param {number} top - Top boundary of the viewing frustum at the near plane.\n \t * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.\n \t * @param {number} near - The distance from the camera to the near plane.\n \t * @param {number} far - The distance from the camera to the far plane.\n \t * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.\n \t * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n makePerspective(e, t, n, s, r, a, o = Tn, l = !1) {\n const c = this.elements, h = 2 * r / (t - e), u = 2 * r / (n - s), d = (t + e) / (t - e), p = (n + s) / (n - s);\n let g, x;\n if (l)\n g = r / (a - r), x = a * r / (a - r);\n else if (o === Tn)\n g = -(a + r) / (a - r), x = -2 * a * r / (a - r);\n else if (o === br)\n g = -a / (a - r), x = -a * r / (a - r);\n else\n throw new Error(\"THREE.Matrix4.makePerspective(): Invalid coordinate system: \" + o);\n return c[0] = h, c[4] = 0, c[8] = d, c[12] = 0, c[1] = 0, c[5] = u, c[9] = p, c[13] = 0, c[2] = 0, c[6] = 0, c[10] = g, c[14] = x, c[3] = 0, c[7] = 0, c[11] = -1, c[15] = 0, this;\n }\n /**\n \t * Creates a orthographic projection matrix. This is used internally by\n \t * {@link OrthographicCamera#updateProjectionMatrix}.\n \n \t * @param {number} left - Left boundary of the viewing frustum at the near plane.\n \t * @param {number} right - Right boundary of the viewing frustum at the near plane.\n \t * @param {number} top - Top boundary of the viewing frustum at the near plane.\n \t * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.\n \t * @param {number} near - The distance from the camera to the near plane.\n \t * @param {number} far - The distance from the camera to the far plane.\n \t * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.\n \t * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n makeOrthographic(e, t, n, s, r, a, o = Tn, l = !1) {\n const c = this.elements, h = 2 / (t - e), u = 2 / (n - s), d = -(t + e) / (t - e), p = -(n + s) / (n - s);\n let g, x;\n if (l)\n g = 1 / (a - r), x = a / (a - r);\n else if (o === Tn)\n g = -2 / (a - r), x = -(a + r) / (a - r);\n else if (o === br)\n g = -1 / (a - r), x = -r / (a - r);\n else\n throw new Error(\"THREE.Matrix4.makeOrthographic(): Invalid coordinate system: \" + o);\n return c[0] = h, c[4] = 0, c[8] = 0, c[12] = d, c[1] = 0, c[5] = u, c[9] = 0, c[13] = p, c[2] = 0, c[6] = 0, c[10] = g, c[14] = x, c[3] = 0, c[7] = 0, c[11] = 0, c[15] = 1, this;\n }\n /**\n * Returns `true` if this matrix is equal with the given one.\n *\n * @param {Matrix4} matrix - The matrix to test for equality.\n * @return {boolean} Whether this matrix is equal with the given one.\n */\n equals(e) {\n const t = this.elements, n = e.elements;\n for (let s = 0; s < 16; s++)\n if (t[s] !== n[s]) return !1;\n return !0;\n }\n /**\n * Sets the elements of the matrix from the given array.\n *\n * @param {Array} array - The matrix elements in column-major order.\n * @param {number} [offset=0] - Index of the first element in the array.\n * @return {Matrix4} A reference to this matrix.\n */\n fromArray(e, t = 0) {\n for (let n = 0; n < 16; n++)\n this.elements[n] = e[n + t];\n return this;\n }\n /**\n * Writes the elements of this matrix to the given array. If no array is provided,\n * the method returns a new instance.\n *\n * @param {Array} [array=[]] - The target array holding the matrix elements in column-major order.\n * @param {number} [offset=0] - Index of the first element in the array.\n * @return {Array} The matrix elements in column-major order.\n */\n toArray(e = [], t = 0) {\n const n = this.elements;\n return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[t + 9] = n[9], e[t + 10] = n[10], e[t + 11] = n[11], e[t + 12] = n[12], e[t + 13] = n[13], e[t + 14] = n[14], e[t + 15] = n[15], e;\n }\n}\nconst bi = /* @__PURE__ */ new w(), an = /* @__PURE__ */ new Ne(), Ou = /* @__PURE__ */ new w(0, 0, 0), Bu = /* @__PURE__ */ new w(1, 1, 1), Xn = /* @__PURE__ */ new w(), Bs = /* @__PURE__ */ new w(), Yt = /* @__PURE__ */ new w(), pl = /* @__PURE__ */ new Ne(), ml = /* @__PURE__ */ new gn();\nclass xn {\n /**\n * Constructs a new euler instance.\n *\n * @param {number} [x=0] - The angle of the x axis in radians.\n * @param {number} [y=0] - The angle of the y axis in radians.\n * @param {number} [z=0] - The angle of the z axis in radians.\n * @param {string} [order=Euler.DEFAULT_ORDER] - A string representing the order that the rotations are applied.\n */\n constructor(e = 0, t = 0, n = 0, s = xn.DEFAULT_ORDER) {\n this.isEuler = !0, this._x = e, this._y = t, this._z = n, this._order = s;\n }\n /**\n * The angle of the x axis in radians.\n *\n * @type {number}\n * @default 0\n */\n get x() {\n return this._x;\n }\n set x(e) {\n this._x = e, this._onChangeCallback();\n }\n /**\n * The angle of the y axis in radians.\n *\n * @type {number}\n * @default 0\n */\n get y() {\n return this._y;\n }\n set y(e) {\n this._y = e, this._onChangeCallback();\n }\n /**\n * The angle of the z axis in radians.\n *\n * @type {number}\n * @default 0\n */\n get z() {\n return this._z;\n }\n set z(e) {\n this._z = e, this._onChangeCallback();\n }\n /**\n * A string representing the order that the rotations are applied.\n *\n * @type {string}\n * @default 'XYZ'\n */\n get order() {\n return this._order;\n }\n set order(e) {\n this._order = e, this._onChangeCallback();\n }\n /**\n * Sets the Euler components.\n *\n * @param {number} x - The angle of the x axis in radians.\n * @param {number} y - The angle of the y axis in radians.\n * @param {number} z - The angle of the z axis in radians.\n * @param {string} [order] - A string representing the order that the rotations are applied.\n * @return {Euler} A reference to this Euler instance.\n */\n set(e, t, n, s = this._order) {\n return this._x = e, this._y = t, this._z = n, this._order = s, this._onChangeCallback(), this;\n }\n /**\n * Returns a new Euler instance with copied values from this instance.\n *\n * @return {Euler} A clone of this instance.\n */\n clone() {\n return new this.constructor(this._x, this._y, this._z, this._order);\n }\n /**\n * Copies the values of the given Euler instance to this instance.\n *\n * @param {Euler} euler - The Euler instance to copy.\n * @return {Euler} A reference to this Euler instance.\n */\n copy(e) {\n return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this;\n }\n /**\n * Sets the angles of this Euler instance from a pure rotation matrix.\n *\n * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).\n * @param {string} [order] - A string representing the order that the rotations are applied.\n * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.\n * @return {Euler} A reference to this Euler instance.\n */\n setFromRotationMatrix(e, t = this._order, n = !0) {\n const s = e.elements, r = s[0], a = s[4], o = s[8], l = s[1], c = s[5], h = s[9], u = s[2], d = s[6], p = s[10];\n switch (t) {\n case \"XYZ\":\n this._y = Math.asin(He(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-h, p), this._z = Math.atan2(-a, r)) : (this._x = Math.atan2(d, c), this._z = 0);\n break;\n case \"YXZ\":\n this._x = Math.asin(-He(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._y = Math.atan2(o, p), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-u, r), this._z = 0);\n break;\n case \"ZXY\":\n this._x = Math.asin(He(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._y = Math.atan2(-u, p), this._z = Math.atan2(-a, c)) : (this._y = 0, this._z = Math.atan2(l, r));\n break;\n case \"ZYX\":\n this._y = Math.asin(-He(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._x = Math.atan2(d, p), this._z = Math.atan2(l, r)) : (this._x = 0, this._z = Math.atan2(-a, c));\n break;\n case \"YZX\":\n this._z = Math.asin(He(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(-h, c), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(o, p));\n break;\n case \"XZY\":\n this._z = Math.asin(-He(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(d, c), this._y = Math.atan2(o, r)) : (this._x = Math.atan2(-h, p), this._y = 0);\n break;\n default:\n Te(\"Euler: .setFromRotationMatrix() encountered an unknown order: \" + t);\n }\n return this._order = t, n === !0 && this._onChangeCallback(), this;\n }\n /**\n * Sets the angles of this Euler instance from a normalized quaternion.\n *\n * @param {Quaternion} q - A normalized Quaternion.\n * @param {string} [order] - A string representing the order that the rotations are applied.\n * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.\n * @return {Euler} A reference to this Euler instance.\n */\n setFromQuaternion(e, t, n) {\n return pl.makeRotationFromQuaternion(e), this.setFromRotationMatrix(pl, t, n);\n }\n /**\n * Sets the angles of this Euler instance from the given vector.\n *\n * @param {Vector3} v - The vector.\n * @param {string} [order] - A string representing the order that the rotations are applied.\n * @return {Euler} A reference to this Euler instance.\n */\n setFromVector3(e, t = this._order) {\n return this.set(e.x, e.y, e.z, t);\n }\n /**\n * Resets the euler angle with a new order by creating a quaternion from this\n * euler angle and then setting this euler angle with the quaternion and the\n * new order.\n *\n * Warning: This discards revolution information.\n *\n * @param {string} [newOrder] - A string representing the new order that the rotations are applied.\n * @return {Euler} A reference to this Euler instance.\n */\n reorder(e) {\n return ml.setFromEuler(this), this.setFromQuaternion(ml, e);\n }\n /**\n * Returns `true` if this Euler instance is equal with the given one.\n *\n * @param {Euler} euler - The Euler instance to test for equality.\n * @return {boolean} Whether this Euler instance is equal with the given one.\n */\n equals(e) {\n return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order;\n }\n /**\n * Sets this Euler instance's components to values from the given array. The first three\n * entries of the array are assign to the x,y and z components. An optional fourth entry\n * defines the Euler order.\n *\n * @param {Array} array - An array holding the Euler component values.\n * @return {Euler} A reference to this Euler instance.\n */\n fromArray(e) {\n return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this;\n }\n /**\n * Writes the components of this Euler instance to the given array. If no array is provided,\n * the method returns a new instance.\n *\n * @param {Array} [array=[]] - The target array holding the Euler components.\n * @param {number} [offset=0] - Index of the first element in the array.\n * @return {Array} The Euler components.\n */\n toArray(e = [], t = 0) {\n return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e;\n }\n _onChange(e) {\n return this._onChangeCallback = e, this;\n }\n _onChangeCallback() {\n }\n *[Symbol.iterator]() {\n yield this._x, yield this._y, yield this._z, yield this._order;\n }\n}\nxn.DEFAULT_ORDER = \"XYZ\";\nclass Uo {\n /**\n * Constructs a new layers instance, with membership\n * initially set to layer `0`.\n */\n constructor() {\n this.mask = 1;\n }\n /**\n * Sets membership to the given layer, and remove membership all other layers.\n *\n * @param {number} layer - The layer to set.\n */\n set(e) {\n this.mask = (1 << e | 0) >>> 0;\n }\n /**\n * Adds membership of the given layer.\n *\n * @param {number} layer - The layer to enable.\n */\n enable(e) {\n this.mask |= 1 << e | 0;\n }\n /**\n * Adds membership to all layers.\n */\n enableAll() {\n this.mask = -1;\n }\n /**\n * Toggles the membership of the given layer.\n *\n * @param {number} layer - The layer to toggle.\n */\n toggle(e) {\n this.mask ^= 1 << e | 0;\n }\n /**\n * Removes membership of the given layer.\n *\n * @param {number} layer - The layer to enable.\n */\n disable(e) {\n this.mask &= ~(1 << e | 0);\n }\n /**\n * Removes the membership from all layers.\n */\n disableAll() {\n this.mask = 0;\n }\n /**\n * Returns `true` if this and the given layers object have at least one\n * layer in common.\n *\n * @param {Layers} layers - The layers to test.\n * @return {boolean } Whether this and the given layers object have at least one layer in common or not.\n */\n test(e) {\n return (this.mask & e.mask) !== 0;\n }\n /**\n * Returns `true` if the given layer is enabled.\n *\n * @param {number} layer - The layer to test.\n * @return {boolean } Whether the given layer is enabled or not.\n */\n isEnabled(e) {\n return (this.mask & (1 << e | 0)) !== 0;\n }\n}\nlet zu = 0;\nconst gl = /* @__PURE__ */ new w(), yi = /* @__PURE__ */ new gn(), Ln = /* @__PURE__ */ new Ne(), zs = /* @__PURE__ */ new w(), as = /* @__PURE__ */ new w(), ku = /* @__PURE__ */ new w(), Vu = /* @__PURE__ */ new gn(), xl = /* @__PURE__ */ new w(1, 0, 0), _l = /* @__PURE__ */ new w(0, 1, 0), vl = /* @__PURE__ */ new w(0, 0, 1), Ml = { type: \"added\" }, Gu = { type: \"removed\" }, Ti = { type: \"childadded\", child: null }, jr = { type: \"childremoved\", child: null };\nclass pt extends mi {\n /**\n * Constructs a new 3D object.\n */\n constructor() {\n super(), this.isObject3D = !0, Object.defineProperty(this, \"id\", { value: zu++ }), this.uuid = fn(), this.name = \"\", this.type = \"Object3D\", this.parent = null, this.children = [], this.up = pt.DEFAULT_UP.clone();\n const e = new w(), t = new xn(), n = new gn(), s = new w(1, 1, 1);\n function r() {\n n.setFromEuler(t, !1);\n }\n function a() {\n t.setFromQuaternion(n, void 0, !1);\n }\n t._onChange(r), n._onChange(a), Object.defineProperties(this, {\n /**\n * Represents the object's local position.\n *\n * @name Object3D#position\n * @type {Vector3}\n * @default (0,0,0)\n */\n position: {\n configurable: !0,\n enumerable: !0,\n value: e\n },\n /**\n * Represents the object's local rotation as Euler angles, in radians.\n *\n * @name Object3D#rotation\n * @type {Euler}\n * @default (0,0,0)\n */\n rotation: {\n configurable: !0,\n enumerable: !0,\n value: t\n },\n /**\n * Represents the object's local rotation as Quaternions.\n *\n * @name Object3D#quaternion\n * @type {Quaternion}\n */\n quaternion: {\n configurable: !0,\n enumerable: !0,\n value: n\n },\n /**\n * Represents the object's local scale.\n *\n * @name Object3D#scale\n * @type {Vector3}\n * @default (1,1,1)\n */\n scale: {\n configurable: !0,\n enumerable: !0,\n value: s\n },\n /**\n * Represents the object's model-view matrix.\n *\n * @name Object3D#modelViewMatrix\n * @type {Matrix4}\n */\n modelViewMatrix: {\n value: new Ne()\n },\n /**\n * Represents the object's normal matrix.\n *\n * @name Object3D#normalMatrix\n * @type {Matrix3}\n */\n normalMatrix: {\n value: new ze()\n }\n }), this.matrix = new Ne(), this.matrixWorld = new Ne(), this.matrixAutoUpdate = pt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new Uo(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.customDepthMaterial = void 0, this.customDistanceMaterial = void 0, this.userData = {};\n }\n /**\n * A callback that is executed immediately before a 3D object is rendered to a shadow map.\n *\n * @param {Renderer|WebGLRenderer} renderer - The renderer.\n * @param {Object3D} object - The 3D object.\n * @param {Camera} camera - The camera that is used to render the scene.\n * @param {Camera} shadowCamera - The shadow camera.\n * @param {BufferGeometry} geometry - The 3D object's geometry.\n * @param {Material} depthMaterial - The depth material.\n * @param {Object} group - The geometry group data.\n */\n onBeforeShadow() {\n }\n /**\n * A callback that is executed immediately after a 3D object is rendered to a shadow map.\n *\n * @param {Renderer|WebGLRenderer} renderer - The renderer.\n * @param {Object3D} object - The 3D object.\n * @param {Camera} camera - The camera that is used to render the scene.\n * @param {Camera} shadowCamera - The shadow camera.\n * @param {BufferGeometry} geometry - The 3D object's geometry.\n * @param {Material} depthMaterial - The depth material.\n * @param {Object} group - The geometry group data.\n */\n onAfterShadow() {\n }\n /**\n * A callback that is executed immediately before a 3D object is rendered.\n *\n * @param {Renderer|WebGLRenderer} renderer - The renderer.\n * @param {Object3D} object - The 3D object.\n * @param {Camera} camera - The camera that is used to render the scene.\n * @param {BufferGeometry} geometry - The 3D object's geometry.\n * @param {Material} material - The 3D object's material.\n * @param {Object} group - The geometry group data.\n */\n onBeforeRender() {\n }\n /**\n * A callback that is executed immediately after a 3D object is rendered.\n *\n * @param {Renderer|WebGLRenderer} renderer - The renderer.\n * @param {Object3D} object - The 3D object.\n * @param {Camera} camera - The camera that is used to render the scene.\n * @param {BufferGeometry} geometry - The 3D object's geometry.\n * @param {Material} material - The 3D object's material.\n * @param {Object} group - The geometry group data.\n */\n onAfterRender() {\n }\n /**\n * Applies the given transformation matrix to the object and updates the object's position,\n * rotation and scale.\n *\n * @param {Matrix4} matrix - The transformation matrix.\n */\n applyMatrix4(e) {\n this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale);\n }\n /**\n * Applies a rotation represented by given the quaternion to the 3D object.\n *\n * @param {Quaternion} q - The quaternion.\n * @return {Object3D} A reference to this instance.\n */\n applyQuaternion(e) {\n return this.quaternion.premultiply(e), this;\n }\n /**\n * Sets the given rotation represented as an axis/angle couple to the 3D object.\n *\n * @param {Vector3} axis - The (normalized) axis vector.\n * @param {number} angle - The angle in radians.\n */\n setRotationFromAxisAngle(e, t) {\n this.quaternion.setFromAxisAngle(e, t);\n }\n /**\n * Sets the given rotation represented as Euler angles to the 3D object.\n *\n * @param {Euler} euler - The Euler angles.\n */\n setRotationFromEuler(e) {\n this.quaternion.setFromEuler(e, !0);\n }\n /**\n * Sets the given rotation represented as rotation matrix to the 3D object.\n *\n * @param {Matrix4} m - Although a 4x4 matrix is expected, the upper 3x3 portion must be\n * a pure rotation matrix (i.e, unscaled).\n */\n setRotationFromMatrix(e) {\n this.quaternion.setFromRotationMatrix(e);\n }\n /**\n * Sets the given rotation represented as a Quaternion to the 3D object.\n *\n * @param {Quaternion} q - The Quaternion\n */\n setRotationFromQuaternion(e) {\n this.quaternion.copy(e);\n }\n /**\n * Rotates the 3D object along an axis in local space.\n *\n * @param {Vector3} axis - The (normalized) axis vector.\n * @param {number} angle - The angle in radians.\n * @return {Object3D} A reference to this instance.\n */\n rotateOnAxis(e, t) {\n return yi.setFromAxisAngle(e, t), this.quaternion.multiply(yi), this;\n }\n /**\n * Rotates the 3D object along an axis in world space.\n *\n * @param {Vector3} axis - The (normalized) axis vector.\n * @param {number} angle - The angle in radians.\n * @return {Object3D} A reference to this instance.\n */\n rotateOnWorldAxis(e, t) {\n return yi.setFromAxisAngle(e, t), this.quaternion.premultiply(yi), this;\n }\n /**\n * Rotates the 3D object around its X axis in local space.\n *\n * @param {number} angle - The angle in radians.\n * @return {Object3D} A reference to this instance.\n */\n rotateX(e) {\n return this.rotateOnAxis(xl, e);\n }\n /**\n * Rotates the 3D object around its Y axis in local space.\n *\n * @param {number} angle - The angle in radians.\n * @return {Object3D} A reference to this instance.\n */\n rotateY(e) {\n return this.rotateOnAxis(_l, e);\n }\n /**\n * Rotates the 3D object around its Z axis in local space.\n *\n * @param {number} angle - The angle in radians.\n * @return {Object3D} A reference to this instance.\n */\n rotateZ(e) {\n return this.rotateOnAxis(vl, e);\n }\n /**\n * Translate the 3D object by a distance along the given axis in local space.\n *\n * @param {Vector3} axis - The (normalized) axis vector.\n * @param {number} distance - The distance in world units.\n * @return {Object3D} A reference to this instance.\n */\n translateOnAxis(e, t) {\n return gl.copy(e).applyQuaternion(this.quaternion), this.position.add(gl.multiplyScalar(t)), this;\n }\n /**\n * Translate the 3D object by a distance along its X-axis in local space.\n *\n * @param {number} distance - The distance in world units.\n * @return {Object3D} A reference to this instance.\n */\n translateX(e) {\n return this.translateOnAxis(xl, e);\n }\n /**\n * Translate the 3D object by a distance along its Y-axis in local space.\n *\n * @param {number} distance - The distance in world units.\n * @return {Object3D} A reference to this instance.\n */\n translateY(e) {\n return this.translateOnAxis(_l, e);\n }\n /**\n * Translate the 3D object by a distance along its Z-axis in local space.\n *\n * @param {number} distance - The distance in world units.\n * @return {Object3D} A reference to this instance.\n */\n translateZ(e) {\n return this.translateOnAxis(vl, e);\n }\n /**\n * Converts the given vector from this 3D object's local space to world space.\n *\n * @param {Vector3} vector - The vector to convert.\n * @return {Vector3} The converted vector.\n */\n localToWorld(e) {\n return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld);\n }\n /**\n * Converts the given vector from this 3D object's word space to local space.\n *\n * @param {Vector3} vector - The vector to convert.\n * @return {Vector3} The converted vector.\n */\n worldToLocal(e) {\n return this.updateWorldMatrix(!0, !1), e.applyMatrix4(Ln.copy(this.matrixWorld).invert());\n }\n /**\n * Rotates the object to face a point in world space.\n *\n * This method does not support objects having non-uniformly-scaled parent(s).\n *\n * @param {number|Vector3} x - The x coordinate in world space. Alternatively, a vector representing a position in world space\n * @param {number} [y] - The y coordinate in world space.\n * @param {number} [z] - The z coordinate in world space.\n */\n lookAt(e, t, n) {\n e.isVector3 ? zs.copy(e) : zs.set(e, t, n);\n const s = this.parent;\n this.updateWorldMatrix(!0, !1), as.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Ln.lookAt(as, zs, this.up) : Ln.lookAt(zs, as, this.up), this.quaternion.setFromRotationMatrix(Ln), s && (Ln.extractRotation(s.matrixWorld), yi.setFromRotationMatrix(Ln), this.quaternion.premultiply(yi.invert()));\n }\n /**\n * Adds the given 3D object as a child to this 3D object. An arbitrary number of\n * objects may be added. Any current parent on an object passed in here will be\n * removed, since an object can have at most one parent.\n *\n * @fires Object3D#added\n * @fires Object3D#childadded\n * @param {Object3D} object - The 3D object to add.\n * @return {Object3D} A reference to this instance.\n */\n add(e) {\n if (arguments.length > 1) {\n for (let t = 0; t < arguments.length; t++)\n this.add(arguments[t]);\n return this;\n }\n return e === this ? (Xe(\"Object3D.add: object can't be added as a child of itself.\", e), this) : (e && e.isObject3D ? (e.removeFromParent(), e.parent = this, this.children.push(e), e.dispatchEvent(Ml), Ti.child = e, this.dispatchEvent(Ti), Ti.child = null) : Xe(\"Object3D.add: object not an instance of THREE.Object3D.\", e), this);\n }\n /**\n * Removes the given 3D object as child from this 3D object.\n * An arbitrary number of objects may be removed.\n *\n * @fires Object3D#removed\n * @fires Object3D#childremoved\n * @param {Object3D} object - The 3D object to remove.\n * @return {Object3D} A reference to this instance.\n */\n remove(e) {\n if (arguments.length > 1) {\n for (let n = 0; n < arguments.length; n++)\n this.remove(arguments[n]);\n return this;\n }\n const t = this.children.indexOf(e);\n return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(Gu), jr.child = e, this.dispatchEvent(jr), jr.child = null), this;\n }\n /**\n * Removes this 3D object from its current parent.\n *\n * @fires Object3D#removed\n * @fires Object3D#childremoved\n * @return {Object3D} A reference to this instance.\n */\n removeFromParent() {\n const e = this.parent;\n return e !== null && e.remove(this), this;\n }\n /**\n * Removes all child objects.\n *\n * @fires Object3D#removed\n * @fires Object3D#childremoved\n * @return {Object3D} A reference to this instance.\n */\n clear() {\n return this.remove(...this.children);\n }\n /**\n * Adds the given 3D object as a child of this 3D object, while maintaining the object's world\n * transform. This method does not support scene graphs having non-uniformly-scaled nodes(s).\n *\n * @fires Object3D#added\n * @fires Object3D#childadded\n * @param {Object3D} object - The 3D object to attach.\n * @return {Object3D} A reference to this instance.\n */\n attach(e) {\n return this.updateWorldMatrix(!0, !1), Ln.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Ln.multiply(e.parent.matrixWorld)), e.applyMatrix4(Ln), e.removeFromParent(), e.parent = this, this.children.push(e), e.updateWorldMatrix(!1, !0), e.dispatchEvent(Ml), Ti.child = e, this.dispatchEvent(Ti), Ti.child = null, this;\n }\n /**\n * Searches through the 3D object and its children, starting with the 3D object\n * itself, and returns the first with a matching ID.\n *\n * @param {number} id - The id.\n * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.\n */\n getObjectById(e) {\n return this.getObjectByProperty(\"id\", e);\n }\n /**\n * Searches through the 3D object and its children, starting with the 3D object\n * itself, and returns the first with a matching name.\n *\n * @param {string} name - The name.\n * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.\n */\n getObjectByName(e) {\n return this.getObjectByProperty(\"name\", e);\n }\n /**\n * Searches through the 3D object and its children, starting with the 3D object\n * itself, and returns the first with a matching property value.\n *\n * @param {string} name - The name of the property.\n * @param {any} value - The value.\n * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.\n */\n getObjectByProperty(e, t) {\n if (this[e] === t) return this;\n for (let n = 0, s = this.children.length; n < s; n++) {\n const a = this.children[n].getObjectByProperty(e, t);\n if (a !== void 0)\n return a;\n }\n }\n /**\n * Searches through the 3D object and its children, starting with the 3D object\n * itself, and returns all 3D objects with a matching property value.\n *\n * @param {string} name - The name of the property.\n * @param {any} value - The value.\n * @param {Array} result - The method stores the result in this array.\n * @return {Array} The found 3D objects.\n */\n getObjectsByProperty(e, t, n = []) {\n this[e] === t && n.push(this);\n const s = this.children;\n for (let r = 0, a = s.length; r < a; r++)\n s[r].getObjectsByProperty(e, t, n);\n return n;\n }\n /**\n * Returns a vector representing the position of the 3D object in world space.\n *\n * @param {Vector3} target - The target vector the result is stored to.\n * @return {Vector3} The 3D object's position in world space.\n */\n getWorldPosition(e) {\n return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld);\n }\n /**\n * Returns a Quaternion representing the position of the 3D object in world space.\n *\n * @param {Quaternion} target - The target Quaternion the result is stored to.\n * @return {Quaternion} The 3D object's rotation in world space.\n */\n getWorldQuaternion(e) {\n return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(as, e, ku), e;\n }\n /**\n * Returns a vector representing the scale of the 3D object in world space.\n *\n * @param {Vector3} target - The target vector the result is stored to.\n * @return {Vector3} The 3D object's scale in world space.\n */\n getWorldScale(e) {\n return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(as, Vu, e), e;\n }\n /**\n * Returns a vector representing the (\"look\") direction of the 3D object in world space.\n *\n * @param {Vector3} target - The target vector the result is stored to.\n * @return {Vector3} The 3D object's direction in world space.\n */\n getWorldDirection(e) {\n this.updateWorldMatrix(!0, !1);\n const t = this.matrixWorld.elements;\n return e.set(t[8], t[9], t[10]).normalize();\n }\n /**\n * Abstract method to get intersections between a casted ray and this\n * 3D object. Renderable 3D objects such as {@link Mesh}, {@link Line} or {@link Points}\n * implement this method in order to use raycasting.\n *\n * @abstract\n * @param {Raycaster} raycaster - The raycaster.\n * @param {Array