UNPKG

@specy/liquid-glass-react

Version:

React component for @specy/liquid-glass - A Three.js powered library to make apple's liquid with glass effect

1,388 lines (1,386 loc) 1.14 MB
import { forwardRef, useState, useRef, useImperativeHandle, useEffect } from 'react'; import { createPortal } from 'react-dom'; import { jsxs, Fragment, jsx } from 'react/jsx-runtime'; // src/LiquidGlass.tsx // node_modules/@specy/liquid-glass/dist/index.js var Po = "177"; var dp = 0; var ju = 1; var pp = 2; var Ah = 1; var gp = 2; var jt = 3; var Cn = 0; var tt = 1; var An = 2; var Fn = 0; var Ur = 1; var eh = 2; var th = 3; var nh = 4; var Bp = 5; var Kn = 100; var mp = 101; var wp = 102; var Cp = 103; var vp = 104; var Up = 200; var yp = 201; var Fp = 202; var Ep = 203; var so = 204; var ao = 205; var xp = 206; var Qp = 207; var _p = 208; var Sp = 209; var Mp = 210; var bp = 211; var Ip = 212; var Tp = 213; var Hp = 214; var Oo = 0; var No = 1; var Ko = 2; var yr = 3; var Go = 4; var Vo = 5; var ko = 6; var zo = 7; var rh = 0; var Lp = 1; var Rp = 2; var En = 0; var Dp = 1; var Pp = 2; var Op = 3; var Np = 4; var Kp = 5; var Gp = 6; var Vp = 7; var ih = 300; var Sr = 301; var Mr = 302; var Wo = 303; var Xo = 304; var Ms = 306; var oo = 1e3; var Kt = 1001; var co = 1002; var Et = 1003; var kp = 1004; var bs = 1005; var Gt = 1006; var Jo = 1007; var Wn = 1008; var en = 1009; var sh = 1010; var ah = 1011; var mi = 1012; var Yo = 1013; var Xn = 1014; var tn = 1015; var wi = 1016; var Zo = 1017; var qo = 1018; var Ci = 1020; var oh = 35902; var ch = 1021; var lh = 1022; var Qt = 1023; var oi = 1026; var vi = 1027; var uh = 1028; var $o = 1029; var hh = 1030; var jo = 1031; var Ac = 1033; var Is = 33776; var Ts = 33777; var Hs = 33778; var Ls = 33779; var ec = 35840; var tc = 35841; var nc = 35842; var rc = 35843; var ic = 36196; var sc = 37492; var ac = 37496; var oc = 37808; var cc = 37809; var lc = 37810; var uc = 37811; var hc = 37812; var fc = 37813; var dc = 37814; var pc = 37815; var gc = 37816; var Bc = 37817; var mc = 37818; var wc = 37819; var Cc = 37820; var vc = 37821; var Rs = 36492; var Uc = 36494; var yc = 36495; var fh = 36283; var Fc = 36284; var Ec = 36285; var xc = 36286; var zp = 3200; var Wp = 3201; var dh = 0; var Xp = 1; var xn = ""; var pt = "srgb"; var Fr = "srgb-linear"; var as = "linear"; var ce = "srgb"; var wr = 7680; var Wu = 519; var Jp = 512; var Yp = 513; var Zp = 514; var ph = 515; var qp = 516; var $p = 517; var jp = 518; var Ag = 519; var Xu = 35044; var gh = "300 es"; var Zt = 2e3; var os = 2001; var vn = class { addEventListener(A, e) { this._listeners === void 0 && (this._listeners = {}); let t = this._listeners; t[A] === void 0 && (t[A] = []), t[A].indexOf(e) === -1 && t[A].push(e); } hasEventListener(A, e) { let t = this._listeners; return t === void 0 ? false : t[A] !== void 0 && t[A].indexOf(e) !== -1; } removeEventListener(A, e) { let t = this._listeners; if (t === void 0) return; let r = t[A]; if (r !== void 0) { let i = r.indexOf(e); i !== -1 && r.splice(i, 1); } } dispatchEvent(A) { let e = this._listeners; if (e === void 0) return; let t = e[A.type]; if (t !== void 0) { A.target = this; let r = t.slice(0); for (let i = 0, s = r.length; i < s; i++) r[i].call(this, A); A.target = null; } } }; var Xe = ["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"]; var Bu = Math.PI / 180; var uo = 180 / Math.PI; function Ui() { let n17 = Math.random() * 4294967295 | 0, A = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0; return (Xe[n17 & 255] + Xe[n17 >> 8 & 255] + Xe[n17 >> 16 & 255] + Xe[n17 >> 24 & 255] + "-" + Xe[A & 255] + Xe[A >> 8 & 255] + "-" + Xe[A >> 16 & 15 | 64] + Xe[A >> 24 & 255] + "-" + Xe[e & 63 | 128] + Xe[e >> 8 & 255] + "-" + Xe[e >> 16 & 255] + Xe[e >> 24 & 255] + Xe[t & 255] + Xe[t >> 8 & 255] + Xe[t >> 16 & 255] + Xe[t >> 24 & 255]).toLowerCase(); } function YA(n17, A, e) { return Math.max(A, Math.min(e, n17)); } function sC(n17, A) { return (n17 % A + A) % A; } function mu(n17, A, e) { return (1 - e) * n17 + e * A; } function $i(n17, A) { switch (A.constructor) { case Float32Array: return n17; case Uint32Array: return n17 / 4294967295; case Uint16Array: return n17 / 65535; case Uint8Array: return n17 / 255; case Int32Array: return Math.max(n17 / 2147483647, -1); case Int16Array: return Math.max(n17 / 32767, -1); case Int8Array: return Math.max(n17 / 127, -1); default: throw new Error("Invalid component type."); } } function st(n17, A) { switch (A.constructor) { case Float32Array: return n17; case Uint32Array: return Math.round(n17 * 4294967295); case Uint16Array: return Math.round(n17 * 65535); case Uint8Array: return Math.round(n17 * 255); case Int32Array: return Math.round(n17 * 2147483647); case Int16Array: return Math.round(n17 * 32767); case Int8Array: return Math.round(n17 * 127); default: throw new Error("Invalid component type."); } } var wA = class n { constructor(A = 0, e = 0) { n.prototype.isVector2 = true, this.x = A, this.y = e; } get width() { return this.x; } set width(A) { this.x = A; } get height() { return this.y; } set height(A) { this.y = A; } set(A, e) { return this.x = A, this.y = e, this; } setScalar(A) { return this.x = A, this.y = A, this; } setX(A) { return this.x = A, this; } setY(A) { return this.y = A, this; } setComponent(A, e) { switch (A) { case 0: this.x = e; break; case 1: this.y = e; break; default: throw new Error("index is out of range: " + A); } return this; } getComponent(A) { switch (A) { case 0: return this.x; case 1: return this.y; default: throw new Error("index is out of range: " + A); } } clone() { return new this.constructor(this.x, this.y); } copy(A) { return this.x = A.x, this.y = A.y, this; } add(A) { return this.x += A.x, this.y += A.y, this; } addScalar(A) { return this.x += A, this.y += A, this; } addVectors(A, e) { return this.x = A.x + e.x, this.y = A.y + e.y, this; } addScaledVector(A, e) { return this.x += A.x * e, this.y += A.y * e, this; } sub(A) { return this.x -= A.x, this.y -= A.y, this; } subScalar(A) { return this.x -= A, this.y -= A, this; } subVectors(A, e) { return this.x = A.x - e.x, this.y = A.y - e.y, this; } multiply(A) { return this.x *= A.x, this.y *= A.y, this; } multiplyScalar(A) { return this.x *= A, this.y *= A, this; } divide(A) { return this.x /= A.x, this.y /= A.y, this; } divideScalar(A) { return this.multiplyScalar(1 / A); } applyMatrix3(A) { let e = this.x, t = this.y, r = A.elements; return this.x = r[0] * e + r[3] * t + r[6], this.y = r[1] * e + r[4] * t + r[7], this; } min(A) { return this.x = Math.min(this.x, A.x), this.y = Math.min(this.y, A.y), this; } max(A) { return this.x = Math.max(this.x, A.x), this.y = Math.max(this.y, A.y), this; } clamp(A, e) { return this.x = YA(this.x, A.x, e.x), this.y = YA(this.y, A.y, e.y), this; } clampScalar(A, e) { return this.x = YA(this.x, A, e), this.y = YA(this.y, A, e), this; } clampLength(A, e) { let t = this.length(); return this.divideScalar(t || 1).multiplyScalar(YA(t, A, e)); } 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(A) { return this.x * A.x + this.y * A.y; } cross(A) { return this.x * A.y - this.y * A.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(A) { let e = Math.sqrt(this.lengthSq() * A.lengthSq()); if (e === 0) return Math.PI / 2; let t = this.dot(A) / e; return Math.acos(YA(t, -1, 1)); } distanceTo(A) { return Math.sqrt(this.distanceToSquared(A)); } distanceToSquared(A) { let e = this.x - A.x, t = this.y - A.y; return e * e + t * t; } manhattanDistanceTo(A) { return Math.abs(this.x - A.x) + Math.abs(this.y - A.y); } setLength(A) { return this.normalize().multiplyScalar(A); } lerp(A, e) { return this.x += (A.x - this.x) * e, this.y += (A.y - this.y) * e, this; } lerpVectors(A, e, t) { return this.x = A.x + (e.x - A.x) * t, this.y = A.y + (e.y - A.y) * t, this; } equals(A) { return A.x === this.x && A.y === this.y; } fromArray(A, e = 0) { return this.x = A[e], this.y = A[e + 1], this; } toArray(A = [], e = 0) { return A[e] = this.x, A[e + 1] = this.y, A; } fromBufferAttribute(A, e) { return this.x = A.getX(e), this.y = A.getY(e), this; } rotateAround(A, e) { let t = Math.cos(e), r = Math.sin(e), i = this.x - A.x, s = this.y - A.y; return this.x = i * t - s * r + A.x, this.y = i * r + s * t + A.y, this; } random() { return this.x = Math.random(), this.y = Math.random(), this; } *[Symbol.iterator]() { yield this.x, yield this.y; } }; var Un = class { constructor(A = 0, e = 0, t = 0, r = 1) { this.isQuaternion = true, this._x = A, this._y = e, this._z = t, this._w = r; } static slerpFlat(A, e, t, r, i, s, a) { let o = t[r + 0], c = t[r + 1], l = t[r + 2], u = t[r + 3], h = i[s + 0], d = i[s + 1], g = i[s + 2], B = i[s + 3]; if (a === 0) { A[e + 0] = o, A[e + 1] = c, A[e + 2] = l, A[e + 3] = u; return; } if (a === 1) { A[e + 0] = h, A[e + 1] = d, A[e + 2] = g, A[e + 3] = B; return; } if (u !== B || o !== h || c !== d || l !== g) { let p = 1 - a, f = o * h + c * d + l * g + u * B, U = f >= 0 ? 1 : -1, y = 1 - f * f; if (y > Number.EPSILON) { let S = Math.sqrt(y), F = Math.atan2(S, f * U); p = Math.sin(p * F) / S, a = Math.sin(a * F) / S; } let m = a * U; if (o = o * p + h * m, c = c * p + d * m, l = l * p + g * m, u = u * p + B * m, p === 1 - a) { let S = 1 / Math.sqrt(o * o + c * c + l * l + u * u); o *= S, c *= S, l *= S, u *= S; } } A[e] = o, A[e + 1] = c, A[e + 2] = l, A[e + 3] = u; } static multiplyQuaternionsFlat(A, e, t, r, i, s) { let a = t[r], o = t[r + 1], c = t[r + 2], l = t[r + 3], u = i[s], h = i[s + 1], d = i[s + 2], g = i[s + 3]; return A[e] = a * g + l * u + o * d - c * h, A[e + 1] = o * g + l * h + c * u - a * d, A[e + 2] = c * g + l * d + a * h - o * u, A[e + 3] = l * g - a * u - o * h - c * d, A; } get x() { return this._x; } set x(A) { this._x = A, this._onChangeCallback(); } get y() { return this._y; } set y(A) { this._y = A, this._onChangeCallback(); } get z() { return this._z; } set z(A) { this._z = A, this._onChangeCallback(); } get w() { return this._w; } set w(A) { this._w = A, this._onChangeCallback(); } set(A, e, t, r) { return this._x = A, this._y = e, this._z = t, this._w = r, this._onChangeCallback(), this; } clone() { return new this.constructor(this._x, this._y, this._z, this._w); } copy(A) { return this._x = A.x, this._y = A.y, this._z = A.z, this._w = A.w, this._onChangeCallback(), this; } setFromEuler(A, e = true) { let t = A._x, r = A._y, i = A._z, s = A._order, a = Math.cos, o = Math.sin, c = a(t / 2), l = a(r / 2), u = a(i / 2), h = o(t / 2), d = o(r / 2), g = o(i / 2); switch (s) { case "XYZ": this._x = h * l * u + c * d * g, this._y = c * d * u - h * l * g, this._z = c * l * g + h * d * u, this._w = c * l * u - h * d * g; break; case "YXZ": this._x = h * l * u + c * d * g, this._y = c * d * u - h * l * g, this._z = c * l * g - h * d * u, this._w = c * l * u + h * d * g; break; case "ZXY": this._x = h * l * u - c * d * g, this._y = c * d * u + h * l * g, this._z = c * l * g + h * d * u, this._w = c * l * u - h * d * g; break; case "ZYX": this._x = h * l * u - c * d * g, this._y = c * d * u + h * l * g, this._z = c * l * g - h * d * u, this._w = c * l * u + h * d * g; break; case "YZX": this._x = h * l * u + c * d * g, this._y = c * d * u + h * l * g, this._z = c * l * g - h * d * u, this._w = c * l * u - h * d * g; break; case "XZY": this._x = h * l * u - c * d * g, this._y = c * d * u - h * l * g, this._z = c * l * g + h * d * u, this._w = c * l * u + h * d * g; break; default: console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + s); } return e === true && this._onChangeCallback(), this; } setFromAxisAngle(A, e) { let t = e / 2, r = Math.sin(t); return this._x = A.x * r, this._y = A.y * r, this._z = A.z * r, this._w = Math.cos(t), this._onChangeCallback(), this; } setFromRotationMatrix(A) { let e = A.elements, t = e[0], r = e[4], i = e[8], s = e[1], a = e[5], o = e[9], c = e[2], l = e[6], u = e[10], h = t + a + u; if (h > 0) { let d = 0.5 / Math.sqrt(h + 1); this._w = 0.25 / d, this._x = (l - o) * d, this._y = (i - c) * d, this._z = (s - r) * d; } else if (t > a && t > u) { let d = 2 * Math.sqrt(1 + t - a - u); this._w = (l - o) / d, this._x = 0.25 * d, this._y = (r + s) / d, this._z = (i + c) / d; } else if (a > u) { let d = 2 * Math.sqrt(1 + a - t - u); this._w = (i - c) / d, this._x = (r + s) / d, this._y = 0.25 * d, this._z = (o + l) / d; } else { let d = 2 * Math.sqrt(1 + u - t - a); this._w = (s - r) / d, this._x = (i + c) / d, this._y = (o + l) / d, this._z = 0.25 * d; } return this._onChangeCallback(), this; } setFromUnitVectors(A, e) { let t = A.dot(e) + 1; return t < Number.EPSILON ? (t = 0, Math.abs(A.x) > Math.abs(A.z) ? (this._x = -A.y, this._y = A.x, this._z = 0, this._w = t) : (this._x = 0, this._y = -A.z, this._z = A.y, this._w = t)) : (this._x = A.y * e.z - A.z * e.y, this._y = A.z * e.x - A.x * e.z, this._z = A.x * e.y - A.y * e.x, this._w = t), this.normalize(); } angleTo(A) { return 2 * Math.acos(Math.abs(YA(this.dot(A), -1, 1))); } rotateTowards(A, e) { let t = this.angleTo(A); if (t === 0) return this; let r = Math.min(1, e / t); return this.slerp(A, r), 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(A) { return this._x * A._x + this._y * A._y + this._z * A._z + this._w * A._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 A = this.length(); return A === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (A = 1 / A, this._x = this._x * A, this._y = this._y * A, this._z = this._z * A, this._w = this._w * A), this._onChangeCallback(), this; } multiply(A) { return this.multiplyQuaternions(this, A); } premultiply(A) { return this.multiplyQuaternions(A, this); } multiplyQuaternions(A, e) { let t = A._x, r = A._y, i = A._z, s = A._w, a = e._x, o = e._y, c = e._z, l = e._w; return this._x = t * l + s * a + r * c - i * o, this._y = r * l + s * o + i * a - t * c, this._z = i * l + s * c + t * o - r * a, this._w = s * l - t * a - r * o - i * c, this._onChangeCallback(), this; } slerp(A, e) { if (e === 0) return this; if (e === 1) return this.copy(A); let t = this._x, r = this._y, i = this._z, s = this._w, a = s * A._w + t * A._x + r * A._y + i * A._z; if (a < 0 ? (this._w = -A._w, this._x = -A._x, this._y = -A._y, this._z = -A._z, a = -a) : this.copy(A), a >= 1) return this._w = s, this._x = t, this._y = r, this._z = i, this; let o = 1 - a * a; if (o <= Number.EPSILON) { let d = 1 - e; return this._w = d * s + e * this._w, this._x = d * t + e * this._x, this._y = d * r + e * this._y, this._z = d * i + e * this._z, this.normalize(), this; } let c = Math.sqrt(o), l = Math.atan2(c, a), u = Math.sin((1 - e) * l) / c, h = Math.sin(e * l) / c; return this._w = s * u + this._w * h, this._x = t * u + this._x * h, this._y = r * u + this._y * h, this._z = i * u + this._z * h, this._onChangeCallback(), this; } slerpQuaternions(A, e, t) { return this.copy(A).slerp(e, t); } random() { let A = 2 * Math.PI * Math.random(), e = 2 * Math.PI * Math.random(), t = Math.random(), r = Math.sqrt(1 - t), i = Math.sqrt(t); return this.set(r * Math.sin(A), r * Math.cos(A), i * Math.sin(e), i * Math.cos(e)); } equals(A) { return A._x === this._x && A._y === this._y && A._z === this._z && A._w === this._w; } fromArray(A, e = 0) { return this._x = A[e], this._y = A[e + 1], this._z = A[e + 2], this._w = A[e + 3], this._onChangeCallback(), this; } toArray(A = [], e = 0) { return A[e] = this._x, A[e + 1] = this._y, A[e + 2] = this._z, A[e + 3] = this._w, A; } fromBufferAttribute(A, e) { return this._x = A.getX(e), this._y = A.getY(e), this._z = A.getZ(e), this._w = A.getW(e), this._onChangeCallback(), this; } toJSON() { return this.toArray(); } _onChange(A) { return this._onChangeCallback = A, this; } _onChangeCallback() { } *[Symbol.iterator]() { yield this._x, yield this._y, yield this._z, yield this._w; } }; var R = class n2 { constructor(A = 0, e = 0, t = 0) { n2.prototype.isVector3 = true, this.x = A, this.y = e, this.z = t; } set(A, e, t) { return t === void 0 && (t = this.z), this.x = A, this.y = e, this.z = t, this; } setScalar(A) { return this.x = A, this.y = A, this.z = A, this; } setX(A) { return this.x = A, this; } setY(A) { return this.y = A, this; } setZ(A) { return this.z = A, this; } setComponent(A, e) { switch (A) { case 0: this.x = e; break; case 1: this.y = e; break; case 2: this.z = e; break; default: throw new Error("index is out of range: " + A); } return this; } getComponent(A) { switch (A) { case 0: return this.x; case 1: return this.y; case 2: return this.z; default: throw new Error("index is out of range: " + A); } } clone() { return new this.constructor(this.x, this.y, this.z); } copy(A) { return this.x = A.x, this.y = A.y, this.z = A.z, this; } add(A) { return this.x += A.x, this.y += A.y, this.z += A.z, this; } addScalar(A) { return this.x += A, this.y += A, this.z += A, this; } addVectors(A, e) { return this.x = A.x + e.x, this.y = A.y + e.y, this.z = A.z + e.z, this; } addScaledVector(A, e) { return this.x += A.x * e, this.y += A.y * e, this.z += A.z * e, this; } sub(A) { return this.x -= A.x, this.y -= A.y, this.z -= A.z, this; } subScalar(A) { return this.x -= A, this.y -= A, this.z -= A, this; } subVectors(A, e) { return this.x = A.x - e.x, this.y = A.y - e.y, this.z = A.z - e.z, this; } multiply(A) { return this.x *= A.x, this.y *= A.y, this.z *= A.z, this; } multiplyScalar(A) { return this.x *= A, this.y *= A, this.z *= A, this; } multiplyVectors(A, e) { return this.x = A.x * e.x, this.y = A.y * e.y, this.z = A.z * e.z, this; } applyEuler(A) { return this.applyQuaternion(Xd.setFromEuler(A)); } applyAxisAngle(A, e) { return this.applyQuaternion(Xd.setFromAxisAngle(A, e)); } applyMatrix3(A) { let e = this.x, t = this.y, r = this.z, i = A.elements; return this.x = i[0] * e + i[3] * t + i[6] * r, this.y = i[1] * e + i[4] * t + i[7] * r, this.z = i[2] * e + i[5] * t + i[8] * r, this; } applyNormalMatrix(A) { return this.applyMatrix3(A).normalize(); } applyMatrix4(A) { let e = this.x, t = this.y, r = this.z, i = A.elements, s = 1 / (i[3] * e + i[7] * t + i[11] * r + i[15]); return this.x = (i[0] * e + i[4] * t + i[8] * r + i[12]) * s, this.y = (i[1] * e + i[5] * t + i[9] * r + i[13]) * s, this.z = (i[2] * e + i[6] * t + i[10] * r + i[14]) * s, this; } applyQuaternion(A) { let e = this.x, t = this.y, r = this.z, i = A.x, s = A.y, a = A.z, o = A.w, c = 2 * (s * r - a * t), l = 2 * (a * e - i * r), u = 2 * (i * t - s * e); return this.x = e + o * c + s * u - a * l, this.y = t + o * l + a * c - i * u, this.z = r + o * u + i * l - s * c, this; } project(A) { return this.applyMatrix4(A.matrixWorldInverse).applyMatrix4(A.projectionMatrix); } unproject(A) { return this.applyMatrix4(A.projectionMatrixInverse).applyMatrix4(A.matrixWorld); } transformDirection(A) { let e = this.x, t = this.y, r = this.z, i = A.elements; return this.x = i[0] * e + i[4] * t + i[8] * r, this.y = i[1] * e + i[5] * t + i[9] * r, this.z = i[2] * e + i[6] * t + i[10] * r, this.normalize(); } divide(A) { return this.x /= A.x, this.y /= A.y, this.z /= A.z, this; } divideScalar(A) { return this.multiplyScalar(1 / A); } min(A) { return this.x = Math.min(this.x, A.x), this.y = Math.min(this.y, A.y), this.z = Math.min(this.z, A.z), this; } max(A) { return this.x = Math.max(this.x, A.x), this.y = Math.max(this.y, A.y), this.z = Math.max(this.z, A.z), this; } clamp(A, e) { return this.x = YA(this.x, A.x, e.x), this.y = YA(this.y, A.y, e.y), this.z = YA(this.z, A.z, e.z), this; } clampScalar(A, e) { return this.x = YA(this.x, A, e), this.y = YA(this.y, A, e), this.z = YA(this.z, A, e), this; } clampLength(A, e) { let t = this.length(); return this.divideScalar(t || 1).multiplyScalar(YA(t, A, e)); } floor() { return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this; } ceil() { return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this; } round() { return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this; } roundToZero() { return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this; } negate() { return this.x = -this.x, this.y = -this.y, this.z = -this.z, this; } dot(A) { return this.x * A.x + this.y * A.y + this.z * A.z; } lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z; } length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } manhattanLength() { return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z); } normalize() { return this.divideScalar(this.length() || 1); } setLength(A) { return this.normalize().multiplyScalar(A); } lerp(A, e) { return this.x += (A.x - this.x) * e, this.y += (A.y - this.y) * e, this.z += (A.z - this.z) * e, this; } lerpVectors(A, e, t) { return this.x = A.x + (e.x - A.x) * t, this.y = A.y + (e.y - A.y) * t, this.z = A.z + (e.z - A.z) * t, this; } cross(A) { return this.crossVectors(this, A); } crossVectors(A, e) { let t = A.x, r = A.y, i = A.z, s = e.x, a = e.y, o = e.z; return this.x = r * o - i * a, this.y = i * s - t * o, this.z = t * a - r * s, this; } projectOnVector(A) { let e = A.lengthSq(); if (e === 0) return this.set(0, 0, 0); let t = A.dot(this) / e; return this.copy(A).multiplyScalar(t); } projectOnPlane(A) { return wu.copy(this).projectOnVector(A), this.sub(wu); } reflect(A) { return this.sub(wu.copy(A).multiplyScalar(2 * this.dot(A))); } angleTo(A) { let e = Math.sqrt(this.lengthSq() * A.lengthSq()); if (e === 0) return Math.PI / 2; let t = this.dot(A) / e; return Math.acos(YA(t, -1, 1)); } distanceTo(A) { return Math.sqrt(this.distanceToSquared(A)); } distanceToSquared(A) { let e = this.x - A.x, t = this.y - A.y, r = this.z - A.z; return e * e + t * t + r * r; } manhattanDistanceTo(A) { return Math.abs(this.x - A.x) + Math.abs(this.y - A.y) + Math.abs(this.z - A.z); } setFromSpherical(A) { return this.setFromSphericalCoords(A.radius, A.phi, A.theta); } setFromSphericalCoords(A, e, t) { let r = Math.sin(e) * A; return this.x = r * Math.sin(t), this.y = Math.cos(e) * A, this.z = r * Math.cos(t), this; } setFromCylindrical(A) { return this.setFromCylindricalCoords(A.radius, A.theta, A.y); } setFromCylindricalCoords(A, e, t) { return this.x = A * Math.sin(e), this.y = t, this.z = A * Math.cos(e), this; } setFromMatrixPosition(A) { let e = A.elements; return this.x = e[12], this.y = e[13], this.z = e[14], this; } setFromMatrixScale(A) { let e = this.setFromMatrixColumn(A, 0).length(), t = this.setFromMatrixColumn(A, 1).length(), r = this.setFromMatrixColumn(A, 2).length(); return this.x = e, this.y = t, this.z = r, this; } setFromMatrixColumn(A, e) { return this.fromArray(A.elements, e * 4); } setFromMatrix3Column(A, e) { return this.fromArray(A.elements, e * 3); } setFromEuler(A) { return this.x = A._x, this.y = A._y, this.z = A._z, this; } setFromColor(A) { return this.x = A.r, this.y = A.g, this.z = A.b, this; } equals(A) { return A.x === this.x && A.y === this.y && A.z === this.z; } fromArray(A, e = 0) { return this.x = A[e], this.y = A[e + 1], this.z = A[e + 2], this; } toArray(A = [], e = 0) { return A[e] = this.x, A[e + 1] = this.y, A[e + 2] = this.z, A; } fromBufferAttribute(A, e) { return this.x = A.getX(e), this.y = A.getY(e), this.z = A.getZ(e), this; } random() { return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this; } randomDirection() { let A = Math.random() * Math.PI * 2, e = Math.random() * 2 - 1, t = Math.sqrt(1 - e * e); return this.x = t * Math.cos(A), this.y = e, this.z = t * Math.sin(A), this; } *[Symbol.iterator]() { yield this.x, yield this.y, yield this.z; } }; var wu = new R(); var Xd = new Un(); var WA = class n3 { constructor(A, e, t, r, i, s, a, o, c) { n3.prototype.isMatrix3 = true, this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1], A !== void 0 && this.set(A, e, t, r, i, s, a, o, c); } set(A, e, t, r, i, s, a, o, c) { let l = this.elements; return l[0] = A, l[1] = r, l[2] = a, l[3] = e, l[4] = i, l[5] = o, l[6] = t, l[7] = s, l[8] = c, this; } identity() { return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this; } copy(A) { let e = this.elements, t = A.elements; return e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[3], e[4] = t[4], e[5] = t[5], e[6] = t[6], e[7] = t[7], e[8] = t[8], this; } extractBasis(A, e, t) { return A.setFromMatrix3Column(this, 0), e.setFromMatrix3Column(this, 1), t.setFromMatrix3Column(this, 2), this; } setFromMatrix4(A) { let e = A.elements; return this.set(e[0], e[4], e[8], e[1], e[5], e[9], e[2], e[6], e[10]), this; } multiply(A) { return this.multiplyMatrices(this, A); } premultiply(A) { return this.multiplyMatrices(A, this); } multiplyMatrices(A, e) { let t = A.elements, r = e.elements, i = this.elements, s = t[0], a = t[3], o = t[6], c = t[1], l = t[4], u = t[7], h = t[2], d = t[5], g = t[8], B = r[0], p = r[3], f = r[6], U = r[1], y = r[4], m = r[7], S = r[2], F = r[5], x = r[8]; return i[0] = s * B + a * U + o * S, i[3] = s * p + a * y + o * F, i[6] = s * f + a * m + o * x, i[1] = c * B + l * U + u * S, i[4] = c * p + l * y + u * F, i[7] = c * f + l * m + u * x, i[2] = h * B + d * U + g * S, i[5] = h * p + d * y + g * F, i[8] = h * f + d * m + g * x, this; } multiplyScalar(A) { let e = this.elements; return e[0] *= A, e[3] *= A, e[6] *= A, e[1] *= A, e[4] *= A, e[7] *= A, e[2] *= A, e[5] *= A, e[8] *= A, this; } determinant() { let A = this.elements, e = A[0], t = A[1], r = A[2], i = A[3], s = A[4], a = A[5], o = A[6], c = A[7], l = A[8]; return e * s * l - e * a * c - t * i * l + t * a * o + r * i * c - r * s * o; } invert() { let A = this.elements, e = A[0], t = A[1], r = A[2], i = A[3], s = A[4], a = A[5], o = A[6], c = A[7], l = A[8], u = l * s - a * c, h = a * o - l * i, d = c * i - s * o, g = e * u + t * h + r * d; if (g === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); let B = 1 / g; return A[0] = u * B, A[1] = (r * c - l * t) * B, A[2] = (a * t - r * s) * B, A[3] = h * B, A[4] = (l * e - r * o) * B, A[5] = (r * i - a * e) * B, A[6] = d * B, A[7] = (t * o - c * e) * B, A[8] = (s * e - t * i) * B, this; } transpose() { let A, e = this.elements; return A = e[1], e[1] = e[3], e[3] = A, A = e[2], e[2] = e[6], e[6] = A, A = e[5], e[5] = e[7], e[7] = A, this; } getNormalMatrix(A) { return this.setFromMatrix4(A).invert().transpose(); } transposeIntoArray(A) { let e = this.elements; return A[0] = e[0], A[1] = e[3], A[2] = e[6], A[3] = e[1], A[4] = e[4], A[5] = e[7], A[6] = e[2], A[7] = e[5], A[8] = e[8], this; } setUvTransform(A, e, t, r, i, s, a) { let o = Math.cos(i), c = Math.sin(i); return this.set(t * o, t * c, -t * (o * s + c * a) + s + A, -r * c, r * o, -r * (-c * s + o * a) + a + e, 0, 0, 1), this; } scale(A, e) { return this.premultiply(Cu.makeScale(A, e)), this; } rotate(A) { return this.premultiply(Cu.makeRotation(-A)), this; } translate(A, e) { return this.premultiply(Cu.makeTranslation(A, e)), this; } makeTranslation(A, e) { return A.isVector2 ? this.set(1, 0, A.x, 0, 1, A.y, 0, 0, 1) : this.set(1, 0, A, 0, 1, e, 0, 0, 1), this; } makeRotation(A) { let e = Math.cos(A), t = Math.sin(A); return this.set(e, -t, 0, t, e, 0, 0, 0, 1), this; } makeScale(A, e) { return this.set(A, 0, 0, 0, e, 0, 0, 0, 1), this; } equals(A) { let e = this.elements, t = A.elements; for (let r = 0; r < 9; r++) if (e[r] !== t[r]) return false; return true; } fromArray(A, e = 0) { for (let t = 0; t < 9; t++) this.elements[t] = A[t + e]; return this; } toArray(A = [], e = 0) { let t = this.elements; return A[e] = t[0], A[e + 1] = t[1], A[e + 2] = t[2], A[e + 3] = t[3], A[e + 4] = t[4], A[e + 5] = t[5], A[e + 6] = t[6], A[e + 7] = t[7], A[e + 8] = t[8], A; } clone() { return new this.constructor().fromArray(this.elements); } }; var Cu = new WA(); function Bh(n17) { for (let A = n17.length - 1; A >= 0; --A) if (n17[A] >= 65535) return true; return false; } function cs(n17) { return document.createElementNS("http://www.w3.org/1999/xhtml", n17); } function eg() { let n17 = cs("canvas"); return n17.style.display = "block", n17; } var Jd = {}; function Er(n17) { n17 in Jd || (Jd[n17] = true, console.warn(n17)); } function tg(n17, A, e) { return new Promise(function(t, r) { function i() { switch (n17.clientWaitSync(A, n17.SYNC_FLUSH_COMMANDS_BIT, 0)) { case n17.WAIT_FAILED: r(); break; case n17.TIMEOUT_EXPIRED: setTimeout(i, e); break; default: t(); } } setTimeout(i, e); }); } function ng(n17) { let A = n17.elements; A[2] = 0.5 * A[2] + 0.5 * A[3], A[6] = 0.5 * A[6] + 0.5 * A[7], A[10] = 0.5 * A[10] + 0.5 * A[11], A[14] = 0.5 * A[14] + 0.5 * A[15]; } function rg(n17) { let A = n17.elements; A[11] === -1 ? (A[10] = -A[10] - 1, A[14] = -A[14]) : (A[10] = -A[10], A[14] = -A[14] + 1); } var Yd = new WA().set(0.4123908, 0.3575843, 0.1804808, 0.212639, 0.7151687, 0.0721923, 0.0193308, 0.1191948, 0.9505322); var Zd = new WA().set(3.2409699, -1.5373832, -0.4986108, -0.9692436, 1.8759675, 0.0415551, 0.0556301, -0.203977, 1.0569715); function aC() { let n17 = { enabled: true, workingColorSpace: Fr, spaces: {}, convert: function(r, i, s) { return this.enabled === false || i === s || !i || !s || (this.spaces[i].transfer === ce && (r.r = wn(r.r), r.g = wn(r.g), r.b = wn(r.b)), this.spaces[i].primaries !== this.spaces[s].primaries && (r.applyMatrix3(this.spaces[i].toXYZ), r.applyMatrix3(this.spaces[s].fromXYZ)), this.spaces[s].transfer === ce && (r.r = ai(r.r), r.g = ai(r.g), r.b = ai(r.b))), r; }, workingToColorSpace: function(r, i) { return this.convert(r, this.workingColorSpace, i); }, colorSpaceToWorking: function(r, i) { return this.convert(r, i, this.workingColorSpace); }, getPrimaries: function(r) { return this.spaces[r].primaries; }, getTransfer: function(r) { return r === xn ? as : this.spaces[r].transfer; }, getLuminanceCoefficients: function(r, i = this.workingColorSpace) { return r.fromArray(this.spaces[i].luminanceCoefficients); }, define: function(r) { Object.assign(this.spaces, r); }, _getMatrix: function(r, i, s) { return r.copy(this.spaces[i].toXYZ).multiply(this.spaces[s].fromXYZ); }, _getDrawingBufferColorSpace: function(r) { return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace; }, _getUnpackColorSpace: function(r = this.workingColorSpace) { return this.spaces[r].workingColorSpaceConfig.unpackColorSpace; }, fromWorkingColorSpace: function(r, i) { return Er("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."), n17.workingToColorSpace(r, i); }, toWorkingColorSpace: function(r, i) { return Er("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."), n17.colorSpaceToWorking(r, i); } }, A = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], e = [0.2126, 0.7152, 0.0722], t = [0.3127, 0.329]; return n17.define({ [Fr]: { primaries: A, whitePoint: t, transfer: as, toXYZ: Yd, fromXYZ: Zd, luminanceCoefficients: e, workingColorSpaceConfig: { unpackColorSpace: pt }, outputColorSpaceConfig: { drawingBufferColorSpace: pt } }, [pt]: { primaries: A, whitePoint: t, transfer: ce, toXYZ: Yd, fromXYZ: Zd, luminanceCoefficients: e, outputColorSpaceConfig: { drawingBufferColorSpace: pt } } }), n17; } var te = aC(); function wn(n17) { return n17 < 0.04045 ? n17 * 0.0773993808 : Math.pow(n17 * 0.9478672986 + 0.0521327014, 2.4); } function ai(n17) { return n17 < 31308e-7 ? n17 * 12.92 : 1.055 * Math.pow(n17, 0.41666) - 0.055; } var Yr; var ho = class { static getDataURL(A, e = "image/png") { if (/^data:/i.test(A.src) || typeof HTMLCanvasElement > "u") return A.src; let t; if (A instanceof HTMLCanvasElement) t = A; else { Yr === void 0 && (Yr = cs("canvas")), Yr.width = A.width, Yr.height = A.height; let r = Yr.getContext("2d"); A instanceof ImageData ? r.putImageData(A, 0, 0) : r.drawImage(A, 0, 0, A.width, A.height), t = Yr; } return t.toDataURL(e); } static sRGBToLinear(A) { if (typeof HTMLImageElement < "u" && A instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && A instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && A instanceof ImageBitmap) { let e = cs("canvas"); e.width = A.width, e.height = A.height; let t = e.getContext("2d"); t.drawImage(A, 0, 0, A.width, A.height); let r = t.getImageData(0, 0, A.width, A.height), i = r.data; for (let s = 0; s < i.length; s++) i[s] = wn(i[s] / 255) * 255; return t.putImageData(r, 0, 0), e; } else if (A.data) { let e = A.data.slice(0); for (let t = 0; t < e.length; t++) e instanceof Uint8Array || e instanceof Uint8ClampedArray ? e[t] = Math.floor(wn(e[t] / 255) * 255) : e[t] = wn(e[t]); return { data: e, width: A.width, height: A.height }; } else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), A; } }; var oC = 0; var ci = class { constructor(A = null) { this.isSource = true, Object.defineProperty(this, "id", { value: oC++ }), this.uuid = Ui(), this.data = A, this.dataReady = true, this.version = 0; } getSize(A) { let e = this.data; return e instanceof HTMLVideoElement ? A.set(e.videoWidth, e.videoHeight) : e !== null ? A.set(e.width, e.height, e.depth || 0) : A.set(0, 0, 0), A; } set needsUpdate(A) { A === true && this.version++; } toJSON(A) { let e = A === void 0 || typeof A == "string"; if (!e && A.images[this.uuid] !== void 0) return A.images[this.uuid]; let t = { uuid: this.uuid, url: "" }, r = this.data; if (r !== null) { let i; if (Array.isArray(r)) { i = []; for (let s = 0, a = r.length; s < a; s++) r[s].isDataTexture ? i.push(vu(r[s].image)) : i.push(vu(r[s])); } else i = vu(r); t.url = i; } return e || (A.images[this.uuid] = t), t; } }; function vu(n17) { return typeof HTMLImageElement < "u" && n17 instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && n17 instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && n17 instanceof ImageBitmap ? ho.getDataURL(n17) : n17.data ? { data: Array.from(n17.data), width: n17.width, height: n17.height, type: n17.data.constructor.name } : (console.warn("THREE.Texture: Unable to serialize Texture."), {}); } var cC = 0; var Uu = new R(); var ot = class n4 extends vn { constructor(A = n4.DEFAULT_IMAGE, e = n4.DEFAULT_MAPPING, t = Kt, r = Kt, i = Gt, s = Wn, a = Qt, o = en, c = n4.DEFAULT_ANISOTROPY, l = xn) { super(), this.isTexture = true, Object.defineProperty(this, "id", { value: cC++ }), this.uuid = Ui(), this.name = "", this.source = new ci(A), this.mipmaps = [], this.mapping = e, this.channel = 0, this.wrapS = t, this.wrapT = r, this.magFilter = i, this.minFilter = s, this.anisotropy = c, this.format = a, this.internalFormat = null, this.type = o, this.offset = new wA(0, 0), this.repeat = new wA(1, 1), this.center = new wA(0, 0), this.rotation = 0, this.matrixAutoUpdate = true, this.matrix = new WA(), this.generateMipmaps = true, this.premultiplyAlpha = false, this.flipY = true, this.unpackAlignment = 4, this.colorSpace = l, this.userData = {}, this.updateRanges = [], this.version = 0, this.onUpdate = null, this.renderTarget = null, this.isRenderTargetTexture = false, this.isArrayTexture = !!(A && A.depth && A.depth > 1), this.pmremVersion = 0; } get width() { return this.source.getSize(Uu).x; } get height() { return this.source.getSize(Uu).y; } get depth() { return this.source.getSize(Uu).z; } get image() { return this.source.data; } set image(A = null) { this.source.data = A; } updateMatrix() { this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y); } addUpdateRange(A, e) { this.updateRanges.push({ start: A, count: e }); } clearUpdateRanges() { this.updateRanges.length = 0; } clone() { return new this.constructor().copy(this); } copy(A) { return this.name = A.name, this.source = A.source, this.mipmaps = A.mipmaps.slice(0), this.mapping = A.mapping, this.channel = A.channel, this.wrapS = A.wrapS, this.wrapT = A.wrapT, this.magFilter = A.magFilter, this.minFilter = A.minFilter, this.anisotropy = A.anisotropy, this.format = A.format, this.internalFormat = A.internalFormat, this.type = A.type, this.offset.copy(A.offset), this.repeat.copy(A.repeat), this.center.copy(A.center), this.rotation = A.rotation, this.matrixAutoUpdate = A.matrixAutoUpdate, this.matrix.copy(A.matrix), this.generateMipmaps = A.generateMipmaps, this.premultiplyAlpha = A.premultiplyAlpha, this.flipY = A.flipY, this.unpackAlignment = A.unpackAlignment, this.colorSpace = A.colorSpace, this.renderTarget = A.renderTarget, this.isRenderTargetTexture = A.isRenderTargetTexture, this.isArrayTexture = A.isArrayTexture, this.userData = JSON.parse(JSON.stringify(A.userData)), this.needsUpdate = true, this; } setValues(A) { for (let e in A) { let t = A[e]; if (t === void 0) { console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`); continue; } let r = this[e]; if (r === void 0) { console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`); continue; } r && t && r.isVector2 && t.isVector2 || r && t && r.isVector3 && t.isVector3 || r && t && r.isMatrix3 && t.isMatrix3 ? r.copy(t) : this[e] = t; } } toJSON(A) { let e = A === void 0 || typeof A == "string"; if (!e && A.textures[this.uuid] !== void 0) return A.textures[this.uuid]; let t = { metadata: { version: 4.7, type: "Texture", generator: "Texture.toJSON" }, uuid: this.uuid, name: this.name, image: this.source.toJSON(A).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 && (t.userData = this.userData), e || (A.textures[this.uuid] = t), t; } dispose() { this.dispatchEvent({ type: "dispose" }); } transformUv(A) { if (this.mapping !== ih) return A; if (A.applyMatrix3(this.matrix), A.x < 0 || A.x > 1) switch (this.wrapS) { case oo: A.x = A.x - Math.floor(A.x); break; case Kt: A.x = A.x < 0 ? 0 : 1; break; case co: Math.abs(Math.floor(A.x) % 2) === 1 ? A.x = Math.ceil(A.x) - A.x : A.x = A.x - Math.floor(A.x); break; } if (A.y < 0 || A.y > 1) switch (this.wrapT) { case oo: A.y = A.y - Math.floor(A.y); break; case Kt: A.y = A.y < 0 ? 0 : 1; break; case co: Math.abs(Math.floor(A.y) % 2) === 1 ? A.y = Math.ceil(A.y) - A.y : A.y = A.y - Math.floor(A.y); break; } return this.flipY && (A.y = 1 - A.y), A; } set needsUpdate(A) { A === true && (this.version++, this.source.needsUpdate = true); } set needsPMREMUpdate(A) { A === true && this.pmremVersion++; } }; ot.DEFAULT_IMAGE = null; ot.DEFAULT_MAPPING = ih; ot.DEFAULT_ANISOTROPY = 1; var ye = class n5 { constructor(A = 0, e = 0, t = 0, r = 1) { n5.prototype.isVector4 = true, this.x = A, this.y = e, this.z = t, this.w = r; } get width() { return this.z; } set width(A) { this.z = A; } get height() { return this.w; } set height(A) { this.w = A; } set(A, e, t, r) { return this.x = A, this.y = e, this.z = t, this.w = r, this; } setScalar(A) { return this.x = A, this.y = A, this.z = A, this.w = A, this; } setX(A) { return this.x = A, this; } setY(A) { return this.y = A, this; } setZ(A) { return this.z = A, this; } setW(A) { return this.w = A, this; } setComponent(A, e) { switch (A) { case 0: this.x = e; break; case 1: this.y = e; break; case 2: this.z = e; break; case 3: this.w = e; break; default: throw new Error("index is out of range: " + A); } return this; } getComponent(A) { switch (A) { 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: " + A); } } clone() { return new this.constructor(this.x, this.y, this.z, this.w); } copy(A) { return this.x = A.x, this.y = A.y, this.z = A.z, this.w = A.w !== void 0 ? A.w : 1, this; } add(A) { return this.x += A.x, this.y += A.y, this.z += A.z, this.w += A.w, this; } addScalar(A) { return this.x += A, this.y += A, this.z += A, this.w += A, this; } addVectors(A, e) { return this.x = A.x + e.x, this.y = A.y + e.y, this.z = A.z + e.z, this.w = A.w + e.w, this; } addScaledVector(A, e) { return this.x += A.x * e, this.y += A.y * e, this.z += A.z * e, this.w += A.w * e, this; } sub(A) { return this.x -= A.x, this.y -= A.y, this.z -= A.z, this.w -= A.w, this; } subScalar(A) { return this.x -= A, this.y -= A, this.z -= A, this.w -= A, this; } subVectors(A, e) { return this.x = A.x - e.x, this.y = A.y - e.y, this.z = A.z - e.z, this.w = A.w - e.w, this; } multiply(A) { return this.x *= A.x, this.y *= A.y, this.z *= A.z, this.w *= A.w, this; } multiplyScalar(A) { return this.x *= A, this.y *= A, this.z *= A, this.w *= A, this; } applyMatrix4(A) { let e = this.x, t = this.y, r = this.z, i = this.w, s = A.elements; return this.x = s[0] * e + s[4] * t + s[8] * r + s[12] * i, this.y = s[1] * e + s[5] * t + s[9] * r + s[13] * i, this.z = s[2] * e + s[6] * t + s[10] * r + s[14] * i, this.w = s[3] * e + s[7] * t + s[11] * r + s[15] * i, this; } divide(A) { return this.x /= A.x, this.y /= A.y, this.z /= A.z, this.w /= A.w, this; } divideScalar(A) { return this.multiplyScalar(1 / A); } setAxisAngleFromQuaternion(A) { this.w = 2 * Math.acos(A.w); let e = Math.sqrt(1 - A.w * A.w); return e < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = A.x / e, this.y = A.y / e, this.z = A.z / e), this; } setAxisAngleFromRotationMatrix(A) { let e, t, r, i, o = A.elements, c = o[0], l = o[4], u = o[8], h = o[1], d = o[5], g = o[9], B = o[2], p = o[6], f = o[10]; if (Math.abs(l - h) < 0.01 && Math.abs(u - B) < 0.01 && Math.abs(g - p) < 0.01) { if (Math.abs(l + h) < 0.1 && Math.abs(u + B) < 0.1 && Math.abs(g + p) < 0.1 && Math.abs(c + d + f - 3) < 0.1) return this.set(1, 0, 0, 0), this; e = Math.PI; let y = (c + 1) / 2, m = (d + 1) / 2, S = (f + 1) / 2, F = (l + h) / 4, x = (u + B) / 4, M = (g + p) / 4; return y > m && y > S ? y < 0.01 ? (t = 0, r = 0.707106781, i = 0.707106781) : (t = Math.sqrt(y), r = F / t, i = x / t) : m > S ? m < 0.01 ? (t = 0.707106781, r = 0, i = 0.707106781) : (r = Math.sqrt(m), t = F / r, i = M / r) : S < 0.01 ? (t = 0.707106781, r = 0.707106781, i = 0) : (i = Math.sqrt(S), t = x / i, r = M / i), this.set(t, r, i, e), this; } let U = Math.sqrt((p - g) * (p - g) + (u - B) * (u - B) + (h - l) * (h - l)); return Math.abs(U) < 1e-3 && (U = 1), this.x = (p - g) / U, this.y = (u - B) / U, this.z = (h - l) / U, this.w = Math.acos((c + d + f - 1) / 2), this; } setFromMatrixPosition(A) { let e = A.elements; return this.x = e[12], this.y = e[13], this.z = e[14], this.w = e[15], this; } min(A) { return this.x = Math.min(this.x, A.x), this.y = Math.min(this.y, A.y), this.z = Math.min(this.z, A.z), this.w = Math.min(this.w, A.w), this; } max(A) { return this.x = Math.max(this.x, A.x), this.y = Math.max(this.y, A.y), this.z = Math.max(this.z, A.z), this.w = Math.max(this.w, A.w), this; } clamp(A, e) { return this.x = YA(this.x, A.x, e.x), this.y = YA(this.y, A.y, e.y), this.z = YA(this.z, A.z, e.z), this.w = YA(this.w, A.w, e.w), this; } clampScalar(A, e) { return this.x = YA(this.x, A, e), this.y = YA(this.y, A, e), this.z = YA(this.z, A, e), this.w = YA(this.w, A, e), this; } clampLength(A, e) { let t = this.length(); return this.divideScalar(t || 1).multiplyScalar(YA(t, A, e)); } 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.