UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

1,416 lines (1,415 loc) • 1.26 MB
const Dr = "169.19", lw = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }, uw = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, x_ = 0, Ap = 1, __ = 2, hw = 3, dw = 0, of = 1, y_ = 2, si = 3, Is = 0, dn = 1, rs = 2, Wi = 0, qs = 1, hu = 2, Np = 3, Ep = 4, v_ = 5, Ws = 100, M_ = 101, S_ = 102, T_ = 103, b_ = 104, w_ = 200, A_ = 201, N_ = 202, E_ = 203, du = 204, pu = 205, C_ = 206, R_ = 207, I_ = 208, P_ = 209, L_ = 210, D_ = 211, U_ = 212, F_ = 213, O_ = 214, fu = 0, mu = 1, gu = 2, Wr = 3, xu = 4, _u = 5, yu = 6, vu = 7, Ko = 0, af = 1, cf = 2, Pi = 0, lf = 1, uf = 2, hf = 3, df = 4, V_ = 5, pf = 6, ff = 7, Cp = "attached", z_ = "detached", ph = 300, vi = 301, Li = 302, Xr = 303, qr = 304, eo = 306, $r = 1e3, Ci = 1001, Za = 1002, sn = 1003, mf = 1004, pw = 1004, Xs = 1005, fw = 1005, Bt = 1006, Ur = 1007, mw = 1007, ci = 1008, B_ = 1008, us = 1009, gf = 1010, xf = 1011, Go = 1012, jo = 1013, $i = 1014, qn = 1015, Vn = 1016, fh = 1017, mh = 1018, Yr = 1020, _f = 35902, yf = 35899, vf = 1021, Mf = 1022, On = 1023, Sf = 1024, Tf = 1025, Fr = 1026, Zr = 1027, gh = 1028, yc = 1029, Ja = 1030, xh = 1031, gw = 1032, _h = 1033, La = 33776, Da = 33777, Ua = 33778, Fa = 33779, Mu = 35840, Su = 35841, Tu = 35842, bu = 35843, wu = 36196, Au = 37492, Nu = 37496, Eu = 37808, Cu = 37809, Ru = 37810, Iu = 37811, Pu = 37812, Lu = 37813, Du = 37814, Uu = 37815, Fu = 37816, Ou = 37817, Vu = 37818, zu = 37819, Bu = 37820, ku = 37821, Oa = 36492, Hu = 36494, Gu = 36495, bf = 36283, Wu = 36284, Xu = 36285, qu = 36286, k_ = 2200, H_ = 2201, G_ = 2202, Ka = 2300, $u = 2301, nu = 2302, Er = 2400, Cr = 2401, ja = 2402, yh = 2500, wf = 2501, xw = 0, _w = 1, yw = 2, W_ = 3200, X_ = 3201, vw = 3202, Mw = 3203, hs = 0, Af = 1, Hi = "", Wn = "srgb", Mi = "srgb-linear", vh = "display-p3", vc = "display-p3-linear", Qa = "linear", Ot = "srgb", ec = "rec709", tc = "p3", Sw = 0, Tr = 7680, Tw = 7681, bw = 7682, ww = 7683, Aw = 34055, Nw = 34056, Ew = 5386, Cw = 512, Rw = 513, Iw = 514, Pw = 515, Lw = 516, Dw = 517, Uw = 518, Rp = 519, q_ = 512, Nf = 513, $_ = 514, Ef = 515, Y_ = 516, Z_ = 517, J_ = 518, K_ = 519, Wo = 35044, Lo = 35048, Fw = 35040, Ow = 35045, Vw = 35049, zw = 35041, Bw = 35046, kw = 35050, Hw = 35042, Gw = "100", Ip = "300 es", Ri = 2e3, Jr = 2001; class Di { 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, o = i.length; r < o; r++) i[r].call(this, e); e.target = null; } } } const Dn = ["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 $g = 1234567; const Or = Math.PI / 180, Xo = 180 / Math.PI; function yi() { const s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0; return (Dn[s & 255] + Dn[s >> 8 & 255] + Dn[s >> 16 & 255] + Dn[s >> 24 & 255] + "-" + Dn[e & 255] + Dn[e >> 8 & 255] + "-" + Dn[e >> 16 & 15 | 64] + Dn[e >> 24 & 255] + "-" + Dn[t & 63 | 128] + Dn[t >> 8 & 255] + "-" + Dn[t >> 16 & 255] + Dn[t >> 24 & 255] + Dn[n & 255] + Dn[n >> 8 & 255] + Dn[n >> 16 & 255] + Dn[n >> 24 & 255]).toLowerCase(); } function jt(s, e, t) { return Math.max(e, Math.min(t, s)); } function Cf(s, e) { return (s % e + e) % e; } function Ww(s, e, t, n, i) { return n + (s - e) * (i - n) / (t - e); } function Xw(s, e, t) { return s !== e ? (t - s) / (e - s) : 0; } function Va(s, e, t) { return (1 - t) * s + t * e; } function qw(s, e, t, n) { return Va(s, e, 1 - Math.exp(-t * n)); } function $w(s, e = 1) { return e - Math.abs(Cf(s, e * 2) - e); } function Yw(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * (3 - 2 * s)); } function Zw(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * s * (s * (s * 6 - 15) + 10)); } function Jw(s, e) { return s + Math.floor(Math.random() * (e - s + 1)); } function Kw(s, e) { return s + Math.random() * (e - s); } function jw(s) { return s * (0.5 - Math.random()); } function Qw(s) { s !== void 0 && ($g = s); let e = $g += 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 e1(s) { return s * Or; } function t1(s) { return s * Xo; } function n1(s) { return (s & s - 1) === 0 && s !== 0; } function i1(s) { return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2)); } function s1(s) { return Math.pow(2, Math.floor(Math.log(s) / Math.LN2)); } function r1(s, e, t, n, i) { const r = Math.cos, o = Math.sin, a = r(t / 2), c = o(t / 2), l = r((e + n) / 2), u = o((e + n) / 2), h = r((e - n) / 2), d = o((e - n) / 2), p = r((n - e) / 2), f = o((n - e) / 2); switch (i) { case "XYX": s.set(a * u, c * h, c * d, a * l); break; case "YZY": s.set(c * d, a * u, c * h, a * l); break; case "ZXZ": s.set(c * h, c * d, a * u, a * l); break; case "XZX": s.set(a * u, c * f, c * p, a * l); break; case "YXY": s.set(c * p, a * u, c * f, a * l); break; case "ZYZ": s.set(c * f, c * p, a * u, a * l); break; default: console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i); } } function Xn(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 ct(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 Rf = { DEG2RAD: Or, RAD2DEG: Xo, generateUUID: yi, clamp: jt, euclideanModulo: Cf, mapLinear: Ww, inverseLerp: Xw, lerp: Va, damp: qw, pingpong: $w, smoothstep: Yw, smootherstep: Zw, randInt: Jw, randFloat: Kw, randFloatSpread: jw, seededRandom: Qw, degToRad: e1, radToDeg: t1, isPowerOfTwo: n1, ceilPowerOfTwo: i1, floorPowerOfTwo: s1, setQuaternionFromProperEuler: r1, normalize: ct, denormalize: Xn }; class J { constructor(e = 0, t = 0) { J.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(jt(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, o = this.y - e.y; return this.x = r * n - o * i + e.x, this.y = r * i + o * n + e.y, this; } random() { return this.x = Math.random(), this.y = Math.random(), this; } *[Symbol.iterator]() { yield this.x, yield this.y; } } class je { constructor(e, t, n, i, r, o, a, c, l) { je.prototype.isMatrix3 = !0, this.elements = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ], e !== void 0 && this.set(e, t, n, i, r, o, a, c, l); } set(e, t, n, i, r, o, a, c, l) { const u = this.elements; return u[0] = e, u[1] = i, u[2] = a, u[3] = t, u[4] = r, u[5] = c, u[6] = n, u[7] = o, u[8] = l, 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, o = n[0], a = n[3], c = n[6], l = n[1], u = n[4], h = n[7], d = n[2], p = n[5], f = n[8], x = i[0], m = i[3], g = i[6], y = i[1], _ = i[4], v = i[7], I = i[2], T = i[5], w = i[8]; return r[0] = o * x + a * y + c * I, r[3] = o * m + a * _ + c * T, r[6] = o * g + a * v + c * w, r[1] = l * x + u * y + h * I, r[4] = l * m + u * _ + h * T, r[7] = l * g + u * v + h * w, r[2] = d * x + p * y + f * I, r[5] = d * m + p * _ + f * T, r[8] = d * g + p * v + f * w, 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], o = e[4], a = e[5], c = e[6], l = e[7], u = e[8]; return t * o * u - t * a * l - n * r * u + n * a * c + i * r * l - i * o * c; } invert() { const e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], c = e[6], l = e[7], u = e[8], h = u * o - a * l, d = a * c - u * r, p = l * r - o * c, f = t * h + n * d + i * p; if (f === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); const x = 1 / f; return e[0] = h * x, e[1] = (i * l - u * n) * x, e[2] = (a * n - i * o) * x, e[3] = d * x, e[4] = (u * t - i * c) * x, e[5] = (i * r - a * t) * x, e[6] = p * x, e[7] = (n * c - l * t) * x, e[8] = (o * t - n * r) * x, 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, o, a) { const c = Math.cos(r), l = Math.sin(r); return this.set( n * c, n * l, -n * (c * o + l * a) + o + e, -i * l, i * c, -i * (-l * o + c * a) + a + t, 0, 0, 1 ), this; } // scale(e, t) { return this.premultiply(md.makeScale(e, t)), this; } rotate(e) { return this.premultiply(md.makeRotation(-e)), this; } translate(e, t) { return this.premultiply(md.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 md = /* @__PURE__ */ new je(); function j_(s) { for (let e = s.length - 1; e >= 0; --e) if (s[e] >= 65535) return !0; return !1; } const o1 = { Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array }; function Do(s, e) { return new o1[s](e); } function nc(s) { return document.createElementNS("http://www.w3.org/1999/xhtml", s); } function Q_() { const s = nc("canvas"); return s.style.display = "block", s; } const Yg = {}; function iu(s) { s in Yg || (Yg[s] = !0, console.warn(s)); } function a1(s, e, t) { return new Promise(function(n, i) { function r() { switch (s.clientWaitSync(e, s.SYNC_FLUSH_COMMANDS_BIT, 0)) { case s.WAIT_FAILED: i(); break; case s.TIMEOUT_EXPIRED: setTimeout(r, t); break; default: n(); } } setTimeout(r, t); }); } function c1(s) { const e = s.elements; e[2] = 0.5 * e[2] + 0.5 * e[3], e[6] = 0.5 * e[6] + 0.5 * e[7], e[10] = 0.5 * e[10] + 0.5 * e[11], e[14] = 0.5 * e[14] + 0.5 * e[15]; } function l1(s) { const e = s.elements; e[11] === -1 ? (e[10] = -e[10] - 1, e[14] = -e[14]) : (e[10] = -e[10], e[14] = -e[14] + 1); } const Zg = /* @__PURE__ */ new je().set( 0.8224621, 0.177538, 0, 0.0331941, 0.9668058, 0, 0.0170827, 0.0723974, 0.9105199 ), Jg = /* @__PURE__ */ new je().set( 1.2249401, -0.2249404, 0, -0.0420569, 1.0420571, 0, -0.0196376, -0.0786361, 1.0982735 ), ha = { [Mi]: { transfer: Qa, primaries: ec, luminanceCoefficients: [0.2126, 0.7152, 0.0722], toReference: (s) => s, fromReference: (s) => s }, [Wn]: { transfer: Ot, primaries: ec, luminanceCoefficients: [0.2126, 0.7152, 0.0722], toReference: (s) => s.convertSRGBToLinear(), fromReference: (s) => s.convertLinearToSRGB() }, [vc]: { transfer: Qa, primaries: tc, luminanceCoefficients: [0.2289, 0.6917, 0.0793], toReference: (s) => s.applyMatrix3(Jg), fromReference: (s) => s.applyMatrix3(Zg) }, [vh]: { transfer: Ot, primaries: tc, luminanceCoefficients: [0.2289, 0.6917, 0.0793], toReference: (s) => s.convertSRGBToLinear().applyMatrix3(Jg), fromReference: (s) => s.applyMatrix3(Zg).convertLinearToSRGB() } }, u1 = /* @__PURE__ */ new Set([Mi, vc]), xt = { enabled: !0, _workingColorSpace: Mi, get workingColorSpace() { return this._workingColorSpace; }, set workingColorSpace(s) { if (!u1.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 = ha[e].toReference, i = ha[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 ha[s].primaries; }, getTransfer: function(s) { return s === Hi ? Qa : ha[s].transfer; }, getLuminanceCoefficients: function(s, e = this._workingColorSpace) { return s.fromArray(ha[e].luminanceCoefficients); } }; function ko(s) { return s < 0.04045 ? s * 0.0773993808 : Math.pow(s * 0.9478672986 + 0.0521327014, 2.4); } function gd(s) { return s < 31308e-7 ? s * 12.92 : 1.055 * Math.pow(s, 0.41666) - 0.055; } let ao; class ey { static getDataURL(e) { if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") return e.src; let t; if (e instanceof HTMLCanvasElement) t = e; else { ao === void 0 && (ao = nc("canvas")), ao.width = e.width, ao.height = e.height; const n = ao.getContext("2d"); e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0, e.width, e.height), t = ao; } return t.width > 2048 || t.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), t.toDataURL("image/jpeg", 0.6)) : t.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 = nc("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 o = 0; o < r.length; o++) r[o] = ko(r[o] / 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(ko(t[n] / 255) * 255) : t[n] = ko(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 h1 = 0; class Rr { constructor(e = null) { this.isSource = !0, Object.defineProperty(this, "id", { value: h1++ }), this.uuid = yi(), 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 n = { uuid: this.uuid, url: "" }, i = this.data; if (i !== null) { let r; if (Array.isArray(i)) { r = []; for (let o = 0, a = i.length; o < a; o++) i[o].isDataTexture ? r.push(xd(i[o].image)) : r.push(xd(i[o])); } else r = xd(i); n.url = r; } return t || (e.images[this.uuid] = n), n; } } function xd(s) { return typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap ? ey.getDataURL(s) : s.data ? { data: Array.from(s.data), width: s.width, height: s.height, type: s.data.constructor.name } : (console.warn("THREE.Texture: Unable to serialize Texture."), {}); } let d1 = 0; class Zt extends Di { constructor(e = Zt.DEFAULT_IMAGE, t = Zt.DEFAULT_MAPPING, n = Ci, i = Ci, r = Bt, o = ci, a = On, c = us, l = Zt.DEFAULT_ANISOTROPY, u = Hi) { super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: d1++ }), this.uuid = yi(), this.name = "", this.source = new Rr(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = n, this.wrapT = i, this.magFilter = r, this.minFilter = o, this.anisotropy = l, this.format = a, this.internalFormat = null, this.type = c, this.offset = new J(0, 0), this.repeat = new J(1, 1), this.center = new J(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new je(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = u, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.pmremVersion = 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 = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this; } toJSON(e) { const t = e === void 0 || typeof e == "string"; if (!t && 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, 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[this.uuid] = n), n; } dispose() { this.dispatchEvent({ type: "dispose" }); } transformUv(e) { if (this.mapping !== ph) return e; if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch (this.wrapS) { case $r: e.x = e.x - Math.floor(e.x); break; case Ci: e.x = e.x < 0 ? 0 : 1; break; case Za: 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 $r: e.y = e.y - Math.floor(e.y); break; case Ci: e.y = e.y < 0 ? 0 : 1; break; case Za: 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); } set needsPMREMUpdate(e) { e === !0 && this.pmremVersion++; } } Zt.DEFAULT_IMAGE = null; Zt.DEFAULT_MAPPING = ph; Zt.DEFAULT_ANISOTROPY = 4; class rt { constructor(e = 0, t = 0, n = 0, i = 1) { rt.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, o = e.elements; return this.x = o[0] * t + o[4] * n + o[8] * i + o[12] * r, this.y = o[1] * t + o[5] * n + o[9] * i + o[13] * r, this.z = o[2] * t + o[6] * n + o[10] * i + o[14] * r, this.w = o[3] * t + o[7] * n + o[11] * i + o[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 c = e.elements, l = c[0], u = c[4], h = c[8], d = c[1], p = c[5], f = c[9], x = c[2], m = c[6], g = c[10]; if (Math.abs(u - d) < 0.01 && Math.abs(h - x) < 0.01 && Math.abs(f - m) < 0.01) { if (Math.abs(u + d) < 0.1 && Math.abs(h + x) < 0.1 && Math.abs(f + m) < 0.1 && Math.abs(l + p + g - 3) < 0.1) return this.set(1, 0, 0, 0), this; t = Math.PI; const _ = (l + 1) / 2, v = (p + 1) / 2, I = (g + 1) / 2, T = (u + d) / 4, w = (h + x) / 4, C = (f + m) / 4; return _ > v && _ > I ? _ < 0.01 ? (n = 0, i = 0.707106781, r = 0.707106781) : (n = Math.sqrt(_), i = T / n, r = w / n) : v > I ? v < 0.01 ? (n = 0.707106781, i = 0, r = 0.707106781) : (i = Math.sqrt(v), n = T / i, r = C / i) : I < 0.01 ? (n = 0.707106781, i = 0.707106781, r = 0) : (r = Math.sqrt(I), n = w / r, i = C / r), this.set(n, i, r, t), this; } let y = Math.sqrt((m - f) * (m - f) + (h - x) * (h - x) + (d - u) * (d - u)); return Math.abs(y) < 1e-3 && (y = 1), this.x = (m - f) / y, this.y = (h - x) / y, this.z = (d - u) / y, this.w = Math.acos((l + p + g - 1) / 2), this; } setFromMatrixPosition(e) { const t = e.elements; return this.x = t[12], this.y = t[13], this.z = t[14], this.w = t[15], 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 pn extends Di { constructor(e = 1, t = 1, n = {}) { super(), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = 1, this.scissor = new rt(0, 0, e, t), this.scissorTest = !1, this.viewport = new rt(0, 0, e, t); const i = { width: e, height: t, depth: 1 }; n = Object.assign({ generateMipmaps: !1, internalFormat: null, minFilter: Bt, depthBuffer: !0, stencilBuffer: !1, resolveDepthBuffer: !0, resolveStencilBuffer: !0, depthTexture: null, samples: 0, count: 1 }, n); const r = new Zt(i, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.colorSpace); r.flipY = !1, r.generateMipmaps = n.generateMipmaps, r.internalFormat = n.internalFormat, this.textures = []; const o = n.count; for (let a = 0; a < o; a++) this.textures[a] = r.clone(), this.textures[a].isRenderTargetTexture = !0; this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.resolveDepthBuffer = n.resolveDepthBuffer, this.resolveStencilBuffer = n.resolveStencilBuffer, this.depthTexture = n.depthTexture, this.samples = n.samples; } get texture() { return this.textures[0]; } set texture(e) { this.textures[0] = e; } 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.textures.length; i < r; i++) this.textures[i].image.width = e, this.textures[i].image.height = t, this.textures[i].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.textures.length = 0; for (let n = 0, i = e.textures.length; n < i; n++) this.textures[n] = e.textures[n].clone(), this.textures[n].isRenderTargetTexture = !0; const t = Object.assign({}, e.texture.image); return this.texture.source = new Rr(t), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.resolveDepthBuffer = e.resolveDepthBuffer, this.resolveStencilBuffer = e.resolveStencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this; } dispose() { this.dispatchEvent({ type: "dispose" }); } } class Yi extends pn { constructor(e = 1, t = 1, n = {}) { super(e, t, n), this.isWebGLRenderTarget = !0; } } class Mc extends Zt { 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 = sn, this.minFilter = sn, this.wrapR = Ci, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set(); } addLayerUpdate(e) { this.layerUpdates.add(e); } clearLayerUpdates() { this.layerUpdates.clear(); } } class p1 extends Yi { constructor(e = 1, t = 1, n = 1, i = {}) { super(e, t, i), this.isWebGLArrayRenderTarget = !0, this.depth = n, this.texture = new Mc(null, e, t, n), this.texture.isRenderTargetTexture = !0; } } class If extends Zt { 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 = sn, this.minFilter = sn, this.wrapR = Ci, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } } class f1 extends Yi { constructor(e = 1, t = 1, n = 1, i = {}) { super(e, t, i), this.isWebGL3DRenderTarget = !0, this.depth = n, this.texture = new If(null, e, t, n), this.texture.isRenderTargetTexture = !0; } } class Zn { 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, o, a) { let c = n[i + 0], l = n[i + 1], u = n[i + 2], h = n[i + 3]; const d = r[o + 0], p = r[o + 1], f = r[o + 2], x = r[o + 3]; if (a === 0) { e[t + 0] = c, e[t + 1] = l, e[t + 2] = u, e[t + 3] = h; return; } if (a === 1) { e[t + 0] = d, e[t + 1] = p, e[t + 2] = f, e[t + 3] = x; return; } if (h !== x || c !== d || l !== p || u !== f) { let m = 1 - a; const g = c * d + l * p + u * f + h * x, y = g >= 0 ? 1 : -1, _ = 1 - g * g; if (_ > Number.EPSILON) { const I = Math.sqrt(_), T = Math.atan2(I, g * y); m = Math.sin(m * T) / I, a = Math.sin(a * T) / I; } const v = a * y; if (c = c * m + d * v, l = l * m + p * v, u = u * m + f * v, h = h * m + x * v, m === 1 - a) { const I = 1 / Math.sqrt(c * c + l * l + u * u + h * h); c *= I, l *= I, u *= I, h *= I; } } e[t] = c, e[t + 1] = l, e[t + 2] = u, e[t + 3] = h; } static multiplyQuaternionsFlat(e, t, n, i, r, o) { const a = n[i], c = n[i + 1], l = n[i + 2], u = n[i + 3], h = r[o], d = r[o + 1], p = r[o + 2], f = r[o + 3]; return e[t] = a * f + u * h + c * p - l * d, e[t + 1] = c * f + u * d + l * h - a * p, e[t + 2] = l * f + u * p + a * d - c * h, e[t + 3] = u * f - a * h - c * d - l * 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, 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 = !0) { const n = e._x, i = e._y, r = e._z, o = e._order, a = Math.cos, c = Math.sin, l = a(n / 2), u = a(i / 2), h = a(r / 2), d = c(n / 2), p = c(i / 2), f = c(r / 2); switch (o) { case "XYZ": this._x = d * u * h + l * p * f, this._y = l * p * h - d * u * f, this._z = l * u * f + d * p * h, this._w = l * u * h - d * p * f; break; case "YXZ": this._x = d * u * h + l * p * f, this._y = l * p * h - d * u * f, this._z = l * u * f - d * p * h, this._w = l * u * h + d * p * f; break; case "ZXY": this._x = d * u * h - l * p * f, this._y = l * p * h + d * u * f, this._z = l * u * f + d * p * h, this._w = l * u * h - d * p * f; break; case "ZYX": this._x = d * u * h - l * p * f, this._y = l * p * h + d * u * f, this._z = l * u * f - d * p * h, this._w = l * u * h + d * p * f; break; case "YZX": this._x = d * u * h + l * p * f, this._y = l * p * h + d * u * f, this._z = l * u * f - d * p * h, this._w = l * u * h - d * p * f; break; case "XZY": this._x = d * u * h - l * p * f, this._y = l * p * h - d * u * f, this._z = l * u * f + d * p * h, this._w = l * u * h + d * p * f; break; default: console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + o); } return t === !0 && 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], o = t[1], a = t[5], c = t[9], l = t[2], u = t[6], h = t[10], d = n + a + h; if (d > 0) { const p = 0.5 / Math.sqrt(d + 1); this._w = 0.25 / p, this._x = (u - c) * p, this._y = (r - l) * p, this._z = (o - i) * p; } else if (n > a && n > h) { const p = 2 * Math.sqrt(1 + n - a - h); this._w = (u - c) / p, this._x = 0.25 * p, this._y = (i + o) / p, this._z = (r + l) / p; } else if (a > h) { const p = 2 * Math.sqrt(1 + a - n - h); this._w = (r - l) / p, this._x = (i + o) / p, this._y = 0.25 * p, this._z = (c + u) / p; } else { const p = 2 * Math.sqrt(1 + h - n - a); this._w = (o - i) / p, this._x = (r + l) / p, this._y = (c + u) / p, this._z = 0.25 * p; } 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(jt(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, o = e._w, a = t._x, c = t._y, l = t._z, u = t._w; return this._x = n * u + o * a + i * l - r * c, this._y = i * u + o * c + r * a - n * l, this._z = r * u + o * l + n * c - i * a, this._w = o * u - n * a - i * c - r * l, 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, o = this._w; let a = o * e._w + n * e._x + i * e._y + r * e._z; if (a < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, a = -a) : this.copy(e), a >= 1) return this._w = o, this._x = n, this._y = i, this._z = r, this; const c = 1 - a * a; if (c <= Number.EPSILON) { const p = 1 - t; return this._w = p * o + t * this._w, this._x = p * n + t * this._x, this._y = p * i + t * this._y, this._z = p * r + t * this._z, this.normalize(), this; } const l = Math.sqrt(c), u = Math.atan2(l, a), h = Math.sin((1 - t) * u) / l, d = Math.sin(t * u) / l; return this._w = o * h + this._w * d, this._x = n * h + this._x * d, this._y = i * h + this._y * d, this._z = r * h + this._z * d, this._onChangeCallback(), this; } slerpQuaternions(e, t, n) { return this.copy(e).slerp(t, n); } random() { const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), n = Math.random(), i = Math.sqrt(1 - n), r = Math.sqrt(n); return this.set( i * Math.sin(e), i * 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 E { constructor(e = 0, t = 0, n = 0) { E.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: