UNPKG

threepipe

Version:

A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.

1,386 lines 2.18 MB
/** * @license * threepipe v0.0.39 * Copyright 2022-2025 repalash <palash@shaders.app> * Apache-2.0 License * See ./dependencies.txt for bundled third-party dependencies and licenses. */ /** * @license * Copyright 2010-2023 Three.js Authors * SPDX-License-Identifier: MIT */ const wg = "157", Ho = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }, Vo = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, Kb = 0, xy = 1, Jb = 2, Eg = 1, $b = 2, Mr = 3, Ji = 0, mi = 1, zn = 2, gi = 0, rr = 1, Pd = 2, Ld = 3, Ud = 4, dx = 5, qa = 100, Zb = 101, eS = 102, wy = 103, Ey = 104, tS = 200, nS = 201, iS = 202, sS = 203, bg = 204, Sg = 205, rS = 206, aS = 207, oS = 208, lS = 209, cS = 210, fx = 0, px = 1, mx = 2, vh = 3, gx = 4, Ax = 5, yx = 6, _x = 7, fc = 0, hS = 1, uS = 2, Ur = 0, vx = 1, xx = 2, wx = 3, Cg = 4, Ex = 5, zh = 300, Nr = 301, so = 302, va = 303, Fd = 304, pc = 306, Ai = 1e3, Kt = 1001, kr = 1002, ln = 1003, Hl = 1004, $a = 1005, tt = 1006, Qh = 1007, zi = 1008, by = 1008, Lt = 1009, bx = 1010, Sx = 1011, xf = 1012, Mg = 1013, zs = 1014, jt = 1015, Gt = 1016, Tg = 1017, Ig = 1018, fa = 1020, dS = 1021, Jt = 1023, fS = 1024, pS = 1025, pa = 1026, Vl = 1027, Ya = 1028, Cx = 1029, vl = 1030, Mx = 1031, Tx = 1033, gd = 33776, Zf = 33777, ep = 33778, Ad = 33779, pm = 35840, Sy = 35841, mm = 35842, Cy = 35843, Ix = 36196, gm = 37492, Am = 37496, ym = 37808, My = 37809, Ty = 37810, Iy = 37811, Od = 37812, Dy = 37813, Ry = 37814, By = 37815, Py = 37816, Ly = 37817, Uy = 37818, Fy = 37819, Oy = 37820, Ny = 37821, yd = 36492, ky = 36494, Gy = 36495, mS = 36283, zy = 36284, Qy = 36285, Hy = 36286, _m = 2200, vm = 2201, gS = 2202, Wl = 2300, ro = 2301, tp = 2302, xl = 2400, wl = 2401, Nd = 2402, Dg = 2500, Dx = 2501, AS = 0, Rx = 1, xm = 2, wm = 3e3, oa = 3001, Pl = 3200, Bx = 3201, Es = 0, Px = 1, Ht = "", ot = "srgb", wt = "srgb-linear", Hh = "display-p3", Vh = "display-p3-linear", vs = "rgbm-16", kd = "linear", pn = "srgb", Gd = "rec709", zd = "p3", Ll = 7680, Lx = 519, yS = 512, _S = 513, vS = 514, xS = 515, wS = 516, ES = 517, bS = 518, SS = 519, Qd = 35044, CS = "100", Em = "300 es", bm = 1035, Br = 2e3, Hd = 2001; class Hn { addEventListener(e, t) { this._listeners === void 0 && (this._listeners = {}); const n = this._listeners; n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t); } hasEventListener(e, t) { if (this._listeners === void 0) return !1; const n = this._listeners; return n[e] !== void 0 && n[e].indexOf(t) !== -1; } removeEventListener(e, t) { if (this._listeners === void 0) return; const i = this._listeners[e]; if (i !== void 0) { const r = i.indexOf(t); r !== -1 && i.splice(r, 1); } } dispatchEvent(e) { if (this._listeners === void 0) return; const n = this._listeners[e.type]; if (n !== void 0) { e.target = this; const i = n.slice(0); for (let r = 0, a = i.length; r < a; r++) i[r].call(this, e); e.target = null; } } } const xi = ["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"]; let Vy = 1234567; const Za = Math.PI / 180, jl = 180 / Math.PI; function hs() { const s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0; return (xi[s & 255] + xi[s >> 8 & 255] + xi[s >> 16 & 255] + xi[s >> 24 & 255] + "-" + xi[e & 255] + xi[e >> 8 & 255] + "-" + xi[e >> 16 & 15 | 64] + xi[e >> 24 & 255] + "-" + xi[t & 63 | 128] + xi[t >> 8 & 255] + "-" + xi[t >> 16 & 255] + xi[t >> 24 & 255] + xi[n & 255] + xi[n >> 8 & 255] + xi[n >> 16 & 255] + xi[n >> 24 & 255]).toLowerCase(); } function Rn(s, e, t) { return Math.max(e, Math.min(t, s)); } function Rg(s, e) { return (s % e + e) % e; } function MS(s, e, t, n, i) { return n + (s - e) * (i - n) / (t - e); } function TS(s, e, t) { return s !== e ? (t - s) / (e - s) : 0; } function ah(s, e, t) { return (1 - t) * s + t * e; } function IS(s, e, t, n) { return ah(s, e, 1 - Math.exp(-t * n)); } function DS(s, e = 1) { return e - Math.abs(Rg(s, e * 2) - e); } function RS(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * (3 - 2 * s)); } function BS(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * s * (s * (s * 6 - 15) + 10)); } function PS(s, e) { return s + Math.floor(Math.random() * (e - s + 1)); } function LS(s, e) { return s + Math.random() * (e - s); } function US(s) { return s * (0.5 - Math.random()); } function FS(s) { s !== void 0 && (Vy = s); let e = Vy += 1831565813; return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296; } function OS(s) { return s * Za; } function NS(s) { return s * jl; } function Sm(s) { return (s & s - 1) === 0 && s !== 0; } function Ux(s) { return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2)); } function Vd(s) { return Math.pow(2, Math.floor(Math.log(s) / Math.LN2)); } function kS(s, e, t, n, i) { 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), f = r((n - e) / 2), p = a((n - e) / 2); switch (i) { case "XYX": s.set(o * h, l * u, l * d, o * c); break; case "YZY": s.set(l * d, o * h, l * u, o * c); break; case "ZXZ": s.set(l * u, l * d, o * h, o * c); break; case "XZX": s.set(o * h, l * p, l * f, o * c); break; case "YXY": s.set(l * f, o * h, l * p, o * c); break; case "ZYZ": s.set(l * p, l * f, o * h, o * c); break; default: console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i); } } function Xi(s, e) { switch (e.constructor) { case Float32Array: return s; case Uint32Array: return s / 4294967295; case Uint16Array: return s / 65535; case Uint8Array: return s / 255; case Int32Array: return Math.max(s / 2147483647, -1); case Int16Array: return Math.max(s / 32767, -1); case Int8Array: return Math.max(s / 127, -1); default: throw new Error("Invalid component type."); } } function mt(s, e) { switch (e.constructor) { case Float32Array: return s; case Uint32Array: return Math.round(s * 4294967295); case Uint16Array: return Math.round(s * 65535); case Uint8Array: return Math.round(s * 255); case Int32Array: return Math.round(s * 2147483647); case Int16Array: return Math.round(s * 32767); case Int8Array: return Math.round(s * 127); default: throw new Error("Invalid component type."); } } const tn = { DEG2RAD: Za, RAD2DEG: jl, generateUUID: hs, clamp: Rn, euclideanModulo: Rg, mapLinear: MS, inverseLerp: TS, lerp: ah, damp: IS, pingpong: DS, smoothstep: RS, smootherstep: BS, randInt: PS, randFloat: LS, randFloatSpread: US, seededRandom: FS, degToRad: OS, radToDeg: NS, isPowerOfTwo: Sm, ceilPowerOfTwo: Ux, floorPowerOfTwo: Vd, setQuaternionFromProperEuler: kS, normalize: mt, denormalize: Xi }; class Z { constructor(e = 0, t = 0) { Z.prototype.isVector2 = !0, this.x = e, this.y = t; } get width() { return this.x; } set width(e) { this.x = e; } get height() { return this.y; } set height(e) { this.y = e; } set(e, t) { return this.x = e, this.y = t, this; } setScalar(e) { return this.x = e, this.y = e, this; } setX(e) { return this.x = e, this; } setY(e) { return this.y = e, this; } setComponent(e, t) { switch (e) { case 0: this.x = t; break; case 1: this.y = t; break; default: throw new Error("index is out of range: " + e); } return this; } getComponent(e) { switch (e) { case 0: return this.x; case 1: return this.y; default: throw new Error("index is out of range: " + e); } } clone() { return new this.constructor(this.x, this.y); } copy(e) { return this.x = e.x, this.y = e.y, this; } add(e) { return this.x += e.x, this.y += e.y, this; } addScalar(e) { return this.x += e, this.y += e, this; } addVectors(e, t) { return this.x = e.x + t.x, this.y = e.y + t.y, this; } addScaledVector(e, t) { return this.x += e.x * t, this.y += e.y * t, this; } sub(e) { return this.x -= e.x, this.y -= e.y, this; } subScalar(e) { return this.x -= e, this.y -= e, this; } subVectors(e, t) { return this.x = e.x - t.x, this.y = e.y - t.y, this; } multiply(e) { return this.x *= e.x, this.y *= e.y, this; } multiplyScalar(e) { return this.x *= e, this.y *= e, this; } divide(e) { return this.x /= e.x, this.y /= e.y, this; } divideScalar(e) { return this.multiplyScalar(1 / e); } applyMatrix3(e) { const t = this.x, n = this.y, i = e.elements; return this.x = i[0] * t + i[3] * n + i[6], this.y = i[1] * t + i[4] * n + i[7], this; } min(e) { return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this; } max(e) { return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this; } clamp(e, t) { return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this; } clampScalar(e, t) { return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this; } clampLength(e, t) { const n = this.length(); return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); } floor() { return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this; } ceil() { return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this; } round() { return this.x = Math.round(this.x), this.y = Math.round(this.y), this; } roundToZero() { return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this; } negate() { return this.x = -this.x, this.y = -this.y, this; } dot(e) { return this.x * e.x + this.y * e.y; } cross(e) { return this.x * e.y - this.y * e.x; } lengthSq() { return this.x * this.x + this.y * this.y; } length() { return Math.sqrt(this.x * this.x + this.y * this.y); } manhattanLength() { return Math.abs(this.x) + Math.abs(this.y); } normalize() { return this.divideScalar(this.length() || 1); } angle() { return Math.atan2(-this.y, -this.x) + Math.PI; } angleTo(e) { const t = Math.sqrt(this.lengthSq() * e.lengthSq()); if (t === 0) return Math.PI / 2; const n = this.dot(e) / t; return Math.acos(Rn(n, -1, 1)); } distanceTo(e) { return Math.sqrt(this.distanceToSquared(e)); } distanceToSquared(e) { const t = this.x - e.x, n = this.y - e.y; return t * t + n * n; } manhattanDistanceTo(e) { return Math.abs(this.x - e.x) + Math.abs(this.y - e.y); } setLength(e) { return this.normalize().multiplyScalar(e); } lerp(e, t) { return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this; } lerpVectors(e, t, n) { return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this; } equals(e) { return e.x === this.x && e.y === this.y; } fromArray(e, t = 0) { return this.x = e[t], this.y = e[t + 1], this; } toArray(e = [], t = 0) { return e[t] = this.x, e[t + 1] = this.y, e; } fromBufferAttribute(e, t) { return this.x = e.getX(t), this.y = e.getY(t), this; } rotateAround(e, t) { const n = Math.cos(t), i = Math.sin(t), r = this.x - e.x, a = this.y - e.y; return this.x = r * n - a * i + e.x, this.y = r * i + a * n + e.y, this; } random() { return this.x = Math.random(), this.y = Math.random(), this; } *[Symbol.iterator]() { yield this.x, yield this.y; } } class ft { constructor(e, t, n, i, r, a, o, l, c) { ft.prototype.isMatrix3 = !0, this.elements = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ], e !== void 0 && this.set(e, t, n, i, r, a, o, l, c); } set(e, t, n, i, r, a, o, l, c) { const h = this.elements; return h[0] = e, h[1] = i, h[2] = o, h[3] = t, h[4] = r, h[5] = l, h[6] = n, h[7] = a, h[8] = c, this; } identity() { return this.set( 1, 0, 0, 0, 1, 0, 0, 0, 1 ), this; } copy(e) { const t = this.elements, n = e.elements; 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; } extractBasis(e, t, n) { return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this; } setFromMatrix4(e) { const t = e.elements; return this.set( t[0], t[4], t[8], t[1], t[5], t[9], t[2], t[6], t[10] ), this; } multiply(e) { return this.multiplyMatrices(this, e); } premultiply(e) { return this.multiplyMatrices(e, this); } multiplyMatrices(e, t) { const n = e.elements, i = 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], f = n[5], p = n[8], y = i[0], A = i[3], m = i[6], _ = i[1], g = i[4], v = i[7], E = i[2], C = i[5], M = i[8]; return r[0] = a * y + o * _ + l * E, r[3] = a * A + o * g + l * C, r[6] = a * m + o * v + l * M, r[1] = c * y + h * _ + u * E, r[4] = c * A + h * g + u * C, r[7] = c * m + h * v + u * M, r[2] = d * y + f * _ + p * E, r[5] = d * A + f * g + p * C, r[8] = d * m + f * v + p * M, this; } multiplyScalar(e) { const t = this.elements; 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; } determinant() { const e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8]; return t * a * h - t * o * c - n * r * h + n * o * l + i * r * c - i * a * l; } invert() { const e = this.elements, t = e[0], n = e[1], i = 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, f = c * r - a * l, p = t * u + n * d + i * f; if (p === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); const y = 1 / p; return e[0] = u * y, e[1] = (i * c - h * n) * y, e[2] = (o * n - i * a) * y, e[3] = d * y, e[4] = (h * t - i * l) * y, e[5] = (i * r - o * t) * y, e[6] = f * y, e[7] = (n * l - c * t) * y, e[8] = (a * t - n * r) * y, this; } transpose() { let e; const t = this.elements; 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; } getNormalMatrix(e) { return this.setFromMatrix4(e).invert().transpose(); } transposeIntoArray(e) { const t = this.elements; 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; } setUvTransform(e, t, n, i, r, a, o) { const l = Math.cos(r), c = Math.sin(r); return this.set( n * l, n * c, -n * (l * a + c * o) + a + e, -i * c, i * l, -i * (-c * a + l * o) + o + t, 0, 0, 1 ), this; } // scale(e, t) { return this.premultiply(np.makeScale(e, t)), this; } rotate(e) { return this.premultiply(np.makeRotation(-e)), this; } translate(e, t) { return this.premultiply(np.makeTranslation(e, t)), this; } // for 2D Transforms makeTranslation(e, t) { return e.isVector2 ? this.set( 1, 0, e.x, 0, 1, e.y, 0, 0, 1 ) : this.set( 1, 0, e, 0, 1, t, 0, 0, 1 ), this; } makeRotation(e) { const t = Math.cos(e), n = Math.sin(e); return this.set( t, -n, 0, n, t, 0, 0, 0, 1 ), this; } makeScale(e, t) { return this.set( e, 0, 0, 0, t, 0, 0, 0, 1 ), this; } // equals(e) { const t = this.elements, n = e.elements; for (let i = 0; i < 9; i++) if (t[i] !== n[i]) return !1; return !0; } fromArray(e, t = 0) { for (let n = 0; n < 9; n++) this.elements[n] = e[n + t]; return this; } toArray(e = [], t = 0) { const n = this.elements; 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; } clone() { return new this.constructor().fromArray(this.elements); } } const np = /* @__PURE__ */ new ft(); function Fx(s) { for (let e = s.length - 1; e >= 0; --e) if (s[e] >= 65535) return !0; return !1; } const GS = { Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array }; function El(s, e) { return new GS[s](e); } function xh(s) { return document.createElementNS("http://www.w3.org/1999/xhtml", s); } function zS() { const s = xh("canvas"); return s.style.display = "block", s; } const Wy = {}; function oh(s) { s in Wy || (Wy[s] = !0, console.warn(s)); } const jy = /* @__PURE__ */ new ft().set( 0.8224621, 0.177538, 0, 0.0331941, 0.9668058, 0, 0.0170827, 0.0723974, 0.9105199 ), qy = /* @__PURE__ */ new ft().set( 1.2249401, -0.2249404, 0, -0.0420569, 1.0420571, 0, -0.0196376, -0.0786361, 1.0982735 ), fu = { [wt]: { transfer: kd, primaries: Gd, toReference: (s) => s, fromReference: (s) => s }, [ot]: { transfer: pn, primaries: Gd, toReference: (s) => s.convertSRGBToLinear(), fromReference: (s) => s.convertLinearToSRGB() }, [Vh]: { transfer: kd, primaries: zd, toReference: (s) => s.applyMatrix3(qy), fromReference: (s) => s.applyMatrix3(jy) }, [Hh]: { transfer: pn, primaries: zd, toReference: (s) => s.convertSRGBToLinear().applyMatrix3(qy), fromReference: (s) => s.applyMatrix3(jy).convertLinearToSRGB() } }, QS = /* @__PURE__ */ new Set([wt, Vh]), Tt = { enabled: !0, _workingColorSpace: wt, get legacyMode() { return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."), !this.enabled; }, set legacyMode(s) { console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."), this.enabled = !s; }, get workingColorSpace() { return this._workingColorSpace; }, set workingColorSpace(s) { if (!QS.has(s)) throw new Error(`Unsupported working color space, "${s}".`); this._workingColorSpace = s; }, convert: function(s, e, t) { if (this.enabled === !1 || e === t || !e || !t) return s; const n = fu[e].toReference, i = fu[t].fromReference; return i(n(s)); }, fromWorkingColorSpace: function(s, e) { return this.convert(s, this._workingColorSpace, e); }, toWorkingColorSpace: function(s, e) { return this.convert(s, e, this._workingColorSpace); }, getPrimaries: function(s) { return fu[s].primaries; }, getTransfer: function(s) { return s === Ht || s === vs ? kd : fu[s].transfer; } }; function Ul(s) { return s < 0.04045 ? s * 0.0773993808 : Math.pow(s * 0.9478672986 + 0.0521327014, 2.4); } function ip(s) { return s < 31308e-7 ? s * 12.92 : 1.055 * Math.pow(s, 0.41666) - 0.055; } let Wo; class Bg { static getDataURL(e, t = !1) { if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") return e.src; let n; if (e instanceof HTMLCanvasElement) n = e; else { Wo === void 0 && (Wo = xh("canvas")), Wo.width = e.width, Wo.height = e.height; const i = Wo.getContext("2d"); e instanceof ImageData ? i.putImageData(e, 0, 0) : i.drawImage(e, 0, 0, e.width, e.height), n = Wo; } return !t && (n.width > 2048 || n.height > 2048) ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), n.toDataURL("image/jpeg", 0.6)) : n.toDataURL("image/png"); } static sRGBToLinear(e) { if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) { const t = xh("canvas"); t.width = e.width, t.height = e.height; const n = t.getContext("2d"); n.drawImage(e, 0, 0, e.width, e.height); const i = n.getImageData(0, 0, e.width, e.height), r = i.data; for (let a = 0; a < r.length; a++) r[a] = Ul(r[a] / 255) * 255; return n.putImageData(i, 0, 0), t; } else if (e.data) { const t = e.data.slice(0); for (let n = 0; n < t.length; n++) t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[n] = Math.floor(Ul(t[n] / 255) * 255) : t[n] = Ul(t[n]); return { data: t, width: e.width, height: e.height }; } else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e; } } let HS = 0; class la { constructor(e = null) { this.isSource = !0, Object.defineProperty(this, "id", { value: HS++ }), this.uuid = hs(), this.data = e, this.version = 0; } set needsUpdate(e) { e === !0 && this.version++; } toJSON(e) { const t = e === void 0 || typeof e == "string"; if (!t && e.images[this.uuid] !== void 0) return e.images[this.uuid]; const n = { uuid: this.uuid, url: "" }, i = this.data; if (i !== null) { let r; if (Array.isArray(i)) { r = []; for (let a = 0, o = i.length; a < o; a++) i[a].isDataTexture ? r.push(sp(i[a].image)) : r.push(sp(i[a])); } else r = sp(i); n.url = r; } return t || (e.images[this.uuid] = n), n; } } function sp(s) { if (typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap) return Bg.getDataURL(s); if (s.data) { let e = []; try { e = Array.from(s.data); } catch (t) { t.message.includes("Invalid array length") ? console.warn("Serializing large texture, might not be saved in JSON structure.") : console.error(t), e = s.data; } return { data: e, width: s.width, height: s.height, type: s.data.constructor.name }; } else return s.url !== void 0 ? s.url : (console.warn("THREE.Texture: Unable to serialize Texture."), {}); } let VS = 0; class An extends Hn { constructor(e = An.DEFAULT_IMAGE, t = An.DEFAULT_MAPPING, n = Kt, i = Kt, r = tt, a = zi, o = Jt, l = Lt, c = An.DEFAULT_ANISOTROPY, h = Ht) { super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: VS++ }), this.uuid = hs(), this.name = "", this.source = new la(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = n, this.wrapT = i, this.magFilter = r, this.minFilter = a, this.anisotropy = c, this.format = o, this.internalFormat = null, this.type = l, this.offset = new Z(0, 0), this.repeat = new Z(1, 1), this.center = new Z(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new ft(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, typeof h == "string" ? this.colorSpace = h : (oh("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = h === oa ? ot : Ht), this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.needsPMREMUpdate = !1; } get image() { return this.source.data; } set image(e = null) { this.source.data = e; } updateMatrix() { this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y); } clone() { return new this.constructor().copy(this); } copy(e) { 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.userData = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this; } toJSON(e) { const t = e === void 0 || typeof e == "string"; if (!t && e.textures && e.textures[this.uuid] !== void 0) return e.textures[this.uuid]; const n = { metadata: { version: 4.6, type: "Texture", generator: "Texture.toJSON" }, uuid: this.uuid, name: this.name, image: this.source.toJSON(e).uuid, mapping: this.mapping, channel: this.channel, repeat: [this.repeat.x, this.repeat.y], offset: [this.offset.x, this.offset.y], center: [this.center.x, this.center.y], rotation: this.rotation, wrap: [this.wrapS, this.wrapT], format: this.format, internalFormat: this.internalFormat, type: this.type, colorSpace: this.colorSpace, encoding: this.colorSpace === ot ? oa : wm, // deprecated in r152, added for backwards compatibility, remove later minFilter: this.minFilter, magFilter: this.magFilter, anisotropy: this.anisotropy, flipY: this.flipY, generateMipmaps: this.generateMipmaps, premultiplyAlpha: this.premultiplyAlpha, unpackAlignment: this.unpackAlignment }; return Object.keys(this.userData).length > 0 && (n.userData = this.userData), !t && e.textures && (e.textures[this.uuid] = n), n; } dispose() { this.dispatchEvent({ type: "dispose" }); } transformUv(e) { if (this.mapping !== zh) return e; if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch (this.wrapS) { case Ai: e.x = e.x - Math.floor(e.x); break; case Kt: e.x = e.x < 0 ? 0 : 1; break; case kr: Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x); break; } if (e.y < 0 || e.y > 1) switch (this.wrapT) { case Ai: e.y = e.y - Math.floor(e.y); break; case Kt: e.y = e.y < 0 ? 0 : 1; break; case kr: Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y); break; } return this.flipY && (e.y = 1 - e.y), e; } set needsUpdate(e) { e === !0 && (this.version++, this.source.needsUpdate = !0, this.dispatchEvent({ type: "update" })); } get encoding() { return oh("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace === ot ? oa : wm; } set encoding(e) { oh("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = e === oa ? ot : Ht; } } An.DEFAULT_IMAGE = null; An.DEFAULT_MAPPING = zh; An.DEFAULT_ANISOTROPY = 1; class nt { constructor(e = 0, t = 0, n = 0, i = 1) { nt.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = n, this.w = i; } get width() { return this.z; } set width(e) { this.z = e; } get height() { return this.w; } set height(e) { this.w = e; } set(e, t, n, i) { return this.x = e, this.y = t, this.z = n, this.w = i, this; } setScalar(e) { return this.x = e, this.y = e, this.z = e, this.w = e, this; } setX(e) { return this.x = e, this; } setY(e) { return this.y = e, this; } setZ(e) { return this.z = e, this; } setW(e) { return this.w = e, this; } setComponent(e, t) { switch (e) { case 0: this.x = t; break; case 1: this.y = t; break; case 2: this.z = t; break; case 3: this.w = t; break; default: throw new Error("index is out of range: " + e); } return this; } getComponent(e) { switch (e) { case 0: return this.x; case 1: return this.y; case 2: return this.z; case 3: return this.w; default: throw new Error("index is out of range: " + e); } } clone() { return new this.constructor(this.x, this.y, this.z, this.w); } copy(e) { return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this; } add(e) { return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this; } addScalar(e) { return this.x += e, this.y += e, this.z += e, this.w += e, this; } addVectors(e, t) { 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; } addScaledVector(e, t) { return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this; } sub(e) { return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this; } subScalar(e) { return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this; } subVectors(e, t) { 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; } multiply(e) { return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this; } multiplyScalar(e) { return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this; } applyMatrix4(e) { const t = this.x, n = this.y, i = this.z, r = this.w, a = e.elements; return this.x = a[0] * t + a[4] * n + a[8] * i + a[12] * r, this.y = a[1] * t + a[5] * n + a[9] * i + a[13] * r, this.z = a[2] * t + a[6] * n + a[10] * i + a[14] * r, this.w = a[3] * t + a[7] * n + a[11] * i + a[15] * r, this; } divideScalar(e) { return this.multiplyScalar(1 / e); } setAxisAngleFromQuaternion(e) { this.w = 2 * Math.acos(e.w); const t = Math.sqrt(1 - e.w * e.w); 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; } setAxisAngleFromRotationMatrix(e) { let t, n, i, r; const l = e.elements, c = l[0], h = l[4], u = l[8], d = l[1], f = l[5], p = l[9], y = l[2], A = l[6], m = l[10]; if (Math.abs(h - d) < 0.01 && Math.abs(u - y) < 0.01 && Math.abs(p - A) < 0.01) { if (Math.abs(h + d) < 0.1 && Math.abs(u + y) < 0.1 && Math.abs(p + A) < 0.1 && Math.abs(c + f + m - 3) < 0.1) return this.set(1, 0, 0, 0), this; t = Math.PI; const g = (c + 1) / 2, v = (f + 1) / 2, E = (m + 1) / 2, C = (h + d) / 4, M = (u + y) / 4, b = (p + A) / 4; return g > v && g > E ? g < 0.01 ? (n = 0, i = 0.707106781, r = 0.707106781) : (n = Math.sqrt(g), i = C / n, r = M / n) : v > E ? v < 0.01 ? (n = 0.707106781, i = 0, r = 0.707106781) : (i = Math.sqrt(v), n = C / i, r = b / i) : E < 0.01 ? (n = 0.707106781, i = 0.707106781, r = 0) : (r = Math.sqrt(E), n = M / r, i = b / r), this.set(n, i, r, t), this; } let _ = Math.sqrt((A - p) * (A - p) + (u - y) * (u - y) + (d - h) * (d - h)); return Math.abs(_) < 1e-3 && (_ = 1), this.x = (A - p) / _, this.y = (u - y) / _, this.z = (d - h) / _, this.w = Math.acos((c + f + m - 1) / 2), this; } min(e) { 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; } max(e) { 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; } clamp(e, t) { return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this.w = Math.max(e.w, Math.min(t.w, this.w)), this; } clampScalar(e, t) { return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this.w = Math.max(e, Math.min(t, this.w)), this; } clampLength(e, t) { const n = this.length(); return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); } floor() { 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; } ceil() { 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; } round() { 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; } roundToZero() { 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; } negate() { return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this; } dot(e) { return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w; } lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; } length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } manhattanLength() { return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w); } normalize() { return this.divideScalar(this.length() || 1); } setLength(e) { return this.normalize().multiplyScalar(e); } lerp(e, t) { 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; } lerpVectors(e, t, 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; } equals(e) { return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w; } fromArray(e, t = 0) { return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this; } toArray(e = [], t = 0) { return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e; } fromBufferAttribute(e, t) { return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), this; } random() { return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this; } *[Symbol.iterator]() { yield this.x, yield this.y, yield this.z, yield this.w; } } class WS extends Hn { constructor(e = 1, t = 1, n = {}) { super(), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = 1, this.scissor = new nt(0, 0, e, t), this.scissorTest = !1, this.viewport = new nt(0, 0, e, t); const i = { width: e, height: t, depth: 1 }; n.encoding !== void 0 && (oh("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."), n.colorSpace = n.encoding === oa ? ot : Ht), n = Object.assign({ generateMipmaps: !1, internalFormat: null, minFilter: tt, depthBuffer: !0, stencilBuffer: !1, depthTexture: null, samples: 0 }, n), this.texture = new An(i, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.flipY = !1, this.texture.generateMipmaps = n.generateMipmaps, this.texture.internalFormat = n.internalFormat, this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.depthTexture = n.depthTexture, this.samples = n.samples; } setSize(e, t, n = 1) { (this.width !== e || this.height !== t || this.depth !== n) && (this.width = e, this.height = t, this.depth = n, this.texture.image.width = e, this.texture.image.height = t, this.texture.image.depth = n, this.dispose()), this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t); } clone() { return new this.constructor().copy(this); } copy(e) { 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.texture = e.texture.clone(), this.texture.isRenderTargetTexture = !0; const t = Object.assign({}, e.texture.image); return this.texture.source = new la(t), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, e.depthTexture && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this; } dispose() { this.dispatchEvent({ type: "dispose" }); } } class $i extends WS { constructor(e = 1, t = 1, n = {}) { super(e, t, n), this.isWebGLRenderTarget = !0; } } class Pg extends An { constructor(e = null, t = 1, n = 1, i = 1) { super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: n, depth: i }, this.magFilter = ln, this.minFilter = ln, this.wrapR = Kt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } } class mk extends $i { constructor(e = 1, t = 1, n = 1) { super(e, t), this.isWebGLArrayRenderTarget = !0, this.depth = n, this.texture = new Pg(null, e, t, n), this.texture.isRenderTargetTexture = !0; } } class Lg extends An { constructor(e = null, t = 1, n = 1, i = 1) { super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: n, depth: i }, this.magFilter = ln, this.minFilter = ln, this.wrapR = Kt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } } class gk extends $i { constructor(e = 1, t = 1, n = 1) { super(e, t), this.isWebGL3DRenderTarget = !0, this.depth = n, this.texture = new Lg(null, e, t, n), this.texture.isRenderTargetTexture = !0; } } class jS extends $i { constructor(e = 1, t = 1, n = 1, i = {}) { super(e, t, i), this.isWebGLMultipleRenderTargets = !0; const r = this.texture; this.texture = []; for (let a = 0; a < n; a++) this.texture[a] = r.clone(), this.texture[a].isRenderTargetTexture = !0; } setSize(e, t, n = 1) { if (this.width !== e || this.height !== t || this.depth !== n) { this.width = e, this.height = t, this.depth = n; for (let i = 0, r = this.texture.length; i < r; i++) this.texture[i].image.width = e, this.texture[i].image.height = t, this.texture[i].image.depth = n; this.dispose(); } this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t); } copy(e) { this.dispose(), 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.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.texture.length = 0; for (let t = 0, n = e.texture.length; t < n; t++) this.texture[t] = e.texture[t].clone(), this.texture[t].isRenderTargetTexture = !0; return this; } } class st { constructor(e = 0, t = 0, n = 0, i = 1) { this.isQuaternion = !0, this._x = e, this._y = t, this._z = n, this._w = i; } static slerpFlat(e, t, n, i, r, a, o) { let l = n[i + 0], c = n[i + 1], h = n[i + 2], u = n[i + 3]; const d = r[a + 0], f = r[a + 1], p = r[a + 2], y = r[a + 3]; if (o === 0) { e[t + 0] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; return; } if (o === 1) { e[t + 0] = d, e[t + 1] = f, e[t + 2] = p, e[t + 3] = y; return; } if (u !== y || l !== d || c !== f || h !== p) { let A = 1 - o; const m = l * d + c * f + h * p + u * y, _ = m >= 0 ? 1 : -1, g = 1 - m * m; if (g > Number.EPSILON) { const E = Math.sqrt(g), C = Math.atan2(E, m * _); A = Math.sin(A * C) / E, o = Math.sin(o * C) / E; } const v = o * _; if (l = l * A + d * v, c = c * A + f * v, h = h * A + p * v, u = u * A + y * v, A === 1 - o) { const E = 1 / Math.sqrt(l * l + c * c + h * h + u * u); l *= E, c *= E, h *= E, u *= E; } } e[t] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; } static multiplyQuaternionsFlat(e, t, n, i, r, a) { const o = n[i], l = n[i + 1], c = n[i + 2], h = n[i + 3], u = r[a], d = r[a + 1], f = r[a + 2], p = r[a + 3]; return e[t] = o * p + h * u + l * f - c * d, e[t + 1] = l * p + h * d + c * u - o * f, e[t + 2] = c * p + h * f + o * d - l * u, e[t + 3] = h * p - o * u - l * d - c * f, e; } get x() { return this._x; } set x(e) { this._x = e, this._onChangeCallback(); } get y() { return this._y; } set y(e) { this._y = e, this._onChangeCallback(); } get z() { return this._z; } set z(e) { this._z = e, this._onChangeCallback(); } get w() { return this._w; } set w(e) { this._w = e, this._onChangeCallback(); } set(e, t, n, i) { return this._x = e, this._y = t, this._z = n, this._w = i, this._onChangeCallback(), this; } clone() { return new this.constructor(this._x, this._y, this._z, this._w); } copy(e) { return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this; } setFromEuler(e, t) { const n = e._x, i = e._y, r = e._z, a = e._order, o = Math.cos, l = Math.sin, c = o(n / 2), h = o(i / 2), u = o(r / 2), d = l(n / 2), f = l(i / 2), p = l(r / 2); switch (a) { case "XYZ": this._x = d * h * u + c * f * p, this._y = c * f * u - d * h * p, this._z = c * h * p + d * f * u, this._w = c * h * u - d * f * p; break; case "YXZ": this._x = d * h * u + c * f * p, this._y = c * f * u - d * h * p, this._z = c * h * p - d * f * u, this._w = c * h * u + d * f * p; break; case "ZXY": this._x = d * h * u - c * f * p, this._y = c * f * u + d * h * p, this._z = c * h * p + d * f * u, this._w = c * h * u - d * f * p; break; case "ZYX": this._x = d * h * u - c * f * p, this._y = c * f * u + d * h * p, this._z = c * h * p - d * f * u, this._w = c * h * u + d * f * p; break; case "YZX": this._x = d * h * u + c * f * p, this._y = c * f * u + d * h * p, this._z = c * h * p - d * f * u, this._w = c * h * u - d * f * p; break; case "XZY": this._x = d * h * u - c * f * p, this._y = c * f * u - d * h * p, this._z = c * h * p + d * f * u, this._w = c * h * u + d * f * p; break; default: console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + a); } return t !== !1 && this._onChangeCallback(), this; } setFromAxisAngle(e, t) { const n = t / 2, i = Math.sin(n); return this._x = e.x * i, this._y = e.y * i, this._z = e.z * i, this._w = Math.cos(n), this._onChangeCallback(), this; } setFromRotationMatrix(e) { const t = e.elements, n = t[0], i = 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; if (d > 0) { const f = 0.5 / Math.sqrt(d + 1); this._w = 0.25 / f, this._x = (h - l) * f, this._y = (r - c) * f, this._z = (a - i) * f; } else if (n > o && n > u) { const f = 2 * Math.sqrt(1 + n - o - u); this._w = (h - l) / f, this._x = 0.25 * f, this._y = (i + a) / f, this._z = (r + c) / f; } else if (o > u) { const f = 2 * Math.sqrt(1 + o - n - u); this._w = (r - c) / f, this._x = (i + a) / f, this._y = 0.25 * f, this._z = (l + h) / f; } else { const f = 2 * Math.sqrt(1 + u - n - o); this._w = (a - i) / f, this._x = (r + c) / f, this._y = (l + h) / f, this._z = 0.25 * f; } return this._onChangeCallback(), this; } setFromUnitVectors(e, t) { let n = e.dot(t) + 1; return n < Number.EPSILON ? (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(); } angleTo(e) { return 2 * Math.acos(Math.abs(Rn(this.dot(e), -1, 1))); } rotateTowards(e, t) { const n = this.angleTo(e); if (n === 0) return this; const i = Math.min(1, t / n); return this.slerp(e, i), this; } identity() { return this.set(0, 0, 0, 1); } invert() { return this.conjugate(); } conjugate() { return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this; } dot(e) { return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w; } lengthSq() { return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; } length() { return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w); } normalize() { let e = this.length(); 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; } multiply(e) { return this.multiplyQuaternions(this, e); } premultiply(e) { return this.multiplyQuaternions(e, this); } multiplyQuaternions(e, t) { const n = e._x, i = e._y, r = e._z, a = e._w, o = t._x, l = t._y, c = t._z, h = t._w; return this._x = n * h + a * o + i * c - r * l, this._y = i * h + a * l + r * o - n * c, this._z = r * h + a * c + n * l - i * o, this._w = a * h - n * o - i * l - r * c, this._onChangeCallback(), this; } slerp(e, t) { if (t === 0) return this; if (t === 1) return this.copy(e); const n = this._x, i = this._y, r = this._z, a = this._w; let o = a * e._w + n * e._x + i * e._y + r * e._z; if (o < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, o = -o) : this.copy(e), o >= 1) return this._w = a, this._x = n, this._y = i, this._z = r, this; const l = 1 - o * o; if (l <= Number.EPSILON) { const f = 1 - t; return this._w = f * a + t * this._w, this._x = f * n + t * this._x, this._y = f * i + t * this._y, this._z = f * r + t * this._z, this.normalize(), this._onChangeCallback(), this; } const c = Math.sqrt(l), h = Math.atan2(c, o), u = Math.sin((1 - t) * h) / c, d = Math.sin(t * h) / c; return this._w = a * u + this._w * d, this._x = n * u + this._x * d, this._y = i * u + this._y * d, this._z = r * u + this._z * d, this._onChangeCallback(), this; } slerpQuaternions(e, t, n) { return this.copy(e).slerp(t, n); } random() { const e = Math.random(), t = Math.sqrt(1 - e), n = Math.sqrt(e), i = 2 * Math.PI * Math.random(), r = 2 * Math.PI * Math.random(); return this.set( t * Math.cos(i), n * Math.sin(r), n * Math.cos(r), t * Math.sin(i) ); } equals(e) { return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w; } fromArray(e, t = 0) { return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this; } toArray(e = [], t = 0) { return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e; } fromBufferAttribute(e, t) { return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this; } toJSON() { return this.toArray(); } _onChange(e) { return this._onChangeCallback = e, this; } _onChangeCallback() { } *[Symbol.iterator]() { yield this._x, yield this._y, yield this._z, yield this._w; } } class T { constructor(e = 0, t = 0, n = 0) { T.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = n; } set(e, t, n) { return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this; } setScalar(e) { return this.x = e, this.y = e, this.z = e, this; } setX(e) { return this.x = e, this; } setY(e) { return this.y = e, this; } setZ(e) { return this.z = e, this; } set