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,377 lines 2.13 MB
/** * @license * threepipe v0.0.37 * 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 ag = "153", Lo = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }, Uo = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, Ib = 0, dy = 1, Db = 2, og = 1, Rb = 2, vr = 3, Ni = 0, ti = 1, In = 2, di = 0, Zs = 1, bd = 2, Md = 3, Sd = 4, Kv = 5, Na = 100, Bb = 101, Pb = 102, fy = 103, py = 104, Lb = 200, Ub = 201, Fb = 202, Ob = 203, lg = 204, cg = 205, Nb = 206, kb = 207, Gb = 208, zb = 209, Qb = 210, Jv = 0, $v = 1, Zv = 2, fh = 3, ex = 4, tx = 5, nx = 6, ix = 7, oc = 0, Hb = 1, Vb = 2, er = 0, sx = 1, rx = 2, ax = 3, hg = 4, ox = 5, Lh = 300, da = 301, Ya = 302, fa = 303, Cd = 304, lc = 306, ii = 1e3, zt = 1001, Ir = 1002, Zt = 1003, Pl = 1004, Qa = 1005, tt = 1006, Uh = 1007, Ci = 1008, my = 1008, Rt = 1009, lx = 1010, cx = 1011, af = 1012, ug = 1013, Rs = 1014, Wt = 1015, Ft = 1016, dg = 1017, fg = 1018, aa = 1020, Wb = 1021, Vt = 1023, jb = 1024, qb = 1025, oa = 1026, Ll = 1027, ul = 1028, hx = 1029, jc = 1030, ux = 1031, dx = 1033, od = 33776, kf = 33777, Gf = 33778, ld = 33779, Zp = 35840, gy = 35841, em = 35842, Ay = 35843, fx = 36196, tm = 37492, nm = 37496, im = 37808, yy = 37809, _y = 37810, vy = 37811, xy = 37812, wy = 37813, Ey = 37814, by = 37815, My = 37816, Sy = 37817, Cy = 37818, Ty = 37819, Iy = 37820, Dy = 37821, cd = 36492, Xb = 36283, Ry = 36284, By = 36285, Py = 36286, sm = 2200, rm = 2201, Yb = 2202, Ul = 2300, Ka = 2301, zf = 2302, dl = 2400, fl = 2401, Td = 2402, pg = 2500, px = 2501, Kb = 0, mx = 1, am = 2, om = 3e3, ea = 3001, El = 3200, gx = 3201, fs = 0, Ax = 1, Dn = "", Fe = "srgb", jt = "srgb-linear", mg = "display-p3", Fh = "rgbm-16", bl = 7680, yx = 519, Jb = 512, $b = 513, Zb = 514, eM = 515, tM = 516, nM = 517, iM = 518, sM = 519, Id = 35044, rM = "100", lm = "300 es", cm = 1035, br = 2e3, Dd = 2001; class Bn { 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 ai = ["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 Ly = 1234567; const Ha = Math.PI / 180, Fl = 180 / Math.PI; function Zi() { const s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0; return (ai[s & 255] + ai[s >> 8 & 255] + ai[s >> 16 & 255] + ai[s >> 24 & 255] + "-" + ai[e & 255] + ai[e >> 8 & 255] + "-" + ai[e >> 16 & 15 | 64] + ai[e >> 24 & 255] + "-" + ai[t & 63 | 128] + ai[t >> 8 & 255] + "-" + ai[t >> 16 & 255] + ai[t >> 24 & 255] + ai[n & 255] + ai[n >> 8 & 255] + ai[n >> 16 & 255] + ai[n >> 24 & 255]).toLowerCase(); } function yn(s, e, t) { return Math.max(e, Math.min(t, s)); } function gg(s, e) { return (s % e + e) % e; } function aM(s, e, t, n, i) { return n + (s - e) * (i - n) / (t - e); } function oM(s, e, t) { return s !== e ? (t - s) / (e - s) : 0; } function Zc(s, e, t) { return (1 - t) * s + t * e; } function lM(s, e, t, n) { return Zc(s, e, 1 - Math.exp(-t * n)); } function cM(s, e = 1) { return e - Math.abs(gg(s, e * 2) - e); } function hM(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * (3 - 2 * s)); } function uM(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * s * (s * (s * 6 - 15) + 10)); } function dM(s, e) { return s + Math.floor(Math.random() * (e - s + 1)); } function fM(s, e) { return s + Math.random() * (e - s); } function pM(s) { return s * (0.5 - Math.random()); } function mM(s) { s !== void 0 && (Ly = s); let e = Ly += 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 gM(s) { return s * Ha; } function AM(s) { return s * Fl; } function hm(s) { return (s & s - 1) === 0 && s !== 0; } function _x(s) { return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2)); } function Rd(s) { return Math.pow(2, Math.floor(Math.log(s) / Math.LN2)); } function yM(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 Ki(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 ft(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 Xt = { DEG2RAD: Ha, RAD2DEG: Fl, generateUUID: Zi, clamp: yn, euclideanModulo: gg, mapLinear: aM, inverseLerp: oM, lerp: Zc, damp: lM, pingpong: cM, smoothstep: hM, smootherstep: uM, randInt: dM, randFloat: fM, randFloatSpread: pM, seededRandom: mM, degToRad: gM, radToDeg: AM, isPowerOfTwo: hm, ceilPowerOfTwo: _x, floorPowerOfTwo: Rd, setQuaternionFromProperEuler: yM, normalize: ft, denormalize: Ki }; class K { constructor(e = 0, t = 0) { K.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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(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(yn(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 ut { constructor(e, t, n, i, r, a, o, l, c) { ut.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], g = i[6], _ = i[1], m = i[4], v = i[7], E = i[2], w = i[5], M = i[8]; return r[0] = a * y + o * _ + l * E, r[3] = a * A + o * m + l * w, r[6] = a * g + o * v + l * M, r[1] = c * y + h * _ + u * E, r[4] = c * A + h * m + u * w, r[7] = c * g + h * v + u * M, r[2] = d * y + f * _ + p * E, r[5] = d * A + f * m + p * w, r[8] = d * g + 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(Qf.makeScale(e, t)), this; } rotate(e) { return this.premultiply(Qf.makeRotation(-e)), this; } translate(e, t) { return this.premultiply(Qf.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 Qf = /* @__PURE__ */ new ut(); function vx(s) { for (let e = s.length - 1; e >= 0; --e) if (s[e] >= 65535) return !0; return !1; } const _M = { Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array }; function pl(s, e) { return new _M[s](e); } function ph(s) { return document.createElementNS("http://www.w3.org/1999/xhtml", s); } const Uy = {}; function eh(s) { s in Uy || (Uy[s] = !0, console.warn(s)); } function Ml(s) { return s < 0.04045 ? s * 0.0773993808 : Math.pow(s * 0.9478672986 + 0.0521327014, 2.4); } function Hf(s) { return s < 31308e-7 ? s * 12.92 : 1.055 * Math.pow(s, 0.41666) - 0.055; } const vM = /* @__PURE__ */ new ut().fromArray([ 0.8224621, 0.0331941, 0.0170827, 0.177538, 0.9668058, 0.0723974, -1e-7, 1e-7, 0.9105199 ]), xM = /* @__PURE__ */ new ut().fromArray([ 1.2249401, -0.0420569, -0.0196376, -0.2249404, 1.0420571, -0.0786361, 1e-7, 0, 1.0982735 ]); function wM(s) { return s.convertSRGBToLinear().applyMatrix3(xM); } function EM(s) { return s.applyMatrix3(vM).convertLinearToSRGB(); } const bM = { [jt]: (s) => s, [Fe]: (s) => s.convertSRGBToLinear(), [mg]: wM }, MM = { [jt]: (s) => s, [Fe]: (s) => s.convertLinearToSRGB(), [mg]: EM }, Zn = { enabled: !0, 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 jt; }, set workingColorSpace(s) { console.warn("THREE.ColorManagement: .workingColorSpace is readonly."); }, convert: function(s, e, t) { if (this.enabled === !1 || e === t || !e || !t) return s; const n = bM[e], i = MM[t]; if (n === void 0 || i === void 0) throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`); 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); } }; let Fo; class Ag { 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 { Fo === void 0 && (Fo = ph("canvas")), Fo.width = e.width, Fo.height = e.height; const i = Fo.getContext("2d"); e instanceof ImageData ? i.putImageData(e, 0, 0) : i.drawImage(e, 0, 0, e.width, e.height), n = Fo; } 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 = ph("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] = Ml(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(Ml(t[n] / 255) * 255) : t[n] = Ml(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 SM = 0; class ta { constructor(e = null) { this.isSource = !0, Object.defineProperty(this, "id", { value: SM++ }), this.uuid = Zi(), 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(Vf(i[a].image)) : r.push(Vf(i[a])); } else r = Vf(i); n.url = r; } return t || (e.images[this.uuid] = n), n; } } function Vf(s) { if (typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap) return Ag.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 CM = 0; class on extends Bn { constructor(e = on.DEFAULT_IMAGE, t = on.DEFAULT_MAPPING, n = zt, i = zt, r = tt, a = Ci, o = Vt, l = Rt, c = on.DEFAULT_ANISOTROPY, h = Dn) { super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: CM++ }), this.uuid = Zi(), this.name = "", this.source = new ta(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 K(0, 0), this.repeat = new K(1, 1), this.center = new K(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new ut(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, typeof h == "string" ? this.colorSpace = h : (eh("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = h === ea ? Fe : Dn), 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 === Fe ? ea : om, // 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 !== Lh) return e; if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch (this.wrapS) { case ii: e.x = e.x - Math.floor(e.x); break; case zt: e.x = e.x < 0 ? 0 : 1; break; case Ir: 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 ii: e.y = e.y - Math.floor(e.y); break; case zt: e.y = e.y < 0 ? 0 : 1; break; case Ir: 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 eh("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace === Fe ? ea : om; } set encoding(e) { eh("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = e === ea ? Fe : Dn; } } on.DEFAULT_IMAGE = null; on.DEFAULT_MAPPING = Lh; on.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], g = 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 + g - 3) < 0.1) return this.set(1, 0, 0, 0), this; t = Math.PI; const m = (c + 1) / 2, v = (f + 1) / 2, E = (g + 1) / 2, w = (h + d) / 4, M = (u + y) / 4, C = (p + A) / 4; return m > v && m > E ? m < 0.01 ? (n = 0, i = 0.707106781, r = 0.707106781) : (n = Math.sqrt(m), i = w / n, r = M / n) : v > E ? v < 0.01 ? (n = 0.707106781, i = 0, r = 0.707106781) : (i = Math.sqrt(v), n = w / i, r = C / i) : E < 0.01 ? (n = 0.707106781, i = 0.707106781, r = 0) : (r = Math.sqrt(E), n = M / r, i = C / 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 + g - 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z), this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(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 ki extends Bn { constructor(e = 1, t = 1, n = {}) { super(), this.isWebGLRenderTarget = !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 && (eh("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."), n.colorSpace = n.encoding === ea ? Fe : Dn), this.texture = new on(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 !== void 0 ? n.generateMipmaps : !1, this.texture.internalFormat = n.internalFormat !== void 0 ? n.internalFormat : null, this.texture.minFilter = n.minFilter !== void 0 ? n.minFilter : tt, this.depthBuffer = n.depthBuffer !== void 0 ? n.depthBuffer : !0, this.stencilBuffer = n.stencilBuffer !== void 0 ? n.stencilBuffer : !1, this.depthTexture = n.depthTexture !== void 0 ? n.depthTexture : null, this.samples = n.samples !== void 0 ? n.samples : 0; } 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 ta(t), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this; } dispose() { this.dispatchEvent({ type: "dispose" }); } } class yg extends on { 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 = Zt, this.minFilter = Zt, this.wrapR = zt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } } class HN extends ki { constructor(e = 1, t = 1, n = 1) { super(e, t), this.isWebGLArrayRenderTarget = !0, this.depth = n, this.texture = new yg(null, e, t, n), this.texture.isRenderTargetTexture = !0; } } class _g extends on { 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 = Zt, this.minFilter = Zt, this.wrapR = zt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } } class VN extends ki { constructor(e = 1, t = 1, n = 1) { super(e, t), this.isWebGL3DRenderTarget = !0, this.depth = n, this.texture = new _g(null, e, t, n), this.texture.isRenderTargetTexture = !0; } } class TM extends ki { 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(); } return this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t), this; } 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 it { 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 g = l * d + c * f + h * p + u * y, _ = g >= 0 ? 1 : -1, m = 1 - g * g; if (m > Number.EPSILON) { const E = Math.sqrt(m), w = Math.atan2(E, g * _); A = Math.sin(A * w) / E, o = Math.sin(o * w) / 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(yn(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 S { constructor(e = 0, t = 0, n = 0) { S.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; } 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 Err