UNPKG

threepipe

Version:

A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.

1,423 lines 2.58 MB
/** * @license * threepipe v0.5.0 * Copyright 2022-2026 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 sc = { ROTATE: 0, DOLLY: 1, PAN: 2 }, rc = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, aT = 0, P_ = 1, oT = 2, Av = 1, lT = 2, _a = 3, Ps = 0, Wn = 1, hn = 2, Sn = 0, Zr = 1, kf = 2, zf = 3, Gf = 4, Pr = 5, Yr = 100, iE = 101, nE = 102, sE = 103, rE = 104, iy = 200, ny = 201, sy = 202, ry = 203, lh = 204, ch = 205, ay = 206, oy = 207, ly = 208, cy = 209, aE = 210, Lu = 211, Ou = 212, Uc = 213, Fc = 214, oE = 0, lE = 1, cE = 2, hh = 3, hE = 4, uE = 5, dE = 6, pE = 7, Rh = 0, cT = 1, hT = 2, Ta = 0, fE = 1, mE = 2, gE = 3, yv = 4, AE = 5, yE = 6, uT = 7, R_ = "attached", dT = "detached", Id = 300, Ba = 301, Cl = 302, La = 303, Vf = 304, Bh = 306, qn = 1e3, fi = 1001, Oa = 1002, vi = 1003, Dd = 1004, mo = 1005, st = 1006, gl = 1007, Hn = 1008, B_ = 1008, jt = 1009, vE = 1010, _E = 1011, vv = 1012, _v = 1013, Ua = 1014, Qt = 1015, Kt = 1016, xv = 1017, wv = 1018, Lh = 1020, pT = 35902, fT = 1021, mT = 1022, Jt = 1023, gT = 1024, AT = 1025, Al = 1026, id = 1027, go = 1028, xE = 1029, Nc = 1030, wE = 1031, bE = 1033, xf = 33776, wg = 33777, bg = 33778, wf = 33779, hy = 35840, L_ = 35841, uy = 35842, O_ = 35843, bv = 36196, dy = 37492, py = 37496, fy = 37808, U_ = 37809, F_ = 37810, N_ = 37811, Qf = 37812, k_ = 37813, z_ = 37814, G_ = 37815, V_ = 37816, Q_ = 37817, H_ = 37818, j_ = 37819, W_ = 37820, q_ = 37821, bf = 36492, X_ = 36494, Y_ = 36495, yT = 36283, $_ = 36284, K_ = 36285, J_ = 36286, my = 2200, gy = 2201, vT = 2202, uh = 2300, El = 2301, Cg = 2302, kc = 2400, zc = 2401, Hf = 2402, Cv = 2500, CE = 2501, _T = 0, EE = 1, Ay = 2, Ev = 3200, eh = 3201, cr = 0, SE = 1, ai = "", At = "srgb", Pt = "srgb-linear", Pd = "display-p3", Rd = "display-p3-linear", nr = "rgbm-16", jf = "linear", Ci = "srgb", Wf = "rec709", qf = "p3", wa = 7680, yy = 519, xT = 512, wT = 513, bT = 514, ME = 515, CT = 516, ET = 517, ST = 518, MT = 519, Xf = 35044, TT = "100", vy = "300 es", Ca = 2e3, Yf = 2001, Z_ = 3e3, rp = 3001; class Oi { addEventListener(e, t) { this._listeners === void 0 && (this._listeners = {}); const i = this._listeners; i[e] === void 0 && (i[e] = []), i[e].indexOf(t) === -1 && i[e].push(t); } hasEventListener(e, t) { if (this._listeners === void 0) return !1; const i = this._listeners; return i[e] !== void 0 && i[e].indexOf(t) !== -1; } removeEventListener(e, t) { if (this._listeners === void 0) return; const n = this._listeners[e]; if (n !== void 0) { const r = n.indexOf(t); r !== -1 && n.splice(r, 1); } } dispatchEvent(e) { if (this._listeners === void 0) return; const i = this._listeners[e.type]; if (i !== void 0) { e.target = this; const n = i.slice(0); for (let r = 0, a = n.length; r < a; r++) n[r].call(this, e); e.target = null; } } } const es = ["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 ex = 1234567; const yl = Math.PI / 180, dh = 180 / Math.PI; function Gs() { const s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, i = Math.random() * 4294967295 | 0; return (es[s & 255] + es[s >> 8 & 255] + es[s >> 16 & 255] + es[s >> 24 & 255] + "-" + es[e & 255] + es[e >> 8 & 255] + "-" + es[e >> 16 & 15 | 64] + es[e >> 24 & 255] + "-" + es[t & 63 | 128] + es[t >> 8 & 255] + "-" + es[t >> 16 & 255] + es[t >> 24 & 255] + es[i & 255] + es[i >> 8 & 255] + es[i >> 16 & 255] + es[i >> 24 & 255]).toLowerCase(); } function qi(s, e, t) { return Math.max(e, Math.min(t, s)); } function Sv(s, e) { return (s % e + e) % e; } function IT(s, e, t, i, n) { return i + (s - e) * (n - i) / (t - e); } function DT(s, e, t) { return s !== e ? (t - s) / (e - s) : 0; } function Qu(s, e, t) { return (1 - t) * s + t * e; } function PT(s, e, t, i) { return Qu(s, e, 1 - Math.exp(-t * i)); } function RT(s, e = 1) { return e - Math.abs(Sv(s, e * 2) - e); } function BT(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * (3 - 2 * s)); } function LT(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * s * (s * (s * 6 - 15) + 10)); } function OT(s, e) { return s + Math.floor(Math.random() * (e - s + 1)); } function UT(s, e) { return s + Math.random() * (e - s); } function FT(s) { return s * (0.5 - Math.random()); } function NT(s) { s !== void 0 && (ex = s); let e = ex += 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 kT(s) { return s * yl; } function zT(s) { return s * dh; } function GT(s) { return (s & s - 1) === 0 && s !== 0; } function VT(s) { return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2)); } function QT(s) { return Math.pow(2, Math.floor(Math.log(s) / Math.LN2)); } function HT(s, e, t, i, n) { const r = Math.cos, a = Math.sin, o = r(t / 2), l = a(t / 2), c = r((e + i) / 2), h = a((e + i) / 2), u = r((e - i) / 2), d = a((e - i) / 2), p = r((i - e) / 2), f = a((i - e) / 2); switch (n) { 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 * f, l * p, o * c); break; case "YXY": s.set(l * p, o * h, l * f, o * c); break; case "ZYZ": s.set(l * f, l * p, o * h, o * c); break; default: console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + n); } } function gs(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 xt(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 kt = { DEG2RAD: yl, RAD2DEG: dh, generateUUID: Gs, clamp: qi, euclideanModulo: Sv, mapLinear: IT, inverseLerp: DT, lerp: Qu, damp: PT, pingpong: RT, smoothstep: BT, smootherstep: LT, randInt: OT, randFloat: UT, randFloatSpread: FT, seededRandom: NT, degToRad: kT, radToDeg: zT, isPowerOfTwo: GT, ceilPowerOfTwo: VT, floorPowerOfTwo: QT, setQuaternionFromProperEuler: HT, normalize: xt, denormalize: gs }; class Y { constructor(e = 0, t = 0) { Y.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, i = this.y, n = e.elements; return this.x = n[0] * t + n[3] * i + n[6], this.y = n[1] * t + n[4] * i + n[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 i = this.length(); return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i))); } 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 i = this.dot(e) / t; return Math.acos(qi(i, -1, 1)); } distanceTo(e) { return Math.sqrt(this.distanceToSquared(e)); } distanceToSquared(e) { const t = this.x - e.x, i = this.y - e.y; return t * t + i * i; } 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, i) { return this.x = e.x + (t.x - e.x) * i, this.y = e.y + (t.y - e.y) * i, 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 i = Math.cos(t), n = Math.sin(t), r = this.x - e.x, a = this.y - e.y; return this.x = r * i - a * n + e.x, this.y = r * n + a * i + e.y, this; } random() { return this.x = Math.random(), this.y = Math.random(), this; } *[Symbol.iterator]() { yield this.x, yield this.y; } } class mt { constructor(e, t, i, n, r, a, o, l, c) { mt.prototype.isMatrix3 = !0, this.elements = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ], e !== void 0 && this.set(e, t, i, n, r, a, o, l, c); } set(e, t, i, n, r, a, o, l, c) { const h = this.elements; return h[0] = e, h[1] = n, h[2] = o, h[3] = t, h[4] = r, h[5] = l, h[6] = i, 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, i = e.elements; return t[0] = i[0], t[1] = i[1], t[2] = i[2], t[3] = i[3], t[4] = i[4], t[5] = i[5], t[6] = i[6], t[7] = i[7], t[8] = i[8], this; } extractBasis(e, t, i) { return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), i.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 i = e.elements, n = t.elements, r = this.elements, a = i[0], o = i[3], l = i[6], c = i[1], h = i[4], u = i[7], d = i[2], p = i[5], f = i[8], g = n[0], m = n[3], A = n[6], v = n[1], y = n[4], _ = n[7], M = n[2], E = n[5], S = n[8]; return r[0] = a * g + o * v + l * M, r[3] = a * m + o * y + l * E, r[6] = a * A + o * _ + l * S, r[1] = c * g + h * v + u * M, r[4] = c * m + h * y + u * E, r[7] = c * A + h * _ + u * S, r[2] = d * g + p * v + f * M, r[5] = d * m + p * y + f * E, r[8] = d * A + p * _ + f * S, 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], i = e[1], n = 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 - i * r * h + i * o * l + n * r * c - n * a * l; } invert() { const e = this.elements, t = e[0], i = e[1], n = 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, f = t * u + i * d + n * p; if (f === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); const g = 1 / f; return e[0] = u * g, e[1] = (n * c - h * i) * g, e[2] = (o * i - n * a) * g, e[3] = d * g, e[4] = (h * t - n * l) * g, e[5] = (n * r - o * t) * g, e[6] = p * g, e[7] = (i * l - c * t) * g, e[8] = (a * t - i * r) * g, 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, i, n, r, a, o) { const l = Math.cos(r), c = Math.sin(r); return this.set( i * l, i * c, -i * (l * a + c * o) + a + e, -n * c, n * l, -n * (-c * a + l * o) + o + t, 0, 0, 1 ), this; } // scale(e, t) { return this.premultiply(Eg.makeScale(e, t)), this; } rotate(e) { return this.premultiply(Eg.makeRotation(-e)), this; } translate(e, t) { return this.premultiply(Eg.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), i = Math.sin(e); return this.set( t, -i, 0, i, 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, i = e.elements; for (let n = 0; n < 9; n++) if (t[n] !== i[n]) return !1; return !0; } fromArray(e, t = 0) { for (let i = 0; i < 9; i++) this.elements[i] = e[i + t]; return this; } toArray(e = [], t = 0) { const i = this.elements; return e[t] = i[0], e[t + 1] = i[1], e[t + 2] = i[2], e[t + 3] = i[3], e[t + 4] = i[4], e[t + 5] = i[5], e[t + 6] = i[6], e[t + 7] = i[7], e[t + 8] = i[8], e; } clone() { return new this.constructor().fromArray(this.elements); } } const Eg = /* @__PURE__ */ new mt(); function TE(s) { for (let e = s.length - 1; e >= 0; --e) if (s[e] >= 65535) return !0; return !1; } const jT = { Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array }; function Gc(s, e) { return new jT[s](e); } function nd(s) { return document.createElementNS("http://www.w3.org/1999/xhtml", s); } function WT() { const s = nd("canvas"); return s.style.display = "block", s; } const tx = {}; function Hu(s) { s in tx || (tx[s] = !0, console.warn(s)); } const ix = /* @__PURE__ */ new mt().set( 0.8224621, 0.177538, 0, 0.0331941, 0.9668058, 0, 0.0170827, 0.0723974, 0.9105199 ), nx = /* @__PURE__ */ new mt().set( 1.2249401, -0.2249404, 0, -0.0420569, 1.0420571, 0, -0.0196376, -0.0786361, 1.0982735 ), ap = { [Pt]: { transfer: jf, primaries: Wf, toReference: (s) => s, fromReference: (s) => s }, [At]: { transfer: Ci, primaries: Wf, toReference: (s) => s.convertSRGBToLinear(), fromReference: (s) => s.convertLinearToSRGB() }, [Rd]: { transfer: jf, primaries: qf, toReference: (s) => s.applyMatrix3(nx), fromReference: (s) => s.applyMatrix3(ix) }, [Pd]: { transfer: Ci, primaries: qf, toReference: (s) => s.convertSRGBToLinear().applyMatrix3(nx), fromReference: (s) => s.applyMatrix3(ix).convertLinearToSRGB() } }, qT = /* @__PURE__ */ new Set([Pt, Rd]), $t = { enabled: !0, _workingColorSpace: Pt, get workingColorSpace() { return this._workingColorSpace; }, set workingColorSpace(s) { if (!qT.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 i = ap[e].toReference, n = ap[t].fromReference; return n(i(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 ap[s].primaries; }, getTransfer: function(s) { return s === ai || s === nr ? jf : ap[s].transfer; } }; function th(s) { return s < 0.04045 ? s * 0.0773993808 : Math.pow(s * 0.9478672986 + 0.0521327014, 2.4); } function Sg(s) { return s < 31308e-7 ? s * 12.92 : 1.055 * Math.pow(s, 0.41666) - 0.055; } let ac; class IE { static getDataURL(e, t = !1) { if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") return e.src; let i; if (e instanceof HTMLCanvasElement) i = e; else { ac === void 0 && (ac = nd("canvas")), ac.width = e.width, ac.height = e.height; const n = ac.getContext("2d"); e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0, e.width, e.height), i = ac; } return !t && (i.width > 2048 || i.height > 2048) ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), i.toDataURL("image/jpeg", 0.6)) : i.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 = nd("canvas"); t.width = e.width, t.height = e.height; const i = t.getContext("2d"); i.drawImage(e, 0, 0, e.width, e.height); const n = i.getImageData(0, 0, e.width, e.height), r = n.data; for (let a = 0; a < r.length; a++) r[a] = th(r[a] / 255) * 255; return i.putImageData(n, 0, 0), t; } else if (e.data) { const t = e.data.slice(0); for (let i = 0; i < t.length; i++) t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[i] = Math.floor(th(t[i] / 255) * 255) : t[i] = th(t[i]); 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 XT = 0; class Ao { constructor(e = null) { this.isSource = !0, Object.defineProperty(this, "id", { value: XT++ }), this.uuid = Gs(), this.data = e, this.dataReady = !0, 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 i = { uuid: this.uuid, url: "" }, n = this.data; if (n !== null) { let r; if (Array.isArray(n)) { r = []; for (let a = 0, o = n.length; a < o; a++) n[a].isDataTexture ? r.push(Mg(n[a].image)) : r.push(Mg(n[a])); } else r = Mg(n); i.url = r; } return t || (e.images[this.uuid] = i), i; } } function Mg(s) { if (typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap) return IE.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 YT = 0; class Ot extends Oi { constructor(e = Ot.DEFAULT_IMAGE, t = Ot.DEFAULT_MAPPING, i = fi, n = fi, r = st, a = Hn, o = Jt, l = jt, c = Ot.DEFAULT_ANISOTROPY, h = ai) { super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: YT++ }), this.uuid = Gs(), this.name = "", this.source = new Ao(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = i, this.wrapT = n, this.magFilter = r, this.minFilter = a, this.anisotropy = c, this.format = o, this.internalFormat = null, this.type = l, this.offset = new Y(0, 0), this.repeat = new Y(1, 1), this.center = new Y(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new mt(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, typeof h == "string" ? this.colorSpace = h : (Hu("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = h === rp ? At : ai), this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.pmremVersion = 0, e instanceof ImageData && e !== Ot.DEFAULT_IMAGE && (this.needsUpdate = !0); } 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 = sx(this.userData, 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 i = { 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 === At ? rp : Z_, // 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 && (i.userData = sx({}, this.userData)), !t && e.textures && (e.textures[this.uuid] = i), i; } dispose() { this.dispatchEvent({ type: "dispose" }); } transformUv(e) { if (this.mapping !== Id) return e; if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch (this.wrapS) { case qn: e.x = e.x - Math.floor(e.x); break; case fi: e.x = e.x < 0 ? 0 : 1; break; case Oa: 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 qn: e.y = e.y - Math.floor(e.y); break; case fi: e.y = e.y < 0 ? 0 : 1; break; case Oa: 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" })); } // todo repalash remove later get encoding() { return Hu("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace === At ? rp : Z_; } set encoding(e) { Hu("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = e === rp ? At : ai; } set needsPMREMUpdate(e) { e === !0 && this.pmremVersion++; } } Ot.DEFAULT_IMAGE = null; Ot.DEFAULT_MAPPING = Id; Ot.DEFAULT_ANISOTROPY = 1; const $T = ["appliedMaterials", "uuid"]; function sx(s, e) { if (e) for (const t of Object.keys(e)) $T.includes(t) || t.startsWith("__") || typeof s[t] == "function" || typeof e[t] == "function" || (s[t] = typeof e[t] == "object" ? JSON.parse(JSON.stringify(e[t])) : e[t]); return s; } class ot { constructor(e = 0, t = 0, i = 0, n = 1) { ot.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = i, this.w = n; } 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, i, n) { return this.x = e, this.y = t, this.z = i, this.w = n, 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, i = this.y, n = this.z, r = this.w, a = e.elements; return this.x = a[0] * t + a[4] * i + a[8] * n + a[12] * r, this.y = a[1] * t + a[5] * i + a[9] * n + a[13] * r, this.z = a[2] * t + a[6] * i + a[10] * n + a[14] * r, this.w = a[3] * t + a[7] * i + a[11] * n + 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, i, n, r; const l = e.elements, c = l[0], h = l[4], u = l[8], d = l[1], p = l[5], f = l[9], g = l[2], m = l[6], A = l[10]; if (Math.abs(h - d) < 0.01 && Math.abs(u - g) < 0.01 && Math.abs(f - m) < 0.01) { if (Math.abs(h + d) < 0.1 && Math.abs(u + g) < 0.1 && Math.abs(f + m) < 0.1 && Math.abs(c + p + A - 3) < 0.1) return this.set(1, 0, 0, 0), this; t = Math.PI; const y = (c + 1) / 2, _ = (p + 1) / 2, M = (A + 1) / 2, E = (h + d) / 4, S = (u + g) / 4, C = (f + m) / 4; return y > _ && y > M ? y < 0.01 ? (i = 0, n = 0.707106781, r = 0.707106781) : (i = Math.sqrt(y), n = E / i, r = S / i) : _ > M ? _ < 0.01 ? (i = 0.707106781, n = 0, r = 0.707106781) : (n = Math.sqrt(_), i = E / n, r = C / n) : M < 0.01 ? (i = 0.707106781, n = 0.707106781, r = 0) : (r = Math.sqrt(M), i = S / r, n = C / r), this.set(i, n, r, t), this; } let v = Math.sqrt((m - f) * (m - f) + (u - g) * (u - g) + (d - h) * (d - h)); return Math.abs(v) < 1e-3 && (v = 1), this.x = (m - f) / v, this.y = (u - g) / v, this.z = (d - h) / v, this.w = Math.acos((c + p + A - 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 i = this.length(); return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i))); } 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, i) { return this.x = e.x + (t.x - e.x) * i, this.y = e.y + (t.y - e.y) * i, this.z = e.z + (t.z - e.z) * i, this.w = e.w + (t.w - e.w) * i, 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 KT extends Oi { constructor(e = 1, t = 1, i = {}) { super(), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = 1, this.scissor = new ot(0, 0, e, t), this.scissorTest = !1, this.viewport = new ot(0, 0, e, t); const n = { width: e, height: t, depth: 1 }; i = Object.assign({ generateMipmaps: !1, internalFormat: null, minFilter: st, depthBuffer: !0, stencilBuffer: !1, depthTexture: null, samples: 0, count: 1 }, i); const r = new Ot(n, i.mapping, i.wrapS, i.wrapT, i.magFilter, i.minFilter, i.format, i.type, i.anisotropy, i.colorSpace); r.flipY = !1, r.generateMipmaps = i.generateMipmaps, r.internalFormat = i.internalFormat, this.textures = []; const a = i.count; for (let o = 0; o < a; o++) this.textures[o] = r.clone(), this.textures[o].isRenderTargetTexture = !0; this.depthBuffer = i.depthBuffer, this.stencilBuffer = i.stencilBuffer, this.depthTexture = i.depthTexture, this.samples = i.samples; } get texture() { return this.textures[0]; } set texture(e) { this.textures[0] = e; } setSize(e, t, i = 1) { if (this.width !== e || this.height !== t || this.depth !== i) { this.width = e, this.height = t, this.depth = i; for (let n = 0, r = this.textures.length; n < r; n++) this.textures[n].image.width = e, this.textures[n].image.height = t, this.textures[n].image.depth = i; 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.textures.length = 0; for (let i = 0, n = e.textures.length; i < n; i++) this.textures[i] = e.textures[i].clone(), this.textures[i].isRenderTargetTexture = !0; const t = Object.assign({}, e.texture.image); return this.texture.source = new Ao(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 js extends KT { constructor(e = 1, t = 1, i = {}) { super(e, t, i), this.isWebGLRenderTarget = !0; } } class Mv extends Ot { constructor(e = null, t = 1, i = 1, n = 1) { super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: i, depth: n }, this.magFilter = vi, this.minFilter = vi, this.wrapR = fi, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } } class q4 extends js { constructor(e = 1, t = 1, i = 1, n = {}) { super(e, t, n), this.isWebGLArrayRenderTarget = !0, this.depth = i, this.texture = new Mv(null, e, t, i), this.texture.isRenderTargetTexture = !0; } } class Tv extends Ot { constructor(e = null, t = 1, i = 1, n = 1) { super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: i, depth: n }, this.magFilter = vi, this.minFilter = vi, this.wrapR = fi, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } } class X4 extends js { constructor(e = 1, t = 1, i = 1, n = {}) { super(e, t, n), this.isWebGL3DRenderTarget = !0, this.depth = i, this.texture = new Tv(null, e, t, i), this.texture.isRenderTargetTexture = !0; } } class We { constructor(e = 0, t = 0, i = 0, n = 1) { this.isQuaternion = !0, this._x = e, this._y = t, this._z = i, this._w = n; } static slerpFlat(e, t, i, n, r, a, o) { let l = i[n + 0], c = i[n + 1], h = i[n + 2], u = i[n + 3]; const d = r[a + 0], p = r[a + 1], f = r[a + 2], g = 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] = p, e[t + 2] = f, e[t + 3] = g; return; } if (u !== g || l !== d || c !== p || h !== f) { let m = 1 - o; const A = l * d + c * p + h * f + u * g, v = A >= 0 ? 1 : -1, y = 1 - A * A; if (y > Number.EPSILON) { const M = Math.sqrt(y), E = Math.atan2(M, A * v); m = Math.sin(m * E) / M, o = Math.sin(o * E) / M; } const _ = o * v; if (l = l * m + d * _, c = c * m + p * _, h = h * m + f * _, u = u * m + g * _, m === 1 - o) { const M = 1 / Math.sqrt(l * l + c * c + h * h + u * u); l *= M, c *= M, h *= M, u *= M; } } e[t] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; } static multiplyQuaternionsFlat(e, t, i, n, r, a) { const o = i[n], l = i[n + 1], c = i[n + 2], h = i[n + 3], u = r[a], d = r[a + 1], p = r[a + 2], f = r[a + 3]; return e[t] = o * f + h * u + l * p - c * d, e[t + 1] = l * f + h * d + c * u - o * p, e[t + 2] = c * f + h * p + o * d - l * u, e[t + 3] = h * f - o * u - l * d - c * p, 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, i, n) { return this._x = e, this._y = t, this._z = i, this._w = n, 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 = !0) { const i = e._x, n = e._y, r = e._z, a = e._order, o = Math.cos, l = Math.sin, c = o(i / 2), h = o(n / 2), u = o(r / 2), d = l(i / 2), p = l(n / 2), f = l(r / 2); switch (a) { case "XYZ": this._x = d * h * u + c * p * f, this._y = c * p * u - d * h * f, this._z = c * h * f + d * p * u, this._w = c * h * u - d * p * f; break; case "YXZ": this._x = d * h * u + c * p * f, this._y = c * p * u - d * h * f, this._z = c * h * f - d * p * u, this._w = c * h * u + d * p * f; break; case "ZXY": this._x = d * h * u - c * p * f, this._y = c * p * u + d * h * f, this._z = c * h * f + d * p * u, this._w = c * h * u - d * p * f; break; case "ZYX": this._x = d * h * u - c * p * f, this._y = c * p * u + d * h * f, this._z = c * h * f - d * p * u, this._w = c * h * u + d * p * f; break; case "YZX": this._x = d * h * u + c * p * f, this._y = c * p * u + d * h * f, this._z = c * h * f - d * p * u, this._w = c * h * u - d * p * f; break; case "XZY": this._x = d * h * u - c * p * f, this._y = c * p * u - d * h * f, this._z = c * h * f + d * p * u, this._w = c * h * u + d * p * f; break; default: console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + a); } return t === !0 && this._onChangeCallback(), this; } setFromAxisAngle(e, t) { const i = t / 2, n = Math.sin(i); return this._x = e.x * n, this._y = e.y * n, this._z = e.z * n, this._w = Math.cos(i), this._onChangeCallback(), this; } setFromRotationMatrix(e) { const t = e.elements, i = t[0], n = t[4], r = t[8], a = t[1], o = t[5], l = t[9], c = t[2], h = t[6], u = t[10], d = i + o + u; if (d > 0) { const p = 0.5 / Math.sqrt(d + 1); this._w = 0.25 / p, this._x = (h - l) * p, this._y = (r - c) * p, this._z = (a - n) * p; } else if (i > o && i > u) { const p = 2 * Math.sqrt(1 + i - o - u); this._w = (h - l) / p, this._x = 0.25 * p, this._y = (n + a) / p, this._z = (r + c) / p; } else if (o > u) { const p = 2 * Math.sqrt(1 + o - i - u); this._w = (r - c) / p, this._x = (n + a) / p, this._y = 0.25 * p, this._z = (l + h) / p; } else { const p = 2 * Math.sqrt(1 + u - i - o); this._w = (a - n) / p, this._x = (r + c) / p, this._y = (l + h) / p, this._z = 0.25 * p; } return this._onChangeCallback(), this; } setFromUnitVectors(e, t) { let i = e.dot(t) + 1; return i < Number.EPSILON ? (i = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = i) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = i)) : (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 = i), this.normalize(); } angleTo(e) { return 2 * Math.acos(Math.abs(qi(this.dot(e), -1, 1))); } rotateTowards(e, t) { const i = this.angleTo(e); if (i === 0) return this; const n = Math.min(1, t / i); return this.slerp(e, n), 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 i = e._x, n = e._y, r = e._z, a = e._w, o = t._x, l = t._y, c = t._z, h = t._w; return this._x = i * h + a * o + n * c - r * l, this._y = n * h + a * l + r * o - i * c, this._z = r * h + a * c + i * l - n * o, this._w = a * h - i * o - n * l - r * c, this._onChangeCallback(), this; } slerp(e, t) { if (t === 0) return this; if (t === 1) return this.copy(e); const i = this._x, n = this._y, r = this._z, a = this._w; let o = a * e._w + i * e._x + n * 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 = i, this._y = n, this._z = r, this; const l = 1 - o * o; if (l <= Number.EPSILON) { const p = 1 - t; return this._w = p * a + t * this._w, this._x = p * i + t * this._x, this._y = p * n + t * this._y, this._z = p * r + t * this._z, this.normalize(), 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 = i * u + this._x * d, this._y = n * u + this._y * d, this._z = r * u + this._z * d, this._onChangeCallback(), this; } slerpQuaternions(e, t, i) { return this.copy(e).slerp(t, i); } random() { const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), i = Math.random(), n = Math.sqrt(1 - i), r = Math.sqrt(i); return this.set( n * Math.sin(e), n * Math.cos(e), r * Math.sin(t), r * Math.cos(t) ); } 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._onChangeCallback(), 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 b { constructor(e = 0, t = 0, i = 0) { b.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = i; } set(e, t, i) { return i === void 0 && (i = this.z), this.x = e, this.y = t, this.z = i, 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; } setComponent(e, t) { switch (e) { case 0: this.x = t; break; case 1: this.y = t; break; case 2: this.z = 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; default: throw new Error("index is out of range: " + e); } } clone() { return new this.constructor(this.x, this.y, this.z); } copy(e) { return this.x = e.x, this.y = e.y, this.z = e.z, this; } add(e) { return this.x += e.x, this.