var vu = "180", Ui = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }, Ni = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, _u = 0, dl = 1, Su = 2; var fl = 1, Fo = 2, qn = 3, Fi = 0, Gt = 1, Yt = 2, Oi = 0, Ur = 1, pl = 2, ml = 3, gl = 4, bu = 5, qs = 100, Mu = 101, wu = 102, Tu = 103, Eu = 104, Au = 200, Ru = 201, Lu = 202, Cu = 203, Iu = 204, Pu = 205, Du = 206, Uu = 207, Nu = 208, Fu = 209, Ou = 210, ku = 211, zu = 212, Hu = 213, Bu = 214, Oo = 0, ko = 1, zo = 2, Nr = 3, Ho = 4, Bo = 5, Go = 6, Vo = 7, Gu = 0, Vu = 1, Wu = 2, mi = 0, Xu = 1, qu = 2, Yu = 3, Ys = 4, ju = 5, Wo = 6, Fr = 7; var js = 301, us = 302, Zs = 303, Xo = 304, Or = 306, On = 1000, ds = 1001, qo = 1002, gi = 1003, Yo = 1004; var fs = 1005; var kn = 1006, Ks = 1007; var yi = 1008; var ki = 1009, Zu = 1010, Ku = 1011, kr = 1012, yl = 1013, $s = 1014, zi = 1015, zr = 1016, xl = 1017, vl = 1018, Js = 1020, $u = 35902, Ju = 35899, Qu = 1021, ed = 1022, Yn = 1023, jo = 1026, Hr = 1027, td = 1028, _l = 1029, nd = 1030, Sl = 1031; var bl = 1033, Zo = 33776, Ko = 33777, $o = 33778, Jo = 33779, Ml = 35840, wl = 35841, Tl = 35842, El = 35843, Al = 36196, Rl = 37492, Ll = 37496, Cl = 37808, Il = 37809, Pl = 37810, Dl = 37811, Ul = 37812, Nl = 37813, Fl = 37814, Ol = 37815, kl = 37816, zl = 37817, Hl = 37818, Bl = 37819, Gl = 37820, Vl = 37821, Wl = 36492, Xl = 36494, ql = 36495, Yl = 36283, jl = 36284, Zl = 36285, Kl = 36286; var $l = 2201; var Jl = 2300, Qo = 2301; var Ql = 0, Br = 1, Qs = 2; var id = 3201; var sd = 0, rd = 1, xi = "", lt = "srgb", Ut = "srgb-linear", ec = "linear", xt = "srgb"; var od = 512, ad = 513, ld = 514, tc = 515, cd = 516, hd = 517, ud = 518, dd = 519; var nc = "300 es", ic = 2000; class jn { addEventListener(e, t) { if (this._listeners === void 0) this._listeners = {}; let n = this._listeners; if (n[e] === void 0) n[e] = []; if (n[e].indexOf(t) === -1) n[e].push(t); } hasEventListener(e, t) { let n = this._listeners; if (n === void 0) return !1; return n[e] !== void 0 && n[e].indexOf(t) !== -1; } removeEventListener(e, t) { let n = this._listeners; if (n === void 0) return; let i = n[e]; if (i !== void 0) { let s = i.indexOf(t); if (s !== -1) i.splice(s, 1); } } dispatchEvent(e) { let t = this._listeners; if (t === void 0) return; let n = t[e.type]; if (n !== void 0) { e.target = this; let i = n.slice(0); for (let s = 0, r = i.length; s < r; s++) i[s].call(this, e); e.target = null; } } } var Xt = [ "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", ], Ph = 1234567, Lr = Math.PI / 180, ls = 180 / Math.PI; function Un() { let e = (Math.random() * 4294967295) | 0, t = (Math.random() * 4294967295) | 0, n = (Math.random() * 4294967295) | 0, i = (Math.random() * 4294967295) | 0; return ( Xt[e & 255] + Xt[(e >> 8) & 255] + Xt[(e >> 16) & 255] + Xt[(e >> 24) & 255] + "-" + Xt[t & 255] + Xt[(t >> 8) & 255] + "-" + Xt[((t >> 16) & 15) | 64] + Xt[(t >> 24) & 255] + "-" + Xt[(n & 63) | 128] + Xt[(n >> 8) & 255] + "-" + Xt[(n >> 16) & 255] + Xt[(n >> 24) & 255] + Xt[i & 255] + Xt[(i >> 8) & 255] + Xt[(i >> 16) & 255] + Xt[(i >> 24) & 255] ).toLowerCase(); } function qe(e, t, n) { return Math.max(t, Math.min(n, e)); } function sc(e, t) { return ((e % t) + t) % t; } function Jp(e, t, n, i, s) { return i + ((e - t) * (s - i)) / (n - t); } function Qp(e, t, n) { if (e !== t) return (n - e) / (t - e); else return 0; } function Cr(e, t, n) { return (1 - n) * e + n * t; } function em(e, t, n, i) { return Cr(e, t, 1 - Math.exp(-n * i)); } function tm(e, t = 1) { return t - Math.abs(sc(e, t * 2) - t); } function nm(e, t, n) { if (e <= t) return 0; if (e >= n) return 1; return ((e = (e - t) / (n - t)), e * e * (3 - 2 * e)); } function im(e, t, n) { if (e <= t) return 0; if (e >= n) return 1; return ((e = (e - t) / (n - t)), e * e * e * (e * (e * 6 - 15) + 10)); } function sm(e, t) { return e + Math.floor(Math.random() * (t - e + 1)); } function rm(e, t) { return e + Math.random() * (t - e); } function om(e) { return e * (0.5 - Math.random()); } function am(e) { if (e !== void 0) Ph = e; let t = (Ph += 1831565813); return ( (t = Math.imul(t ^ (t >>> 15), t | 1)), (t ^= t + Math.imul(t ^ (t >>> 7), t | 61)), ((t ^ (t >>> 14)) >>> 0) / 4294967296 ); } function lm(e) { return e * Lr; } function cm(e) { return e * ls; } function hm(e) { return (e & (e - 1)) === 0 && e !== 0; } function um(e) { return Math.pow(2, Math.ceil(Math.log(e) / Math.LN2)); } function dm(e) { return Math.pow(2, Math.floor(Math.log(e) / Math.LN2)); } function fm(e, t, n, i, s) { let { cos: r, sin: o } = Math, a = r(n / 2), l = o(n / 2), c = r((t + i) / 2), h = o((t + i) / 2), u = r((t - i) / 2), d = o((t - i) / 2), f = r((i - t) / 2), m = o((i - t) / 2); switch (s) { case "XYX": e.set(a * h, l * u, l * d, a * c); break; case "YZY": e.set(l * d, a * h, l * u, a * c); break; case "ZXZ": e.set(l * u, l * d, a * h, a * c); break; case "XZX": e.set(a * h, l * m, l * f, a * c); break; case "YXY": e.set(l * f, a * h, l * m, a * c); break; case "ZYZ": e.set(l * m, l * f, a * h, a * c); break; default: console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + s); } } function Dn(e, t) { switch (t.constructor) { case Float32Array: return e; case Uint32Array: return e / 4294967295; case Uint16Array: return e / 65535; case Uint8Array: return e / 255; case Int32Array: return Math.max(e / 2147483647, -1); case Int16Array: return Math.max(e / 32767, -1); case Int8Array: return Math.max(e / 127, -1); default: throw Error("Invalid component type."); } } function ct(e, t) { switch (t.constructor) { case Float32Array: return e; case Uint32Array: return Math.round(e * 4294967295); case Uint16Array: return Math.round(e * 65535); case Uint8Array: return Math.round(e * 255); case Int32Array: return Math.round(e * 2147483647); case Int16Array: return Math.round(e * 32767); case Int8Array: return Math.round(e * 127); default: throw Error("Invalid component type."); } } var bt = { DEG2RAD: Lr, RAD2DEG: ls, generateUUID: Un, clamp: qe, euclideanModulo: sc, mapLinear: Jp, inverseLerp: Qp, lerp: Cr, damp: em, pingpong: tm, smoothstep: nm, smootherstep: im, randInt: sm, randFloat: rm, randFloatSpread: om, seededRandom: am, degToRad: lm, radToDeg: cm, isPowerOfTwo: hm, ceilPowerOfTwo: um, floorPowerOfTwo: dm, setQuaternionFromProperEuler: fm, normalize: ct, denormalize: Dn, }; class ve { constructor(e = 0, t = 0) { ((ve.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 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 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) { let 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 = qe(this.x, e.x, t.x)), (this.y = qe(this.y, e.y, t.y)), this); } clampScalar(e, t) { return ((this.x = qe(this.x, e, t)), (this.y = qe(this.y, e, t)), this); } clampLength(e, t) { let n = this.length(); return this.divideScalar(n || 1).multiplyScalar(qe(n, e, t)); } 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) { let t = Math.sqrt(this.lengthSq() * e.lengthSq()); if (t === 0) return Math.PI / 2; let n = this.dot(e) / t; return Math.acos(qe(n, -1, 1)); } distanceTo(e) { return Math.sqrt(this.distanceToSquared(e)); } distanceToSquared(e) { let 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) { let n = Math.cos(t), i = Math.sin(t), s = this.x - e.x, r = this.y - e.y; return ((this.x = s * n - r * i + e.x), (this.y = s * i + r * n + e.y), this); } random() { return ((this.x = Math.random()), (this.y = Math.random()), this); } *[Symbol.iterator]() { (yield this.x, yield this.y); } } class Ne { 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, s, r, o) { let a = n[i + 0], l = n[i + 1], c = n[i + 2], h = n[i + 3], u = s[r + 0], d = s[r + 1], f = s[r + 2], m = s[r + 3]; if (o === 0) { ((e[t + 0] = a), (e[t + 1] = l), (e[t + 2] = c), (e[t + 3] = h)); return; } if (o === 1) { ((e[t + 0] = u), (e[t + 1] = d), (e[t + 2] = f), (e[t + 3] = m)); return; } if (h !== m || a !== u || l !== d || c !== f) { let y = 1 - o, p = a * u + l * d + c * f + h * m, g = p >= 0 ? 1 : -1, _ = 1 - p * p; if (_ > Number.EPSILON) { let w = Math.sqrt(_), L = Math.atan2(w, p * g); ((y = Math.sin(y * L) / w), (o = Math.sin(o * L) / w)); } let x = o * g; if (((a = a * y + u * x), (l = l * y + d * x), (c = c * y + f * x), (h = h * y + m * x), y === 1 - o)) { let w = 1 / Math.sqrt(a * a + l * l + c * c + h * h); ((a *= w), (l *= w), (c *= w), (h *= w)); } } ((e[t] = a), (e[t + 1] = l), (e[t + 2] = c), (e[t + 3] = h)); } static multiplyQuaternionsFlat(e, t, n, i, s, r) { let o = n[i], a = n[i + 1], l = n[i + 2], c = n[i + 3], h = s[r], u = s[r + 1], d = s[r + 2], f = s[r + 3]; return ( (e[t] = o * f + c * h + a * d - l * u), (e[t + 1] = a * f + c * u + l * h - o * d), (e[t + 2] = l * f + c * d + o * u - a * h), (e[t + 3] = c * f - o * h - a * u - l * d), 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) { let { _x: n, _y: i, _z: s, _order: r } = e, { cos: o, sin: a } = Math, l = o(n / 2), c = o(i / 2), h = o(s / 2), u = a(n / 2), d = a(i / 2), f = a(s / 2); switch (r) { case "XYZ": ((this._x = u * c * h + l * d * f), (this._y = l * d * h - u * c * f), (this._z = l * c * f + u * d * h), (this._w = l * c * h - u * d * f)); break; case "YXZ": ((this._x = u * c * h + l * d * f), (this._y = l * d * h - u * c * f), (this._z = l * c * f - u * d * h), (this._w = l * c * h + u * d * f)); break; case "ZXY": ((this._x = u * c * h - l * d * f), (this._y = l * d * h + u * c * f), (this._z = l * c * f + u * d * h), (this._w = l * c * h - u * d * f)); break; case "ZYX": ((this._x = u * c * h - l * d * f), (this._y = l * d * h + u * c * f), (this._z = l * c * f - u * d * h), (this._w = l * c * h + u * d * f)); break; case "YZX": ((this._x = u * c * h + l * d * f), (this._y = l * d * h + u * c * f), (this._z = l * c * f - u * d * h), (this._w = l * c * h - u * d * f)); break; case "XZY": ((this._x = u * c * h - l * d * f), (this._y = l * d * h - u * c * f), (this._z = l * c * f + u * d * h), (this._w = l * c * h + u * d * f)); break; default: console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + r); } if (t === !0) this._onChangeCallback(); return this; } setFromAxisAngle(e, t) { let 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) { let t = e.elements, n = t[0], i = t[4], s = t[8], r = t[1], o = t[5], a = t[9], l = t[2], c = t[6], h = t[10], u = n + o + h; if (u > 0) { let d = 0.5 / Math.sqrt(u + 1); ((this._w = 0.25 / d), (this._x = (c - a) * d), (this._y = (s - l) * d), (this._z = (r - i) * d)); } else if (n > o && n > h) { let d = 2 * Math.sqrt(1 + n - o - h); ((this._w = (c - a) / d), (this._x = 0.25 * d), (this._y = (i + r) / d), (this._z = (s + l) / d)); } else if (o > h) { let d = 2 * Math.sqrt(1 + o - n - h); ((this._w = (s - l) / d), (this._x = (i + r) / d), (this._y = 0.25 * d), (this._z = (a + c) / d)); } else { let d = 2 * Math.sqrt(1 + h - n - o); ((this._w = (r - i) / d), (this._x = (s + l) / d), (this._y = (a + c) / d), (this._z = 0.25 * d)); } return (this._onChangeCallback(), this); } setFromUnitVectors(e, t) { let n = e.dot(t) + 1; if (n < 0.00000001) if (((n = 0), Math.abs(e.x) > Math.abs(e.z))) ((this._x = -e.y), (this._y = e.x), (this._z = 0), (this._w = n)); else ((this._x = 0), (this._y = -e.z), (this._z = e.y), (this._w = n)); else ((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)); return this.normalize(); } angleTo(e) { return 2 * Math.acos(Math.abs(qe(this.dot(e), -1, 1))); } rotateTowards(e, t) { let n = this.angleTo(e); if (n === 0) return this; let 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(); if (e === 0) ((this._x = 0), (this._y = 0), (this._z = 0), (this._w = 1)); else ((e = 1 / e), (this._x = this._x * e), (this._y = this._y * e), (this._z = this._z * e), (this._w = this._w * e)); return (this._onChangeCallback(), this); } multiply(e) { return this.multiplyQuaternions(this, e); } premultiply(e) { return this.multiplyQuaternions(e, this); } multiplyQuaternions(e, t) { let { _x: n, _y: i, _z: s, _w: r } = e, { _x: o, _y: a, _z: l, _w: c } = t; return ( (this._x = n * c + r * o + i * l - s * a), (this._y = i * c + r * a + s * o - n * l), (this._z = s * c + r * l + n * a - i * o), (this._w = r * c - n * o - i * a - s * l), this._onChangeCallback(), this ); } slerp(e, t) { if (t === 0) return this; if (t === 1) return this.copy(e); let n = this._x, i = this._y, s = this._z, r = this._w, o = r * e._w + n * e._x + i * e._y + s * e._z; if (o < 0) ((this._w = -e._w), (this._x = -e._x), (this._y = -e._y), (this._z = -e._z), (o = -o)); else this.copy(e); if (o >= 1) return ((this._w = r), (this._x = n), (this._y = i), (this._z = s), this); let a = 1 - o * o; if (a <= Number.EPSILON) { let d = 1 - t; return ( (this._w = d * r + t * this._w), (this._x = d * n + t * this._x), (this._y = d * i + t * this._y), (this._z = d * s + t * this._z), this.normalize(), this ); } let l = Math.sqrt(a), c = Math.atan2(l, o), h = Math.sin((1 - t) * c) / l, u = Math.sin(t * c) / l; return ( (this._w = r * h + this._w * u), (this._x = n * h + this._x * u), (this._y = i * h + this._y * u), (this._z = s * h + this._z * u), this._onChangeCallback(), this ); } slerpQuaternions(e, t, n) { return this.copy(e).slerp(t, n); } random() { let e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), n = Math.random(), i = Math.sqrt(1 - n), s = Math.sqrt(n); return this.set(i * Math.sin(e), i * Math.cos(e), s * Math.sin(t), s * 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) { if (n === void 0) n = this.z; return ((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 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 Error("index is out of range: " + e); } } clone() { return new this.constructor(this.x, this.y, this.z); } copy(e) { return ((this.x = e.x), (this.y = e.y), (this.z = e.z), this); } add(e) { return ((this.x += e.x), (this.y += e.y), (this.z += e.z), this); } addScalar(e) { return ((this.x += e), (this.y += e), (this.z += 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); } addScaledVector(e, t) { return ((this.x += e.x * t), (this.y += e.y * t), (this.z += e.z * t), this); } sub(e) { return ((this.x -= e.x), (this.y -= e.y), (this.z -= e.z), this); } subScalar(e) { return ((this.x -= e), (this.y -= e), (this.z -= 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); } multiply(e) { return ((this.x *= e.x), (this.y *= e.y), (this.z *= e.z), this); } multiplyScalar(e) { return ((this.x *= e), (this.y *= e), (this.z *= e), this); } multiplyVectors(e, t) { return ((this.x = e.x * t.x), (this.y = e.y * t.y), (this.z = e.z * t.z), this); } applyEuler(e) { return this.applyQuaternion(Dh.setFromEuler(e)); } applyAxisAngle(e, t) { return this.applyQuaternion(Dh.setFromAxisAngle(e, t)); } applyMatrix3(e) { let t = this.x, n = this.y, i = this.z, s = e.elements; return ( (this.x = s[0] * t + s[3] * n + s[6] * i), (this.y = s[1] * t + s[4] * n + s[7] * i), (this.z = s[2] * t + s[5] * n + s[8] * i), this ); } applyNormalMatrix(e) { return this.applyMatrix3(e).normalize(); } applyMatrix4(e) { let t = this.x, n = this.y, i = this.z, s = e.elements, r = 1 / (s[3] * t + s[7] * n + s[11] * i + s[15]); return ( (this.x = (s[0] * t + s[4] * n + s[8] * i + s[12]) * r), (this.y = (s[1] * t + s[5] * n + s[9] * i + s[13]) * r), (this.z = (s[2] * t + s[6] * n + s[10] * i + s[14]) * r), this ); } applyQuaternion(e) { let t = this.x, n = this.y, i = this.z, { x: s, y: r, z: o, w: a } = e, l = 2 * (r * i - o * n), c = 2 * (o * t - s * i), h = 2 * (s * n - r * t); return ( (this.x = t + a * l + r * h - o * c), (this.y = n + a * c + o * l - s * h), (this.z = i + a * h + s * c - r * l), this ); } project(e) { return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix); } unproject(e) { return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld); } transformDirection(e) { let t = this.x, n = this.y, i = this.z, s = e.elements; return ( (this.x = s[0] * t + s[4] * n + s[8] * i), (this.y = s[1] * t + s[5] * n + s[9] * i), (this.z = s[2] * t + s[6] * n + s[10] * i), this.normalize() ); } divide(e) { return ((this.x /= e.x), (this.y /= e.y), (this.z /= e.z), this); } divideScalar(e) { return this.multiplyScalar(1 / e); } 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); } 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); } clamp(e, t) { return ((this.x = qe(this.x, e.x, t.x)), (this.y = qe(this.y, e.y, t.y)), (this.z = qe(this.z, e.z, t.z)), this); } clampScalar(e, t) { return ((this.x = qe(this.x, e, t)), (this.y = qe(this.y, e, t)), (this.z = qe(this.z, e, t)), this); } clampLength(e, t) { let n = this.length(); return this.divideScalar(n || 1).multiplyScalar(qe(n, e, t)); } 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(e) { return this.x * e.x + this.y * e.y + this.z * e.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(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); } 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); } cross(e) { return this.crossVectors(this, e); } crossVectors(e, t) { let { x: n, y: i, z: s } = e, { x: r, y: o, z: a } = t; return ((this.x = i * a - s * o), (this.y = s * r - n * a), (this.z = n * o - i * r), this); } projectOnVector(e) { let t = e.lengthSq(); if (t === 0) return this.set(0, 0, 0); let n = e.dot(this) / t; return this.copy(e).multiplyScalar(n); } projectOnPlane(e) { return (Na.copy(this).projectOnVector(e), this.sub(Na)); } reflect(e) { return this.sub(Na.copy(e).multiplyScalar(2 * this.dot(e))); } angleTo(e) { let t = Math.sqrt(this.lengthSq() * e.lengthSq()); if (t === 0) return Math.PI / 2; let n = this.dot(e) / t; return Math.acos(qe(n, -1, 1)); } distanceTo(e) { return Math.sqrt(this.distanceToSquared(e)); } distanceToSquared(e) { let t = this.x - e.x, n = this.y - e.y, i = this.z - e.z; return t * t + n * n + i * i; } manhattanDistanceTo(e) { return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z); } setFromSpherical(e) { return this.setFromSphericalCoords(e.radius, e.phi, e.theta); } setFromSphericalCoords(e, t, n) { let i = Math.sin(t) * e; return ((this.x = i * Math.sin(n)), (this.y = Math.cos(t) * e), (this.z = i * Math.cos(n)), this); } setFromCylindrical(e) { return this.setFromCylindricalCoords(e.radius, e.theta, e.y); } setFromCylindricalCoords(e, t, n) { return ((this.x = e * Math.sin(t)), (this.y = n), (this.z = e * Math.cos(t)), this); } setFromMatrixPosition(e) { let t = e.elements; return ((this.x = t[12]), (this.y = t[13]), (this.z = t[14]), this); } setFromMatrixScale(e) { let t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), i = this.setFromMatrixColumn(e, 2).length(); return ((this.x = t), (this.y = n), (this.z = i), this); } setFromMatrixColumn(e, t) { return this.fromArray(e.elements, t * 4); } setFromMatrix3Column(e, t) { return this.fromArray(e.elements, t * 3); } setFromEuler(e) { return ((this.x = e._x), (this.y = e._y), (this.z = e._z), this); } setFromColor(e) { return ((this.x = e.r), (this.y = e.g), (this.z = e.b), this); } equals(e) { return e.x === this.x && e.y === this.y && e.z === this.z; } fromArray(e, t = 0) { return ((this.x = e[t]), (this.y = e[t + 1]), (this.z = e[t + 2]), this); } toArray(e = [], t = 0) { return ((e[t] = this.x), (e[t + 1] = this.y), (e[t + 2] = this.z), e); } fromBufferAttribute(e, t) { return ((this.x = e.getX(t)), (this.y = e.getY(t)), (this.z = e.getZ(t)), this); } random() { return ((this.x = Math.random()), (this.y = Math.random()), (this.z = Math.random()), this); } randomDirection() { let e = Math.random() * Math.PI * 2, t = Math.random() * 2 - 1, n = Math.sqrt(1 - t * t); return ((this.x = n * Math.cos(e)), (this.y = t), (this.z = n * Math.sin(e)), this); } *[Symbol.iterator]() { (yield this.x, yield this.y, yield this.z); } } var Na = new E(), Dh = new Ne(); class Be { constructor(e, t, n, i, s, r, o, a, l) { if (((Be.prototype.isMatrix3 = !0), (this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1]), e !== void 0)) this.set(e, t, n, i, s, r, o, a, l); } set(e, t, n, i, s, r, o, a, l) { let c = this.elements; return ( (c[0] = e), (c[1] = i), (c[2] = o), (c[3] = t), (c[4] = s), (c[5] = a), (c[6] = n), (c[7] = r), (c[8] = l), this ); } identity() { return (this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this); } copy(e) { let 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) { let 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) { let n = e.elements, i = t.elements, s = this.elements, r = n[0], o = n[3], a = n[6], l = n[1], c = n[4], h = n[7], u = n[2], d = n[5], f = n[8], m = i[0], y = i[3], p = i[6], g = i[1], _ = i[4], x = i[7], w = i[2], L = i[5], b = i[8]; return ( (s[0] = r * m + o * g + a * w), (s[3] = r * y + o * _ + a * L), (s[6] = r * p + o * x + a * b), (s[1] = l * m + c * g + h * w), (s[4] = l * y + c * _ + h * L), (s[7] = l * p + c * x + h * b), (s[2] = u * m + d * g + f * w), (s[5] = u * y + d * _ + f * L), (s[8] = u * p + d * x + f * b), this ); } multiplyScalar(e) { let 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() { let e = this.elements, t = e[0], n = e[1], i = e[2], s = e[3], r = e[4], o = e[5], a = e[6], l = e[7], c = e[8]; return t * r * c - t * o * l - n * s * c + n * o * a + i * s * l - i * r * a; } invert() { let e = this.elements, t = e[0], n = e[1], i = e[2], s = e[3], r = e[4], o = e[5], a = e[6], l = e[7], c = e[8], h = c * r - o * l, u = o * a - c * s, d = l * s - r * a, f = t * h + n * u + i * d; if (f === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); let m = 1 / f; return ( (e[0] = h * m), (e[1] = (i * l - c * n) * m), (e[2] = (o * n - i * r) * m), (e[3] = u * m), (e[4] = (c * t - i * a) * m), (e[5] = (i * s - o * t) * m), (e[6] = d * m), (e[7] = (n * a - l * t) * m), (e[8] = (r * t - n * s) * m), this ); } transpose() { let e, 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) { let 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, s, r, o) { let a = Math.cos(s), l = Math.sin(s); return ( this.set(n * a, n * l, -n * (a * r + l * o) + r + e, -i * l, i * a, -i * (-l * r + a * o) + o + t, 0, 0, 1), this ); } scale(e, t) { return (this.premultiply(Fa.makeScale(e, t)), this); } rotate(e) { return (this.premultiply(Fa.makeRotation(-e)), this); } translate(e, t) { return (this.premultiply(Fa.makeTranslation(e, t)), this); } makeTranslation(e, t) { if (e.isVector2) this.set(1, 0, e.x, 0, 1, e.y, 0, 0, 1); else this.set(1, 0, e, 0, 1, t, 0, 0, 1); return this; } makeRotation(e) { let 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) { let 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) { let 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); } } var Fa = new Be(); function rc(e) { for (let t = e.length - 1; t >= 0; --t) if (e[t] >= 65535) return !0; return !1; } function Vs(e) { return document.createElementNS("http://www.w3.org/1999/xhtml", e); } function fd() { let e = Vs("canvas"); return ((e.style.display = "block"), e); } var Uh = {}; function Ws(e) { if (e in Uh) return; ((Uh[e] = !0), console.warn(e)); } function pd(e, t, n) { return new Promise(function (i, s) { function r() { switch (e.clientWaitSync(t, e.SYNC_FLUSH_COMMANDS_BIT, 0)) { case e.WAIT_FAILED: s(); break; case e.TIMEOUT_EXPIRED: setTimeout(r, n); break; default: i(); } } setTimeout(r, n); }); } var Nh = new Be().set(0.4123908, 0.3575843, 0.1804808, 0.212639, 0.7151687, 0.0721923, 0.0193308, 0.1191948, 0.9505322), Fh = new Be().set( 3.2409699, -1.5373832, -0.4986108, -0.9692436, 1.8759675, 0.0415551, 0.0556301, -0.203977, 1.0569715, ); function pm() { let e = { enabled: !0, workingColorSpace: "srgb-linear", spaces: {}, convert: function (s, r, o) { if (this.enabled === !1 || r === o || !r || !o) return s; if (this.spaces[r].transfer === "srgb") ((s.r = pi(s.r)), (s.g = pi(s.g)), (s.b = pi(s.b))); if (this.spaces[r].primaries !== this.spaces[o].primaries) (s.applyMatrix3(this.spaces[r].toXYZ), s.applyMatrix3(this.spaces[o].fromXYZ)); if (this.spaces[o].transfer === "srgb") ((s.r = Gs(s.r)), (s.g = Gs(s.g)), (s.b = Gs(s.b))); return s; }, workingToColorSpace: function (s, r) { return this.convert(s, this.workingColorSpace, r); }, colorSpaceToWorking: function (s, r) { return this.convert(s, r, this.workingColorSpace); }, getPrimaries: function (s) { return this.spaces[s].primaries; }, getTransfer: function (s) { if (s === "") return "linear"; return this.spaces[s].transfer; }, getToneMappingMode: function (s) { return this.spaces[s].outputColorSpaceConfig.toneMappingMode || "standard"; }, getLuminanceCoefficients: function (s, r = this.workingColorSpace) { return s.fromArray(this.spaces[r].luminanceCoefficients); }, define: function (s) { Object.assign(this.spaces, s); }, _getMatrix: function (s, r, o) { return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ); }, _getDrawingBufferColorSpace: function (s) { return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace; }, _getUnpackColorSpace: function (s = this.workingColorSpace) { return this.spaces[s].workingColorSpaceConfig.unpackColorSpace; }, fromWorkingColorSpace: function (s, r) { return ( Ws("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."), e.workingToColorSpace(s, r) ); }, toWorkingColorSpace: function (s, r) { return ( Ws("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."), e.colorSpaceToWorking(s, r) ); }, }, t = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], n = [0.2126, 0.7152, 0.0722], i = [0.3127, 0.329]; return ( e.define({ ["srgb-linear"]: { primaries: t, whitePoint: i, transfer: "linear", toXYZ: Nh, fromXYZ: Fh, luminanceCoefficients: n, workingColorSpaceConfig: { unpackColorSpace: "srgb" }, outputColorSpaceConfig: { drawingBufferColorSpace: "srgb" }, }, ["srgb"]: { primaries: t, whitePoint: i, transfer: "srgb", toXYZ: Nh, fromXYZ: Fh, luminanceCoefficients: n, outputColorSpaceConfig: { drawingBufferColorSpace: "srgb" }, }, }), e ); } var ke = pm(); function pi(e) { return e < 0.04045 ? e * 0.0773993808 : Math.pow(e * 0.9478672986 + 0.0521327014, 2.4); } function Gs(e) { return e < 0.0031308 ? e * 12.92 : 1.055 * Math.pow(e, 0.41666) - 0.055; } var Rs; class oc { static getDataURL(e, t = "image/png") { if (/^data:/i.test(e.src)) return e.src; if (typeof HTMLCanvasElement > "u") return e.src; let n; if (e instanceof HTMLCanvasElement) n = e; else { if (Rs === void 0) Rs = Vs("canvas"); ((Rs.width = e.width), (Rs.height = e.height)); let i = Rs.getContext("2d"); if (e instanceof ImageData) i.putImageData(e, 0, 0); else i.drawImage(e, 0, 0, e.width, e.height); n = Rs; } return n.toDataURL(t); } static sRGBToLinear(e) { if ( (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement) || (typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement) || (typeof ImageBitmap < "u" && e instanceof ImageBitmap) ) { let t = Vs("canvas"); ((t.width = e.width), (t.height = e.height)); let n = t.getContext("2d"); n.drawImage(e, 0, 0, e.width, e.height); let i = n.getImageData(0, 0, e.width, e.height), s = i.data; for (let r = 0; r < s.length; r++) s[r] = pi(s[r] / 255) * 255; return (n.putImageData(i, 0, 0), t); } else if (e.data) { let t = e.data.slice(0); for (let n = 0; n < t.length; n++) if (t instanceof Uint8Array || t instanceof Uint8ClampedArray) t[n] = Math.floor(pi(t[n] / 255) * 255); else t[n] = pi(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 ); } } var mm = 0; class Gr { constructor(e = null) { ((this.isSource = !0), Object.defineProperty(this, "id", { value: mm++ }), (this.uuid = Un()), (this.data = e), (this.dataReady = !0), (this.version = 0)); } getSize(e) { let t = this.data; if (typeof HTMLVideoElement < "u" && t instanceof HTMLVideoElement) e.set(t.videoWidth, t.videoHeight, 0); else if (t instanceof VideoFrame) e.set(t.displayHeight, t.displayWidth, 0); else if (t !== null) e.set(t.width, t.height, t.depth || 0); else e.set(0, 0, 0); return e; } set needsUpdate(e) { if (e === !0) this.version++; } toJSON(e) { let t = e === void 0 || typeof e === "string"; if (!t && e.images[this.uuid] !== void 0) return e.images[this.uuid]; let n = { uuid: this.uuid, url: "" }, i = this.data; if (i !== null) { let s; if (Array.isArray(i)) { s = []; for (let r = 0, o = i.length; r < o; r++) if (i[r].isDataTexture) s.push(Oa(i[r].image)); else s.push(Oa(i[r])); } else s = Oa(i); n.url = s; } if (!t) e.images[this.uuid] = n; return n; } } function Oa(e) { if ( (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement) || (typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement) || (typeof ImageBitmap < "u" && e instanceof ImageBitmap) ) return oc.getDataURL(e); else if (e.data) return { data: Array.from(e.data), width: e.width, height: e.height, type: e.data.constructor.name }; else return (console.warn("THREE.Texture: Unable to serialize Texture."), {}); } var gm = 0, ka = new E(); class Rt extends jn { constructor( e = Rt.DEFAULT_IMAGE, t = Rt.DEFAULT_MAPPING, n = 1001, i = 1001, s = 1006, r = 1008, o = 1023, a = 1009, l = Rt.DEFAULT_ANISOTROPY, c = "", ) { super(); ((this.isTexture = !0), Object.defineProperty(this, "id", { value: gm++ }), (this.uuid = Un()), (this.name = ""), (this.source = new Gr(e)), (this.mipmaps = []), (this.mapping = t), (this.channel = 0), (this.wrapS = n), (this.wrapT = i), (this.magFilter = s), (this.minFilter = r), (this.anisotropy = l), (this.format = o), (this.internalFormat = null), (this.type = a), (this.offset = new ve(0, 0)), (this.repeat = new ve(1, 1)), (this.center = new ve(0, 0)), (this.rotation = 0), (this.matrixAutoUpdate = !0), (this.matrix = new Be()), (this.generateMipmaps = !0), (this.premultiplyAlpha = !1), (this.flipY = !0), (this.unpackAlignment = 4), (this.colorSpace = c), (this.userData = {}), (this.updateRanges = []), (this.version = 0), (this.onUpdate = null), (this.renderTarget = null), (this.isRenderTargetTexture = !1), (this.isArrayTexture = e && e.depth && e.depth > 1 ? !0 : !1), (this.pmremVersion = 0)); } get width() { return this.source.getSize(ka).x; } get height() { return this.source.getSize(ka).y; } get depth() { return this.source.getSize(ka).z; } 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, ); } addUpdateRange(e, t) { this.updateRanges.push({ start: e, count: t }); } clearUpdateRanges() { this.updateRanges.length = 0; } 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.renderTarget = e.renderTarget), (this.isRenderTargetTexture = e.isRenderTargetTexture), (this.isArrayTexture = e.isArrayTexture), (this.userData = JSON.parse(JSON.stringify(e.userData))), (this.needsUpdate = !0), this ); } setValues(e) { for (let t in e) { let n = e[t]; if (n === void 0) { console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`); continue; } let i = this[t]; if (i === void 0) { console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`); continue; } if (i && n && i.isVector2 && n.isVector2) i.copy(n); else if (i && n && i.isVector3 && n.isVector3) i.copy(n); else if (i && n && i.isMatrix3 && n.isMatrix3) i.copy(n); else this[t] = n; } } toJSON(e) { let t = e === void 0 || typeof e === "string"; if (!t && e.textures[this.uuid] !== void 0) return e.textures[this.uuid]; let n = { metadata: { version: 4.7, 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, }; if (Object.keys(this.userData).length > 0) n.userData = this.userData; if (!t) e.textures[this.uuid] = n; return n; } dispose() { this.dispatchEvent({ type: "dispose" }); } transformUv(e) { if (this.mapping !== 300) return e; if ((e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1)) switch (this.wrapS) { case 1000: e.x = e.x - Math.floor(e.x); break; case 1001: e.x = e.x < 0 ? 0 : 1; break; case 1002: if (Math.abs(Math.floor(e.x) % 2) === 1) e.x = Math.ceil(e.x) - e.x; else e.x = e.x - Math.floor(e.x); break; } if (e.y < 0 || e.y > 1) switch (this.wrapT) { case 1000: e.y = e.y - Math.floor(e.y); break; case 1001: e.y = e.y < 0 ? 0 : 1; break; case 1002: if (Math.abs(Math.floor(e.y) % 2) === 1) e.y = Math.ceil(e.y) - e.y; else e.y = e.y - Math.floor(e.y); break; } if (this.flipY) e.y = 1 - e.y; return e; } set needsUpdate(e) { if (e === !0) (this.version++, (this.source.needsUpdate = !0)); } set needsPMREMUpdate(e) { if (e === !0) this.pmremVersion++; } } Rt.DEFAULT_IMAGE = null; Rt.DEFAULT_MAPPING = 300; Rt.DEFAULT_ANISOTROPY = 1; class Ye { constructor(e = 0, t = 0, n = 0, i = 1) { ((Ye.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 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 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) { let t = this.x, n = this.y, i = this.z, s = this.w, r = e.elements; return ( (this.x = r[0] * t + r[4] * n + r[8] * i + r[12] * s), (this.y = r[1] * t + r[5] * n + r[9] * i + r[13] * s), (this.z = r[2] * t + r[6] * n + r[10] * i + r[14] * s), (this.w = r[3] * t + r[7] * n + r[11] * i + r[15] * s), this ); } divide(e) { return ((this.x /= e.x), (this.y /= e.y), (this.z /= e.z), (this.w /= e.w), this); } divideScalar(e) { return this.multiplyScalar(1 / e); } setAxisAngleFromQuaternion(e) { this.w = 2 * Math.acos(e.w); let t = Math.sqrt(1 - e.w * e.w); if (t < 0.0001) ((this.x = 1), (this.y = 0), (this.z = 0)); else ((this.x = e.x / t), (this.y = e.y / t), (this.z = e.z / t)); return this; } setAxisAngleFromRotationMatrix(e) { let t, n, i, s, r = 0.01, o = 0.1, a = e.elements, l = a[0], c = a[4], h = a[8], u = a[1], d = a[5], f = a[9], m = a[2], y = a[6], p = a[10]; if (Math.abs(c - u) < 0.01 && Math.abs(h - m) < 0.01 && Math.abs(f - y) < 0.01) { if (Math.abs(c + u) < 0.1 && Math.abs(h + m) < 0.1 && Math.abs(f + y) < 0.1 && Math.abs(l + d + p - 3) < 0.1) return (this.set(1, 0, 0, 0), this); t = Math.PI; let _ = (l + 1) / 2, x = (d + 1) / 2, w = (p + 1) / 2, L = (c + u) / 4, b = (h + m) / 4, R = (f + y) / 4; if (_ > x && _ > w) if (_ < 0.01) ((n = 0), (i = 0.707106781), (s = 0.707106781)); else ((n = Math.sqrt(_)), (i = L / n), (s = b / n)); else if (x > w) if (x < 0.01) ((n = 0.707106781), (i = 0), (s = 0.707106781)); else ((i = Math.sqrt(x)), (n = L / i), (s = R / i)); else if (w < 0.01) ((n = 0.707106781), (i = 0.707106781), (s = 0)); else ((s = Math.sqrt(w)), (n = b / s), (i = R / s)); return (this.set(n, i, s, t), this); } let g = Math.sqrt((y - f) * (y - f) + (h - m) * (h - m) + (u - c) * (u - c)); if (Math.abs(g) < 0.001) g = 1; return ( (this.x = (y - f) / g), (this.y = (h - m) / g), (this.z = (u - c) / g), (this.w = Math.acos((l + d + p - 1) / 2)), this ); } setFromMatrixPosition(e) { let 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 = qe(this.x, e.x, t.x)), (this.y = qe(this.y, e.y, t.y)), (this.z = qe(this.z, e.z, t.z)), (this.w = qe(this.w, e.w, t.w)), this ); } clampScalar(e, t) { return ( (this.x = qe(this.x, e, t)), (this.y = qe(this.y, e, t)), (this.z = qe(this.z, e, t)), (this.w = qe(this.w, e, t)), this ); } clampLength(e, t) { let n = this.length(); return this.divideScalar(n || 1).multiplyScalar(qe(n, e, t)); } 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 ac extends jn { constructor(e = 1, t = 1, n = {}) { super(); ((n = Object.assign( { generateMipmaps: !1, internalFormat: null, minFilter: 1006, depthBuffer: !0, stencilBuffer: !1, resolveDepthBuffer: !0, resolveStencilBuffer: !0, depthTexture: null, samples: 0, count: 1, depth: 1, multiview: !1, }, n, )), (this.isRenderTarget = !0), (this.width = e), (this.height = t), (this.depth = n.depth), (this.scissor = new Ye(0, 0, e, t)), (this.scissorTest = !1), (this.viewport = new Ye(0, 0, e, t))); let i = { width: e, height: t, depth: n.depth }, s = new Rt(i); this.textures = []; let r = n.count; for (let o = 0; o < r; o++) ((this.textures[o] = s.clone()), (this.textures[o].isRenderTargetTexture = !0), (this.textures[o].renderTarget = this)); (this._setTextureOptions(n), (this.depthBuffer = n.depthBuffer), (this.stencilBuffer = n.stencilBuffer), (this.resolveDepthBuffer = n.resolveDepthBuffer), (this.resolveStencilBuffer = n.resolveStencilBuffer), (this._depthTexture = null), (this.depthTexture = n.depthTexture), (this.samples = n.samples), (this.multiview = n.multiview)); } _setTextureOptions(e = {}) { let t = { minFilter: 1006, generateMipmaps: !1, flipY: !1, internalFormat: null }; if (e.mapping !== void 0) t.mapping = e.mapping; if (e.wrapS !== void 0) t.wrapS = e.wrapS; if (e.wrapT !== void 0) t.wrapT = e.wrapT; if (e.wrapR !== void 0) t.wrapR = e.wrapR; if (e.magFilter !== void 0) t.magFilter = e.magFilter; if (e.minFilter !== void 0) t.minFilter = e.minFilter; if (e.format !== void 0) t.format = e.format; if (e.type !== void 0) t.type = e.type; if (e.anisotropy !== void 0) t.anisotropy = e.anisotropy; if (e.colorSpace !== void 0) t.colorSpace = e.colorSpace; if (e.flipY !== void 0) t.flipY = e.flipY; if (e.generateMipmaps !== void 0) t.generateMipmaps = e.generateMipmaps; if (e.internalFormat !== void 0) t.internalFormat = e.internalFormat; for (let n = 0; n < this.textures.length; n++) this.textures[n].setValues(t); } get texture() { return this.textures[0]; } set texture(e) { this.textures[0] = e; } set depthTexture(e) { if (this._depthTexture !== null) this._depthTexture.renderTarget = null; if (e !== null) e.renderTarget = this; this._depthTexture = e; } get depthTexture() { return this._depthTexture; } 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, s = this.textures.length; i < s; i++) ((this.textures[i].image.width = e), (this.textures[i].image.height = t), (this.textures[i].image.depth = n), (this.textures[i].isArrayTexture = this.textures[i].image.depth > 1)); 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 t = 0, n = e.textures.length; t < n; t++) { ((this.textures[t] = e.textures[t].clone()), (this.textures[t].isRenderTargetTexture = !0), (this.textures[t].renderTarget = this)); let i = Object.assign({}, e.textures[t].image); this.textures[t].source = new Gr(i); } if ( ((this.depthBuffer = e.depthBuffer), (this.stencilBuffer = e.stencilBuffer), (this.resolveDepthBuffer = e.resolveDepthBuffer), (this.resolveStencilBuffer = e.resolveStencilBuffer), e.depthTexture !== null) ) this.depthTexture = e.depthTexture.clone(); return ((this.samples = e.samples), this); } dispose() { this.dispatchEvent({ type: "dispose" }); } } class vi extends ac { constructor(e = 1, t = 1, n = {}) { super(e, t, n); this.isWebGLRenderTarget = !0; } } class ea extends Rt { 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 = 1003), (this.minFilter = 1003), (this.wrapR = 1001), (this.generateMipmaps = !1), (this.flipY = !1), (this.unpackAlignment = 1), (this.layerUpdates = new Set())); } addLayerUpdate(e) { this.layerUpdates.add(e); } clearLayerUpdates() { this.layerUpdates.clear(); } } class lc extends Rt { 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 = 1003), (this.minFilter = 1003), (this.wrapR = 1001), (this.generateMipmaps = !1), (this.flipY = !1), (this.unpackAlignment = 1)); } } class ln { constructor(e = new E(1 / 0, 1 / 0, 1 / 0), t = new E(-1 / 0, -1 / 0, -1 / 0)) { ((this.isBox3 = !0), (this.min = e), (this.max = t)); } set(e, t) { return (this.min.copy(e), this.max.copy(t), this); } setFromArray(e) { this.makeEmpty(); for (let t = 0, n = e.length; t < n; t += 3) this.expandByPoint(Cn.fromArray(e, t)); return this; } setFromBufferAttribute(e) { this.makeEmpty(); for (let t = 0, n = e.count; t < n; t++) this.expandByPoint(Cn.fromBufferAttribute(e, t)); return this; } setFromPoints(e) { this.makeEmpty(); for (let t = 0, n = e.length; t < n; t++) this.expandByPoint(e[t]); return this; } setFromCenterAndSize(e, t) { let n = Cn.copy(t).multiplyScalar(0.5); return (this.min.copy(e).sub(n), this.max.copy(e).add(n), this); } setFromObject(e, t = !1) { return (this.makeEmpty(), this.expandByObject(e, t)); } clone() { return new this.constructor().copy(this); } copy(e) { return (this.min.copy(e.min), this.max.copy(e.max), this); } makeEmpty() { return ((this.min.x = this.min.y = this.min.z = 1 / 0), (this.max.x = this.max.y = this.max.z = -1 / 0), this); } isEmpty() { return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z; } getCenter(e) { return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5); } getSize(e) { return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min); } expandByPoint(e) { return (this.min.min(e), this.max.max(e), this); } expandByVector(e) { return (this.min.sub(e), this.max.add(e), this); } expandByScalar(e) { return (this.min.addScalar(-e), this.max.addScalar(e), this); } expandByObject(e, t = !1) { e.updateWorldMatrix(!1, !1); let n = e.geometry; if (n !== void 0) { let s = n.getAttribute("position"); if (t === !0 && s !== void 0 && e.isInstancedMesh !== !0) for (let r = 0, o = s.count; r < o; r++) { if (e.isMesh === !0) e.getVertexPosition(r, Cn); else Cn.fromBufferAttribute(s, r); (Cn.applyMatrix4(e.matrixWorld), this.expandByPoint(Cn)); } else { if (e.boundingBox !== void 0) { if (e.boundingBox === null) e.computeBoundingBox(); ao.copy(e.boundingBox); } else { if (n.boundingBox === null) n.computeBoundingBox(); ao.copy(n.boundingBox); } (ao.applyMatrix4(e.matrixWorld), this.union(ao)); } } let i = e.children; for (let s = 0, r = i.length; s < r; s++) this.expandByObject(i[s], t); return this; } containsPoint(e) { return ( e.x >= this.min.x && e.x <= this.max.x && e.y >= this.min.y && e.y <= this.max.y && e.z >= this.min.z && e.z <= this.max.z ); } containsBox(e) { return ( this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z ); } getParameter(e, t) { return t.set( (e.x - this.min.x) / (this.max.x - this.min.x), (e.y - this.min.y) / (this.max.y - this.min.y), (e.z - this.min.z) / (this.max.z - this.min.z), ); } intersectsBox(e) { return ( e.max.x >= this.min.x && e.min.x <= this.max.x && e.max.y >= this.min.y && e.min.y <= this.max.y && e.max.z >= this.min.z && e.min.z <= this.max.z ); } intersectsSphere(e) { return (this.clampPoint(e.center, Cn), Cn.distanceToSquared(e.center) <= e.radius * e.radius); } intersectsPlane(e) { let t, n; if (e.normal.x > 0) ((t = e.normal.x * this.min.x), (n = e.normal.x * this.max.x)); else ((t = e.normal.x * this.max.x), (n = e.normal.x * this.min.x)); if (e.normal.y > 0) ((t += e.normal.y * this.min.y), (n += e.normal.y * this.max.y)); else ((t += e.normal.y * this.max.y), (n += e.normal.y * this.min.y)); if (e.normal.z > 0) ((t += e.normal.z * this.min.z), (n += e.normal.z * this.max.z)); else ((t += e.normal.z * this.max.z), (n += e.normal.z * this.min.z)); return t <= -e.constant && n >= -e.constant; } intersectsTriangle(e) { if (this.isEmpty()) return !1; (this.getCenter(_r), lo.subVectors(this.max, _r), Ls.subVectors(e.a, _r), Cs.subVectors(e.b, _r), Is.subVectors(e.c, _r), Ai.subVectors(Cs, Ls), Ri.subVectors(Is, Cs), ss.subVectors(Ls, Is)); let t = [ 0, -Ai.z, Ai.y, 0, -Ri.z, Ri.y, 0, -ss.z, ss.y, Ai.z, 0, -Ai.x, Ri.z, 0, -Ri.x, ss.z, 0, -ss.x, -Ai.y, Ai.x, 0, -Ri.y, Ri.x, 0, -ss.y, ss.x, 0, ]; if (!za(t, Ls, Cs, Is, lo)) return !1; if (((t = [1, 0, 0, 0, 1, 0, 0, 0, 1]), !za(t, Ls, Cs, Is, lo))) return !1; return (co.crossVectors(Ai, Ri), (t = [co.x, co.y, co.z]), za(t, Ls, Cs, Is, lo)); } clampPoint(e, t) { return t.copy(e).clamp(this.min, this.max); } distanceToPoint(e) { return this.clampPoint(e, Cn).distanceTo(e); } getBoundingSphere(e) { if (this.isEmpty()) e.makeEmpty(); else (this.getCenter(e.center), (e.radius = this.getSize(Cn).length() * 0.5)); return e; } intersect(e) { if ((this.min.max(e.min), this.max.min(e.max), this.isEmpty())) this.makeEmpty(); return this; } union(e) { return (this.min.min(e.min), this.max.max(e.max), this); } applyMatrix4(e) { if (this.isEmpty()) return this; return ( li[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), li[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), li[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), li[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), li[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), li[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), li[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), li[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(li), this ); } translate(e) { return (this.min.add(e), this.max.add(e), this); } equals(e) { return e.min.equals(this.min) && e.max.equals(this.max); } toJSON() { return { min: this.min.toArray(), max: this.max.toArray() }; } fromJSON(e) { return (this.min.fromArray(e.min), this.max.fromArray(e.max), this); } } var li = [new E(), new E(), new E(), new E(), new E(), new E(), new E(), new E()], Cn = new E(), ao = new ln(), Ls = new E(), Cs = new E(), Is = new E(), Ai = new E(), Ri = new E(), ss = new E(), _r = new E(), lo = new E(), co = new E(), rs = new E(); function za(e, t, n, i, s) { for (let r = 0, o = e.length - 3; r <= o; r += 3) { rs.fromArray(e, r); let a = s.x * Math.abs(rs.x) + s.y * Math.abs(rs.y) + s.z * Math.abs(rs.z), l = t.dot(rs), c = n.dot(rs), h = i.dot(rs); if (Math.max(-Math.max(l, c, h), Math.min(l, c, h)) > a) return !1; } return !0; } var ym = new ln(), Sr = new E(), Ha = new E(); class yn { constructor(e = new E(), t = -1) { ((this.isSphere = !0), (this.center = e), (this.radius = t)); } set(e, t) { return (this.center.copy(e), (this.radius = t), this); } setFromPoints(e, t) { let n = this.center; if (t !== void 0) n.copy(t); else ym.setFromPoints(e).getCenter(n); let i = 0; for (let s = 0, r = e.length; s < r; s++) i = Math.max(i, n.distanceToSquared(e[s])); return ((this.radius = Math.sqrt(i)), this); } copy(e) { return (this.center.copy(e.center), (this.radius = e.radius), this); } isEmpty() { return this.radius < 0; } makeEmpty() { return (this.center.set(0, 0, 0), (this.radius = -1), this); } containsPoint(e) { return e.distanceToSquared(this.center) <= this.radius * this.radius; } distanceToPoint(e) { return e.distanceTo(this.center) - this.radius; } intersectsSphere(e) { let t = this.radius + e.radius; return e.center.distanceToSquared(this.center) <= t * t; } intersectsBox(e) { return e.intersectsSphere(this); } intersectsPlane(e) { return Math.abs(e.distanceToPoint(this.center)) <= this.radius; } clampPoint(e, t) { let n = this.center.distanceToSquared(e); if ((t.copy(e), n > this.radius * this.radius)) (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)); return t; } getBoundingBox(e) { if (this.isEmpty()) return (e.makeEmpty(), e); return (e.set(this.center, this.center), e.expandByScalar(this.radius), e); } applyMatrix4(e) { return (this.center.applyMatrix4(e), (this.radius = this.radius * e.getMaxScaleOnAxis()), this); } translate(e) { return (this.center.add(e), this); } expandByPoint(e) { if (this.isEmpty()) return (this.center.copy(e), (this.radius = 0), this); Sr.subVectors(e, this.center); let t = Sr.lengthSq(); if (t > this.radius * this.radius) { let n = Math.sqrt(t), i = (n - this.radius) * 0.5; (this.center.addScaledVector(Sr, i / n), (this.radius += i)); } return this; } union(e) { if (e.isEmpty()) return this; if (this.isEmpty()) return (this.copy(e), this); if (this.center.equals(e.center) === !0) this.radius = Math.max(this.radius, e.radius); else (Ha.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(Sr.copy(e.center).add(Ha)), this.expandByPoint(Sr.copy(e.center).sub(Ha))); return this; } equals(e) { return e.center.equals(this.center) && e.radius === this.radius; } clone() { return new this.constructor().copy(this); } toJSON() { return { radius: this.radius, center: this.center.toArray() }; } fromJSON(e) { return ((this.radius = e.radius), this.center.fromArray(e.center), this); } } var ci = new E(), Ba = new E(), ho = new E(), Li = new E(), Ga = new E(), uo = new E(), Va = new E(); class zn { constructor(e = new E(), t = new E(0, 0, -1)) { ((this.origin = e), (this.direction = t)); } set(e, t) { return (this.origin.copy(e), this.direction.copy(t), this); } copy(e) { return (this.origin.copy(e.origin), this.direction.copy(e.direction), this); } at(e, t) { return t.copy(this.origin).addScaledVector(this.direction, e); } lookAt(e) { return (this.direction.copy(e).sub(this.origin).normalize(), this); } recast(e) { return (this.origin.copy(this.at(e, ci)), this); } closestPointToPoint(e, t) { t.subVectors(e, this.origin); let n = t.dot(this.direction); if (n < 0) return t.copy(this.origin); return t.copy(this.origin).addScaledVector(this.direction, n); } distanceToPoint(e) { return Math.sqrt(this.distanceSqToPoint(e)); } distanceSqToPoint(e) { let t = ci.subVectors(e, this.origin).dot(this.direction); if (t < 0) return this.origin.distanceToSquared(e); return (ci.copy(this.origin).addScaledVector(this.direction, t), ci.distanceToSquared(e)); } distanceSqToSegment(e, t, n, i) { (Ba.copy(e).add(t).multiplyScalar(0.5), ho.copy(t).sub(e).normalize(), Li.copy(this.origin).sub(Ba)); let s = e.distanceTo(t) * 0.5, r = -this.direction.dot(ho), o = Li.dot(this.direction), a = -Li.dot(ho), l = Li.lengthSq(), c = Math.abs(1 - r * r), h, u, d, f; if (c > 0) if (((h = r * a - o), (u = r * o - a), (f = s * c), h >= 0)) if (u >= -f) if (u <= f) { let m = 1 / c; ((h *= m), (u *= m), (d = h * (h + r * u + 2 * o) + u * (r * h + u + 2 * a) + l)); } else ((u = s), (h = Math.max(0, -(r * u + o))), (d = -h * h + u * (u + 2 * a) + l)); else ((u = -s), (h = Math.max(0, -(r * u + o))), (d = -h * h + u * (u + 2 * a) + l)); else if (u <= -f) ((h = Math.max(0, -(-r * s + o))), (u = h > 0 ? -s : Math.min(Math.max(-s, -a), s)), (d = -h * h + u * (u + 2 * a) + l)); else if (u <= f) ((h = 0), (u = Math.min(Math.max(-s, -a), s)), (d = u * (u + 2 * a) + l)); else ((h = Math.max(0, -(r * s + o))), (u = h > 0 ? s : Math.min(Math.max(-s, -a), s)), (d = -h * h + u * (u + 2 * a) + l)); else ((u = r > 0 ? -s : s), (h = Math.max(0, -(r * u + o))), (d = -h * h + u * (u + 2 * a) + l)); if (n) n.copy(this.origin).addScaledVector(this.direction, h); if (i) i.copy(Ba).addScaledVector(ho, u); return d; } intersectSphere(e, t) { ci.subVectors(e.center, this.origin); let n = ci.dot(this.direction), i = ci.dot(ci) - n * n, s = e.radius * e.radius; if (i > s) return null; let r = Math.sqrt(s - i), o = n - r, a = n + r; if (a < 0) return null; if (o < 0) return this.at(a, t); return this.at(o, t); } intersectsSphere(e) { if (e.radius < 0) return !1; return this.distanceSqToPoint(e.center) <= e.radius * e.radius; } distanceToPlane(e) { let t = e.normal.dot(this.direction); if (t === 0) { if (e.distanceToPoint(this.origin) === 0) return 0; return null; } let n = -(this.origin.dot(e.normal) + e.constant) / t; return n >= 0 ? n : null; } intersectPlane(e, t) { let n = this.distanceToPlane(e); if (n === null) return null; return this.at(n, t); } intersectsPlane(e) { let t = e.distanceToPoint(this.origin); if (t === 0) return !0; if (e.normal.dot(this.direction) * t < 0) return !0; return !1; } intersectBox(e, t) { let n, i, s, r, o, a, l = 1 / this.direction.x, c = 1 / this.direction.y, h = 1 / this.direction.z, u = this.origin; if (l >= 0) ((n = (e.min.x - u.x) * l), (i = (e.max.x - u.x) * l)); else ((n = (e.max.x - u.x) * l), (i = (e.min.x - u.x) * l)); if (c >= 0) ((s = (e.min.y - u.y) * c), (r = (e.max.y - u.y) * c)); else ((s = (e.max.y - u.y) * c), (r = (e.min.y - u.y) * c)); if (n > r || s > i) return null; if (s > n || isNaN(n)) n = s; if (r < i || isNaN(i)) i = r; if (h >= 0) ((o = (e.min.z - u.z) * h), (a = (e.max.z - u.z) * h)); else ((o = (e.max.z - u.z) * h), (a = (e.min.z - u.z) * h)); if (n > a || o > i) return null; if (o > n || n !== n) n = o; if (a < i || i !== i) i = a; if (i < 0) return null; return this.at(n >= 0 ? n : i, t); } intersectsBox(e) { return this.intersectBox(e, ci) !== null; } intersectTriangle(e, t, n, i, s) { (Ga.subVectors(t, e), uo.subVectors(n, e), Va.crossVectors(Ga, uo)); let r = this.direction.dot(Va), o; if (r > 0) { if (i) return null; o = 1; } else if (r < 0) ((o = -1), (r = -r)); else return null; Li.subVectors(this.origin, e); let a = o * this.direction.dot(uo.crossVectors(Li, uo)); if (a < 0) return null; let l = o * this.direction.dot(Ga.cross(Li)); if (l < 0) return null; if (a + l > r) return null; let c = -o * Li.dot(Va); if (c < 0) return null; return this.at(c / r, s); } applyMatrix4(e) { return (this.origin.applyMatrix4(e), this.direction.transformDirection(e), this); } equals(e) { return e.origin.equals(this.origin) && e.direction.equals(this.direction); } clone() { return new this.constructor().copy(this); } } class ue { constructor(e, t, n, i, s, r, o, a, l, c, h, u, d, f, m, y) { if ( ((ue.prototype.isMatrix4 = !0), (this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), e !== void 0) ) this.set(e, t, n, i, s, r, o, a, l, c, h, u, d, f, m, y); } set(e, t, n, i, s, r, o, a, l, c, h, u, d, f, m, y) { let p = this.elements; return ( (p[0] = e), (p[4] = t), (p[8] = n), (p[12] = i), (p[1] = s), (p[5] = r), (p[9] = o), (p[13] = a), (p[2] = l), (p[6] = c), (p[10] = h), (p[14] = u), (p[3] = d), (p[7] = f), (p[11] = m), (p[15] = y), this ); } identity() { return (this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this); } clone() { return new ue().fromArray(this.elements); } copy(e) { let 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]), (t[9] = n[9]), (t[10] = n[10]), (t[11] = n[11]), (t[12] = n[12]), (t[13] = n[13]), (t[14] = n[14]), (t[15] = n[15]), this ); } copyPosition(e) { let t = this.elements, n = e.elements; return ((t[12] = n[12]), (t[13] = n[13]), (t[14] = n[14]), this); } setFromMatrix3(e) { let t = e.elements; return (this.set(t[0], t[3], t[6], 0, t[1], t[4], t[7], 0, t[2], t[5], t[8], 0, 0, 0, 0, 1), this); } extractBasis(e, t, n) { return (e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this); } makeBasis(e, t, n) { return (this.set(e.x, t.x, n.x, 0, e.y, t.y, n.y, 0, e.z, t.z, n.z, 0, 0, 0, 0, 1), this); } extractRotation(e) { let t = this.elements, n = e.elements, i = 1 / Ps.setFromMatrixColumn(e, 0).length(), s = 1 / Ps.setFromMatrixColumn(e, 1).length(), r = 1 / Ps.setFromMatrixColumn(e, 2).length(); return ( (t[0] = n[0] * i), (t[1] = n[1] * i), (t[2] = n[2] * i), (t[3] = 0), (t[4] = n[4] * s), (t[5] = n[5] * s), (t[6] = n[6] * s), (t[7] = 0), (t[8] = n[8] * r), (t[9] = n[9] * r), (t[10] = n[10] * r), (t[11] = 0), (t[12] = 0), (t[13] = 0), (t[14] = 0), (t[15] = 1), this ); } makeRotationFromEuler(e) { let t = this.elements, { x: n, y: i, z: s } = e, r = Math.cos(n), o = Math.sin(n), a = Math.cos(i), l = Math.sin(i), c = Math.cos(s), h = Math.sin(s); if (e.order === "XYZ") { let u = r * c, d = r * h, f = o * c, m = o * h; ((t[0] = a * c), (t[4] = -a * h), (t[8] = l), (t[1] = d + f * l), (t[5] = u - m * l), (t[9] = -o * a), (t[2] = m - u * l), (t[6] = f + d * l), (t[10] = r * a)); } else if (e.order === "YXZ") { let u = a * c, d = a * h, f = l * c, m = l * h; ((t[0] = u + m * o), (t[4] = f * o - d), (t[8] = r * l), (t[1] = r * h), (t[5] = r * c), (t[9] = -o), (t[2] = d * o - f), (t[6] = m + u * o), (t[10] = r * a)); } else if (e.order === "ZXY") { let u = a * c, d = a * h, f = l * c, m = l * h; ((t[0] = u - m * o), (t[4] = -r * h), (t[8] = f + d * o), (t[1] = d + f * o), (t[5] = r * c), (t[9] = m - u * o), (t[2] = -r * l), (t[6] = o), (t[10] = r * a)); } else if (e.order === "ZYX") { let u = r * c, d = r * h, f = o * c, m = o * h; ((t[0] = a * c), (t[4] = f * l - d), (t[8] = u * l + m), (t[1] = a * h), (t[5] = m * l + u), (t[9] = d * l - f), (t[2] = -l), (t[6] = o * a), (t[10] = r * a)); } else if (e.order === "YZX") { let u = r * a, d = r * l, f = o * a, m = o * l; ((t[0] = a * c), (t[4] = m - u * h), (t[8] = f * h + d), (t[1] = h), (t[5] = r * c), (t[9] = -o * c), (t[2] = -l * c), (t[6] = d * h + f), (t[10] = u - m * h)); } else if (e.order === "XZY") { let u = r * a, d = r * l, f = o * a, m = o * l; ((t[0] = a * c), (t[4] = -h), (t[8] = l * c), (t[1] = u * h + m), (t[5] = r * c), (t[9] = d * h - f), (t[2] = f * h - d), (t[6] = o * c), (t[10] = m * h + u)); } return ((t[3] = 0), (t[7] = 0), (t[11] = 0), (t[12] = 0), (t[13] = 0), (t[14] = 0), (t[15] = 1), this); } makeRotationFromQuaternion(e) { return this.compose(xm, e, vm); } lookAt(e, t, n) { let i = this.elements; if ((fn.subVectors(e, t), fn.lengthSq() === 0)) fn.z = 1; if ((fn.normalize(), Ci.crossVectors(n, fn), Ci.lengthSq() === 0)) { if (Math.abs(n.z) === 1) fn.x += 0.0001; else fn.z += 0.0001; (fn.normalize(), Ci.crossVectors(n, fn)); } return ( Ci.normalize(), fo.crossVectors(fn, Ci), (i[0] = Ci.x), (i[4] = fo.x), (i[8] = fn.x), (i[1] = Ci.y), (i[5] = fo.y), (i[9] = fn.y), (i[2] = Ci.z), (i[6] = fo.z), (i[10] = fn.z), this ); } multiply(e) { return this.multiplyMatrices(this, e); } premultiply(e) { return this.multiplyMatrices(e, this); } multiplyMatrices(e, t) { let n = e.elements, i = t.elements, s = this.elements, r = n[0], o = n[4], a = n[8], l = n[12], c = n[1], h = n[5], u = n[9], d = n[13], f = n[2], m = n[6], y = n[10], p = n[14], g = n[3], _ = n[7], x = n[11], w = n[15], L = i[0], b = i[4], R = i[8], F = i[12], M = i[1], T = i[5], I = i[9], G = i[13], q = i[2], B = i[6], Z = i[10], W = i[14], K = i[3], V = i[7], se = i[11], ce = i[15]; return ( (s[0] = r * L + o * M + a * q + l * K), (s[4] = r * b + o * T + a * B + l * V), (s[8] = r * R + o * I + a * Z + l * se), (s[12] = r * F + o * G + a * W + l * ce), (s[1] = c * L + h * M + u * q + d * K), (s[5] = c * b + h * T + u * B + d * V), (s[9] = c * R + h * I + u * Z + d * se), (s[13] = c * F + h * G + u * W + d * ce), (s[2] = f * L + m * M + y * q + p * K), (s[6] = f * b + m * T + y * B + p * V), (s[10] = f * R + m * I + y * Z + p * se), (s[14] = f * F + m * G + y * W + p * ce), (s[3] = g * L + _ * M + x * q + w * K), (s[7] = g * b + _ * T + x * B + w * V), (s[11] = g * R + _ * I + x * Z + w * se), (s[15] = g * F + _ * G + x * W + w * ce), this ); } multiplyScalar(e) { let t = this.elements; return ( (t[0] *= e), (t[4] *= e), (t[8] *= e), (t[12] *= e), (t[1] *= e), (t[5] *= e), (t[9] *= e), (t[13] *= e), (t[2] *= e), (t[6] *= e), (t[10] *= e), (t[14] *= e), (t[3] *= e), (t[7] *= e), (t[11] *= e), (t[15] *= e), this ); } determinant() { let e = this.elements, t = e[0], n = e[4], i = e[8], s = e[12], r = e[1], o = e[5], a = e[9], l = e[13], c = e[2], h = e[6], u = e[10], d = e[14], f = e[3], m = e[7], y = e[11], p = e[15]; return ( f * (+s * a * h - i * l * h - s * o * u + n * l * u + i * o * d - n * a * d) + m * (+t * a * d - t * l * u + s * r * u - i * r * d + i * l * c - s * a * c) + y * (+t * l * h - t * o * d - s * r * h + n * r * d + s * o * c - n * l * c) + p * (-i * o * c - t * a * h + t * o * u + i * r * h - n * r * u + n * a * c) ); } transpose() { let e = this.elements, t; return ( (t = e[1]), (e[1] = e[4]), (e[4] = t), (t = e[2]), (e[2] = e[8]), (e[8] = t), (t = e[6]), (e[6] = e[9]), (e[9] = t), (t = e[3]), (e[3] = e[12]), (e[12] = t), (t = e[7]), (e[7] = e[13]), (e[13] = t), (t = e[11]), (e[11] = e[14]), (e[14] = t), this ); } setPosition(e, t, n) { let i = this.elements; if (e.isVector3) ((i[12] = e.x), (i[13] = e.y), (i[14] = e.z)); else ((i[12] = e), (i[13] = t), (i[14] = n)); return this; } invert() { let e = this.elements, t = e[0], n = e[1], i = e[2], s = e[3], r = e[4], o = e[5], a = e[6], l = e[7], c = e[8], h = e[9], u = e[10], d = e[11], f = e[12], m = e[13], y = e[14], p = e[15], g = h * y * l - m * u * l + m * a * d - o * y * d - h * a * p + o * u * p, _ = f * u * l - c * y * l - f * a * d + r * y * d + c * a * p - r * u * p, x = c * m * l - f * h * l + f * o * d - r * m * d - c * o * p + r * h * p, w = f * h * a - c * m * a - f * o * u + r * m * u + c * o * y - r * h * y, L = t * g + n * _ + i * x + s * w; if (L === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); let b = 1 / L; return ( (e[0] = g * b), (e[1] = (m * u * s - h * y * s - m * i * d + n * y * d + h * i * p - n * u * p) * b), (e[2] = (o * y * s - m * a * s + m * i * l - n * y * l - o * i * p + n * a * p) * b), (e[3] = (h * a * s - o * u * s - h * i * l + n * u * l + o * i * d - n * a * d) * b), (e[4] = _ * b), (e[5] = (c * y * s - f * u * s + f * i * d - t * y * d - c * i * p + t * u * p) * b), (e[6] = (f * a * s - r * y * s - f * i * l + t * y * l + r * i * p - t * a * p) * b), (e[7] = (r * u * s - c * a * s + c * i * l - t * u * l - r * i * d + t * a * d) * b), (e[8] = x * b), (e[9] = (f * h * s - c * m * s - f * n * d + t * m * d + c * n * p - t * h * p) * b), (e[10] = (r * m * s - f * o * s + f * n * l - t * m * l - r * n * p + t * o * p) * b), (e[11] = (c * o * s - r * h * s - c * n * l + t * h * l + r * n * d - t * o * d) * b), (e[12] = w * b), (e[13] = (c * m * i - f * h * i + f * n * u - t * m * u - c * n * y + t * h * y) * b), (e[14] = (f * o * i - r * m * i - f * n * a + t * m * a + r * n * y - t * o * y) * b), (e[15] = (r * h * i - c * o * i + c * n * a - t * h * a - r * n * u + t * o * u) * b), this ); } scale(e) { let t = this.elements, { x: n, y: i, z: s } = e; return ( (t[0] *= n), (t[4] *= i), (t[8] *= s), (t[1] *= n), (t[5] *= i), (t[9] *= s), (t[2] *= n), (t[6] *= i), (t[10] *= s), (t[3] *= n), (t[7] *= i), (t[11] *= s), this ); } getMaxScaleOnAxis() { let e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], i = e[8] * e[8] + e[9] * e[9] + e[10] * e[10]; return Math.sqrt(Math.max(t, n, i)); } makeTranslation(e, t, n) { if (e.isVector3) this.set(1, 0, 0, e.x, 0, 1, 0, e.y, 0, 0, 1, e.z, 0, 0, 0, 1); else this.set(1, 0, 0, e, 0, 1, 0, t, 0, 0, 1, n, 0, 0, 0, 1); return this; } makeRotationX(e) { let t = Math.cos(e), n = Math.sin(e); return (this.set(1, 0, 0, 0, 0, t, -n, 0, 0, n, t, 0, 0, 0, 0, 1), this); } makeRotationY(e) { let t = Math.cos(e), n = Math.sin(e); return (this.set(t, 0, n, 0, 0, 1, 0, 0, -n, 0, t, 0, 0, 0, 0, 1), this); } makeRotationZ(e) { let t = Math.cos(e), n = Math.sin(e); return (this.set(t, -n, 0, 0, n, t, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this); } makeRotationAxis(e, t) { let n = Math.cos(t), i = Math.sin(t), s = 1 - n, { x: r, y: o, z: a } = e, l = s * r, c = s * o; return ( this.set( l * r + n, l * o - i * a, l * a + i * o, 0, l * o + i * a, c * o + n, c * a - i * r, 0, l * a - i * o, c * a + i * r, s * a * a + n, 0, 0, 0, 0, 1, ), this ); } makeScale(e, t, n) { return (this.set(e, 0, 0, 0, 0, t, 0, 0, 0, 0, n, 0, 0, 0, 0, 1), this); } makeShear(e, t, n, i, s, r) { return (this.set(1, n, s, 0, e, 1, r, 0, t, i, 1, 0, 0, 0, 0, 1), this); } compose(e, t, n) { let i = this.elements, { _x: s, _y: r, _z: o, _w: a } = t, l = s + s, c = r + r, h = o + o, u = s * l, d = s * c, f = s * h, m = r * c, y = r * h, p = o * h, g = a * l, _ = a * c, x = a * h, { x: w, y: L, z: b } = n; return ( (i[0] = (1 - (m + p)) * w), (i[1] = (d + x) * w), (i[2] = (f - _) * w), (i[3] = 0), (i[4] = (d - x) * L), (i[5] = (1 - (u + p)) * L), (i[6] = (y + g) * L), (i[7] = 0), (i[8] = (f + _) * b), (i[9] = (y - g) * b), (i[10] = (1 - (u + m)) * b), (i[11] = 0), (i[12] = e.x), (i[13] = e.y), (i[14] = e.z), (i[15] = 1), this ); } decompose(e, t, n) { let i = this.elements, s = Ps.set(i[0], i[1], i[2]).length(), r = Ps.set(i[4], i[5], i[6]).length(), o = Ps.set(i[8], i[9], i[10]).length(); if (this.determinant() < 0) s = -s; ((e.x = i[12]), (e.y = i[13]), (e.z = i[14]), In.copy(this)); let l = 1 / s, c = 1 / r, h = 1 / o; return ( (In.elements[0] *= l), (In.elements[1] *= l), (In.elements[2] *= l), (In.elements[4] *= c), (In.elements[5] *= c), (In.elements[6] *= c), (In.elements[8] *= h), (In.elements[9] *= h), (In.elements[10] *= h), t.setFromRotationMatrix(In), (n.x = s), (n.y = r), (n.z = o), this ); } makePerspective(e, t, n, i, s, r, o = 2000, a = !1) { let l = this.elements, c = (2 * s) / (t - e), h = (2 * s) / (n - i), u = (t + e) / (t - e), d = (n + i) / (n - i), f, m; if (a) ((f = s / (r - s)), (m = (r * s) / (r - s))); else if (o === 2000) ((f = -(r + s) / (r - s)), (m = (-2 * r * s) / (r - s))); else if (o === 2001) ((f = -r / (r - s)), (m = (-r * s) / (r - s))); else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o); return ( (l[0] = c), (l[4] = 0), (l[8] = u), (l[12] = 0), (l[1] = 0), (l[5] = h), (l[9] = d), (l[13] = 0), (l[2] = 0), (l[6] = 0), (l[10] = f), (l[14] = m), (l[3] = 0), (l[7] = 0), (l[11] = -1), (l[15] = 0), this ); } makeOrthographic(e, t, n, i, s, r, o = 2000, a = !1) { let l = this.elements, c = 2 / (t - e), h = 2 / (n - i), u = -(t + e) / (t - e), d = -(n + i) / (n - i), f, m; if (a) ((f = 1 / (r - s)), (m = r / (r - s))); else if (o === 2000) ((f = -2 / (r - s)), (m = -(r + s) / (r - s))); else if (o === 2001) ((f = -1 / (r - s)), (m = -s / (r - s))); else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o); return ( (l[0] = c), (l[4] = 0), (l[8] = 0), (l[12] = u), (l[1] = 0), (l[5] = h), (l[9] = 0), (l[13] = d), (l[2] = 0), (l[6] = 0), (l[10] = f), (l[14] = m), (l[3] = 0), (l[7] = 0), (l[11] = 0), (l[15] = 1), this ); } equals(e) { let t = this.elements, n = e.elements; for (let i = 0; i < 16; i++) if (t[i] !== n[i]) return !1; return !0; } fromArray(e, t = 0) { for (let n = 0; n < 16; n++) this.elements[n] = e[n + t]; return this; } toArray(e = [], t = 0) { let 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[t + 9] = n[9]), (e[t + 10] = n[10]), (e[t + 11] = n[11]), (e[t + 12] = n[12]), (e[t + 13] = n[13]), (e[t + 14] = n[14]), (e[t + 15] = n[15]), e ); } } var Ps = new E(), In = new ue(), xm = new E(0, 0, 0), vm = new E(1, 1, 1), Ci = new E(), fo = new E(), fn = new E(), Oh = new ue(), kh = new Ne(); class tt { constructor(e = 0, t = 0, n = 0, i = tt.DEFAULT_ORDER) { ((this.isEuler = !0), (this._x = e), (this._y = t), (this._z = n), (this._order = i)); } 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 order() { return this._order; } set order(e) { ((this._order = e), this._onChangeCallback()); } set(e, t, n, i = this._order) { return ((this._x = e), (this._y = t), (this._z = n), (this._order = i), this._onChangeCallback(), this); } clone() { return new this.constructor(this._x, this._y, this._z, this._order); } copy(e) { return ( (this._x = e._x), (this._y = e._y), (this._z = e._z), (this._order = e._order), this._onChangeCallback(), this ); } setFromRotationMatrix(e, t = this._order, n = !0) { let i = e.elements, s = i[0], r = i[4], o = i[8], a = i[1], l = i[5], c = i[9], h = i[2], u = i[6], d = i[10]; switch (t) { case "XYZ": if (((this._y = Math.asin(qe(o, -1, 1))), Math.abs(o) < 0.9999999)) ((this._x = Math.atan2(-c, d)), (this._z = Math.atan2(-r, s))); else ((this._x = Math.atan2(u, l)), (this._z = 0)); break; case "YXZ": if (((this._x = Math.asin(-qe(c, -1, 1))), Math.abs(c) < 0.9999999)) ((this._y = Math.atan2(o, d)), (this._z = Math.atan2(a, l))); else ((this._y = Math.atan2(-h, s)), (this._z = 0)); break; case "ZXY": if (((this._x = Math.asin(qe(u, -1, 1))), Math.abs(u) < 0.9999999)) ((this._y = Math.atan2(-h, d)), (this._z = Math.atan2(-r, l))); else ((this._y = 0), (this._z = Math.atan2(a, s))); break; case "ZYX": if (((this._y = Math.asin(-qe(h, -1, 1))), Math.abs(h) < 0.9999999)) ((this._x = Math.atan2(u, d)), (this._z = Math.atan2(a, s))); else ((this._x = 0), (this._z = Math.atan2(-r, l))); break; case "YZX": if (((this._z = Math.asin(qe(a, -1, 1))), Math.abs(a) < 0.9999999)) ((this._x = Math.atan2(-c, l)), (this._y = Math.atan2(-h, s))); else ((this._x = 0), (this._y = Math.atan2(o, d))); break; case "XZY": if (((this._z = Math.asin(-qe(r, -1, 1))), Math.abs(r) < 0.9999999)) ((this._x = Math.atan2(u, l)), (this._y = Math.atan2(o, s))); else ((this._x = Math.atan2(-c, d)), (this._y = 0)); break; default: console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + t); } if (((this._order = t), n === !0)) this._onChangeCallback(); return this; } setFromQuaternion(e, t, n) { return (Oh.makeRotationFromQuaternion(e), this.setFromRotationMatrix(Oh, t, n)); } setFromVector3(e, t = this._order) { return this.set(e.x, e.y, e.z, t); } reorder(e) { return (kh.setFromEuler(this), this.setFromQuaternion(kh, e)); } equals(e) { return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order; } fromArray(e) { if (((this._x = e[0]), (this._y = e[1]), (this._z = e[2]), e[3] !== void 0)) this._order = e[3]; return (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._order), e); } _onChange(e) { return ((this._onChangeCallback = e), this); } _onChangeCallback() {} *[Symbol.iterator]() { (yield this._x, yield this._y, yield this._z, yield this._order); } } tt.DEFAULT_ORDER = "XYZ"; class Vr { constructor() { this.mask = 1; } set(e) { this.mask = ((1 << e) | 0) >>> 0; } enable(e) { this.mask |= (1 << e) | 0; } enableAll() { this.mask = -1; } toggle(e) { this.mask ^= (1 << e) | 0; } disable(e) { this.mask &= ~((1 << e) | 0); } disableAll() { this.mask = 0; } test(e) { return (this.mask & e.mask) !== 0; } isEnabled(e) { return (this.mask & ((1 << e) | 0)) !== 0; } } var _m = 0, zh = new E(), Ds = new Ne(), hi = new ue(), po = new E(), br = new E(), Sm = new E(), bm = new Ne(), Hh = new E(1, 0, 0), Bh = new E(0, 1, 0), Gh = new E(0, 0, 1), Vh = { type: "added" }, Mm = { type: "removed" }, Us = { type: "childadded", child: null }, Wa = { type: "childremoved", child: null }; class it extends jn { constructor() { super(); ((this.isObject3D = !0), Object.defineProperty(this, "id", { value: _m++ }), (this.uuid = Un()), (this.name = ""), (this.type = "Object3D"), (this.parent = null), (this.children = []), (this.up = it.DEFAULT_UP.clone())); let e = new E(), t = new tt(), n = new Ne(), i = new E(1, 1, 1); function s() { n.setFromEuler(t, !1); } function r() { t.setFromQuaternion(n, void 0, !1); } (t._onChange(s), n._onChange(r), Object.defineProperties(this, { position: { configurable: !0, enumerable: !0, value: e }, rotation: { configurable: !0, enumerable: !0, value: t }, quaternion: { configurable: !0, enumerable: !0, value: n }, scale: { configurable: !0, enumerable: !0, value: i }, modelViewMatrix: { value: new ue() }, normalMatrix: { value: new Be() }, }), (this.matrix = new ue()), (this.matrixWorld = new ue()), (this.matrixAutoUpdate = it.DEFAULT_MATRIX_AUTO_UPDATE), (this.matrixWorldAutoUpdate = it.DEFAULT_MATRIX_WORLD_AUTO_UPDATE), (this.matrixWorldNeedsUpdate = !1), (this.layers = new Vr()), (this.visible = !0), (this.castShadow = !1), (this.receiveShadow = !1), (this.frustumCulled = !0), (this.renderOrder = 0), (this.animations = []), (this.customDepthMaterial = void 0), (this.customDistanceMaterial = void 0), (this.userData = {})); } onBeforeShadow() {} onAfterShadow() {} onBeforeRender() {} onAfterRender() {} applyMatrix4(e) { if (this.matrixAutoUpdate) this.updateMatrix(); (this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale)); } applyQuaternion(e) { return (this.quaternion.premultiply(e), this); } setRotationFromAxisAngle(e, t) { this.quaternion.setFromAxisAngle(e, t); } setRotationFromEuler(e) { this.quaternion.setFromEuler(e, !0); } setRotationFromMatrix(e) { this.quaternion.setFromRotationMatrix(e); } setRotationFromQuaternion(e) { this.quaternion.copy(e); } rotateOnAxis(e, t) { return (Ds.setFromAxisAngle(e, t), this.quaternion.multiply(Ds), this); } rotateOnWorldAxis(e, t) { return (Ds.setFromAxisAngle(e, t), this.quaternion.premultiply(Ds), this); } rotateX(e) { return this.rotateOnAxis(Hh, e); } rotateY(e) { return this.rotateOnAxis(Bh, e); } rotateZ(e) { return this.rotateOnAxis(Gh, e); } translateOnAxis(e, t) { return (zh.copy(e).applyQuaternion(this.quaternion), this.position.add(zh.multiplyScalar(t)), this); } translateX(e) { return this.translateOnAxis(Hh, e); } translateY(e) { return this.translateOnAxis(Bh, e); } translateZ(e) { return this.translateOnAxis(Gh, e); } localToWorld(e) { return (this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld)); } worldToLocal(e) { return (this.updateWorldMatrix(!0, !1), e.applyMatrix4(hi.copy(this.matrixWorld).invert())); } lookAt(e, t, n) { if (e.isVector3) po.copy(e); else po.set(e, t, n); let i = this.parent; if ((this.updateWorldMatrix(!0, !1), br.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight)) hi.lookAt(br, po, this.up); else hi.lookAt(po, br, this.up); if ((this.quaternion.setFromRotationMatrix(hi), i)) (hi.extractRotation(i.matrixWorld), Ds.setFromRotationMatrix(hi), this.quaternion.premultiply(Ds.invert())); } add(e) { if (arguments.length > 1) { for (let t = 0; t < arguments.length; t++) this.add(arguments[t]); return this; } if (e === this) return (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this); if (e && e.isObject3D) (e.removeFromParent(), (e.parent = this), this.children.push(e), e.dispatchEvent(Vh), (Us.child = e), this.dispatchEvent(Us), (Us.child = null)); else console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", e); return this; } remove(e) { if (arguments.length > 1) { for (let n = 0; n < arguments.length; n++) this.remove(arguments[n]); return this; } let t = this.children.indexOf(e); if (t !== -1) ((e.parent = null), this.children.splice(t, 1), e.dispatchEvent(Mm), (Wa.child = e), this.dispatchEvent(Wa), (Wa.child = null)); return this; } removeFromParent() { let e = this.parent; if (e !== null) e.remove(this); return this; } clear() { return this.remove(...this.children); } attach(e) { if ((this.updateWorldMatrix(!0, !1), hi.copy(this.matrixWorld).invert(), e.parent !== null)) (e.parent.updateWorldMatrix(!0, !1), hi.multiply(e.parent.matrixWorld)); return ( e.applyMatrix4(hi), e.removeFromParent(), (e.parent = this), this.children.push(e), e.updateWorldMatrix(!1, !0), e.dispatchEvent(Vh), (Us.child = e), this.dispatchEvent(Us), (Us.child = null), this ); } getObjectById(e) { return this.getObjectByProperty("id", e); } getObjectByName(e) { return this.getObjectByProperty("name", e); } getObjectByProperty(e, t) { if (this[e] === t) return this; for (let n = 0, i = this.children.length; n < i; n++) { let r = this.children[n].getObjectByProperty(e, t); if (r !== void 0) return r; } return; } getObjectsByProperty(e, t, n = []) { if (this[e] === t) n.push(this); let i = this.children; for (let s = 0, r = i.length; s < r; s++) i[s].getObjectsByProperty(e, t, n); return n; } getWorldPosition(e) { return (this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld)); } getWorldQuaternion(e) { return (this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(br, e, Sm), e); } getWorldScale(e) { return (this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(br, bm, e), e); } getWorldDirection(e) { this.updateWorldMatrix(!0, !1); let t = this.matrixWorld.elements; return e.set(t[8], t[9], t[10]).normalize(); } raycast() {} traverse(e) { e(this); let t = this.children; for (let n = 0, i = t.length; n < i; n++) t[n].traverse(e); } traverseVisible(e) { if (this.visible === !1) return; e(this); let t = this.children; for (let n = 0, i = t.length; n < i; n++) t[n].traverseVisible(e); } traverseAncestors(e) { let t = this.parent; if (t !== null) (e(t), t.traverseAncestors(e)); } updateMatrix() { (this.matrix.compose(this.position, this.quaternion, this.scale), (this.matrixWorldNeedsUpdate = !0)); } updateMatrixWorld(e) { if (this.matrixAutoUpdate) this.updateMatrix(); if (this.matrixWorldNeedsUpdate || e) { if (this.matrixWorldAutoUpdate === !0) if (this.parent === null) this.matrixWorld.copy(this.matrix); else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix); ((this.matrixWorldNeedsUpdate = !1), (e = !0)); } let t = this.children; for (let n = 0, i = t.length; n < i; n++) t[n].updateMatrixWorld(e); } updateWorldMatrix(e, t) { let n = this.parent; if (e === !0 && n !== null) n.updateWorldMatrix(!0, !1); if (this.matrixAutoUpdate) this.updateMatrix(); if (this.matrixWorldAutoUpdate === !0) if (this.parent === null) this.matrixWorld.copy(this.matrix); else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix); if (t === !0) { let i = this.children; for (let s = 0, r = i.length; s < r; s++) i[s].updateWorldMatrix(!1, !0); } } toJSON(e) { let t = e === void 0 || typeof e === "string", n = {}; if (t) ((e = { geometries: {}, materials: {}, textures: {}, images: {}, shapes: {}, skeletons: {}, animations: {}, nodes: {}, }), (n.metadata = { version: 4.7, type: "Object", generator: "Object3D.toJSON" })); let i = {}; if (((i.uuid = this.uuid), (i.type = this.type), this.name !== "")) i.name = this.name; if (this.castShadow === !0) i.castShadow = !0; if (this.receiveShadow === !0) i.receiveShadow = !0; if (this.visible === !1) i.visible = !1; if (this.frustumCulled === !1) i.frustumCulled = !1; if (this.renderOrder !== 0) i.renderOrder = this.renderOrder; if (Object.keys(this.userData).length > 0) i.userData = this.userData; if ( ((i.layers = this.layers.mask), (i.matrix = this.matrix.toArray()), (i.up = this.up.toArray()), this.matrixAutoUpdate === !1) ) i.matrixAutoUpdate = !1; if (this.isInstancedMesh) { if ( ((i.type = "InstancedMesh"), (i.count = this.count), (i.instanceMatrix = this.instanceMatrix.toJSON()), this.instanceColor !== null) ) i.instanceColor = this.instanceColor.toJSON(); } if (this.isBatchedMesh) { if ( ((i.type = "BatchedMesh"), (i.perObjectFrustumCulled = this.perObjectFrustumCulled), (i.sortObjects = this.sortObjects), (i.drawRanges = this._drawRanges), (i.reservedRanges = this._reservedRanges), (i.geometryInfo = this._geometryInfo.map((o) => ({ ...o, boundingBox: o.boundingBox ? o.boundingBox.toJSON() : void 0, boundingSphere: o.boundingSphere ? o.boundingSphere.toJSON() : void 0, }))), (i.instanceInfo = this._instanceInfo.map((o) => ({ ...o }))), (i.availableInstanceIds = this._availableInstanceIds.slice()), (i.availableGeometryIds = this._availableGeometryIds.slice()), (i.nextIndexStart = this._nextIndexStart), (i.nextVertexStart = this._nextVertexStart), (i.geometryCount = this._geometryCount), (i.maxInstanceCount = this._maxInstanceCount), (i.maxVertexCount = this._maxVertexCount), (i.maxIndexCount = this._maxIndexCount), (i.geometryInitialized = this._geometryInitialized), (i.matricesTexture = this._matricesTexture.toJSON(e)), (i.indirectTexture = this._indirectTexture.toJSON(e)), this._colorsTexture !== null) ) i.colorsTexture = this._colorsTexture.toJSON(e); if (this.boundingSphere !== null) i.boundingSphere = this.boundingSphere.toJSON(); if (this.boundingBox !== null) i.boundingBox = this.boundingBox.toJSON(); } function s(o, a) { if (o[a.uuid] === void 0) o[a.uuid] = a.toJSON(e); return a.uuid; } if (this.isScene) { if (this.background) { if (this.background.isColor) i.background = this.background.toJSON(); else if (this.background.isTexture) i.background = this.background.toJSON(e).uuid; } if (this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0) i.environment = this.environment.toJSON(e).uuid; } else if (this.isMesh || this.isLine || this.isPoints) { i.geometry = s(e.geometries, this.geometry); let o = this.geometry.parameters; if (o !== void 0 && o.shapes !== void 0) { let a = o.shapes; if (Array.isArray(a)) for (let l = 0, c = a.length; l < c; l++) { let h = a[l]; s(e.shapes, h); } else s(e.shapes, a); } } if (this.isSkinnedMesh) { if (((i.bindMode = this.bindMode), (i.bindMatrix = this.bindMatrix.toArray()), this.skeleton !== void 0)) (s(e.skeletons, this.skeleton), (i.skeleton = this.skeleton.uuid)); } if (this.material !== void 0) if (Array.isArray(this.material)) { let o = []; for (let a = 0, l = this.material.length; a < l; a++) o.push(s(e.materials, this.material[a])); i.material = o; } else i.material = s(e.materials, this.material); if (this.children.length > 0) { i.children = []; for (let o = 0; o < this.children.length; o++) i.children.push(this.children[o].toJSON(e).object); } if (this.animations.length > 0) { i.animations = []; for (let o = 0; o < this.animations.length; o++) { let a = this.animations[o]; i.animations.push(s(e.animations, a)); } } if (t) { let o = r(e.geometries), a = r(e.materials), l = r(e.textures), c = r(e.images), h = r(e.shapes), u = r(e.skeletons), d = r(e.animations), f = r(e.nodes); if (o.length > 0) n.geometries = o; if (a.length > 0) n.materials = a; if (l.length > 0) n.textures = l; if (c.length > 0) n.images = c; if (h.length > 0) n.shapes = h; if (u.length > 0) n.skeletons = u; if (d.length > 0) n.animations = d; if (f.length > 0) n.nodes = f; } return ((n.object = i), n); function r(o) { let a = []; for (let l in o) { let c = o[l]; (delete c.metadata, a.push(c)); } return a; } } clone(e) { return new this.constructor().copy(this, e); } copy(e, t = !0) { if ( ((this.name = e.name), this.up.copy(e.up), this.position.copy(e.position), (this.rotation.order = e.rotation.order), this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), (this.matrixAutoUpdate = e.matrixAutoUpdate), (this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate), (this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate), (this.layers.mask = e.layers.mask), (this.visible = e.visible), (this.castShadow = e.castShadow), (this.receiveShadow = e.receiveShadow), (this.frustumCulled = e.frustumCulled), (this.renderOrder = e.renderOrder), (this.animations = e.animations.slice()), (this.userData = JSON.parse(JSON.stringify(e.userData))), t === !0) ) for (let n = 0; n < e.children.length; n++) { let i = e.children[n]; this.add(i.clone()); } return this; } } it.DEFAULT_UP = new E(0, 1, 0); it.DEFAULT_MATRIX_AUTO_UPDATE = !0; it.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0; var Pn = new E(), ui = new E(), Xa = new E(), di = new E(), Ns = new E(), Fs = new E(), Wh = new E(), qa = new E(), Ya = new E(), ja = new E(), Za = new Ye(), Ka = new Ye(), $a = new Ye(); class Mn { constructor(e = new E(), t = new E(), n = new E()) { ((this.a = e), (this.b = t), (this.c = n)); } static getNormal(e, t, n, i) { (i.subVectors(n, t), Pn.subVectors(e, t), i.cross(Pn)); let s = i.lengthSq(); if (s > 0) return i.multiplyScalar(1 / Math.sqrt(s)); return i.set(0, 0, 0); } static getBarycoord(e, t, n, i, s) { (Pn.subVectors(i, t), ui.subVectors(n, t), Xa.subVectors(e, t)); let r = Pn.dot(Pn), o = Pn.dot(ui), a = Pn.dot(Xa), l = ui.dot(ui), c = ui.dot(Xa), h = r * l - o * o; if (h === 0) return (s.set(0, 0, 0), null); let u = 1 / h, d = (l * a - o * c) * u, f = (r * c - o * a) * u; return s.set(1 - d - f, f, d); } static containsPoint(e, t, n, i) { if (this.getBarycoord(e, t, n, i, di) === null) return !1; return di.x >= 0 && di.y >= 0 && di.x + di.y <= 1; } static getInterpolation(e, t, n, i, s, r, o, a) { if (this.getBarycoord(e, t, n, i, di) === null) { if (((a.x = 0), (a.y = 0), "z" in a)) a.z = 0; if ("w" in a) a.w = 0; return null; } return (a.setScalar(0), a.addScaledVector(s, di.x), a.addScaledVector(r, di.y), a.addScaledVector(o, di.z), a); } static getInterpolatedAttribute(e, t, n, i, s, r) { return ( Za.setScalar(0), Ka.setScalar(0), $a.setScalar(0), Za.fromBufferAttribute(e, t), Ka.fromBufferAttribute(e, n), $a.fromBufferAttribute(e, i), r.setScalar(0), r.addScaledVector(Za, s.x), r.addScaledVector(Ka, s.y), r.addScaledVector($a, s.z), r ); } static isFrontFacing(e, t, n, i) { return (Pn.subVectors(n, t), ui.subVectors(e, t), Pn.cross(ui).dot(i) < 0 ? !0 : !1); } set(e, t, n) { return (this.a.copy(e), this.b.copy(t), this.c.copy(n), this); } setFromPointsAndIndices(e, t, n, i) { return (this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[i]), this); } setFromAttributeAndIndices(e, t, n, i) { return (this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, i), this); } clone() { return new this.constructor().copy(this); } copy(e) { return (this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this); } getArea() { return (Pn.subVectors(this.c, this.b), ui.subVectors(this.a, this.b), Pn.cross(ui).length() * 0.5); } getMidpoint(e) { return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(0.3333333333333333); } getNormal(e) { return Mn.getNormal(this.a, this.b, this.c, e); } getPlane(e) { return e.setFromCoplanarPoints(this.a, this.b, this.c); } getBarycoord(e, t) { return Mn.getBarycoord(e, this.a, this.b, this.c, t); } getInterpolation(e, t, n, i, s) { return Mn.getInterpolation(e, this.a, this.b, this.c, t, n, i, s); } containsPoint(e) { return Mn.containsPoint(e, this.a, this.b, this.c); } isFrontFacing(e) { return Mn.isFrontFacing(this.a, this.b, this.c, e); } intersectsBox(e) { return e.intersectsTriangle(this); } closestPointToPoint(e, t) { let n = this.a, i = this.b, s = this.c, r, o; (Ns.subVectors(i, n), Fs.subVectors(s, n), qa.subVectors(e, n)); let a = Ns.dot(qa), l = Fs.dot(qa); if (a <= 0 && l <= 0) return t.copy(n); Ya.subVectors(e, i); let c = Ns.dot(Ya), h = Fs.dot(Ya); if (c >= 0 && h <= c) return t.copy(i); let u = a * h - c * l; if (u <= 0 && a >= 0 && c <= 0) return ((r = a / (a - c)), t.copy(n).addScaledVector(Ns, r)); ja.subVectors(e, s); let d = Ns.dot(ja), f = Fs.dot(ja); if (f >= 0 && d <= f) return t.copy(s); let m = d * l - a * f; if (m <= 0 && l >= 0 && f <= 0) return ((o = l / (l - f)), t.copy(n).addScaledVector(Fs, o)); let y = c * f - d * h; if (y <= 0 && h - c >= 0 && d - f >= 0) return (Wh.subVectors(s, i), (o = (h - c) / (h - c + (d - f))), t.copy(i).addScaledVector(Wh, o)); let p = 1 / (y + m + u); return ((r = m * p), (o = u * p), t.copy(n).addScaledVector(Ns, r).addScaledVector(Fs, o)); } equals(e) { return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c); } } var md = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, rebeccapurple: 6697881, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074, }, Ii = { h: 0, s: 0, l: 0 }, mo = { h: 0, s: 0, l: 0 }; function Ja(e, t, n) { if (n < 0) n += 1; if (n > 1) n -= 1; if (n < 0.16666666666666666) return e + (t - e) * 6 * n; if (n < 0.5) return t; if (n < 0.6666666666666666) return e + (t - e) * 6 * (0.6666666666666666 - n); return e; } class re { constructor(e, t, n) { return ((this.isColor = !0), (this.r = 1), (this.g = 1), (this.b = 1), this.set(e, t, n)); } set(e, t, n) { if (t === void 0 && n === void 0) { let i = e; if (i && i.isColor) this.copy(i); else if (typeof i === "number") this.setHex(i); else if (typeof i === "string") this.setStyle(i); } else this.setRGB(e, t, n); return this; } setScalar(e) { return ((this.r = e), (this.g = e), (this.b = e), this); } setHex(e, t = "srgb") { return ( (e = Math.floor(e)), (this.r = ((e >> 16) & 255) / 255), (this.g = ((e >> 8) & 255) / 255), (this.b = (e & 255) / 255), ke.colorSpaceToWorking(this, t), this ); } setRGB(e, t, n, i = ke.workingColorSpace) { return ((this.r = e), (this.g = t), (this.b = n), ke.colorSpaceToWorking(this, i), this); } setHSL(e, t, n, i = ke.workingColorSpace) { if (((e = sc(e, 1)), (t = qe(t, 0, 1)), (n = qe(n, 0, 1)), t === 0)) this.r = this.g = this.b = n; else { let s = n <= 0.5 ? n * (1 + t) : n + t - n * t, r = 2 * n - s; ((this.r = Ja(r, s, e + 0.3333333333333333)), (this.g = Ja(r, s, e)), (this.b = Ja(r, s, e - 0.3333333333333333))); } return (ke.colorSpaceToWorking(this, i), this); } setStyle(e, t = "srgb") { function n(s) { if (s === void 0) return; if (parseFloat(s) < 1) console.warn("THREE.Color: Alpha component of " + e + " will be ignored."); } let i; if ((i = /^(\w+)\(([^\)]*)\)/.exec(e))) { let s, r = i[1], o = i[2]; switch (r) { case "rgb": case "rgba": if ((s = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))) return ( n(s[4]), this.setRGB( Math.min(255, parseInt(s[1], 10)) / 255, Math.min(255, parseInt(s[2], 10)) / 255, Math.min(255, parseInt(s[3], 10)) / 255, t, ) ); if ((s = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))) return ( n(s[4]), this.setRGB( Math.min(100, parseInt(s[1], 10)) / 100, Math.min(100, parseInt(s[2], 10)) / 100, Math.min(100, parseInt(s[3], 10)) / 100, t, ) ); break; case "hsl": case "hsla": if ((s = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))) return (n(s[4]), this.setHSL(parseFloat(s[1]) / 360, parseFloat(s[2]) / 100, parseFloat(s[3]) / 100, t)); break; default: console.warn("THREE.Color: Unknown color model " + e); } } else if ((i = /^\#([A-Fa-f\d]+)$/.exec(e))) { let s = i[1], r = s.length; if (r === 3) return this.setRGB( parseInt(s.charAt(0), 16) / 15, parseInt(s.charAt(1), 16) / 15, parseInt(s.charAt(2), 16) / 15, t, ); else if (r === 6) return this.setHex(parseInt(s, 16), t); else console.warn("THREE.Color: Invalid hex color " + e); } else if (e && e.length > 0) return this.setColorName(e, t); return this; } setColorName(e, t = "srgb") { let n = md[e.toLowerCase()]; if (n !== void 0) this.setHex(n, t); else console.warn("THREE.Color: Unknown color " + e); return this; } clone() { return new this.constructor(this.r, this.g, this.b); } copy(e) { return ((this.r = e.r), (this.g = e.g), (this.b = e.b), this); } copySRGBToLinear(e) { return ((this.r = pi(e.r)), (this.g = pi(e.g)), (this.b = pi(e.b)), this); } copyLinearToSRGB(e) { return ((this.r = Gs(e.r)), (this.g = Gs(e.g)), (this.b = Gs(e.b)), this); } convertSRGBToLinear() { return (this.copySRGBToLinear(this), this); } convertLinearToSRGB() { return (this.copyLinearToSRGB(this), this); } getHex(e = "srgb") { return ( ke.workingToColorSpace(qt.copy(this), e), Math.round(qe(qt.r * 255, 0, 255)) * 65536 + Math.round(qe(qt.g * 255, 0, 255)) * 256 + Math.round(qe(qt.b * 255, 0, 255)) ); } getHexString(e = "srgb") { return ("000000" + this.getHex(e).toString(16)).slice(-6); } getHSL(e, t = ke.workingColorSpace) { ke.workingToColorSpace(qt.copy(this), t); let { r: n, g: i, b: s } = qt, r = Math.max(n, i, s), o = Math.min(n, i, s), a, l, c = (o + r) / 2; if (o === r) ((a = 0), (l = 0)); else { let h = r - o; switch (((l = c <= 0.5 ? h / (r + o) : h / (2 - r - o)), r)) { case n: a = (i - s) / h + (i < s ? 6 : 0); break; case i: a = (s - n) / h + 2; break; case s: a = (n - i) / h + 4; break; } a /= 6; } return ((e.h = a), (e.s = l), (e.l = c), e); } getRGB(e, t = ke.workingColorSpace) { return (ke.workingToColorSpace(qt.copy(this), t), (e.r = qt.r), (e.g = qt.g), (e.b = qt.b), e); } getStyle(e = "srgb") { ke.workingToColorSpace(qt.copy(this), e); let { r: t, g: n, b: i } = qt; if (e !== "srgb") return `color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`; return `rgb(${Math.round(t * 255)},${Math.round(n * 255)},${Math.round(i * 255)})`; } offsetHSL(e, t, n) { return (this.getHSL(Ii), this.setHSL(Ii.h + e, Ii.s + t, Ii.l + n)); } add(e) { return ((this.r += e.r), (this.g += e.g), (this.b += e.b), this); } addColors(e, t) { return ((this.r = e.r + t.r), (this.g = e.g + t.g), (this.b = e.b + t.b), this); } addScalar(e) { return ((this.r += e), (this.g += e), (this.b += e), this); } sub(e) { return ( (this.r = Math.max(0, this.r - e.r)), (this.g = Math.max(0, this.g - e.g)), (this.b = Math.max(0, this.b - e.b)), this ); } multiply(e) { return ((this.r *= e.r), (this.g *= e.g), (this.b *= e.b), this); } multiplyScalar(e) { return ((this.r *= e), (this.g *= e), (this.b *= e), this); } lerp(e, t) { return ((this.r += (e.r - this.r) * t), (this.g += (e.g - this.g) * t), (this.b += (e.b - this.b) * t), this); } lerpColors(e, t, n) { return ((this.r = e.r + (t.r - e.r) * n), (this.g = e.g + (t.g - e.g) * n), (this.b = e.b + (t.b - e.b) * n), this); } lerpHSL(e, t) { (this.getHSL(Ii), e.getHSL(mo)); let n = Cr(Ii.h, mo.h, t), i = Cr(Ii.s, mo.s, t), s = Cr(Ii.l, mo.l, t); return (this.setHSL(n, i, s), this); } setFromVector3(e) { return ((this.r = e.x), (this.g = e.y), (this.b = e.z), this); } applyMatrix3(e) { let t = this.r, n = this.g, i = this.b, s = e.elements; return ( (this.r = s[0] * t + s[3] * n + s[6] * i), (this.g = s[1] * t + s[4] * n + s[7] * i), (this.b = s[2] * t + s[5] * n + s[8] * i), this ); } equals(e) { return e.r === this.r && e.g === this.g && e.b === this.b; } fromArray(e, t = 0) { return ((this.r = e[t]), (this.g = e[t + 1]), (this.b = e[t + 2]), this); } toArray(e = [], t = 0) { return ((e[t] = this.r), (e[t + 1] = this.g), (e[t + 2] = this.b), e); } fromBufferAttribute(e, t) { return ((this.r = e.getX(t)), (this.g = e.getY(t)), (this.b = e.getZ(t)), this); } toJSON() { return this.getHex(); } *[Symbol.iterator]() { (yield this.r, yield this.g, yield this.b); } } var qt = new re(); re.NAMES = md; var wm = 0; class Vt extends jn { constructor() { super(); ((this.isMaterial = !0), Object.defineProperty(this, "id", { value: wm++ }), (this.uuid = Un()), (this.name = ""), (this.type = "Material"), (this.blending = 1), (this.side = 0), (this.vertexColors = !1), (this.opacity = 1), (this.transparent = !1), (this.alphaHash = !1), (this.blendSrc = 204), (this.blendDst = 205), (this.blendEquation = 100), (this.blendSrcAlpha = null), (this.blendDstAlpha = null), (this.blendEquationAlpha = null), (this.blendColor = new re(0, 0, 0)), (this.blendAlpha = 0), (this.depthFunc = 3), (this.depthTest = !0), (this.depthWrite = !0), (this.stencilWriteMask = 255), (this.stencilFunc = 519), (this.stencilRef = 0), (this.stencilFuncMask = 255), (this.stencilFail = 7680), (this.stencilZFail = 7680), (this.stencilZPass = 7680), (this.stencilWrite = !1), (this.clippingPlanes = null), (this.clipIntersection = !1), (this.clipShadows = !1), (this.shadowSide = null), (this.colorWrite = !0), (this.precision = null), (this.polygonOffset = !1), (this.polygonOffsetFactor = 0), (this.polygonOffsetUnits = 0), (this.dithering = !1), (this.alphaToCoverage = !1), (this.premultipliedAlpha = !1), (this.forceSinglePass = !1), (this.allowOverride = !0), (this.visible = !0), (this.toneMapped = !0), (this.userData = {}), (this.version = 0), (this._alphaTest = 0)); } get alphaTest() { return this._alphaTest; } set alphaTest(e) { if (this._alphaTest > 0 !== e > 0) this.version++; this._alphaTest = e; } onBeforeRender() {} onBeforeCompile() {} customProgramCacheKey() { return this.onBeforeCompile.toString(); } setValues(e) { if (e === void 0) return; for (let t in e) { let n = e[t]; if (n === void 0) { console.warn(`THREE.Material: parameter '${t}' has value of undefined.`); continue; } let i = this[t]; if (i === void 0) { console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`); continue; } if (i && i.isColor) i.set(n); else if (i && i.isVector3 && n && n.isVector3) i.copy(n); else this[t] = n; } } toJSON(e) { let t = e === void 0 || typeof e === "string"; if (t) e = { textures: {}, images: {} }; let n = { metadata: { version: 4.7, type: "Material", generator: "Material.toJSON" } }; if (((n.uuid = this.uuid), (n.type = this.type), this.name !== "")) n.name = this.name; if (this.color && this.color.isColor) n.color = this.color.getHex(); if (this.roughness !== void 0) n.roughness = this.roughness; if (this.metalness !== void 0) n.metalness = this.metalness; if (this.sheen !== void 0) n.sheen = this.sheen; if (this.sheenColor && this.sheenColor.isColor) n.sheenColor = this.sheenColor.getHex(); if (this.sheenRoughness !== void 0) n.sheenRoughness = this.sheenRoughness; if (this.emissive && this.emissive.isColor) n.emissive = this.emissive.getHex(); if (this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1) n.emissiveIntensity = this.emissiveIntensity; if (this.specular && this.specular.isColor) n.specular = this.specular.getHex(); if (this.specularIntensity !== void 0) n.specularIntensity = this.specularIntensity; if (this.specularColor && this.specularColor.isColor) n.specularColor = this.specularColor.getHex(); if (this.shininess !== void 0) n.shininess = this.shininess; if (this.clearcoat !== void 0) n.clearcoat = this.clearcoat; if (this.clearcoatRoughness !== void 0) n.clearcoatRoughness = this.clearcoatRoughness; if (this.clearcoatMap && this.clearcoatMap.isTexture) n.clearcoatMap = this.clearcoatMap.toJSON(e).uuid; if (this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture) n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid; if (this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture) ((n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid), (n.clearcoatNormalScale = this.clearcoatNormalScale.toArray())); if (this.sheenColorMap && this.sheenColorMap.isTexture) n.sheenColorMap = this.sheenColorMap.toJSON(e).uuid; if (this.sheenRoughnessMap && this.sheenRoughnessMap.isTexture) n.sheenRoughnessMap = this.sheenRoughnessMap.toJSON(e).uuid; if (this.dispersion !== void 0) n.dispersion = this.dispersion; if (this.iridescence !== void 0) n.iridescence = this.iridescence; if (this.iridescenceIOR !== void 0) n.iridescenceIOR = this.iridescenceIOR; if (this.iridescenceThicknessRange !== void 0) n.iridescenceThicknessRange = this.iridescenceThicknessRange; if (this.iridescenceMap && this.iridescenceMap.isTexture) n.iridescenceMap = this.iridescenceMap.toJSON(e).uuid; if (this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture) n.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid; if (this.anisotropy !== void 0) n.anisotropy = this.anisotropy; if (this.anisotropyRotation !== void 0) n.anisotropyRotation = this.anisotropyRotation; if (this.anisotropyMap && this.anisotropyMap.isTexture) n.anisotropyMap = this.anisotropyMap.toJSON(e).uuid; if (this.map && this.map.isTexture) n.map = this.map.toJSON(e).uuid; if (this.matcap && this.matcap.isTexture) n.matcap = this.matcap.toJSON(e).uuid; if (this.alphaMap && this.alphaMap.isTexture) n.alphaMap = this.alphaMap.toJSON(e).uuid; if (this.lightMap && this.lightMap.isTexture) ((n.lightMap = this.lightMap.toJSON(e).uuid), (n.lightMapIntensity = this.lightMapIntensity)); if (this.aoMap && this.aoMap.isTexture) ((n.aoMap = this.aoMap.toJSON(e).uuid), (n.aoMapIntensity = this.aoMapIntensity)); if (this.bumpMap && this.bumpMap.isTexture) ((n.bumpMap = this.bumpMap.toJSON(e).uuid), (n.bumpScale = this.bumpScale)); if (this.normalMap && this.normalMap.isTexture) ((n.normalMap = this.normalMap.toJSON(e).uuid), (n.normalMapType = this.normalMapType), (n.normalScale = this.normalScale.toArray())); if (this.displacementMap && this.displacementMap.isTexture) ((n.displacementMap = this.displacementMap.toJSON(e).uuid), (n.displacementScale = this.displacementScale), (n.displacementBias = this.displacementBias)); if (this.roughnessMap && this.roughnessMap.isTexture) n.roughnessMap = this.roughnessMap.toJSON(e).uuid; if (this.metalnessMap && this.metalnessMap.isTexture) n.metalnessMap = this.metalnessMap.toJSON(e).uuid; if (this.emissiveMap && this.emissiveMap.isTexture) n.emissiveMap = this.emissiveMap.toJSON(e).uuid; if (this.specularMap && this.specularMap.isTexture) n.specularMap = this.specularMap.toJSON(e).uuid; if (this.specularIntensityMap && this.specularIntensityMap.isTexture) n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid; if (this.specularColorMap && this.specularColorMap.isTexture) n.specularColorMap = this.specularColorMap.toJSON(e).uuid; if (this.envMap && this.envMap.isTexture) { if (((n.envMap = this.envMap.toJSON(e).uuid), this.combine !== void 0)) n.combine = this.combine; } if (this.envMapRotation !== void 0) n.envMapRotation = this.envMapRotation.toArray(); if (this.envMapIntensity !== void 0) n.envMapIntensity = this.envMapIntensity; if (this.reflectivity !== void 0) n.reflectivity = this.reflectivity; if (this.refractionRatio !== void 0) n.refractionRatio = this.refractionRatio; if (this.gradientMap && this.gradientMap.isTexture) n.gradientMap = this.gradientMap.toJSON(e).uuid; if (this.transmission !== void 0) n.transmission = this.transmission; if (this.transmissionMap && this.transmissionMap.isTexture) n.transmissionMap = this.transmissionMap.toJSON(e).uuid; if (this.thickness !== void 0) n.thickness = this.thickness; if (this.thicknessMap && this.thicknessMap.isTexture) n.thicknessMap = this.thicknessMap.toJSON(e).uuid; if (this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0) n.attenuationDistance = this.attenuationDistance; if (this.attenuationColor !== void 0) n.attenuationColor = this.attenuationColor.getHex(); if (this.size !== void 0) n.size = this.size; if (this.shadowSide !== null) n.shadowSide = this.shadowSide; if (this.sizeAttenuation !== void 0) n.sizeAttenuation = this.sizeAttenuation; if (this.blending !== 1) n.blending = this.blending; if (this.side !== 0) n.side = this.side; if (this.vertexColors === !0) n.vertexColors = !0; if (this.opacity < 1) n.opacity = this.opacity; if (this.transparent === !0) n.transparent = !0; if (this.blendSrc !== 204) n.blendSrc = this.blendSrc; if (this.blendDst !== 205) n.blendDst = this.blendDst; if (this.blendEquation !== 100) n.blendEquation = this.blendEquation; if (this.blendSrcAlpha !== null) n.blendSrcAlpha = this.blendSrcAlpha; if (this.blendDstAlpha !== null) n.blendDstAlpha = this.blendDstAlpha; if (this.blendEquationAlpha !== null) n.blendEquationAlpha = this.blendEquationAlpha; if (this.blendColor && this.blendColor.isColor) n.blendColor = this.blendColor.getHex(); if (this.blendAlpha !== 0) n.blendAlpha = this.blendAlpha; if (this.depthFunc !== 3) n.depthFunc = this.depthFunc; if (this.depthTest === !1) n.depthTest = this.depthTest; if (this.depthWrite === !1) n.depthWrite = this.depthWrite; if (this.colorWrite === !1) n.colorWrite = this.colorWrite; if (this.stencilWriteMask !== 255) n.stencilWriteMask = this.stencilWriteMask; if (this.stencilFunc !== 519) n.stencilFunc = this.stencilFunc; if (this.stencilRef !== 0) n.stencilRef = this.stencilRef; if (this.stencilFuncMask !== 255) n.stencilFuncMask = this.stencilFuncMask; if (this.stencilFail !== 7680) n.stencilFail = this.stencilFail; if (this.stencilZFail !== 7680) n.stencilZFail = this.stencilZFail; if (this.stencilZPass !== 7680) n.stencilZPass = this.stencilZPass; if (this.stencilWrite === !0) n.stencilWrite = this.stencilWrite; if (this.rotation !== void 0 && this.rotation !== 0) n.rotation = this.rotation; if (this.polygonOffset === !0) n.polygonOffset = !0; if (this.polygonOffsetFactor !== 0) n.polygonOffsetFactor = this.polygonOffsetFactor; if (this.polygonOffsetUnits !== 0) n.polygonOffsetUnits = this.polygonOffsetUnits; if (this.linewidth !== void 0 && this.linewidth !== 1) n.linewidth = this.linewidth; if (this.dashSize !== void 0) n.dashSize = this.dashSize; if (this.gapSize !== void 0) n.gapSize = this.gapSize; if (this.scale !== void 0) n.scale = this.scale; if (this.dithering === !0) n.dithering = !0; if (this.alphaTest > 0) n.alphaTest = this.alphaTest; if (this.alphaHash === !0) n.alphaHash = !0; if (this.alphaToCoverage === !0) n.alphaToCoverage = !0; if (this.premultipliedAlpha === !0) n.premultipliedAlpha = !0; if (this.forceSinglePass === !0) n.forceSinglePass = !0; if (this.wireframe === !0) n.wireframe = !0; if (this.wireframeLinewidth > 1) n.wireframeLinewidth = this.wireframeLinewidth; if (this.wireframeLinecap !== "round") n.wireframeLinecap = this.wireframeLinecap; if (this.wireframeLinejoin !== "round") n.wireframeLinejoin = this.wireframeLinejoin; if (this.flatShading === !0) n.flatShading = !0; if (this.visible === !1) n.visible = !1; if (this.toneMapped === !1) n.toneMapped = !1; if (this.fog === !1) n.fog = !1; if (Object.keys(this.userData).length > 0) n.userData = this.userData; function i(s) { let r = []; for (let o in s) { let a = s[o]; (delete a.metadata, r.push(a)); } return r; } if (t) { let s = i(e.textures), r = i(e.images); if (s.length > 0) n.textures = s; if (r.length > 0) n.images = r; } return n; } clone() { return new this.constructor().copy(this); } copy(e) { ((this.name = e.name), (this.blending = e.blending), (this.side = e.side), (this.vertexColors = e.vertexColors), (this.opacity = e.opacity), (this.transparent = e.transparent), (this.blendSrc = e.blendSrc), (this.blendDst = e.blendDst), (this.blendEquation = e.blendEquation), (this.blendSrcAlpha = e.blendSrcAlpha), (this.blendDstAlpha = e.blendDstAlpha), (this.blendEquationAlpha = e.blendEquationAlpha), this.blendColor.copy(e.blendColor), (this.blendAlpha = e.blendAlpha), (this.depthFunc = e.depthFunc), (this.depthTest = e.depthTest), (this.depthWrite = e.depthWrite), (this.stencilWriteMask = e.stencilWriteMask), (this.stencilFunc = e.stencilFunc), (this.stencilRef = e.stencilRef), (this.stencilFuncMask = e.stencilFuncMask), (this.stencilFail = e.stencilFail), (this.stencilZFail = e.stencilZFail), (this.stencilZPass = e.stencilZPass), (this.stencilWrite = e.stencilWrite)); let t = e.clippingPlanes, n = null; if (t !== null) { let i = t.length; n = Array(i); for (let s = 0; s !== i; ++s) n[s] = t[s].clone(); } return ( (this.clippingPlanes = n), (this.clipIntersection = e.clipIntersection), (this.clipShadows = e.clipShadows), (this.shadowSide = e.shadowSide), (this.colorWrite = e.colorWrite), (this.precision = e.precision), (this.polygonOffset = e.polygonOffset), (this.polygonOffsetFactor = e.polygonOffsetFactor), (this.polygonOffsetUnits = e.polygonOffsetUnits), (this.dithering = e.dithering), (this.alphaTest = e.alphaTest), (this.alphaHash = e.alphaHash), (this.alphaToCoverage = e.alphaToCoverage), (this.premultipliedAlpha = e.premultipliedAlpha), (this.forceSinglePass = e.forceSinglePass), (this.visible = e.visible), (this.toneMapped = e.toneMapped), (this.userData = JSON.parse(JSON.stringify(e.userData))), this ); } dispose() { this.dispatchEvent({ type: "dispose" }); } set needsUpdate(e) { if (e === !0) this.version++; } } class Wt extends Vt { constructor(e) { super(); ((this.isMeshBasicMaterial = !0), (this.type = "MeshBasicMaterial"), (this.color = new re(16777215)), (this.map = null), (this.lightMap = null), (this.lightMapIntensity = 1), (this.aoMap = null), (this.aoMapIntensity = 1), (this.specularMap = null), (this.alphaMap = null), (this.envMap = null), (this.envMapRotation = new tt()), (this.combine = 0), (this.reflectivity = 1), (this.refractionRatio = 0.98), (this.wireframe = !1), (this.wireframeLinewidth = 1), (this.wireframeLinecap = "round"), (this.wireframeLinejoin = "round"), (this.fog = !0), this.setValues(e)); } copy(e) { return ( super.copy(e), this.color.copy(e.color), (this.map = e.map), (this.lightMap = e.lightMap), (this.lightMapIntensity = e.lightMapIntensity), (this.aoMap = e.aoMap), (this.aoMapIntensity = e.aoMapIntensity), (this.specularMap = e.specularMap), (this.alphaMap = e.alphaMap), (this.envMap = e.envMap), this.envMapRotation.copy(e.envMapRotation), (this.combine = e.combine), (this.reflectivity = e.reflectivity), (this.refractionRatio = e.refractionRatio), (this.wireframe = e.wireframe), (this.wireframeLinewidth = e.wireframeLinewidth), (this.wireframeLinecap = e.wireframeLinecap), (this.wireframeLinejoin = e.wireframeLinejoin), (this.fog = e.fog), this ); } } var Dt = new E(), go = new ve(), Tm = 0; class gt { constructor(e, t, n = !1) { if (Array.isArray(e)) throw TypeError("THREE.BufferAttribute: array should be a Typed Array."); ((this.isBufferAttribute = !0), Object.defineProperty(this, "id", { value: Tm++ }), (this.name = ""), (this.array = e), (this.itemSize = t), (this.count = e !== void 0 ? e.length / t : 0), (this.normalized = n), (this.usage = 35044), (this.updateRanges = []), (this.gpuType = 1015), (this.version = 0)); } onUploadCallback() {} set needsUpdate(e) { if (e === !0) this.version++; } setUsage(e) { return ((this.usage = e), this); } addUpdateRange(e, t) { this.updateRanges.push({ start: e, count: t }); } clearUpdateRanges() { this.updateRanges.length = 0; } copy(e) { return ( (this.name = e.name), (this.array = new e.array.constructor(e.array)), (this.itemSize = e.itemSize), (this.count = e.count), (this.normalized = e.normalized), (this.usage = e.usage), (this.gpuType = e.gpuType), this ); } copyAt(e, t, n) { ((e *= this.itemSize), (n *= t.itemSize)); for (let i = 0, s = this.itemSize; i < s; i++) this.array[e + i] = t.array[n + i]; return this; } copyArray(e) { return (this.array.set(e), this); } applyMatrix3(e) { if (this.itemSize === 2) for (let t = 0, n = this.count; t < n; t++) (go.fromBufferAttribute(this, t), go.applyMatrix3(e), this.setXY(t, go.x, go.y)); else if (this.itemSize === 3) for (let t = 0, n = this.count; t < n; t++) (Dt.fromBufferAttribute(this, t), Dt.applyMatrix3(e), this.setXYZ(t, Dt.x, Dt.y, Dt.z)); return this; } applyMatrix4(e) { for (let t = 0, n = this.count; t < n; t++) (Dt.fromBufferAttribute(this, t), Dt.applyMatrix4(e), this.setXYZ(t, Dt.x, Dt.y, Dt.z)); return this; } applyNormalMatrix(e) { for (let t = 0, n = this.count; t < n; t++) (Dt.fromBufferAttribute(this, t), Dt.applyNormalMatrix(e), this.setXYZ(t, Dt.x, Dt.y, Dt.z)); return this; } transformDirection(e) { for (let t = 0, n = this.count; t < n; t++) (Dt.fromBufferAttribute(this, t), Dt.transformDirection(e), this.setXYZ(t, Dt.x, Dt.y, Dt.z)); return this; } set(e, t = 0) { return (this.array.set(e, t), this); } getComponent(e, t) { let n = this.array[e * this.itemSize + t]; if (this.normalized) n = Dn(n, this.array); return n; } setComponent(e, t, n) { if (this.normalized) n = ct(n, this.array); return ((this.array[e * this.itemSize + t] = n), this); } getX(e) { let t = this.array[e * this.itemSize]; if (this.normalized) t = Dn(t, this.array); return t; } setX(e, t) { if (this.normalized) t = ct(t, this.array); return ((this.array[e * this.itemSize] = t), this); } getY(e) { let t = this.array[e * this.itemSize + 1]; if (this.normalized) t = Dn(t, this.array); return t; } setY(e, t) { if (this.normalized) t = ct(t, this.array); return ((this.array[e * this.itemSize + 1] = t), this); } getZ(e) { let t = this.array[e * this.itemSize + 2]; if (this.normalized) t = Dn(t, this.array); return t; } setZ(e, t) { if (this.normalized) t = ct(t, this.array); return ((this.array[e * this.itemSize + 2] = t), this); } getW(e) { let t = this.array[e * this.itemSize + 3]; if (this.normalized) t = Dn(t, this.array); return t; } setW(e, t) { if (this.normalized) t = ct(t, this.array); return ((this.array[e * this.itemSize + 3] = t), this); } setXY(e, t, n) { if (((e *= this.itemSize), this.normalized)) ((t = ct(t, this.array)), (n = ct(n, this.array))); return ((this.array[e + 0] = t), (this.array[e + 1] = n), this); } setXYZ(e, t, n, i) { if (((e *= this.itemSize), this.normalized)) ((t = ct(t, this.array)), (n = ct(n, this.array)), (i = ct(i, this.array))); return ((this.array[e + 0] = t), (this.array[e + 1] = n), (this.array[e + 2] = i), this); } setXYZW(e, t, n, i, s) { if (((e *= this.itemSize), this.normalized)) ((t = ct(t, this.array)), (n = ct(n, this.array)), (i = ct(i, this.array)), (s = ct(s, this.array))); return ((this.array[e + 0] = t), (this.array[e + 1] = n), (this.array[e + 2] = i), (this.array[e + 3] = s), this); } onUpload(e) { return ((this.onUploadCallback = e), this); } clone() { return new this.constructor(this.array, this.itemSize).copy(this); } toJSON() { let e = { itemSize: this.itemSize, type: this.array.constructor.name, array: Array.from(this.array), normalized: this.normalized, }; if (this.name !== "") e.name = this.name; if (this.usage !== 35044) e.usage = this.usage; return e; } } class er extends gt { constructor(e, t, n) { super(new Uint16Array(e), t, n); } } class ta extends gt { constructor(e, t, n) { super(new Uint32Array(e), t, n); } } class at extends gt { constructor(e, t, n) { super(new Float32Array(e), t, n); } } var Em = 0, bn = new ue(), Qa = new it(), Os = new E(), pn = new ln(), Mr = new ln(), zt = new E(); class Et extends jn { constructor() { super(); ((this.isBufferGeometry = !0), Object.defineProperty(this, "id", { value: Em++ }), (this.uuid = Un()), (this.name = ""), (this.type = "BufferGeometry"), (this.index = null), (this.indirect = null), (this.attributes = {}), (this.morphAttributes = {}), (this.morphTargetsRelative = !1), (this.groups = []), (this.boundingBox = null), (this.boundingSphere = null), (this.drawRange = { start: 0, count: 1 / 0 }), (this.userData = {})); } getIndex() { return this.index; } setIndex(e) { if (Array.isArray(e)) this.index = new (rc(e) ? ta : er)(e, 1); else this.index = e; return this; } setIndirect(e) { return ((this.indirect = e), this); } getIndirect() { return this.indirect; } getAttribute(e) { return this.attributes[e]; } setAttribute(e, t) { return ((this.attributes[e] = t), this); } deleteAttribute(e) { return (delete this.attributes[e], this); } hasAttribute(e) { return this.attributes[e] !== void 0; } addGroup(e, t, n = 0) { this.groups.push({ start: e, count: t, materialIndex: n }); } clearGroups() { this.groups = []; } setDrawRange(e, t) { ((this.drawRange.start = e), (this.drawRange.count = t)); } applyMatrix4(e) { let t = this.attributes.position; if (t !== void 0) (t.applyMatrix4(e), (t.needsUpdate = !0)); let n = this.attributes.normal; if (n !== void 0) { let s = new Be().getNormalMatrix(e); (n.applyNormalMatrix(s), (n.needsUpdate = !0)); } let i = this.attributes.tangent; if (i !== void 0) (i.transformDirection(e), (i.needsUpdate = !0)); if (this.boundingBox !== null) this.computeBoundingBox(); if (this.boundingSphere !== null) this.computeBoundingSphere(); return this; } applyQuaternion(e) { return (bn.makeRotationFromQuaternion(e), this.applyMatrix4(bn), this); } rotateX(e) { return (bn.makeRotationX(e), this.applyMatrix4(bn), this); } rotateY(e) { return (bn.makeRotationY(e), this.applyMatrix4(bn), this); } rotateZ(e) { return (bn.makeRotationZ(e), this.applyMatrix4(bn), this); } translate(e, t, n) { return (bn.makeTranslation(e, t, n), this.applyMatrix4(bn), this); } scale(e, t, n) { return (bn.makeScale(e, t, n), this.applyMatrix4(bn), this); } lookAt(e) { return (Qa.lookAt(e), Qa.updateMatrix(), this.applyMatrix4(Qa.matrix), this); } center() { return (this.computeBoundingBox(), this.boundingBox.getCenter(Os).negate(), this.translate(Os.x, Os.y, Os.z), this); } setFromPoints(e) { let t = this.getAttribute("position"); if (t === void 0) { let n = []; for (let i = 0, s = e.length; i < s; i++) { let r = e[i]; n.push(r.x, r.y, r.z || 0); } this.setAttribute("position", new at(n, 3)); } else { let n = Math.min(e.length, t.count); for (let i = 0; i < n; i++) { let s = e[i]; t.setXYZ(i, s.x, s.y, s.z || 0); } if (e.length > t.count) console.warn( "THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.", ); t.needsUpdate = !0; } return this; } computeBoundingBox() { if (this.boundingBox === null) this.boundingBox = new ln(); let e = this.attributes.position, t = this.morphAttributes.position; if (e && e.isGLBufferAttribute) { (console.error( "THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this, ), this.boundingBox.set(new E(-1 / 0, -1 / 0, -1 / 0), new E(1 / 0, 1 / 0, 1 / 0))); return; } if (e !== void 0) { if ((this.boundingBox.setFromBufferAttribute(e), t)) for (let n = 0, i = t.length; n < i; n++) { let s = t[n]; if ((pn.setFromBufferAttribute(s), this.morphTargetsRelative)) (zt.addVectors(this.boundingBox.min, pn.min), this.boundingBox.expandByPoint(zt), zt.addVectors(this.boundingBox.max, pn.max), this.boundingBox.expandByPoint(zt)); else (this.boundingBox.expandByPoint(pn.min), this.boundingBox.expandByPoint(pn.max)); } } else this.boundingBox.makeEmpty(); if (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) console.error( 'THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this, ); } computeBoundingSphere() { if (this.boundingSphere === null) this.boundingSphere = new yn(); let e = this.attributes.position, t = this.morphAttributes.position; if (e && e.isGLBufferAttribute) { (console.error( "THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this, ), this.boundingSphere.set(new E(), 1 / 0)); return; } if (e) { let n = this.boundingSphere.center; if ((pn.setFromBufferAttribute(e), t)) for (let s = 0, r = t.length; s < r; s++) { let o = t[s]; if ((Mr.setFromBufferAttribute(o), this.morphTargetsRelative)) (zt.addVectors(pn.min, Mr.min), pn.expandByPoint(zt), zt.addVectors(pn.max, Mr.max), pn.expandByPoint(zt)); else (pn.expandByPoint(Mr.min), pn.expandByPoint(Mr.max)); } pn.getCenter(n); let i = 0; for (let s = 0, r = e.count; s < r; s++) (zt.fromBufferAttribute(e, s), (i = Math.max(i, n.distanceToSquared(zt)))); if (t) for (let s = 0, r = t.length; s < r; s++) { let o = t[s], a = this.morphTargetsRelative; for (let l = 0, c = o.count; l < c; l++) { if ((zt.fromBufferAttribute(o, l), a)) (Os.fromBufferAttribute(e, l), zt.add(Os)); i = Math.max(i, n.distanceToSquared(zt)); } } if (((this.boundingSphere.radius = Math.sqrt(i)), isNaN(this.boundingSphere.radius))) console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this, ); } } computeTangents() { let e = this.index, t = this.attributes; if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) { console.error( "THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)", ); return; } let { position: n, normal: i, uv: s } = t; if (this.hasAttribute("tangent") === !1) this.setAttribute("tangent", new gt(new Float32Array(4 * n.count), 4)); let r = this.getAttribute("tangent"), o = [], a = []; for (let R = 0; R < n.count; R++) ((o[R] = new E()), (a[R] = new E())); let l = new E(), c = new E(), h = new E(), u = new ve(), d = new ve(), f = new ve(), m = new E(), y = new E(); function p(R, F, M) { (l.fromBufferAttribute(n, R), c.fromBufferAttribute(n, F), h.fromBufferAttribute(n, M), u.fromBufferAttribute(s, R), d.fromBufferAttribute(s, F), f.fromBufferAttribute(s, M), c.sub(l), h.sub(l), d.sub(u), f.sub(u)); let T = 1 / (d.x * f.y - f.x * d.y); if (!isFinite(T)) return; (m.copy(c).multiplyScalar(f.y).addScaledVector(h, -d.y).multiplyScalar(T), y.copy(h).multiplyScalar(d.x).addScaledVector(c, -f.x).multiplyScalar(T), o[R].add(m), o[F].add(m), o[M].add(m), a[R].add(y), a[F].add(y), a[M].add(y)); } let g = this.groups; if (g.length === 0) g = [{ start: 0, count: e.count }]; for (let R = 0, F = g.length; R < F; ++R) { let M = g[R], { start: T, count: I } = M; for (let G = T, q = T + I; G < q; G += 3) p(e.getX(G + 0), e.getX(G + 1), e.getX(G + 2)); } let _ = new E(), x = new E(), w = new E(), L = new E(); function b(R) { (w.fromBufferAttribute(i, R), L.copy(w)); let F = o[R]; (_.copy(F), _.sub(w.multiplyScalar(w.dot(F))).normalize(), x.crossVectors(L, F)); let T = x.dot(a[R]) < 0 ? -1 : 1; r.setXYZW(R, _.x, _.y, _.z, T); } for (let R = 0, F = g.length; R < F; ++R) { let M = g[R], { start: T, count: I } = M; for (let G = T, q = T + I; G < q; G += 3) (b(e.getX(G + 0)), b(e.getX(G + 1)), b(e.getX(G + 2))); } } computeVertexNormals() { let e = this.index, t = this.getAttribute("position"); if (t !== void 0) { let n = this.getAttribute("normal"); if (n === void 0) ((n = new gt(new Float32Array(t.count * 3), 3)), this.setAttribute("normal", n)); else for (let u = 0, d = n.count; u < d; u++) n.setXYZ(u, 0, 0, 0); let i = new E(), s = new E(), r = new E(), o = new E(), a = new E(), l = new E(), c = new E(), h = new E(); if (e) for (let u = 0, d = e.count; u < d; u += 3) { let f = e.getX(u + 0), m = e.getX(u + 1), y = e.getX(u + 2); (i.fromBufferAttribute(t, f), s.fromBufferAttribute(t, m), r.fromBufferAttribute(t, y), c.subVectors(r, s), h.subVectors(i, s), c.cross(h), o.fromBufferAttribute(n, f), a.fromBufferAttribute(n, m), l.fromBufferAttribute(n, y), o.add(c), a.add(c), l.add(c), n.setXYZ(f, o.x, o.y, o.z), n.setXYZ(m, a.x, a.y, a.z), n.setXYZ(y, l.x, l.y, l.z)); } else for (let u = 0, d = t.count; u < d; u += 3) (i.fromBufferAttribute(t, u + 0), s.fromBufferAttribute(t, u + 1), r.fromBufferAttribute(t, u + 2), c.subVectors(r, s), h.subVectors(i, s), c.cross(h), n.setXYZ(u + 0, c.x, c.y, c.z), n.setXYZ(u + 1, c.x, c.y, c.z), n.setXYZ(u + 2, c.x, c.y, c.z)); (this.normalizeNormals(), (n.needsUpdate = !0)); } } normalizeNormals() { let e = this.attributes.normal; for (let t = 0, n = e.count; t < n; t++) (zt.fromBufferAttribute(e, t), zt.normalize(), e.setXYZ(t, zt.x, zt.y, zt.z)); } toNonIndexed() { function e(o, a) { let { array: l, itemSize: c, normalized: h } = o, u = new l.constructor(a.length * c), d = 0, f = 0; for (let m = 0, y = a.length; m < y; m++) { if (o.isInterleavedBufferAttribute) d = a[m] * o.data.stride + o.offset; else d = a[m] * c; for (let p = 0; p < c; p++) u[f++] = l[d++]; } return new gt(u, c, h); } if (this.index === null) return (console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this); let t = new Et(), n = this.index.array, i = this.attributes; for (let o in i) { let a = i[o], l = e(a, n); t.setAttribute(o, l); } let s = this.morphAttributes; for (let o in s) { let a = [], l = s[o]; for (let c = 0, h = l.length; c < h; c++) { let u = l[c], d = e(u, n); a.push(d); } t.morphAttributes[o] = a; } t.morphTargetsRelative = this.morphTargetsRelative; let r = this.groups; for (let o = 0, a = r.length; o < a; o++) { let l = r[o]; t.addGroup(l.start, l.count, l.materialIndex); } return t; } toJSON() { let e = { metadata: { version: 4.7, type: "BufferGeometry", generator: "BufferGeometry.toJSON" } }; if (((e.uuid = this.uuid), (e.type = this.type), this.name !== "")) e.name = this.name; if (Object.keys(this.userData).length > 0) e.userData = this.userData; if (this.parameters !== void 0) { let a = this.parameters; for (let l in a) if (a[l] !== void 0) e[l] = a[l]; return e; } e.data = { attributes: {} }; let t = this.index; if (t !== null) e.data.index = { type: t.array.constructor.name, array: Array.prototype.slice.call(t.array) }; let n = this.attributes; for (let a in n) { let l = n[a]; e.data.attributes[a] = l.toJSON(e.data); } let i = {}, s = !1; for (let a in this.morphAttributes) { let l = this.morphAttributes[a], c = []; for (let h = 0, u = l.length; h < u; h++) { let d = l[h]; c.push(d.toJSON(e.data)); } if (c.length > 0) ((i[a] = c), (s = !0)); } if (s) ((e.data.morphAttributes = i), (e.data.morphTargetsRelative = this.morphTargetsRelative)); let r = this.groups; if (r.length > 0) e.data.groups = JSON.parse(JSON.stringify(r)); let o = this.boundingSphere; if (o !== null) e.data.boundingSphere = o.toJSON(); return e; } clone() { return new this.constructor().copy(this); } copy(e) { ((this.index = null), (this.attributes = {}), (this.morphAttributes = {}), (this.groups = []), (this.boundingBox = null), (this.boundingSphere = null)); let t = {}; this.name = e.name; let n = e.index; if (n !== null) this.setIndex(n.clone()); let i = e.attributes; for (let l in i) { let c = i[l]; this.setAttribute(l, c.clone(t)); } let s = e.morphAttributes; for (let l in s) { let c = [], h = s[l]; for (let u = 0, d = h.length; u < d; u++) c.push(h[u].clone(t)); this.morphAttributes[l] = c; } this.morphTargetsRelative = e.morphTargetsRelative; let r = e.groups; for (let l = 0, c = r.length; l < c; l++) { let h = r[l]; this.addGroup(h.start, h.count, h.materialIndex); } let o = e.boundingBox; if (o !== null) this.boundingBox = o.clone(); let a = e.boundingSphere; if (a !== null) this.boundingSphere = a.clone(); return ( (this.drawRange.start = e.drawRange.start), (this.drawRange.count = e.drawRange.count), (this.userData = e.userData), this ); } dispose() { this.dispatchEvent({ type: "dispose" }); } } var Xh = new ue(), os = new zn(), yo = new yn(), qh = new E(), xo = new E(), vo = new E(), _o = new E(), el = new E(), So = new E(), Yh = new E(), bo = new E(); class st extends it { constructor(e = new Et(), t = new Wt()) { super(); ((this.isMesh = !0), (this.type = "Mesh"), (this.geometry = e), (this.material = t), (this.morphTargetDictionary = void 0), (this.morphTargetInfluences = void 0), (this.count = 1), this.updateMorphTargets()); } copy(e, t) { if ((super.copy(e, t), e.morphTargetInfluences !== void 0)) this.morphTargetInfluences = e.morphTargetInfluences.slice(); if (e.morphTargetDictionary !== void 0) this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary); return ( (this.material = Array.isArray(e.material) ? e.material.slice() : e.material), (this.geometry = e.geometry), this ); } updateMorphTargets() { let t = this.geometry.morphAttributes, n = Object.keys(t); if (n.length > 0) { let i = t[n[0]]; if (i !== void 0) { ((this.morphTargetInfluences = []), (this.morphTargetDictionary = {})); for (let s = 0, r = i.length; s < r; s++) { let o = i[s].name || String(s); (this.morphTargetInfluences.push(0), (this.morphTargetDictionary[o] = s)); } } } } getVertexPosition(e, t) { let n = this.geometry, i = n.attributes.position, s = n.morphAttributes.position, r = n.morphTargetsRelative; t.fromBufferAttribute(i, e); let o = this.morphTargetInfluences; if (s && o) { So.set(0, 0, 0); for (let a = 0, l = s.length; a < l; a++) { let c = o[a], h = s[a]; if (c === 0) continue; if ((el.fromBufferAttribute(h, e), r)) So.addScaledVector(el, c); else So.addScaledVector(el.sub(t), c); } t.add(So); } return t; } raycast(e, t) { let n = this.geometry, i = this.material, s = this.matrixWorld; if (i === void 0) return; if (n.boundingSphere === null) n.computeBoundingSphere(); if ( (yo.copy(n.boundingSphere), yo.applyMatrix4(s), os.copy(e.ray).recast(e.near), yo.containsPoint(os.origin) === !1) ) { if (os.intersectSphere(yo, qh) === null) return; if (os.origin.distanceToSquared(qh) > (e.far - e.near) ** 2) return; } if ((Xh.copy(s).invert(), os.copy(e.ray).applyMatrix4(Xh), n.boundingBox !== null)) { if (os.intersectsBox(n.boundingBox) === !1) return; } this._computeIntersections(e, t, os); } _computeIntersections(e, t, n) { let i, s = this.geometry, r = this.material, o = s.index, a = s.attributes.position, l = s.attributes.uv, c = s.attributes.uv1, h = s.attributes.normal, { groups: u, drawRange: d } = s; if (o !== null) if (Array.isArray(r)) for (let f = 0, m = u.length; f < m; f++) { let y = u[f], p = r[y.materialIndex], g = Math.max(y.start, d.start), _ = Math.min(o.count, Math.min(y.start + y.count, d.start + d.count)); for (let x = g, w = _; x < w; x += 3) { let L = o.getX(x), b = o.getX(x + 1), R = o.getX(x + 2); if (((i = Mo(this, p, e, n, l, c, h, L, b, R)), i)) ((i.faceIndex = Math.floor(x / 3)), (i.face.materialIndex = y.materialIndex), t.push(i)); } } else { let f = Math.max(0, d.start), m = Math.min(o.count, d.start + d.count); for (let y = f, p = m; y < p; y += 3) { let g = o.getX(y), _ = o.getX(y + 1), x = o.getX(y + 2); if (((i = Mo(this, r, e, n, l, c, h, g, _, x)), i)) ((i.faceIndex = Math.floor(y / 3)), t.push(i)); } } else if (a !== void 0) if (Array.isArray(r)) for (let f = 0, m = u.length; f < m; f++) { let y = u[f], p = r[y.materialIndex], g = Math.max(y.start, d.start), _ = Math.min(a.count, Math.min(y.start + y.count, d.start + d.count)); for (let x = g, w = _; x < w; x += 3) { let L = x, b = x + 1, R = x + 2; if (((i = Mo(this, p, e, n, l, c, h, L, b, R)), i)) ((i.faceIndex = Math.floor(x / 3)), (i.face.materialIndex = y.materialIndex), t.push(i)); } } else { let f = Math.max(0, d.start), m = Math.min(a.count, d.start + d.count); for (let y = f, p = m; y < p; y += 3) { let g = y, _ = y + 1, x = y + 2; if (((i = Mo(this, r, e, n, l, c, h, g, _, x)), i)) ((i.faceIndex = Math.floor(y / 3)), t.push(i)); } } } } function Am(e, t, n, i, s, r, o, a) { let l; if (t.side === 1) l = i.intersectTriangle(o, r, s, !0, a); else l = i.intersectTriangle(s, r, o, t.side === 0, a); if (l === null) return null; (bo.copy(a), bo.applyMatrix4(e.matrixWorld)); let c = n.ray.origin.distanceTo(bo); if (c < n.near || c > n.far) return null; return { distance: c, point: bo.clone(), object: e }; } function Mo(e, t, n, i, s, r, o, a, l, c) { (e.getVertexPosition(a, xo), e.getVertexPosition(l, vo), e.getVertexPosition(c, _o)); let h = Am(e, t, n, i, xo, vo, _o, Yh); if (h) { let u = new E(); if ((Mn.getBarycoord(Yh, xo, vo, _o, u), s)) h.uv = Mn.getInterpolatedAttribute(s, a, l, c, u, new ve()); if (r) h.uv1 = Mn.getInterpolatedAttribute(r, a, l, c, u, new ve()); if (o) { if (((h.normal = Mn.getInterpolatedAttribute(o, a, l, c, u, new E())), h.normal.dot(i.direction) > 0)) h.normal.multiplyScalar(-1); } let d = { a, b: l, c, normal: new E(), materialIndex: 0 }; (Mn.getNormal(xo, vo, _o, d.normal), (h.face = d), (h.barycoord = u)); } return h; } class Hi extends Et { constructor(e = 1, t = 1, n = 1, i = 1, s = 1, r = 1) { super(); ((this.type = "BoxGeometry"), (this.parameters = { width: e, height: t, depth: n, widthSegments: i, heightSegments: s, depthSegments: r })); let o = this; ((i = Math.floor(i)), (s = Math.floor(s)), (r = Math.floor(r))); let a = [], l = [], c = [], h = [], u = 0, d = 0; (f("z", "y", "x", -1, -1, n, t, e, r, s, 0), f("z", "y", "x", 1, -1, n, t, -e, r, s, 1), f("x", "z", "y", 1, 1, e, n, t, i, r, 2), f("x", "z", "y", 1, -1, e, n, -t, i, r, 3), f("x", "y", "z", 1, -1, e, t, n, i, s, 4), f("x", "y", "z", -1, -1, e, t, -n, i, s, 5), this.setIndex(a), this.setAttribute("position", new at(l, 3)), this.setAttribute("normal", new at(c, 3)), this.setAttribute("uv", new at(h, 2))); function f(m, y, p, g, _, x, w, L, b, R, F) { let M = x / b, T = w / R, I = x / 2, G = w / 2, q = L / 2, B = b + 1, Z = R + 1, W = 0, K = 0, V = new E(); for (let se = 0; se < Z; se++) { let ce = se * T - G; for (let Pe = 0; Pe < B; Pe++) { let We = Pe * M - I; ((V[m] = We * g), (V[y] = ce * _), (V[p] = q), l.push(V.x, V.y, V.z), (V[m] = 0), (V[y] = 0), (V[p] = L > 0 ? 1 : -1), c.push(V.x, V.y, V.z), h.push(Pe / b), h.push(1 - se / R), (W += 1)); } } for (let se = 0; se < R; se++) for (let ce = 0; ce < b; ce++) { let Pe = u + ce + B * se, We = u + ce + B * (se + 1), rt = u + (ce + 1) + B * (se + 1), Ke = u + (ce + 1) + B * se; (a.push(Pe, We, Ke), a.push(We, rt, Ke), (K += 6)); } (o.addGroup(d, K, F), (d += K), (u += W)); } } copy(e) { return (super.copy(e), (this.parameters = Object.assign({}, e.parameters)), this); } static fromJSON(e) { return new Hi(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments); } } function ps(e) { let t = {}; for (let n in e) { t[n] = {}; for (let i in e[n]) { let s = e[n][i]; if ( s && (s.isColor || s.isMatrix3 || s.isMatrix4 || s.isVector2 || s.isVector3 || s.isVector4 || s.isTexture || s.isQuaternion) ) if (s.isRenderTargetTexture) (console.warn( "UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().", ), (t[n][i] = null)); else t[n][i] = s.clone(); else if (Array.isArray(s)) t[n][i] = s.slice(); else t[n][i] = s; } } return t; } function jt(e) { let t = {}; for (let n = 0; n < e.length; n++) { let i = ps(e[n]); for (let s in i) t[s] = i[s]; } return t; } function Rm(e) { let t = []; for (let n = 0; n < e.length; n++) t.push(e[n].clone()); return t; } function cc(e) { let t = e.getRenderTarget(); if (t === null) return e.outputColorSpace; if (t.isXRRenderTarget === !0) return t.texture.colorSpace; return ke.workingColorSpace; } var gd = { clone: ps, merge: jt }, Lm = `void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`, Cm = `void main() { gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); }`; class Zn extends Vt { constructor(e) { super(); if ( ((this.isShaderMaterial = !0), (this.type = "ShaderMaterial"), (this.defines = {}), (this.uniforms = {}), (this.uniformsGroups = []), (this.vertexShader = Lm), (this.fragmentShader = Cm), (this.linewidth = 1), (this.wireframe = !1), (this.wireframeLinewidth = 1), (this.fog = !1), (this.lights = !1), (this.clipping = !1), (this.forceSinglePass = !0), (this.extensions = { clipCullDistance: !1, multiDraw: !1 }), (this.defaultAttributeValues = { color: [1, 1, 1], uv: [0, 0], uv1: [0, 0] }), (this.index0AttributeName = void 0), (this.uniformsNeedUpdate = !1), (this.glslVersion = null), e !== void 0) ) this.setValues(e); } copy(e) { return ( super.copy(e), (this.fragmentShader = e.fragmentShader), (this.vertexShader = e.vertexShader), (this.uniforms = ps(e.uniforms)), (this.uniformsGroups = Rm(e.uniformsGroups)), (this.defines = Object.assign({}, e.defines)), (this.wireframe = e.wireframe), (this.wireframeLinewidth = e.wireframeLinewidth), (this.fog = e.fog), (this.lights = e.lights), (this.clipping = e.clipping), (this.extensions = Object.assign({}, e.extensions)), (this.glslVersion = e.glslVersion), this ); } toJSON(e) { let t = super.toJSON(e); ((t.glslVersion = this.glslVersion), (t.uniforms = {})); for (let i in this.uniforms) { let r = this.uniforms[i].value; if (r && r.isTexture) t.uniforms[i] = { type: "t", value: r.toJSON(e).uuid }; else if (r && r.isColor) t.uniforms[i] = { type: "c", value: r.getHex() }; else if (r && r.isVector2) t.uniforms[i] = { type: "v2", value: r.toArray() }; else if (r && r.isVector3) t.uniforms[i] = { type: "v3", value: r.toArray() }; else if (r && r.isVector4) t.uniforms[i] = { type: "v4", value: r.toArray() }; else if (r && r.isMatrix3) t.uniforms[i] = { type: "m3", value: r.toArray() }; else if (r && r.isMatrix4) t.uniforms[i] = { type: "m4", value: r.toArray() }; else t.uniforms[i] = { value: r }; } if (Object.keys(this.defines).length > 0) t.defines = this.defines; ((t.vertexShader = this.vertexShader), (t.fragmentShader = this.fragmentShader), (t.lights = this.lights), (t.clipping = this.clipping)); let n = {}; for (let i in this.extensions) if (this.extensions[i] === !0) n[i] = !0; if (Object.keys(n).length > 0) t.extensions = n; return t; } } class na extends it { constructor() { super(); ((this.isCamera = !0), (this.type = "Camera"), (this.matrixWorldInverse = new ue()), (this.projectionMatrix = new ue()), (this.projectionMatrixInverse = new ue()), (this.coordinateSystem = 2000), (this._reversedDepth = !1)); } get reversedDepth() { return this._reversedDepth; } copy(e, t) { return ( super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), (this.coordinateSystem = e.coordinateSystem), this ); } getWorldDirection(e) { return super.getWorldDirection(e).negate(); } updateMatrixWorld(e) { (super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert()); } updateWorldMatrix(e, t) { (super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert()); } clone() { return new this.constructor().copy(this); } } var Pi = new E(), jh = new ve(), Zh = new ve(); class It extends na { constructor(e = 50, t = 1, n = 0.1, i = 2000) { super(); ((this.isPerspectiveCamera = !0), (this.type = "PerspectiveCamera"), (this.fov = e), (this.zoom = 1), (this.near = n), (this.far = i), (this.focus = 10), (this.aspect = t), (this.view = null), (this.filmGauge = 35), (this.filmOffset = 0), this.updateProjectionMatrix()); } copy(e, t) { return ( super.copy(e, t), (this.fov = e.fov), (this.zoom = e.zoom), (this.near = e.near), (this.far = e.far), (this.focus = e.focus), (this.aspect = e.aspect), (this.view = e.view === null ? null : Object.assign({}, e.view)), (this.filmGauge = e.filmGauge), (this.filmOffset = e.filmOffset), this ); } setFocalLength(e) { let t = (0.5 * this.getFilmHeight()) / e; ((this.fov = ls * 2 * Math.atan(t)), this.updateProjectionMatrix()); } getFocalLength() { let e = Math.tan(Lr * 0.5 * this.fov); return (0.5 * this.getFilmHeight()) / e; } getEffectiveFOV() { return ls * 2 * Math.atan(Math.tan(Lr * 0.5 * this.fov) / this.zoom); } getFilmWidth() { return this.filmGauge * Math.min(this.aspect, 1); } getFilmHeight() { return this.filmGauge / Math.max(this.aspect, 1); } getViewBounds(e, t, n) { (Pi.set(-1, -1, 0.5).applyMatrix4(this.projectionMatrixInverse), t.set(Pi.x, Pi.y).multiplyScalar(-e / Pi.z), Pi.set(1, 1, 0.5).applyMatrix4(this.projectionMatrixInverse), n.set(Pi.x, Pi.y).multiplyScalar(-e / Pi.z)); } getViewSize(e, t) { return (this.getViewBounds(e, jh, Zh), t.subVectors(Zh, jh)); } setViewOffset(e, t, n, i, s, r) { if (((this.aspect = e / t), this.view === null)) this.view = { enabled: !0, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 }; ((this.view.enabled = !0), (this.view.fullWidth = e), (this.view.fullHeight = t), (this.view.offsetX = n), (this.view.offsetY = i), (this.view.width = s), (this.view.height = r), this.updateProjectionMatrix()); } clearViewOffset() { if (this.view !== null) this.view.enabled = !1; this.updateProjectionMatrix(); } updateProjectionMatrix() { let e = this.near, t = (e * Math.tan(Lr * 0.5 * this.fov)) / this.zoom, n = 2 * t, i = this.aspect * n, s = -0.5 * i, r = this.view; if (this.view !== null && this.view.enabled) { let { fullWidth: a, fullHeight: l } = r; ((s += (r.offsetX * i) / a), (t -= (r.offsetY * n) / l), (i *= r.width / a), (n *= r.height / l)); } let o = this.filmOffset; if (o !== 0) s += (e * o) / this.getFilmWidth(); (this.projectionMatrix.makePerspective(s, s + i, t, t - n, e, this.far, this.coordinateSystem, this.reversedDepth), this.projectionMatrixInverse.copy(this.projectionMatrix).invert()); } toJSON(e) { let t = super.toJSON(e); if ( ((t.object.fov = this.fov), (t.object.zoom = this.zoom), (t.object.near = this.near), (t.object.far = this.far), (t.object.focus = this.focus), (t.object.aspect = this.aspect), this.view !== null) ) t.object.view = Object.assign({}, this.view); return ((t.object.filmGauge = this.filmGauge), (t.object.filmOffset = this.filmOffset), t); } } var ks = -90, zs = 1; class hc extends it { constructor(e, t, n) { super(); ((this.type = "CubeCamera"), (this.renderTarget = n), (this.coordinateSystem = null), (this.activeMipmapLevel = 0)); let i = new It(ks, zs, e, t); ((i.layers = this.layers), this.add(i)); let s = new It(ks, zs, e, t); ((s.layers = this.layers), this.add(s)); let r = new It(ks, zs, e, t); ((r.layers = this.layers), this.add(r)); let o = new It(ks, zs, e, t); ((o.layers = this.layers), this.add(o)); let a = new It(ks, zs, e, t); ((a.layers = this.layers), this.add(a)); let l = new It(ks, zs, e, t); ((l.layers = this.layers), this.add(l)); } updateCoordinateSystem() { let e = this.coordinateSystem, t = this.children.concat(), [n, i, s, r, o, a] = t; for (let l of t) this.remove(l); if (e === 2000) (n.up.set(0, 1, 0), n.lookAt(1, 0, 0), i.up.set(0, 1, 0), i.lookAt(-1, 0, 0), s.up.set(0, 0, -1), s.lookAt(0, 1, 0), r.up.set(0, 0, 1), r.lookAt(0, -1, 0), o.up.set(0, 1, 0), o.lookAt(0, 0, 1), a.up.set(0, 1, 0), a.lookAt(0, 0, -1)); else if (e === 2001) (n.up.set(0, -1, 0), n.lookAt(-1, 0, 0), i.up.set(0, -1, 0), i.lookAt(1, 0, 0), s.up.set(0, 0, 1), s.lookAt(0, 1, 0), r.up.set(0, 0, -1), r.lookAt(0, -1, 0), o.up.set(0, -1, 0), o.lookAt(0, 0, 1), a.up.set(0, -1, 0), a.lookAt(0, 0, -1)); else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + e); for (let l of t) (this.add(l), l.updateMatrixWorld()); } update(e, t) { if (this.parent === null) this.updateMatrixWorld(); let { renderTarget: n, activeMipmapLevel: i } = this; if (this.coordinateSystem !== e.coordinateSystem) ((this.coordinateSystem = e.coordinateSystem), this.updateCoordinateSystem()); let [s, r, o, a, l, c] = this.children, h = e.getRenderTarget(), u = e.getActiveCubeFace(), d = e.getActiveMipmapLevel(), f = e.xr.enabled; e.xr.enabled = !1; let m = n.texture.generateMipmaps; ((n.texture.generateMipmaps = !1), e.setRenderTarget(n, 0, i), e.render(t, s), e.setRenderTarget(n, 1, i), e.render(t, r), e.setRenderTarget(n, 2, i), e.render(t, o), e.setRenderTarget(n, 3, i), e.render(t, a), e.setRenderTarget(n, 4, i), e.render(t, l), (n.texture.generateMipmaps = m), e.setRenderTarget(n, 5, i), e.render(t, c), e.setRenderTarget(h, u, d), (e.xr.enabled = f), (n.texture.needsPMREMUpdate = !0)); } } class ia extends Rt { constructor(e = [], t = 301, n, i, s, r, o, a, l, c) { super(e, t, n, i, s, r, o, a, l, c); ((this.isCubeTexture = !0), (this.flipY = !1)); } get images() { return this.image; } set images(e) { this.image = e; } } class uc extends vi { constructor(e = 1, t = {}) { super(e, e, t); this.isWebGLCubeRenderTarget = !0; let n = { width: e, height: e, depth: 1 }, i = [n, n, n, n, n, n]; ((this.texture = new ia(i)), this._setTextureOptions(t), (this.texture.isRenderTargetTexture = !0)); } fromEquirectangularTexture(e, t) { ((this.texture.type = t.type), (this.texture.colorSpace = t.colorSpace), (this.texture.generateMipmaps = t.generateMipmaps), (this.texture.minFilter = t.minFilter), (this.texture.magFilter = t.magFilter)); let n = { uniforms: { tEquirect: { value: null } }, vertexShader: ` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `, fragmentShader: ` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `, }, i = new Hi(5, 5, 5), s = new Zn({ name: "CubemapFromEquirect", uniforms: ps(n.uniforms), vertexShader: n.vertexShader, fragmentShader: n.fragmentShader, side: 1, blending: 0, }); s.uniforms.tEquirect.value = t; let r = new st(i, s), o = t.minFilter; if (t.minFilter === 1008) t.minFilter = 1006; return (new hc(1, 10, this).update(e, r), (t.minFilter = o), r.geometry.dispose(), r.material.dispose(), this); } clear(e, t = !0, n = !0, i = !0) { let s = e.getRenderTarget(); for (let r = 0; r < 6; r++) (e.setRenderTarget(this, r), e.clear(t, n, i)); e.setRenderTarget(s); } } class gn extends it { constructor() { super(); ((this.isGroup = !0), (this.type = "Group")); } } var Im = { type: "move" }; class Wr { constructor() { ((this._targetRay = null), (this._grip = null), (this._hand = null)); } getHandSpace() { if (this._hand === null) ((this._hand = new gn()), (this._hand.matrixAutoUpdate = !1), (this._hand.visible = !1), (this._hand.joints = {}), (this._hand.inputState = { pinching: !1 })); return this._hand; } getTargetRaySpace() { if (this._targetRay === null) ((this._targetRay = new gn()), (this._targetRay.matrixAutoUpdate = !1), (this._targetRay.visible = !1), (this._targetRay.hasLinearVelocity = !1), (this._targetRay.linearVelocity = new E()), (this._targetRay.hasAngularVelocity = !1), (this._targetRay.angularVelocity = new E())); return this._targetRay; } getGripSpace() { if (this._grip === null) ((this._grip = new gn()), (this._grip.matrixAutoUpdate = !1), (this._grip.visible = !1), (this._grip.hasLinearVelocity = !1), (this._grip.linearVelocity = new E()), (this._grip.hasAngularVelocity = !1), (this._grip.angularVelocity = new E())); return this._grip; } dispatchEvent(e) { if (this._targetRay !== null) this._targetRay.dispatchEvent(e); if (this._grip !== null) this._grip.dispatchEvent(e); if (this._hand !== null) this._hand.dispatchEvent(e); return this; } connect(e) { if (e && e.hand) { let t = this._hand; if (t) for (let n of e.hand.values()) this._getHandJoint(t, n); } return (this.dispatchEvent({ type: "connected", data: e }), this); } disconnect(e) { if ((this.dispatchEvent({ type: "disconnected", data: e }), this._targetRay !== null)) this._targetRay.visible = !1; if (this._grip !== null) this._grip.visible = !1; if (this._hand !== null) this._hand.visible = !1; return this; } update(e, t, n) { let i = null, s = null, r = null, o = this._targetRay, a = this._grip, l = this._hand; if (e && t.session.visibilityState !== "visible-blurred") { if (l && e.hand) { r = !0; for (let m of e.hand.values()) { let y = t.getJointPose(m, n), p = this._getHandJoint(l, m); if (y !== null) (p.matrix.fromArray(y.transform.matrix), p.matrix.decompose(p.position, p.rotation, p.scale), (p.matrixWorldNeedsUpdate = !0), (p.jointRadius = y.radius)); p.visible = y !== null; } let c = l.joints["index-finger-tip"], h = l.joints["thumb-tip"], u = c.position.distanceTo(h.position), d = 0.02, f = 0.005; if (l.inputState.pinching && u > d + f) ((l.inputState.pinching = !1), this.dispatchEvent({ type: "pinchend", handedness: e.handedness, target: this })); else if (!l.inputState.pinching && u <= d - f) ((l.inputState.pinching = !0), this.dispatchEvent({ type: "pinchstart", handedness: e.handedness, target: this })); } else if (a !== null && e.gripSpace) { if (((s = t.getPose(e.gripSpace, n)), s !== null)) { if ( (a.matrix.fromArray(s.transform.matrix), a.matrix.decompose(a.position, a.rotation, a.scale), (a.matrixWorldNeedsUpdate = !0), s.linearVelocity) ) ((a.hasLinearVelocity = !0), a.linearVelocity.copy(s.linearVelocity)); else a.hasLinearVelocity = !1; if (s.angularVelocity) ((a.hasAngularVelocity = !0), a.angularVelocity.copy(s.angularVelocity)); else a.hasAngularVelocity = !1; } } if (o !== null) { if (((i = t.getPose(e.targetRaySpace, n)), i === null && s !== null)) i = s; if (i !== null) { if ( (o.matrix.fromArray(i.transform.matrix), o.matrix.decompose(o.position, o.rotation, o.scale), (o.matrixWorldNeedsUpdate = !0), i.linearVelocity) ) ((o.hasLinearVelocity = !0), o.linearVelocity.copy(i.linearVelocity)); else o.hasLinearVelocity = !1; if (i.angularVelocity) ((o.hasAngularVelocity = !0), o.angularVelocity.copy(i.angularVelocity)); else o.hasAngularVelocity = !1; this.dispatchEvent(Im); } } } if (o !== null) o.visible = i !== null; if (a !== null) a.visible = s !== null; if (l !== null) l.visible = r !== null; return this; } _getHandJoint(e, t) { if (e.joints[t.jointName] === void 0) { let n = new gn(); ((n.matrixAutoUpdate = !1), (n.visible = !1), (e.joints[t.jointName] = n), e.add(n)); } return e.joints[t.jointName]; } } class _i extends it { constructor() { super(); if ( ((this.isScene = !0), (this.type = "Scene"), (this.background = null), (this.environment = null), (this.fog = null), (this.backgroundBlurriness = 0), (this.backgroundIntensity = 1), (this.backgroundRotation = new tt()), (this.environmentIntensity = 1), (this.environmentRotation = new tt()), (this.overrideMaterial = null), typeof __THREE_DEVTOOLS__ < "u") ) __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this })); } copy(e, t) { if ((super.copy(e, t), e.background !== null)) this.background = e.background.clone(); if (e.environment !== null) this.environment = e.environment.clone(); if (e.fog !== null) this.fog = e.fog.clone(); if ( ((this.backgroundBlurriness = e.backgroundBlurriness), (this.backgroundIntensity = e.backgroundIntensity), this.backgroundRotation.copy(e.backgroundRotation), (this.environmentIntensity = e.environmentIntensity), this.environmentRotation.copy(e.environmentRotation), e.overrideMaterial !== null) ) this.overrideMaterial = e.overrideMaterial.clone(); return ((this.matrixAutoUpdate = e.matrixAutoUpdate), this); } toJSON(e) { let t = super.toJSON(e); if (this.fog !== null) t.object.fog = this.fog.toJSON(); if (this.backgroundBlurriness > 0) t.object.backgroundBlurriness = this.backgroundBlurriness; if (this.backgroundIntensity !== 1) t.object.backgroundIntensity = this.backgroundIntensity; if (((t.object.backgroundRotation = this.backgroundRotation.toArray()), this.environmentIntensity !== 1)) t.object.environmentIntensity = this.environmentIntensity; return ((t.object.environmentRotation = this.environmentRotation.toArray()), t); } } class Xr { constructor(e, t) { ((this.isInterleavedBuffer = !0), (this.array = e), (this.stride = t), (this.count = e !== void 0 ? e.length / t : 0), (this.usage = 35044), (this.updateRanges = []), (this.version = 0), (this.uuid = Un())); } onUploadCallback() {} set needsUpdate(e) { if (e === !0) this.version++; } setUsage(e) { return ((this.usage = e), this); } addUpdateRange(e, t) { this.updateRanges.push({ start: e, count: t }); } clearUpdateRanges() { this.updateRanges.length = 0; } copy(e) { return ( (this.array = new e.array.constructor(e.array)), (this.count = e.count), (this.stride = e.stride), (this.usage = e.usage), this ); } copyAt(e, t, n) { ((e *= this.stride), (n *= t.stride)); for (let i = 0, s = this.stride; i < s; i++) this.array[e + i] = t.array[n + i]; return this; } set(e, t = 0) { return (this.array.set(e, t), this); } clone(e) { if (e.arrayBuffers === void 0) e.arrayBuffers = {}; if (this.array.buffer._uuid === void 0) this.array.buffer._uuid = Un(); if (e.arrayBuffers[this.array.buffer._uuid] === void 0) e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer; let t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]), n = new this.constructor(t, this.stride); return (n.setUsage(this.usage), n); } onUpload(e) { return ((this.onUploadCallback = e), this); } toJSON(e) { if (e.arrayBuffers === void 0) e.arrayBuffers = {}; if (this.array.buffer._uuid === void 0) this.array.buffer._uuid = Un(); if (e.arrayBuffers[this.array.buffer._uuid] === void 0) e.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer)); return { uuid: this.uuid, buffer: this.array.buffer._uuid, type: this.array.constructor.name, stride: this.stride }; } } var en = new E(); class tr { constructor(e, t, n, i = !1) { ((this.isInterleavedBufferAttribute = !0), (this.name = ""), (this.data = e), (this.itemSize = t), (this.offset = n), (this.normalized = i)); } get count() { return this.data.count; } get array() { return this.data.array; } set needsUpdate(e) { this.data.needsUpdate = e; } applyMatrix4(e) { for (let t = 0, n = this.data.count; t < n; t++) (en.fromBufferAttribute(this, t), en.applyMatrix4(e), this.setXYZ(t, en.x, en.y, en.z)); return this; } applyNormalMatrix(e) { for (let t = 0, n = this.count; t < n; t++) (en.fromBufferAttribute(this, t), en.applyNormalMatrix(e), this.setXYZ(t, en.x, en.y, en.z)); return this; } transformDirection(e) { for (let t = 0, n = this.count; t < n; t++) (en.fromBufferAttribute(this, t), en.transformDirection(e), this.setXYZ(t, en.x, en.y, en.z)); return this; } getComponent(e, t) { let n = this.array[e * this.data.stride + this.offset + t]; if (this.normalized) n = Dn(n, this.array); return n; } setComponent(e, t, n) { if (this.normalized) n = ct(n, this.array); return ((this.data.array[e * this.data.stride + this.offset + t] = n), this); } setX(e, t) { if (this.normalized) t = ct(t, this.array); return ((this.data.array[e * this.data.stride + this.offset] = t), this); } setY(e, t) { if (this.normalized) t = ct(t, this.array); return ((this.data.array[e * this.data.stride + this.offset + 1] = t), this); } setZ(e, t) { if (this.normalized) t = ct(t, this.array); return ((this.data.array[e * this.data.stride + this.offset + 2] = t), this); } setW(e, t) { if (this.normalized) t = ct(t, this.array); return ((this.data.array[e * this.data.stride + this.offset + 3] = t), this); } getX(e) { let t = this.data.array[e * this.data.stride + this.offset]; if (this.normalized) t = Dn(t, this.array); return t; } getY(e) { let t = this.data.array[e * this.data.stride + this.offset + 1]; if (this.normalized) t = Dn(t, this.array); return t; } getZ(e) { let t = this.data.array[e * this.data.stride + this.offset + 2]; if (this.normalized) t = Dn(t, this.array); return t; } getW(e) { let t = this.data.array[e * this.data.stride + this.offset + 3]; if (this.normalized) t = Dn(t, this.array); return t; } setXY(e, t, n) { if (((e = e * this.data.stride + this.offset), this.normalized)) ((t = ct(t, this.array)), (n = ct(n, this.array))); return ((this.data.array[e + 0] = t), (this.data.array[e + 1] = n), this); } setXYZ(e, t, n, i) { if (((e = e * this.data.stride + this.offset), this.normalized)) ((t = ct(t, this.array)), (n = ct(n, this.array)), (i = ct(i, this.array))); return ((this.data.array[e + 0] = t), (this.data.array[e + 1] = n), (this.data.array[e + 2] = i), this); } setXYZW(e, t, n, i, s) { if (((e = e * this.data.stride + this.offset), this.normalized)) ((t = ct(t, this.array)), (n = ct(n, this.array)), (i = ct(i, this.array)), (s = ct(s, this.array))); return ( (this.data.array[e + 0] = t), (this.data.array[e + 1] = n), (this.data.array[e + 2] = i), (this.data.array[e + 3] = s), this ); } clone(e) { if (e === void 0) { console.log( "THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.", ); let t = []; for (let n = 0; n < this.count; n++) { let i = n * this.data.stride + this.offset; for (let s = 0; s < this.itemSize; s++) t.push(this.data.array[i + s]); } return new gt(new this.array.constructor(t), this.itemSize, this.normalized); } else { if (e.interleavedBuffers === void 0) e.interleavedBuffers = {}; if (e.interleavedBuffers[this.data.uuid] === void 0) e.interleavedBuffers[this.data.uuid] = this.data.clone(e); return new tr(e.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized); } } toJSON(e) { if (e === void 0) { console.log( "THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.", ); let t = []; for (let n = 0; n < this.count; n++) { let i = n * this.data.stride + this.offset; for (let s = 0; s < this.itemSize; s++) t.push(this.data.array[i + s]); } return { itemSize: this.itemSize, type: this.array.constructor.name, array: t, normalized: this.normalized }; } else { if (e.interleavedBuffers === void 0) e.interleavedBuffers = {}; if (e.interleavedBuffers[this.data.uuid] === void 0) e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e); return { isInterleavedBufferAttribute: !0, itemSize: this.itemSize, data: this.data.uuid, offset: this.offset, normalized: this.normalized, }; } } } var Kh = new E(), $h = new Ye(), Jh = new Ye(), Pm = new E(), Qh = new ue(), wo = new E(), tl = new yn(), eu = new ue(), nl = new zn(); class Bi extends st { constructor(e, t) { super(e, t); ((this.isSkinnedMesh = !0), (this.type = "SkinnedMesh"), (this.bindMode = "attached"), (this.bindMatrix = new ue()), (this.bindMatrixInverse = new ue()), (this.boundingBox = null), (this.boundingSphere = null)); } computeBoundingBox() { let e = this.geometry; if (this.boundingBox === null) this.boundingBox = new ln(); this.boundingBox.makeEmpty(); let t = e.getAttribute("position"); for (let n = 0; n < t.count; n++) (this.getVertexPosition(n, wo), this.boundingBox.expandByPoint(wo)); } computeBoundingSphere() { let e = this.geometry; if (this.boundingSphere === null) this.boundingSphere = new yn(); this.boundingSphere.makeEmpty(); let t = e.getAttribute("position"); for (let n = 0; n < t.count; n++) (this.getVertexPosition(n, wo), this.boundingSphere.expandByPoint(wo)); } copy(e, t) { if ( (super.copy(e, t), (this.bindMode = e.bindMode), this.bindMatrix.copy(e.bindMatrix), this.bindMatrixInverse.copy(e.bindMatrixInverse), (this.skeleton = e.skeleton), e.boundingBox !== null) ) this.boundingBox = e.boundingBox.clone(); if (e.boundingSphere !== null) this.boundingSphere = e.boundingSphere.clone(); return this; } raycast(e, t) { let n = this.material, i = this.matrixWorld; if (n === void 0) return; if (this.boundingSphere === null) this.computeBoundingSphere(); if ((tl.copy(this.boundingSphere), tl.applyMatrix4(i), e.ray.intersectsSphere(tl) === !1)) return; if ((eu.copy(i).invert(), nl.copy(e.ray).applyMatrix4(eu), this.boundingBox !== null)) { if (nl.intersectsBox(this.boundingBox) === !1) return; } this._computeIntersections(e, t, nl); } getVertexPosition(e, t) { return (super.getVertexPosition(e, t), this.applyBoneTransform(e, t), t); } bind(e, t) { if (((this.skeleton = e), t === void 0)) (this.updateMatrixWorld(!0), this.skeleton.calculateInverses(), (t = this.matrixWorld)); (this.bindMatrix.copy(t), this.bindMatrixInverse.copy(t).invert()); } pose() { this.skeleton.pose(); } normalizeSkinWeights() { let e = new Ye(), t = this.geometry.attributes.skinWeight; for (let n = 0, i = t.count; n < i; n++) { e.fromBufferAttribute(t, n); let s = 1 / e.manhattanLength(); if (s !== 1 / 0) e.multiplyScalar(s); else e.set(1, 0, 0, 0); t.setXYZW(n, e.x, e.y, e.z, e.w); } } updateMatrixWorld(e) { if ((super.updateMatrixWorld(e), this.bindMode === "attached")) this.bindMatrixInverse.copy(this.matrixWorld).invert(); else if (this.bindMode === "detached") this.bindMatrixInverse.copy(this.bindMatrix).invert(); else console.warn("THREE.SkinnedMesh: Unrecognized bindMode: " + this.bindMode); } applyBoneTransform(e, t) { let n = this.skeleton, i = this.geometry; ($h.fromBufferAttribute(i.attributes.skinIndex, e), Jh.fromBufferAttribute(i.attributes.skinWeight, e), Kh.copy(t).applyMatrix4(this.bindMatrix), t.set(0, 0, 0)); for (let s = 0; s < 4; s++) { let r = Jh.getComponent(s); if (r !== 0) { let o = $h.getComponent(s); (Qh.multiplyMatrices(n.bones[o].matrixWorld, n.boneInverses[o]), t.addScaledVector(Pm.copy(Kh).applyMatrix4(Qh), r)); } } return t.applyMatrix4(this.bindMatrixInverse); } } class Kn extends it { constructor() { super(); ((this.isBone = !0), (this.type = "Bone")); } } class sa extends Rt { constructor(e = null, t = 1, n = 1, i, s, r, o, a, l = 1003, c = 1003, h, u) { super(null, r, o, a, l, c, i, s, h, u); ((this.isDataTexture = !0), (this.image = { data: e, width: t, height: n }), (this.generateMipmaps = !1), (this.flipY = !1), (this.unpackAlignment = 1)); } } var tu = new ue(), Dm = new ue(); class Si { constructor(e = [], t = []) { ((this.uuid = Un()), (this.bones = e.slice(0)), (this.boneInverses = t), (this.boneMatrices = null), (this.boneTexture = null), this.init()); } init() { let e = this.bones, t = this.boneInverses; if (((this.boneMatrices = new Float32Array(e.length * 16)), t.length === 0)) this.calculateInverses(); else if (e.length !== t.length) { (console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."), (this.boneInverses = [])); for (let n = 0, i = this.bones.length; n < i; n++) this.boneInverses.push(new ue()); } } calculateInverses() { this.boneInverses.length = 0; for (let e = 0, t = this.bones.length; e < t; e++) { let n = new ue(); if (this.bones[e]) n.copy(this.bones[e].matrixWorld).invert(); this.boneInverses.push(n); } } pose() { for (let e = 0, t = this.bones.length; e < t; e++) { let n = this.bones[e]; if (n) n.matrixWorld.copy(this.boneInverses[e]).invert(); } for (let e = 0, t = this.bones.length; e < t; e++) { let n = this.bones[e]; if (n) { if (n.parent && n.parent.isBone) (n.matrix.copy(n.parent.matrixWorld).invert(), n.matrix.multiply(n.matrixWorld)); else n.matrix.copy(n.matrixWorld); n.matrix.decompose(n.position, n.quaternion, n.scale); } } } update() { let e = this.bones, t = this.boneInverses, n = this.boneMatrices, i = this.boneTexture; for (let s = 0, r = e.length; s < r; s++) { let o = e[s] ? e[s].matrixWorld : Dm; (tu.multiplyMatrices(o, t[s]), tu.toArray(n, s * 16)); } if (i !== null) i.needsUpdate = !0; } clone() { return new Si(this.bones, this.boneInverses); } computeBoneTexture() { let e = Math.sqrt(this.bones.length * 4); ((e = Math.ceil(e / 4) * 4), (e = Math.max(e, 4))); let t = new Float32Array(e * e * 4); t.set(this.boneMatrices); let n = new sa(t, e, e, 1023, 1015); return ((n.needsUpdate = !0), (this.boneMatrices = t), (this.boneTexture = n), this); } getBoneByName(e) { for (let t = 0, n = this.bones.length; t < n; t++) { let i = this.bones[t]; if (i.name === e) return i; } return; } dispose() { if (this.boneTexture !== null) (this.boneTexture.dispose(), (this.boneTexture = null)); } fromJSON(e, t) { this.uuid = e.uuid; for (let n = 0, i = e.bones.length; n < i; n++) { let s = e.bones[n], r = t[s]; if (r === void 0) (console.warn("THREE.Skeleton: No bone found with UUID:", s), (r = new Kn())); (this.bones.push(r), this.boneInverses.push(new ue().fromArray(e.boneInverses[n]))); } return (this.init(), this); } toJSON() { let e = { metadata: { version: 4.7, type: "Skeleton", generator: "Skeleton.toJSON" }, bones: [], boneInverses: [] }; e.uuid = this.uuid; let t = this.bones, n = this.boneInverses; for (let i = 0, s = t.length; i < s; i++) { let r = t[i]; e.bones.push(r.uuid); let o = n[i]; e.boneInverses.push(o.toArray()); } return e; } } class cs extends gt { constructor(e, t, n, i = 1) { super(e, t, n); ((this.isInstancedBufferAttribute = !0), (this.meshPerAttribute = i)); } copy(e) { return (super.copy(e), (this.meshPerAttribute = e.meshPerAttribute), this); } toJSON() { let e = super.toJSON(); return ((e.meshPerAttribute = this.meshPerAttribute), (e.isInstancedBufferAttribute = !0), e); } } var Hs = new ue(), nu = new ue(), To = [], iu = new ln(), Um = new ue(), wr = new st(), Tr = new yn(); class nr extends st { constructor(e, t, n) { super(e, t); ((this.isInstancedMesh = !0), (this.instanceMatrix = new cs(new Float32Array(n * 16), 16)), (this.instanceColor = null), (this.morphTexture = null), (this.count = n), (this.boundingBox = null), (this.boundingSphere = null)); for (let i = 0; i < n; i++) this.setMatrixAt(i, Um); } computeBoundingBox() { let e = this.geometry, t = this.count; if (this.boundingBox === null) this.boundingBox = new ln(); if (e.boundingBox === null) e.computeBoundingBox(); this.boundingBox.makeEmpty(); for (let n = 0; n < t; n++) (this.getMatrixAt(n, Hs), iu.copy(e.boundingBox).applyMatrix4(Hs), this.boundingBox.union(iu)); } computeBoundingSphere() { let e = this.geometry, t = this.count; if (this.boundingSphere === null) this.boundingSphere = new yn(); if (e.boundingSphere === null) e.computeBoundingSphere(); this.boundingSphere.makeEmpty(); for (let n = 0; n < t; n++) (this.getMatrixAt(n, Hs), Tr.copy(e.boundingSphere).applyMatrix4(Hs), this.boundingSphere.union(Tr)); } copy(e, t) { if ((super.copy(e, t), this.instanceMatrix.copy(e.instanceMatrix), e.morphTexture !== null)) this.morphTexture = e.morphTexture.clone(); if (e.instanceColor !== null) this.instanceColor = e.instanceColor.clone(); if (((this.count = e.count), e.boundingBox !== null)) this.boundingBox = e.boundingBox.clone(); if (e.boundingSphere !== null) this.boundingSphere = e.boundingSphere.clone(); return this; } getColorAt(e, t) { t.fromArray(this.instanceColor.array, e * 3); } getMatrixAt(e, t) { t.fromArray(this.instanceMatrix.array, e * 16); } getMorphAt(e, t) { let n = t.morphTargetInfluences, i = this.morphTexture.source.data.data, s = n.length + 1, r = e * s + 1; for (let o = 0; o < n.length; o++) n[o] = i[r + o]; } raycast(e, t) { let n = this.matrixWorld, i = this.count; if (((wr.geometry = this.geometry), (wr.material = this.material), wr.material === void 0)) return; if (this.boundingSphere === null) this.computeBoundingSphere(); if ((Tr.copy(this.boundingSphere), Tr.applyMatrix4(n), e.ray.intersectsSphere(Tr) === !1)) return; for (let s = 0; s < i; s++) { (this.getMatrixAt(s, Hs), nu.multiplyMatrices(n, Hs), (wr.matrixWorld = nu), wr.raycast(e, To)); for (let r = 0, o = To.length; r < o; r++) { let a = To[r]; ((a.instanceId = s), (a.object = this), t.push(a)); } To.length = 0; } } setColorAt(e, t) { if (this.instanceColor === null) this.instanceColor = new cs(new Float32Array(this.instanceMatrix.count * 3).fill(1), 3); t.toArray(this.instanceColor.array, e * 3); } setMatrixAt(e, t) { t.toArray(this.instanceMatrix.array, e * 16); } setMorphAt(e, t) { let n = t.morphTargetInfluences, i = n.length + 1; if (this.morphTexture === null) this.morphTexture = new sa(new Float32Array(i * this.count), i, this.count, 1028, 1015); let s = this.morphTexture.source.data.data, r = 0; for (let l = 0; l < n.length; l++) r += n[l]; let o = this.geometry.morphTargetsRelative ? 1 : 1 - r, a = i * e; ((s[a] = o), s.set(n, a + 1)); } updateMorphTargets() {} dispose() { if ((this.dispatchEvent({ type: "dispose" }), this.morphTexture !== null)) (this.morphTexture.dispose(), (this.morphTexture = null)); } } var il = new E(), Nm = new E(), Fm = new Be(); class mn { constructor(e = new E(1, 0, 0), t = 0) { ((this.isPlane = !0), (this.normal = e), (this.constant = t)); } set(e, t) { return (this.normal.copy(e), (this.constant = t), this); } setComponents(e, t, n, i) { return (this.normal.set(e, t, n), (this.constant = i), this); } setFromNormalAndCoplanarPoint(e, t) { return (this.normal.copy(e), (this.constant = -t.dot(this.normal)), this); } setFromCoplanarPoints(e, t, n) { let i = il.subVectors(n, t).cross(Nm.subVectors(e, t)).normalize(); return (this.setFromNormalAndCoplanarPoint(i, e), this); } copy(e) { return (this.normal.copy(e.normal), (this.constant = e.constant), this); } normalize() { let e = 1 / this.normal.length(); return (this.normal.multiplyScalar(e), (this.constant *= e), this); } negate() { return ((this.constant *= -1), this.normal.negate(), this); } distanceToPoint(e) { return this.normal.dot(e) + this.constant; } distanceToSphere(e) { return this.distanceToPoint(e.center) - e.radius; } projectPoint(e, t) { return t.copy(e).addScaledVector(this.normal, -this.distanceToPoint(e)); } intersectLine(e, t) { let n = e.delta(il), i = this.normal.dot(n); if (i === 0) { if (this.distanceToPoint(e.start) === 0) return t.copy(e.start); return null; } let s = -(e.start.dot(this.normal) + this.constant) / i; if (s < 0 || s > 1) return null; return t.copy(e.start).addScaledVector(n, s); } intersectsLine(e) { let t = this.distanceToPoint(e.start), n = this.distanceToPoint(e.end); return (t < 0 && n > 0) || (n < 0 && t > 0); } intersectsBox(e) { return e.intersectsPlane(this); } intersectsSphere(e) { return e.intersectsPlane(this); } coplanarPoint(e) { return e.copy(this.normal).multiplyScalar(-this.constant); } applyMatrix4(e, t) { let n = t || Fm.getNormalMatrix(e), i = this.coplanarPoint(il).applyMatrix4(e), s = this.normal.applyMatrix3(n).normalize(); return ((this.constant = -i.dot(s)), this); } translate(e) { return ((this.constant -= e.dot(this.normal)), this); } equals(e) { return e.normal.equals(this.normal) && e.constant === this.constant; } clone() { return new this.constructor().copy(this); } } var as = new yn(), Om = new ve(0.5, 0.5), Eo = new E(); class qr { constructor(e = new mn(), t = new mn(), n = new mn(), i = new mn(), s = new mn(), r = new mn()) { this.planes = [e, t, n, i, s, r]; } set(e, t, n, i, s, r) { let o = this.planes; return (o[0].copy(e), o[1].copy(t), o[2].copy(n), o[3].copy(i), o[4].copy(s), o[5].copy(r), this); } copy(e) { let t = this.planes; for (let n = 0; n < 6; n++) t[n].copy(e.planes[n]); return this; } setFromProjectionMatrix(e, t = 2000, n = !1) { let i = this.planes, s = e.elements, r = s[0], o = s[1], a = s[2], l = s[3], c = s[4], h = s[5], u = s[6], d = s[7], f = s[8], m = s[9], y = s[10], p = s[11], g = s[12], _ = s[13], x = s[14], w = s[15]; if ( (i[0].setComponents(l - r, d - c, p - f, w - g).normalize(), i[1].setComponents(l + r, d + c, p + f, w + g).normalize(), i[2].setComponents(l + o, d + h, p + m, w + _).normalize(), i[3].setComponents(l - o, d - h, p - m, w - _).normalize(), n) ) (i[4].setComponents(a, u, y, x).normalize(), i[5].setComponents(l - a, d - u, p - y, w - x).normalize()); else if ((i[4].setComponents(l - a, d - u, p - y, w - x).normalize(), t === 2000)) i[5].setComponents(l + a, d + u, p + y, w + x).normalize(); else if (t === 2001) i[5].setComponents(a, u, y, x).normalize(); else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + t); return this; } intersectsObject(e) { if (e.boundingSphere !== void 0) { if (e.boundingSphere === null) e.computeBoundingSphere(); as.copy(e.boundingSphere).applyMatrix4(e.matrixWorld); } else { let t = e.geometry; if (t.boundingSphere === null) t.computeBoundingSphere(); as.copy(t.boundingSphere).applyMatrix4(e.matrixWorld); } return this.intersectsSphere(as); } intersectsSprite(e) { as.center.set(0, 0, 0); let t = Om.distanceTo(e.center); return ((as.radius = 0.7071067811865476 + t), as.applyMatrix4(e.matrixWorld), this.intersectsSphere(as)); } intersectsSphere(e) { let t = this.planes, n = e.center, i = -e.radius; for (let s = 0; s < 6; s++) if (t[s].distanceToPoint(n) < i) return !1; return !0; } intersectsBox(e) { let t = this.planes; for (let n = 0; n < 6; n++) { let i = t[n]; if ( ((Eo.x = i.normal.x > 0 ? e.max.x : e.min.x), (Eo.y = i.normal.y > 0 ? e.max.y : e.min.y), (Eo.z = i.normal.z > 0 ? e.max.z : e.min.z), i.distanceToPoint(Eo) < 0) ) return !1; } return !0; } containsPoint(e) { let t = this.planes; for (let n = 0; n < 6; n++) if (t[n].distanceToPoint(e) < 0) return !1; return !0; } clone() { return new this.constructor().copy(this); } } class bi extends Vt { constructor(e) { super(); ((this.isLineBasicMaterial = !0), (this.type = "LineBasicMaterial"), (this.color = new re(16777215)), (this.map = null), (this.linewidth = 1), (this.linecap = "round"), (this.linejoin = "round"), (this.fog = !0), this.setValues(e)); } copy(e) { return ( super.copy(e), this.color.copy(e.color), (this.map = e.map), (this.linewidth = e.linewidth), (this.linecap = e.linecap), (this.linejoin = e.linejoin), (this.fog = e.fog), this ); } } var Uo = new E(), No = new E(), su = new ue(), Er = new zn(), Ao = new yn(), sl = new E(), ru = new E(); class Gi extends it { constructor(e = new Et(), t = new bi()) { super(); ((this.isLine = !0), (this.type = "Line"), (this.geometry = e), (this.material = t), (this.morphTargetDictionary = void 0), (this.morphTargetInfluences = void 0), this.updateMorphTargets()); } copy(e, t) { return ( super.copy(e, t), (this.material = Array.isArray(e.material) ? e.material.slice() : e.material), (this.geometry = e.geometry), this ); } computeLineDistances() { let e = this.geometry; if (e.index === null) { let t = e.attributes.position, n = [0]; for (let i = 1, s = t.count; i < s; i++) (Uo.fromBufferAttribute(t, i - 1), No.fromBufferAttribute(t, i), (n[i] = n[i - 1]), (n[i] += Uo.distanceTo(No))); e.setAttribute("lineDistance", new at(n, 1)); } else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); return this; } raycast(e, t) { let n = this.geometry, i = this.matrixWorld, s = e.params.Line.threshold, r = n.drawRange; if (n.boundingSphere === null) n.computeBoundingSphere(); if ((Ao.copy(n.boundingSphere), Ao.applyMatrix4(i), (Ao.radius += s), e.ray.intersectsSphere(Ao) === !1)) return; (su.copy(i).invert(), Er.copy(e.ray).applyMatrix4(su)); let o = s / ((this.scale.x + this.scale.y + this.scale.z) / 3), a = o * o, l = this.isLineSegments ? 2 : 1, c = n.index, u = n.attributes.position; if (c !== null) { let d = Math.max(0, r.start), f = Math.min(c.count, r.start + r.count); for (let m = d, y = f - 1; m < y; m += l) { let p = c.getX(m), g = c.getX(m + 1), _ = Ro(this, e, Er, a, p, g, m); if (_) t.push(_); } if (this.isLineLoop) { let m = c.getX(f - 1), y = c.getX(d), p = Ro(this, e, Er, a, m, y, f - 1); if (p) t.push(p); } } else { let d = Math.max(0, r.start), f = Math.min(u.count, r.start + r.count); for (let m = d, y = f - 1; m < y; m += l) { let p = Ro(this, e, Er, a, m, m + 1, m); if (p) t.push(p); } if (this.isLineLoop) { let m = Ro(this, e, Er, a, f - 1, d, f - 1); if (m) t.push(m); } } } updateMorphTargets() { let t = this.geometry.morphAttributes, n = Object.keys(t); if (n.length > 0) { let i = t[n[0]]; if (i !== void 0) { ((this.morphTargetInfluences = []), (this.morphTargetDictionary = {})); for (let s = 0, r = i.length; s < r; s++) { let o = i[s].name || String(s); (this.morphTargetInfluences.push(0), (this.morphTargetDictionary[o] = s)); } } } } } function Ro(e, t, n, i, s, r, o) { let a = e.geometry.attributes.position; if ((Uo.fromBufferAttribute(a, s), No.fromBufferAttribute(a, r), n.distanceSqToSegment(Uo, No, sl, ru) > i)) return; sl.applyMatrix4(e.matrixWorld); let c = t.ray.origin.distanceTo(sl); if (c < t.near || c > t.far) return; return { distance: c, point: ru.clone().applyMatrix4(e.matrixWorld), index: o, face: null, faceIndex: null, barycoord: null, object: e, }; } var ou = new E(), au = new E(); class ir extends Gi { constructor(e, t) { super(e, t); ((this.isLineSegments = !0), (this.type = "LineSegments")); } computeLineDistances() { let e = this.geometry; if (e.index === null) { let t = e.attributes.position, n = []; for (let i = 0, s = t.count; i < s; i += 2) (ou.fromBufferAttribute(t, i), au.fromBufferAttribute(t, i + 1), (n[i] = i === 0 ? 0 : n[i - 1]), (n[i + 1] = n[i] + ou.distanceTo(au))); e.setAttribute("lineDistance", new at(n, 1)); } else console.warn( "THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.", ); return this; } } class ra extends Gi { constructor(e, t) { super(e, t); ((this.isLineLoop = !0), (this.type = "LineLoop")); } } class ms extends Vt { constructor(e) { super(); ((this.isPointsMaterial = !0), (this.type = "PointsMaterial"), (this.color = new re(16777215)), (this.map = null), (this.alphaMap = null), (this.size = 1), (this.sizeAttenuation = !0), (this.fog = !0), this.setValues(e)); } copy(e) { return ( super.copy(e), this.color.copy(e.color), (this.map = e.map), (this.alphaMap = e.alphaMap), (this.size = e.size), (this.sizeAttenuation = e.sizeAttenuation), (this.fog = e.fog), this ); } } var lu = new ue(), ll = new zn(), Lo = new yn(), Co = new E(); class sr extends it { constructor(e = new Et(), t = new ms()) { super(); ((this.isPoints = !0), (this.type = "Points"), (this.geometry = e), (this.material = t), (this.morphTargetDictionary = void 0), (this.morphTargetInfluences = void 0), this.updateMorphTargets()); } copy(e, t) { return ( super.copy(e, t), (this.material = Array.isArray(e.material) ? e.material.slice() : e.material), (this.geometry = e.geometry), this ); } raycast(e, t) { let n = this.geometry, i = this.matrixWorld, s = e.params.Points.threshold, r = n.drawRange; if (n.boundingSphere === null) n.computeBoundingSphere(); if ((Lo.copy(n.boundingSphere), Lo.applyMatrix4(i), (Lo.radius += s), e.ray.intersectsSphere(Lo) === !1)) return; (lu.copy(i).invert(), ll.copy(e.ray).applyMatrix4(lu)); let o = s / ((this.scale.x + this.scale.y + this.scale.z) / 3), a = o * o, l = n.index, h = n.attributes.position; if (l !== null) { let u = Math.max(0, r.start), d = Math.min(l.count, r.start + r.count); for (let f = u, m = d; f < m; f++) { let y = l.getX(f); (Co.fromBufferAttribute(h, y), cu(Co, y, a, i, e, t, this)); } } else { let u = Math.max(0, r.start), d = Math.min(h.count, r.start + r.count); for (let f = u, m = d; f < m; f++) (Co.fromBufferAttribute(h, f), cu(Co, f, a, i, e, t, this)); } } updateMorphTargets() { let t = this.geometry.morphAttributes, n = Object.keys(t); if (n.length > 0) { let i = t[n[0]]; if (i !== void 0) { ((this.morphTargetInfluences = []), (this.morphTargetDictionary = {})); for (let s = 0, r = i.length; s < r; s++) { let o = i[s].name || String(s); (this.morphTargetInfluences.push(0), (this.morphTargetDictionary[o] = s)); } } } } } function cu(e, t, n, i, s, r, o) { let a = ll.distanceSqToPoint(e); if (a < n) { let l = new E(); (ll.closestPointToPoint(e, l), l.applyMatrix4(i)); let c = s.ray.origin.distanceTo(l); if (c < s.near || c > s.far) return; r.push({ distance: c, distanceToRay: Math.sqrt(a), point: l, index: t, face: null, faceIndex: null, barycoord: null, object: o, }); } } class oa extends Rt { constructor(e, t, n = 1014, i, s, r, o = 1003, a = 1003, l, c = 1026, h = 1) { if (c !== 1026 && c !== 1027) throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat"); let u = { width: e, height: t, depth: h }; super(u, i, s, r, o, a, c, n, l); ((this.isDepthTexture = !0), (this.flipY = !1), (this.generateMipmaps = !1), (this.compareFunction = null)); } copy(e) { return ( super.copy(e), (this.source = new Gr(Object.assign({}, e.image))), (this.compareFunction = e.compareFunction), this ); } toJSON(e) { let t = super.toJSON(e); if (this.compareFunction !== null) t.compareFunction = this.compareFunction; return t; } } class aa extends Rt { constructor(e = null) { super(); ((this.sourceTexture = e), (this.isExternalTexture = !0)); } copy(e) { return (super.copy(e), (this.sourceTexture = e.sourceTexture), this); } } class la { constructor() { ((this.type = "Curve"), (this.arcLengthDivisions = 200), (this.needsUpdate = !1), (this.cacheArcLengths = null)); } getPoint() { console.warn("THREE.Curve: .getPoint() not implemented."); } getPointAt(e, t) { let n = this.getUtoTmapping(e); return this.getPoint(n, t); } getPoints(e = 5) { let t = []; for (let n = 0; n <= e; n++) t.push(this.getPoint(n / e)); return t; } getSpacedPoints(e = 5) { let t = []; for (let n = 0; n <= e; n++) t.push(this.getPointAt(n / e)); return t; } getLength() { let e = this.getLengths(); return e[e.length - 1]; } getLengths(e = this.arcLengthDivisions) { if (this.cacheArcLengths && this.cacheArcLengths.length === e + 1 && !this.needsUpdate) return this.cacheArcLengths; this.needsUpdate = !1; let t = [], n, i = this.getPoint(0), s = 0; t.push(0); for (let r = 1; r <= e; r++) ((n = this.getPoint(r / e)), (s += n.distanceTo(i)), t.push(s), (i = n)); return ((this.cacheArcLengths = t), t); } updateArcLengths() { ((this.needsUpdate = !0), this.getLengths()); } getUtoTmapping(e, t = null) { let n = this.getLengths(), i = 0, s = n.length, r; if (t) r = t; else r = e * n[s - 1]; let o = 0, a = s - 1, l; while (o <= a) if (((i = Math.floor(o + (a - o) / 2)), (l = n[i] - r), l < 0)) o = i + 1; else if (l > 0) a = i - 1; else { a = i; break; } if (((i = a), n[i] === r)) return i / (s - 1); let c = n[i], u = n[i + 1] - c, d = (r - c) / u; return (i + d) / (s - 1); } getTangent(e, t) { let i = e - 0.0001, s = e + 0.0001; if (i < 0) i = 0; if (s > 1) s = 1; let r = this.getPoint(i), o = this.getPoint(s), a = t || (r.isVector2 ? new ve() : new E()); return (a.copy(o).sub(r).normalize(), a); } getTangentAt(e, t) { let n = this.getUtoTmapping(e); return this.getTangent(n, t); } computeFrenetFrames(e, t = !1) { let n = new E(), i = [], s = [], r = [], o = new E(), a = new ue(); for (let d = 0; d <= e; d++) { let f = d / e; i[d] = this.getTangentAt(f, new E()); } ((s[0] = new E()), (r[0] = new E())); let l = Number.MAX_VALUE, c = Math.abs(i[0].x), h = Math.abs(i[0].y), u = Math.abs(i[0].z); if (c <= l) ((l = c), n.set(1, 0, 0)); if (h <= l) ((l = h), n.set(0, 1, 0)); if (u <= l) n.set(0, 0, 1); (o.crossVectors(i[0], n).normalize(), s[0].crossVectors(i[0], o), r[0].crossVectors(i[0], s[0])); for (let d = 1; d <= e; d++) { if ( ((s[d] = s[d - 1].clone()), (r[d] = r[d - 1].clone()), o.crossVectors(i[d - 1], i[d]), o.length() > Number.EPSILON) ) { o.normalize(); let f = Math.acos(qe(i[d - 1].dot(i[d]), -1, 1)); s[d].applyMatrix4(a.makeRotationAxis(o, f)); } r[d].crossVectors(i[d], s[d]); } if (t === !0) { let d = Math.acos(qe(s[0].dot(s[e]), -1, 1)); if (((d /= e), i[0].dot(o.crossVectors(s[0], s[e])) > 0)) d = -d; for (let f = 1; f <= e; f++) (s[f].applyMatrix4(a.makeRotationAxis(i[f], d * f)), r[f].crossVectors(i[f], s[f])); } return { tangents: i, normals: s, binormals: r }; } clone() { return new this.constructor().copy(this); } copy(e) { return ((this.arcLengthDivisions = e.arcLengthDivisions), this); } toJSON() { let e = { metadata: { version: 4.7, type: "Curve", generator: "Curve.toJSON" } }; return ((e.arcLengthDivisions = this.arcLengthDivisions), (e.type = this.type), e); } fromJSON(e) { return ((this.arcLengthDivisions = e.arcLengthDivisions), this); } } function km(e, t, n = 2) { let i = t && t.length, s = i ? t[0] * n : e.length, r = yd(e, 0, s, n, !0), o = []; if (!r || r.next === r.prev) return o; let a, l, c; if (i) r = Vm(e, t, r, n); if (e.length > 80 * n) { ((a = 1 / 0), (l = 1 / 0)); let h = -1 / 0, u = -1 / 0; for (let d = n; d < s; d += n) { let f = e[d], m = e[d + 1]; if (f < a) a = f; if (m < l) l = m; if (f > h) h = f; if (m > u) u = m; } ((c = Math.max(h - a, u - l)), (c = c !== 0 ? 32767 / c : 0)); } return (Ir(r, o, n, a, l, c, 0), o); } function yd(e, t, n, i, s) { let r; if (s === e0(e, t, n, i) > 0) for (let o = t; o < n; o += i) r = hu((o / i) | 0, e[o], e[o + 1], r); else for (let o = n - i; o >= t; o -= i) r = hu((o / i) | 0, e[o], e[o + 1], r); if (r && Xs(r, r.next)) (Dr(r), (r = r.next)); return r; } function hs(e, t) { if (!e) return e; if (!t) t = e; let n = e, i; do if (((i = !1), !n.steiner && (Xs(n, n.next) || Tt(n.prev, n, n.next) === 0))) { if ((Dr(n), (n = t = n.prev), n === n.next)) break; i = !0; } else n = n.next; while (i || n !== t); return t; } function Ir(e, t, n, i, s, r, o) { if (!e) return; if (!o && r) jm(e, i, s, r); let a = e; while (e.prev !== e.next) { let l = e.prev, c = e.next; if (r ? Hm(e, i, s, r) : zm(e)) { (t.push(l.i, e.i, c.i), Dr(e), (e = c.next), (a = c.next)); continue; } if (((e = c), e === a)) { if (!o) Ir(hs(e), t, n, i, s, r, 1); else if (o === 1) ((e = Bm(hs(e), t)), Ir(e, t, n, i, s, r, 2)); else if (o === 2) Gm(e, t, n, i, s, r); break; } } } function zm(e) { let t = e.prev, n = e, i = e.next; if (Tt(t, n, i) >= 0) return !1; let s = t.x, r = n.x, o = i.x, a = t.y, l = n.y, c = i.y, h = Math.min(s, r, o), u = Math.min(a, l, c), d = Math.max(s, r, o), f = Math.max(a, l, c), m = i.next; while (m !== t) { if (m.x >= h && m.x <= d && m.y >= u && m.y <= f && Rr(s, a, r, l, o, c, m.x, m.y) && Tt(m.prev, m, m.next) >= 0) return !1; m = m.next; } return !0; } function Hm(e, t, n, i) { let s = e.prev, r = e, o = e.next; if (Tt(s, r, o) >= 0) return !1; let a = s.x, l = r.x, c = o.x, h = s.y, u = r.y, d = o.y, f = Math.min(a, l, c), m = Math.min(h, u, d), y = Math.max(a, l, c), p = Math.max(h, u, d), g = cl(f, m, t, n, i), _ = cl(y, p, t, n, i), { prevZ: x, nextZ: w } = e; while (x && x.z >= g && w && w.z <= _) { if ( x.x >= f && x.x <= y && x.y >= m && x.y <= p && x !== s && x !== o && Rr(a, h, l, u, c, d, x.x, x.y) && Tt(x.prev, x, x.next) >= 0 ) return !1; if ( ((x = x.prevZ), w.x >= f && w.x <= y && w.y >= m && w.y <= p && w !== s && w !== o && Rr(a, h, l, u, c, d, w.x, w.y) && Tt(w.prev, w, w.next) >= 0) ) return !1; w = w.nextZ; } while (x && x.z >= g) { if ( x.x >= f && x.x <= y && x.y >= m && x.y <= p && x !== s && x !== o && Rr(a, h, l, u, c, d, x.x, x.y) && Tt(x.prev, x, x.next) >= 0 ) return !1; x = x.prevZ; } while (w && w.z <= _) { if ( w.x >= f && w.x <= y && w.y >= m && w.y <= p && w !== s && w !== o && Rr(a, h, l, u, c, d, w.x, w.y) && Tt(w.prev, w, w.next) >= 0 ) return !1; w = w.nextZ; } return !0; } function Bm(e, t) { let n = e; do { let i = n.prev, s = n.next.next; if (!Xs(i, s) && vd(i, n, n.next, s) && Pr(i, s) && Pr(s, i)) (t.push(i.i, n.i, s.i), Dr(n), Dr(n.next), (n = e = s)); n = n.next; } while (n !== e); return hs(n); } function Gm(e, t, n, i, s, r) { let o = e; do { let a = o.next.next; while (a !== o.prev) { if (o.i !== a.i && $m(o, a)) { let l = _d(o, a); ((o = hs(o, o.next)), (l = hs(l, l.next)), Ir(o, t, n, i, s, r, 0), Ir(l, t, n, i, s, r, 0)); return; } a = a.next; } o = o.next; } while (o !== e); } function Vm(e, t, n, i) { let s = []; for (let r = 0, o = t.length; r < o; r++) { let a = t[r] * i, l = r < o - 1 ? t[r + 1] * i : e.length, c = yd(e, a, l, i, !1); if (c === c.next) c.steiner = !0; s.push(Km(c)); } s.sort(Wm); for (let r = 0; r < s.length; r++) n = Xm(s[r], n); return n; } function Wm(e, t) { let n = e.x - t.x; if (n === 0) { if (((n = e.y - t.y), n === 0)) { let i = (e.next.y - e.y) / (e.next.x - e.x), s = (t.next.y - t.y) / (t.next.x - t.x); n = i - s; } } return n; } function Xm(e, t) { let n = qm(e, t); if (!n) return t; let i = _d(n, e); return (hs(i, i.next), hs(n, n.next)); } function qm(e, t) { let n = t, { x: i, y: s } = e, r = -1 / 0, o; if (Xs(e, n)) return n; do { if (Xs(e, n.next)) return n.next; else if (s <= n.y && s >= n.next.y && n.next.y !== n.y) { let u = n.x + ((s - n.y) * (n.next.x - n.x)) / (n.next.y - n.y); if (u <= i && u > r) { if (((r = u), (o = n.x < n.next.x ? n : n.next), u === i)) return o; } } n = n.next; } while (n !== t); if (!o) return null; let a = o, l = o.x, c = o.y, h = 1 / 0; n = o; do { if (i >= n.x && n.x >= l && i !== n.x && xd(s < c ? i : r, s, l, c, s < c ? r : i, s, n.x, n.y)) { let u = Math.abs(s - n.y) / (i - n.x); if (Pr(n, e) && (u < h || (u === h && (n.x > o.x || (n.x === o.x && Ym(o, n)))))) ((o = n), (h = u)); } n = n.next; } while (n !== a); return o; } function Ym(e, t) { return Tt(e.prev, e, t.prev) < 0 && Tt(t.next, e, e.next) < 0; } function jm(e, t, n, i) { let s = e; do { if (s.z === 0) s.z = cl(s.x, s.y, t, n, i); ((s.prevZ = s.prev), (s.nextZ = s.next), (s = s.next)); } while (s !== e); ((s.prevZ.nextZ = null), (s.prevZ = null), Zm(s)); } function Zm(e) { let t, n = 1; do { let i = e, s; e = null; let r = null; t = 0; while (i) { t++; let o = i, a = 0; for (let c = 0; c < n; c++) if ((a++, (o = o.nextZ), !o)) break; let l = n; while (a > 0 || (l > 0 && o)) { if (a !== 0 && (l === 0 || !o || i.z <= o.z)) ((s = i), (i = i.nextZ), a--); else ((s = o), (o = o.nextZ), l--); if (r) r.nextZ = s; else e = s; ((s.prevZ = r), (r = s)); } i = o; } ((r.nextZ = null), (n *= 2)); } while (t > 1); return e; } function cl(e, t, n, i, s) { return ( (e = ((e - n) * s) | 0), (t = ((t - i) * s) | 0), (e = (e | (e << 8)) & 16711935), (e = (e | (e << 4)) & 252645135), (e = (e | (e << 2)) & 858993459), (e = (e | (e << 1)) & 1431655765), (t = (t | (t << 8)) & 16711935), (t = (t | (t << 4)) & 252645135), (t = (t | (t << 2)) & 858993459), (t = (t | (t << 1)) & 1431655765), e | (t << 1) ); } function Km(e) { let t = e, n = e; do { if (t.x < n.x || (t.x === n.x && t.y < n.y)) n = t; t = t.next; } while (t !== e); return n; } function xd(e, t, n, i, s, r, o, a) { return ( (s - o) * (t - a) >= (e - o) * (r - a) && (e - o) * (i - a) >= (n - o) * (t - a) && (n - o) * (r - a) >= (s - o) * (i - a) ); } function Rr(e, t, n, i, s, r, o, a) { return !(e === o && t === a) && xd(e, t, n, i, s, r, o, a); } function $m(e, t) { return ( e.next.i !== t.i && e.prev.i !== t.i && !Jm(e, t) && ((Pr(e, t) && Pr(t, e) && Qm(e, t) && (Tt(e.prev, e, t.prev) || Tt(e, t.prev, t))) || (Xs(e, t) && Tt(e.prev, e, e.next) > 0 && Tt(t.prev, t, t.next) > 0)) ); } function Tt(e, t, n) { return (t.y - e.y) * (n.x - t.x) - (t.x - e.x) * (n.y - t.y); } function Xs(e, t) { return e.x === t.x && e.y === t.y; } function vd(e, t, n, i) { let s = Po(Tt(e, t, n)), r = Po(Tt(e, t, i)), o = Po(Tt(n, i, e)), a = Po(Tt(n, i, t)); if (s !== r && o !== a) return !0; if (s === 0 && Io(e, n, t)) return !0; if (r === 0 && Io(e, i, t)) return !0; if (o === 0 && Io(n, e, i)) return !0; if (a === 0 && Io(n, t, i)) return !0; return !1; } function Io(e, t, n) { return ( t.x <= Math.max(e.x, n.x) && t.x >= Math.min(e.x, n.x) && t.y <= Math.max(e.y, n.y) && t.y >= Math.min(e.y, n.y) ); } function Po(e) { return e > 0 ? 1 : e < 0 ? -1 : 0; } function Jm(e, t) { let n = e; do { if (n.i !== e.i && n.next.i !== e.i && n.i !== t.i && n.next.i !== t.i && vd(n, n.next, e, t)) return !0; n = n.next; } while (n !== e); return !1; } function Pr(e, t) { return Tt(e.prev, e, e.next) < 0 ? Tt(e, t, e.next) >= 0 && Tt(e, e.prev, t) >= 0 : Tt(e, t, e.prev) < 0 || Tt(e, e.next, t) < 0; } function Qm(e, t) { let n = e, i = !1, s = (e.x + t.x) / 2, r = (e.y + t.y) / 2; do { if (n.y > r !== n.next.y > r && n.next.y !== n.y && s < ((n.next.x - n.x) * (r - n.y)) / (n.next.y - n.y) + n.x) i = !i; n = n.next; } while (n !== e); return i; } function _d(e, t) { let n = hl(e.i, e.x, e.y), i = hl(t.i, t.x, t.y), s = e.next, r = t.prev; return ( (e.next = t), (t.prev = e), (n.next = s), (s.prev = n), (i.next = n), (n.prev = i), (r.next = i), (i.prev = r), i ); } function hu(e, t, n, i) { let s = hl(e, t, n); if (!i) ((s.prev = s), (s.next = s)); else ((s.next = i.next), (s.prev = i), (i.next.prev = s), (i.next = s)); return s; } function Dr(e) { if (((e.next.prev = e.prev), (e.prev.next = e.next), e.prevZ)) e.prevZ.nextZ = e.nextZ; if (e.nextZ) e.nextZ.prevZ = e.prevZ; } function hl(e, t, n) { return { i: e, x: t, y: n, prev: null, next: null, z: 0, prevZ: null, nextZ: null, steiner: !1 }; } function e0(e, t, n, i) { let s = 0; for (let r = t, o = n - i; r < n; r += i) ((s += (e[o] - e[r]) * (e[r + 1] + e[o + 1])), (o = r)); return s; } class Sd { static triangulate(e, t, n = 2) { return km(e, t, n); } } class Yr { static area(e) { let t = e.length, n = 0; for (let i = t - 1, s = 0; s < t; i = s++) n += e[i].x * e[s].y - e[s].x * e[i].y; return n * 0.5; } static isClockWise(e) { return Yr.area(e) < 0; } static triangulateShape(e, t) { let n = [], i = [], s = []; (uu(e), du(n, e)); let r = e.length; t.forEach(uu); for (let a = 0; a < t.length; a++) (i.push(r), (r += t[a].length), du(n, t[a])); let o = Sd.triangulate(n, i); for (let a = 0; a < o.length; a += 3) s.push(o.slice(a, a + 3)); return s; } } function uu(e) { let t = e.length; if (t > 2 && e[t - 1].equals(e[0])) e.pop(); } function du(e, t) { for (let n = 0; n < t.length; n++) (e.push(t[n].x), e.push(t[n].y)); } class Vi extends Et { constructor(e = 1, t = 1, n = 1, i = 1) { super(); ((this.type = "PlaneGeometry"), (this.parameters = { width: e, height: t, widthSegments: n, heightSegments: i })); let s = e / 2, r = t / 2, o = Math.floor(n), a = Math.floor(i), l = o + 1, c = a + 1, h = e / o, u = t / a, d = [], f = [], m = [], y = []; for (let p = 0; p < c; p++) { let g = p * u - r; for (let _ = 0; _ < l; _++) { let x = _ * h - s; (f.push(x, -g, 0), m.push(0, 0, 1), y.push(_ / o), y.push(1 - p / a)); } } for (let p = 0; p < a; p++) for (let g = 0; g < o; g++) { let _ = g + l * p, x = g + l * (p + 1), w = g + 1 + l * (p + 1), L = g + 1 + l * p; (d.push(_, x, L), d.push(x, w, L)); } (this.setIndex(d), this.setAttribute("position", new at(f, 3)), this.setAttribute("normal", new at(m, 3)), this.setAttribute("uv", new at(y, 2))); } copy(e) { return (super.copy(e), (this.parameters = Object.assign({}, e.parameters)), this); } static fromJSON(e) { return new Vi(e.width, e.height, e.widthSegments, e.heightSegments); } } class gs extends Et { constructor(e = 1, t = 32, n = 16, i = 0, s = Math.PI * 2, r = 0, o = Math.PI) { super(); ((this.type = "SphereGeometry"), (this.parameters = { radius: e, widthSegments: t, heightSegments: n, phiStart: i, phiLength: s, thetaStart: r, thetaLength: o, }), (t = Math.max(3, Math.floor(t))), (n = Math.max(2, Math.floor(n)))); let a = Math.min(r + o, Math.PI), l = 0, c = [], h = new E(), u = new E(), d = [], f = [], m = [], y = []; for (let p = 0; p <= n; p++) { let g = [], _ = p / n, x = 0; if (p === 0 && r === 0) x = 0.5 / t; else if (p === n && a === Math.PI) x = -0.5 / t; for (let w = 0; w <= t; w++) { let L = w / t; ((h.x = -e * Math.cos(i + L * s) * Math.sin(r + _ * o)), (h.y = e * Math.cos(r + _ * o)), (h.z = e * Math.sin(i + L * s) * Math.sin(r + _ * o)), f.push(h.x, h.y, h.z), u.copy(h).normalize(), m.push(u.x, u.y, u.z), y.push(L + x, 1 - _), g.push(l++)); } c.push(g); } for (let p = 0; p < n; p++) for (let g = 0; g < t; g++) { let _ = c[p][g + 1], x = c[p][g], w = c[p + 1][g], L = c[p + 1][g + 1]; if (p !== 0 || r > 0) d.push(_, x, L); if (p !== n - 1 || a < Math.PI) d.push(x, w, L); } (this.setIndex(d), this.setAttribute("position", new at(f, 3)), this.setAttribute("normal", new at(m, 3)), this.setAttribute("uv", new at(y, 2))); } copy(e) { return (super.copy(e), (this.parameters = Object.assign({}, e.parameters)), this); } static fromJSON(e) { return new gs(e.radius, e.widthSegments, e.heightSegments, e.phiStart, e.phiLength, e.thetaStart, e.thetaLength); } } class Mi extends Vt { constructor(e) { super(); ((this.isMeshStandardMaterial = !0), (this.type = "MeshStandardMaterial"), (this.defines = { STANDARD: "" }), (this.color = new re(16777215)), (this.roughness = 1), (this.metalness = 0), (this.map = null), (this.lightMap = null), (this.lightMapIntensity = 1), (this.aoMap = null), (this.aoMapIntensity = 1), (this.emissive = new re(0)), (this.emissiveIntensity = 1), (this.emissiveMap = null), (this.bumpMap = null), (this.bumpScale = 1), (this.normalMap = null), (this.normalMapType = 0), (this.normalScale = new ve(1, 1)), (this.displacementMap = null), (this.displacementScale = 1), (this.displacementBias = 0), (this.roughnessMap = null), (this.metalnessMap = null), (this.alphaMap = null), (this.envMap = null), (this.envMapRotation = new tt()), (this.envMapIntensity = 1), (this.wireframe = !1), (this.wireframeLinewidth = 1), (this.wireframeLinecap = "round"), (this.wireframeLinejoin = "round"), (this.flatShading = !1), (this.fog = !0), this.setValues(e)); } copy(e) { return ( super.copy(e), (this.defines = { STANDARD: "" }), this.color.copy(e.color), (this.roughness = e.roughness), (this.metalness = e.metalness), (this.map = e.map), (this.lightMap = e.lightMap), (this.lightMapIntensity = e.lightMapIntensity), (this.aoMap = e.aoMap), (this.aoMapIntensity = e.aoMapIntensity), this.emissive.copy(e.emissive), (this.emissiveMap = e.emissiveMap), (this.emissiveIntensity = e.emissiveIntensity), (this.bumpMap = e.bumpMap), (this.bumpScale = e.bumpScale), (this.normalMap = e.normalMap), (this.normalMapType = e.normalMapType), this.normalScale.copy(e.normalScale), (this.displacementMap = e.displacementMap), (this.displacementScale = e.displacementScale), (this.displacementBias = e.displacementBias), (this.roughnessMap = e.roughnessMap), (this.metalnessMap = e.metalnessMap), (this.alphaMap = e.alphaMap), (this.envMap = e.envMap), this.envMapRotation.copy(e.envMapRotation), (this.envMapIntensity = e.envMapIntensity), (this.wireframe = e.wireframe), (this.wireframeLinewidth = e.wireframeLinewidth), (this.wireframeLinecap = e.wireframeLinecap), (this.wireframeLinejoin = e.wireframeLinejoin), (this.flatShading = e.flatShading), (this.fog = e.fog), this ); } } class tn extends Mi { constructor(e) { super(); ((this.isMeshPhysicalMaterial = !0), (this.defines = { STANDARD: "", PHYSICAL: "" }), (this.type = "MeshPhysicalMaterial"), (this.anisotropyRotation = 0), (this.anisotropyMap = null), (this.clearcoatMap = null), (this.clearcoatRoughness = 0), (this.clearcoatRoughnessMap = null), (this.clearcoatNormalScale = new ve(1, 1)), (this.clearcoatNormalMap = null), (this.ior = 1.5), Object.defineProperty(this, "reflectivity", { get: function () { return qe((2.5 * (this.ior - 1)) / (this.ior + 1), 0, 1); }, set: function (t) { this.ior = (1 + 0.4 * t) / (1 - 0.4 * t); }, }), (this.iridescenceMap = null), (this.iridescenceIOR = 1.3), (this.iridescenceThicknessRange = [100, 400]), (this.iridescenceThicknessMap = null), (this.sheenColor = new re(0)), (this.sheenColorMap = null), (this.sheenRoughness = 1), (this.sheenRoughnessMap = null), (this.transmissionMap = null), (this.thickness = 0), (this.thicknessMap = null), (this.attenuationDistance = 1 / 0), (this.attenuationColor = new re(1, 1, 1)), (this.specularIntensity = 1), (this.specularIntensityMap = null), (this.specularColor = new re(1, 1, 1)), (this.specularColorMap = null), (this._anisotropy = 0), (this._clearcoat = 0), (this._dispersion = 0), (this._iridescence = 0), (this._sheen = 0), (this._transmission = 0), this.setValues(e)); } get anisotropy() { return this._anisotropy; } set anisotropy(e) { if (this._anisotropy > 0 !== e > 0) this.version++; this._anisotropy = e; } get clearcoat() { return this._clearcoat; } set clearcoat(e) { if (this._clearcoat > 0 !== e > 0) this.version++; this._clearcoat = e; } get iridescence() { return this._iridescence; } set iridescence(e) { if (this._iridescence > 0 !== e > 0) this.version++; this._iridescence = e; } get dispersion() { return this._dispersion; } set dispersion(e) { if (this._dispersion > 0 !== e > 0) this.version++; this._dispersion = e; } get sheen() { return this._sheen; } set sheen(e) { if (this._sheen > 0 !== e > 0) this.version++; this._sheen = e; } get transmission() { return this._transmission; } set transmission(e) { if (this._transmission > 0 !== e > 0) this.version++; this._transmission = e; } copy(e) { return ( super.copy(e), (this.defines = { STANDARD: "", PHYSICAL: "" }), (this.anisotropy = e.anisotropy), (this.anisotropyRotation = e.anisotropyRotation), (this.anisotropyMap = e.anisotropyMap), (this.clearcoat = e.clearcoat), (this.clearcoatMap = e.clearcoatMap), (this.clearcoatRoughness = e.clearcoatRoughness), (this.clearcoatRoughnessMap = e.clearcoatRoughnessMap), (this.clearcoatNormalMap = e.clearcoatNormalMap), this.clearcoatNormalScale.copy(e.clearcoatNormalScale), (this.dispersion = e.dispersion), (this.ior = e.ior), (this.iridescence = e.iridescence), (this.iridescenceMap = e.iridescenceMap), (this.iridescenceIOR = e.iridescenceIOR), (this.iridescenceThicknessRange = [...e.iridescenceThicknessRange]), (this.iridescenceThicknessMap = e.iridescenceThicknessMap), (this.sheen = e.sheen), this.sheenColor.copy(e.sheenColor), (this.sheenColorMap = e.sheenColorMap), (this.sheenRoughness = e.sheenRoughness), (this.sheenRoughnessMap = e.sheenRoughnessMap), (this.transmission = e.transmission), (this.transmissionMap = e.transmissionMap), (this.thickness = e.thickness), (this.thicknessMap = e.thicknessMap), (this.attenuationDistance = e.attenuationDistance), this.attenuationColor.copy(e.attenuationColor), (this.specularIntensity = e.specularIntensity), (this.specularIntensityMap = e.specularIntensityMap), this.specularColor.copy(e.specularColor), (this.specularColorMap = e.specularColorMap), this ); } } class ys extends Vt { constructor(e) { super(); ((this.isMeshPhongMaterial = !0), (this.type = "MeshPhongMaterial"), (this.color = new re(16777215)), (this.specular = new re(1118481)), (this.shininess = 30), (this.map = null), (this.lightMap = null), (this.lightMapIntensity = 1), (this.aoMap = null), (this.aoMapIntensity = 1), (this.emissive = new re(0)), (this.emissiveIntensity = 1), (this.emissiveMap = null), (this.bumpMap = null), (this.bumpScale = 1), (this.normalMap = null), (this.normalMapType = 0), (this.normalScale = new ve(1, 1)), (this.displacementMap = null), (this.displacementScale = 1), (this.displacementBias = 0), (this.specularMap = null), (this.alphaMap = null), (this.envMap = null), (this.envMapRotation = new tt()), (this.combine = 0), (this.reflectivity = 1), (this.refractionRatio = 0.98), (this.wireframe = !1), (this.wireframeLinewidth = 1), (this.wireframeLinecap = "round"), (this.wireframeLinejoin = "round"), (this.flatShading = !1), (this.fog = !0), this.setValues(e)); } copy(e) { return ( super.copy(e), this.color.copy(e.color), this.specular.copy(e.specular), (this.shininess = e.shininess), (this.map = e.map), (this.lightMap = e.lightMap), (this.lightMapIntensity = e.lightMapIntensity), (this.aoMap = e.aoMap), (this.aoMapIntensity = e.aoMapIntensity), this.emissive.copy(e.emissive), (this.emissiveMap = e.emissiveMap), (this.emissiveIntensity = e.emissiveIntensity), (this.bumpMap = e.bumpMap), (this.bumpScale = e.bumpScale), (this.normalMap = e.normalMap), (this.normalMapType = e.normalMapType), this.normalScale.copy(e.normalScale), (this.displacementMap = e.displacementMap), (this.displacementScale = e.displacementScale), (this.displacementBias = e.displacementBias), (this.specularMap = e.specularMap), (this.alphaMap = e.alphaMap), (this.envMap = e.envMap), this.envMapRotation.copy(e.envMapRotation), (this.combine = e.combine), (this.reflectivity = e.reflectivity), (this.refractionRatio = e.refractionRatio), (this.wireframe = e.wireframe), (this.wireframeLinewidth = e.wireframeLinewidth), (this.wireframeLinecap = e.wireframeLinecap), (this.wireframeLinejoin = e.wireframeLinejoin), (this.flatShading = e.flatShading), (this.fog = e.fog), this ); } } class rr extends Vt { constructor(e) { super(); ((this.isMeshLambertMaterial = !0), (this.type = "MeshLambertMaterial"), (this.color = new re(16777215)), (this.map = null), (this.lightMap = null), (this.lightMapIntensity = 1), (this.aoMap = null), (this.aoMapIntensity = 1), (this.emissive = new re(0)), (this.emissiveIntensity = 1), (this.emissiveMap = null), (this.bumpMap = null), (this.bumpScale = 1), (this.normalMap = null), (this.normalMapType = 0), (this.normalScale = new ve(1, 1)), (this.displacementMap = null), (this.displacementScale = 1), (this.displacementBias = 0), (this.specularMap = null), (this.alphaMap = null), (this.envMap = null), (this.envMapRotation = new tt()), (this.combine = 0), (this.reflectivity = 1), (this.refractionRatio = 0.98), (this.wireframe = !1), (this.wireframeLinewidth = 1), (this.wireframeLinecap = "round"), (this.wireframeLinejoin = "round"), (this.flatShading = !1), (this.fog = !0), this.setValues(e)); } copy(e) { return ( super.copy(e), this.color.copy(e.color), (this.map = e.map), (this.lightMap = e.lightMap), (this.lightMapIntensity = e.lightMapIntensity), (this.aoMap = e.aoMap), (this.aoMapIntensity = e.aoMapIntensity), this.emissive.copy(e.emissive), (this.emissiveMap = e.emissiveMap), (this.emissiveIntensity = e.emissiveIntensity), (this.bumpMap = e.bumpMap), (this.bumpScale = e.bumpScale), (this.normalMap = e.normalMap), (this.normalMapType = e.normalMapType), this.normalScale.copy(e.normalScale), (this.displacementMap = e.displacementMap), (this.displacementScale = e.displacementScale), (this.displacementBias = e.displacementBias), (this.specularMap = e.specularMap), (this.alphaMap = e.alphaMap), (this.envMap = e.envMap), this.envMapRotation.copy(e.envMapRotation), (this.combine = e.combine), (this.reflectivity = e.reflectivity), (this.refractionRatio = e.refractionRatio), (this.wireframe = e.wireframe), (this.wireframeLinewidth = e.wireframeLinewidth), (this.wireframeLinecap = e.wireframeLinecap), (this.wireframeLinejoin = e.wireframeLinejoin), (this.flatShading = e.flatShading), (this.fog = e.fog), this ); } } class dc extends Vt { constructor(e) { super(); ((this.isMeshDepthMaterial = !0), (this.type = "MeshDepthMaterial"), (this.depthPacking = 3200), (this.map = null), (this.alphaMap = null), (this.displacementMap = null), (this.displacementScale = 1), (this.displacementBias = 0), (this.wireframe = !1), (this.wireframeLinewidth = 1), this.setValues(e)); } copy(e) { return ( super.copy(e), (this.depthPacking = e.depthPacking), (this.map = e.map), (this.alphaMap = e.alphaMap), (this.displacementMap = e.displacementMap), (this.displacementScale = e.displacementScale), (this.displacementBias = e.displacementBias), (this.wireframe = e.wireframe), (this.wireframeLinewidth = e.wireframeLinewidth), this ); } } class fc extends Vt { constructor(e) { super(); ((this.isMeshDistanceMaterial = !0), (this.type = "MeshDistanceMaterial"), (this.map = null), (this.alphaMap = null), (this.displacementMap = null), (this.displacementScale = 1), (this.displacementBias = 0), this.setValues(e)); } copy(e) { return ( super.copy(e), (this.map = e.map), (this.alphaMap = e.alphaMap), (this.displacementMap = e.displacementMap), (this.displacementScale = e.displacementScale), (this.displacementBias = e.displacementBias), this ); } } function Do(e, t) { if (!e || e.constructor === t) return e; if (typeof t.BYTES_PER_ELEMENT === "number") return new t(e); return Array.prototype.slice.call(e); } function t0(e) { return ArrayBuffer.isView(e) && !(e instanceof DataView); } function n0(e) { function t(s, r) { return e[s] - e[r]; } let n = e.length, i = Array(n); for (let s = 0; s !== n; ++s) i[s] = s; return (i.sort(t), i); } function fu(e, t, n) { let i = e.length, s = new e.constructor(i); for (let r = 0, o = 0; o !== i; ++r) { let a = n[r] * t; for (let l = 0; l !== t; ++l) s[o++] = e[a + l]; } return s; } function bd(e, t, n, i) { let s = 1, r = e[0]; while (r !== void 0 && r[i] === void 0) r = e[s++]; if (r === void 0) return; let o = r[i]; if (o === void 0) return; if (Array.isArray(o)) do { if (((o = r[i]), o !== void 0)) (t.push(r.time), n.push(...o)); r = e[s++]; } while (r !== void 0); else if (o.toArray !== void 0) do { if (((o = r[i]), o !== void 0)) (t.push(r.time), o.toArray(n, n.length)); r = e[s++]; } while (r !== void 0); else do { if (((o = r[i]), o !== void 0)) (t.push(r.time), n.push(o)); r = e[s++]; } while (r !== void 0); } class Wi { constructor(e, t, n, i) { ((this.parameterPositions = e), (this._cachedIndex = 0), (this.resultBuffer = i !== void 0 ? i : new t.constructor(n)), (this.sampleValues = t), (this.valueSize = n), (this.settings = null), (this.DefaultSettings_ = {})); } evaluate(e) { let t = this.parameterPositions, n = this._cachedIndex, i = t[n], s = t[n - 1]; e: { t: { let r; n: { i: if (!(e < i)) { for (let o = n + 2; ;) { if (i === void 0) { if (e < s) break i; return ((n = t.length), (this._cachedIndex = n), this.copySampleValue_(n - 1)); } if (n === o) break; if (((s = i), (i = t[++n]), e < i)) break t; } r = t.length; break n; } if (!(e >= s)) { let o = t[1]; if (e < o) ((n = 2), (s = o)); for (let a = n - 2; ;) { if (s === void 0) return ((this._cachedIndex = 0), this.copySampleValue_(0)); if (n === a) break; if (((i = s), (s = t[--n - 1]), e >= s)) break t; } ((r = n), (n = 0)); break n; } break e; } while (n < r) { let o = (n + r) >>> 1; if (e < t[o]) r = o; else n = o + 1; } if (((i = t[n]), (s = t[n - 1]), s === void 0)) return ((this._cachedIndex = 0), this.copySampleValue_(0)); if (i === void 0) return ((n = t.length), (this._cachedIndex = n), this.copySampleValue_(n - 1)); } ((this._cachedIndex = n), this.intervalChanged_(n, s, i)); } return this.interpolate_(n, s, e, i); } getSettings_() { return this.settings || this.DefaultSettings_; } copySampleValue_(e) { let t = this.resultBuffer, n = this.sampleValues, i = this.valueSize, s = e * i; for (let r = 0; r !== i; ++r) t[r] = n[s + r]; return t; } interpolate_() { throw Error("call to abstract method"); } intervalChanged_() {} } class pc extends Wi { constructor(e, t, n, i) { super(e, t, n, i); ((this._weightPrev = -0), (this._offsetPrev = -0), (this._weightNext = -0), (this._offsetNext = -0), (this.DefaultSettings_ = { endingStart: 2400, endingEnd: 2400 })); } intervalChanged_(e, t, n) { let i = this.parameterPositions, s = e - 2, r = e + 1, o = i[s], a = i[r]; if (o === void 0) switch (this.getSettings_().endingStart) { case 2401: ((s = e), (o = 2 * t - n)); break; case 2402: ((s = i.length - 2), (o = t + i[s] - i[s + 1])); break; default: ((s = e), (o = n)); } if (a === void 0) switch (this.getSettings_().endingEnd) { case 2401: ((r = e), (a = 2 * n - t)); break; case 2402: ((r = 1), (a = n + i[1] - i[0])); break; default: ((r = e - 1), (a = t)); } let l = (n - t) * 0.5, c = this.valueSize; ((this._weightPrev = l / (t - o)), (this._weightNext = l / (a - n)), (this._offsetPrev = s * c), (this._offsetNext = r * c)); } interpolate_(e, t, n, i) { let s = this.resultBuffer, r = this.sampleValues, o = this.valueSize, a = e * o, l = a - o, c = this._offsetPrev, h = this._offsetNext, u = this._weightPrev, d = this._weightNext, f = (n - t) / (i - t), m = f * f, y = m * f, p = -u * y + 2 * u * m - u * f, g = (1 + u) * y + (-1.5 - 2 * u) * m + (-0.5 + u) * f + 1, _ = (-1 - d) * y + (1.5 + d) * m + 0.5 * f, x = d * y - d * m; for (let w = 0; w !== o; ++w) s[w] = p * r[c + w] + g * r[l + w] + _ * r[a + w] + x * r[h + w]; return s; } } class ca extends Wi { constructor(e, t, n, i) { super(e, t, n, i); } interpolate_(e, t, n, i) { let s = this.resultBuffer, r = this.sampleValues, o = this.valueSize, a = e * o, l = a - o, c = (n - t) / (i - t), h = 1 - c; for (let u = 0; u !== o; ++u) s[u] = r[l + u] * h + r[a + u] * c; return s; } } class mc extends Wi { constructor(e, t, n, i) { super(e, t, n, i); } interpolate_(e) { return this.copySampleValue_(e - 1); } } class xn { constructor(e, t, n, i) { if (e === void 0) throw Error("THREE.KeyframeTrack: track name is undefined"); if (t === void 0 || t.length === 0) throw Error("THREE.KeyframeTrack: no keyframes in track named " + e); ((this.name = e), (this.times = Do(t, this.TimeBufferType)), (this.values = Do(n, this.ValueBufferType)), this.setInterpolation(i || this.DefaultInterpolation)); } static toJSON(e) { let t = e.constructor, n; if (t.toJSON !== this.toJSON) n = t.toJSON(e); else { n = { name: e.name, times: Do(e.times, Array), values: Do(e.values, Array) }; let i = e.getInterpolation(); if (i !== e.DefaultInterpolation) n.interpolation = i; } return ((n.type = e.ValueTypeName), n); } InterpolantFactoryMethodDiscrete(e) { return new mc(this.times, this.values, this.getValueSize(), e); } InterpolantFactoryMethodLinear(e) { return new ca(this.times, this.values, this.getValueSize(), e); } InterpolantFactoryMethodSmooth(e) { return new pc(this.times, this.values, this.getValueSize(), e); } setInterpolation(e) { let t; switch (e) { case 2300: t = this.InterpolantFactoryMethodDiscrete; break; case 2301: t = this.InterpolantFactoryMethodLinear; break; case 2302: t = this.InterpolantFactoryMethodSmooth; break; } if (t === void 0) { let n = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name; if (this.createInterpolant === void 0) if (e !== this.DefaultInterpolation) this.setInterpolation(this.DefaultInterpolation); else throw Error(n); return (console.warn("THREE.KeyframeTrack:", n), this); } return ((this.createInterpolant = t), this); } getInterpolation() { switch (this.createInterpolant) { case this.InterpolantFactoryMethodDiscrete: return 2300; case this.InterpolantFactoryMethodLinear: return 2301; case this.InterpolantFactoryMethodSmooth: return 2302; } } getValueSize() { return this.values.length / this.times.length; } shift(e) { if (e !== 0) { let t = this.times; for (let n = 0, i = t.length; n !== i; ++n) t[n] += e; } return this; } scale(e) { if (e !== 1) { let t = this.times; for (let n = 0, i = t.length; n !== i; ++n) t[n] *= e; } return this; } trim(e, t) { let n = this.times, i = n.length, s = 0, r = i - 1; while (s !== i && n[s] < e) ++s; while (r !== -1 && n[r] > t) --r; if ((++r, s !== 0 || r !== i)) { if (s >= r) ((r = Math.max(r, 1)), (s = r - 1)); let o = this.getValueSize(); ((this.times = n.slice(s, r)), (this.values = this.values.slice(s * o, r * o))); } return this; } validate() { let e = !0, t = this.getValueSize(); if (t - Math.floor(t) !== 0) (console.error("THREE.KeyframeTrack: Invalid value size in track.", this), (e = !1)); let n = this.times, i = this.values, s = n.length; if (s === 0) (console.error("THREE.KeyframeTrack: Track is empty.", this), (e = !1)); let r = null; for (let o = 0; o !== s; o++) { let a = n[o]; if (typeof a === "number" && isNaN(a)) { (console.error("THREE.KeyframeTrack: Time is not a valid number.", this, o, a), (e = !1)); break; } if (r !== null && r > a) { (console.error("THREE.KeyframeTrack: Out of order keys.", this, o, a, r), (e = !1)); break; } r = a; } if (i !== void 0) { if (t0(i)) for (let o = 0, a = i.length; o !== a; ++o) { let l = i[o]; if (isNaN(l)) { (console.error("THREE.KeyframeTrack: Value is not a valid number.", this, o, l), (e = !1)); break; } } } return e; } optimize() { let e = this.times.slice(), t = this.values.slice(), n = this.getValueSize(), i = this.getInterpolation() === 2302, s = e.length - 1, r = 1; for (let o = 1; o < s; ++o) { let a = !1, l = e[o], c = e[o + 1]; if (l !== c && (o !== 1 || l !== e[0])) if (!i) { let h = o * n, u = h - n, d = h + n; for (let f = 0; f !== n; ++f) { let m = t[h + f]; if (m !== t[u + f] || m !== t[d + f]) { a = !0; break; } } } else a = !0; if (a) { if (o !== r) { e[r] = e[o]; let h = o * n, u = r * n; for (let d = 0; d !== n; ++d) t[u + d] = t[h + d]; } ++r; } } if (s > 0) { e[r] = e[s]; for (let o = s * n, a = r * n, l = 0; l !== n; ++l) t[a + l] = t[o + l]; ++r; } if (r !== e.length) ((this.times = e.slice(0, r)), (this.values = t.slice(0, r * n))); else ((this.times = e), (this.values = t)); return this; } clone() { let e = this.times.slice(), t = this.values.slice(), i = new this.constructor(this.name, e, t); return ((i.createInterpolant = this.createInterpolant), i); } } xn.prototype.ValueTypeName = ""; xn.prototype.TimeBufferType = Float32Array; xn.prototype.ValueBufferType = Float32Array; xn.prototype.DefaultInterpolation = 2301; class Xi extends xn { constructor(e, t, n) { super(e, t, n); } } Xi.prototype.ValueTypeName = "bool"; Xi.prototype.ValueBufferType = Array; Xi.prototype.DefaultInterpolation = 2300; Xi.prototype.InterpolantFactoryMethodLinear = void 0; Xi.prototype.InterpolantFactoryMethodSmooth = void 0; class ha extends xn { constructor(e, t, n, i) { super(e, t, n, i); } } ha.prototype.ValueTypeName = "color"; class Nn extends xn { constructor(e, t, n, i) { super(e, t, n, i); } } Nn.prototype.ValueTypeName = "number"; class gc extends Wi { constructor(e, t, n, i) { super(e, t, n, i); } interpolate_(e, t, n, i) { let s = this.resultBuffer, r = this.sampleValues, o = this.valueSize, a = (n - t) / (i - t), l = e * o; for (let c = l + o; l !== c; l += 4) Ne.slerpFlat(s, 0, r, l - o, r, l, a); return s; } } class wn extends xn { constructor(e, t, n, i) { super(e, t, n, i); } InterpolantFactoryMethodLinear(e) { return new gc(this.times, this.values, this.getValueSize(), e); } } wn.prototype.ValueTypeName = "quaternion"; wn.prototype.InterpolantFactoryMethodSmooth = void 0; class qi extends xn { constructor(e, t, n) { super(e, t, n); } } qi.prototype.ValueTypeName = "string"; qi.prototype.ValueBufferType = Array; qi.prototype.DefaultInterpolation = 2300; qi.prototype.InterpolantFactoryMethodLinear = void 0; qi.prototype.InterpolantFactoryMethodSmooth = void 0; class Fn extends xn { constructor(e, t, n, i) { super(e, t, n, i); } } Fn.prototype.ValueTypeName = "vector"; class Di { constructor(e = "", t = -1, n = [], i = 2500) { if ( ((this.name = e), (this.tracks = n), (this.duration = t), (this.blendMode = i), (this.uuid = Un()), (this.userData = {}), this.duration < 0) ) this.resetDuration(); } static parse(e) { let t = [], n = e.tracks, i = 1 / (e.fps || 1); for (let r = 0, o = n.length; r !== o; ++r) t.push(s0(n[r]).scale(i)); let s = new this(e.name, e.duration, t, e.blendMode); return ((s.uuid = e.uuid), (s.userData = JSON.parse(e.userData || "{}")), s); } static toJSON(e) { let t = [], n = e.tracks, i = { name: e.name, duration: e.duration, tracks: t, uuid: e.uuid, blendMode: e.blendMode, userData: JSON.stringify(e.userData), }; for (let s = 0, r = n.length; s !== r; ++s) t.push(xn.toJSON(n[s])); return i; } static CreateFromMorphTargetSequence(e, t, n, i) { let s = t.length, r = []; for (let o = 0; o < s; o++) { let a = [], l = []; (a.push((o + s - 1) % s, o, (o + 1) % s), l.push(0, 1, 0)); let c = n0(a); if (((a = fu(a, 1, c)), (l = fu(l, 1, c)), !i && a[0] === 0)) (a.push(s), l.push(l[0])); r.push(new Nn(".morphTargetInfluences[" + t[o].name + "]", a, l).scale(1 / n)); } return new this(e, -1, r); } static findByName(e, t) { let n = e; if (!Array.isArray(e)) { let i = e; n = (i.geometry && i.geometry.animations) || i.animations; } for (let i = 0; i < n.length; i++) if (n[i].name === t) return n[i]; return null; } static CreateClipsFromMorphTargetSequences(e, t, n) { let i = {}, s = /^([\w-]*?)([\d]+)$/; for (let o = 0, a = e.length; o < a; o++) { let l = e[o], c = l.name.match(s); if (c && c.length > 1) { let h = c[1], u = i[h]; if (!u) i[h] = u = []; u.push(l); } } let r = []; for (let o in i) r.push(this.CreateFromMorphTargetSequence(o, i[o], t, n)); return r; } static parseAnimation(e, t) { if ((console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"), !e)) return (console.error("THREE.AnimationClip: No animation in JSONLoader data."), null); let n = function (h, u, d, f, m) { if (d.length !== 0) { let y = [], p = []; if ((bd(d, y, p, f), y.length !== 0)) m.push(new h(u, y, p)); } }, i = [], s = e.name || "default", r = e.fps || 30, o = e.blendMode, a = e.length || -1, l = e.hierarchy || []; for (let h = 0; h < l.length; h++) { let u = l[h].keys; if (!u || u.length === 0) continue; if (u[0].morphTargets) { let d = {}, f; for (f = 0; f < u.length; f++) if (u[f].morphTargets) for (let m = 0; m < u[f].morphTargets.length; m++) d[u[f].morphTargets[m]] = -1; for (let m in d) { let y = [], p = []; for (let g = 0; g !== u[f].morphTargets.length; ++g) { let _ = u[f]; (y.push(_.time), p.push(_.morphTarget === m ? 1 : 0)); } i.push(new Nn(".morphTargetInfluence[" + m + "]", y, p)); } a = d.length * r; } else { let d = ".bones[" + t[h].name + "]"; (n(Fn, d + ".position", u, "pos", i), n(wn, d + ".quaternion", u, "rot", i), n(Fn, d + ".scale", u, "scl", i)); } } if (i.length === 0) return null; return new this(s, a, i, o); } resetDuration() { let e = this.tracks, t = 0; for (let n = 0, i = e.length; n !== i; ++n) { let s = this.tracks[n]; t = Math.max(t, s.times[s.times.length - 1]); } return ((this.duration = t), this); } trim() { for (let e = 0; e < this.tracks.length; e++) this.tracks[e].trim(0, this.duration); return this; } validate() { let e = !0; for (let t = 0; t < this.tracks.length; t++) e = e && this.tracks[t].validate(); return e; } optimize() { for (let e = 0; e < this.tracks.length; e++) this.tracks[e].optimize(); return this; } clone() { let e = []; for (let n = 0; n < this.tracks.length; n++) e.push(this.tracks[n].clone()); let t = new this.constructor(this.name, this.duration, e, this.blendMode); return ((t.userData = JSON.parse(JSON.stringify(this.userData))), t); } toJSON() { return this.constructor.toJSON(this); } } function i0(e) { switch (e.toLowerCase()) { case "scalar": case "double": case "float": case "number": case "integer": return Nn; case "vector": case "vector2": case "vector3": case "vector4": return Fn; case "color": return ha; case "quaternion": return wn; case "bool": case "boolean": return Xi; case "string": return qi; } throw Error("THREE.KeyframeTrack: Unsupported typeName: " + e); } function s0(e) { if (e.type === void 0) throw Error("THREE.KeyframeTrack: track type undefined, can not parse"); let t = i0(e.type); if (e.times === void 0) { let n = [], i = []; (bd(e.keys, n, i, "value"), (e.times = n), (e.values = i)); } if (t.parse !== void 0) return t.parse(e); else return new t(e.name, e.times, e.values, e.interpolation); } var Xn = { enabled: !1, files: {}, add: function (e, t) { if (this.enabled === !1) return; this.files[e] = t; }, get: function (e) { if (this.enabled === !1) return; return this.files[e]; }, remove: function (e) { delete this.files[e]; }, clear: function () { this.files = {}; }, }; class yc { constructor(e, t, n) { let i = this, s = !1, r = 0, o = 0, a = void 0, l = []; ((this.onStart = void 0), (this.onLoad = e), (this.onProgress = t), (this.onError = n), (this.abortController = new AbortController()), (this.itemStart = function (c) { if ((o++, s === !1)) { if (i.onStart !== void 0) i.onStart(c, r, o); } s = !0; }), (this.itemEnd = function (c) { if ((r++, i.onProgress !== void 0)) i.onProgress(c, r, o); if (r === o) { if (((s = !1), i.onLoad !== void 0)) i.onLoad(); } }), (this.itemError = function (c) { if (i.onError !== void 0) i.onError(c); }), (this.resolveURL = function (c) { if (a) return a(c); return c; }), (this.setURLModifier = function (c) { return ((a = c), this); }), (this.addHandler = function (c, h) { return (l.push(c, h), this); }), (this.removeHandler = function (c) { let h = l.indexOf(c); if (h !== -1) l.splice(h, 2); return this; }), (this.getHandler = function (c) { for (let h = 0, u = l.length; h < u; h += 2) { let d = l[h], f = l[h + 1]; if (d.global) d.lastIndex = 0; if (d.test(c)) return f; } return null; }), (this.abort = function () { return (this.abortController.abort(), (this.abortController = new AbortController()), this); })); } } var Md = new yc(); class nn { constructor(e) { ((this.manager = e !== void 0 ? e : Md), (this.crossOrigin = "anonymous"), (this.withCredentials = !1), (this.path = ""), (this.resourcePath = ""), (this.requestHeader = {})); } load() {} loadAsync(e, t) { let n = this; return new Promise(function (i, s) { n.load(e, i, t, s); }); } parse() {} setCrossOrigin(e) { return ((this.crossOrigin = e), this); } setWithCredentials(e) { return ((this.withCredentials = e), this); } setPath(e) { return ((this.path = e), this); } setResourcePath(e) { return ((this.resourcePath = e), this); } setRequestHeader(e) { return ((this.requestHeader = e), this); } abort() { return this; } } nn.DEFAULT_MATERIAL_NAME = "__DEFAULT"; var fi = {}; class wd extends Error { constructor(e, t) { super(e); this.response = t; } } class $n extends nn { constructor(e) { super(e); ((this.mimeType = ""), (this.responseType = ""), (this._abortController = new AbortController())); } load(e, t, n, i) { if (e === void 0) e = ""; if (this.path !== void 0) e = this.path + e; e = this.manager.resolveURL(e); let s = Xn.get(`file:${e}`); if (s !== void 0) return ( this.manager.itemStart(e), setTimeout(() => { if (t) t(s); this.manager.itemEnd(e); }, 0), s ); if (fi[e] !== void 0) { fi[e].push({ onLoad: t, onProgress: n, onError: i }); return; } ((fi[e] = []), fi[e].push({ onLoad: t, onProgress: n, onError: i })); let r = new Request(e, { headers: new Headers(this.requestHeader), credentials: this.withCredentials ? "include" : "same-origin", signal: typeof AbortSignal.any === "function" ? AbortSignal.any([this._abortController.signal, this.manager.abortController.signal]) : this._abortController.signal, }), o = this.mimeType, a = this.responseType; (fetch(r) .then((l) => { if (l.status === 200 || l.status === 0) { if (l.status === 0) console.warn("THREE.FileLoader: HTTP Status 0 received."); if (typeof ReadableStream > "u" || l.body === void 0 || l.body.getReader === void 0) return l; let c = fi[e], h = l.body.getReader(), u = l.headers.get("X-File-Size") || l.headers.get("Content-Length"), d = u ? parseInt(u) : 0, f = d !== 0, m = 0, y = new ReadableStream({ start(p) { g(); function g() { h.read().then( ({ done: _, value: x }) => { if (_) p.close(); else { m += x.byteLength; let w = new ProgressEvent("progress", { lengthComputable: f, loaded: m, total: d }); for (let L = 0, b = c.length; L < b; L++) { let R = c[L]; if (R.onProgress) R.onProgress(w); } (p.enqueue(x), g()); } }, (_) => { p.error(_); }, ); } }, }); return new Response(y); } else throw new wd(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`, l); }) .then((l) => { switch (a) { case "arraybuffer": return l.arrayBuffer(); case "blob": return l.blob(); case "document": return l.text().then((c) => new DOMParser().parseFromString(c, o)); case "json": return l.json(); default: if (o === "") return l.text(); else { let h = /charset="?([^;"\s]*)"?/i.exec(o), u = h && h[1] ? h[1].toLowerCase() : void 0, d = new TextDecoder(u); return l.arrayBuffer().then((f) => d.decode(f)); } } }) .then((l) => { Xn.add(`file:${e}`, l); let c = fi[e]; delete fi[e]; for (let h = 0, u = c.length; h < u; h++) { let d = c[h]; if (d.onLoad) d.onLoad(l); } }) .catch((l) => { let c = fi[e]; if (c === void 0) throw (this.manager.itemError(e), l); delete fi[e]; for (let h = 0, u = c.length; h < u; h++) { let d = c[h]; if (d.onError) d.onError(l); } this.manager.itemError(e); }) .finally(() => { this.manager.itemEnd(e); }), this.manager.itemStart(e)); } setResponseType(e) { return ((this.responseType = e), this); } setMimeType(e) { return ((this.mimeType = e), this); } abort() { return (this._abortController.abort(), (this._abortController = new AbortController()), this); } } var Bs = new WeakMap(); class xc extends nn { constructor(e) { super(e); } load(e, t, n, i) { if (this.path !== void 0) e = this.path + e; e = this.manager.resolveURL(e); let s = this, r = Xn.get(`image:${e}`); if (r !== void 0) { if (r.complete === !0) (s.manager.itemStart(e), setTimeout(function () { if (t) t(r); s.manager.itemEnd(e); }, 0)); else { let h = Bs.get(r); if (h === void 0) ((h = []), Bs.set(r, h)); h.push({ onLoad: t, onError: i }); } return r; } let o = Vs("img"); function a() { if ((c(), t)) t(this); let h = Bs.get(this) || []; for (let u = 0; u < h.length; u++) { let d = h[u]; if (d.onLoad) d.onLoad(this); } (Bs.delete(this), s.manager.itemEnd(e)); } function l(h) { if ((c(), i)) i(h); Xn.remove(`image:${e}`); let u = Bs.get(this) || []; for (let d = 0; d < u.length; d++) { let f = u[d]; if (f.onError) f.onError(h); } (Bs.delete(this), s.manager.itemError(e), s.manager.itemEnd(e)); } function c() { (o.removeEventListener("load", a, !1), o.removeEventListener("error", l, !1)); } if ((o.addEventListener("load", a, !1), o.addEventListener("error", l, !1), e.slice(0, 5) !== "data:")) { if (this.crossOrigin !== void 0) o.crossOrigin = this.crossOrigin; } return (Xn.add(`image:${e}`, o), s.manager.itemStart(e), (o.src = e), o); } } class Jn extends nn { constructor(e) { super(e); } load(e, t, n, i) { let s = new Rt(), r = new xc(this.manager); return ( r.setCrossOrigin(this.crossOrigin), r.setPath(this.path), r.load( e, function (o) { if (((s.image = o), (s.needsUpdate = !0), t !== void 0)) t(s); }, n, i, ), s ); } } class or extends it { constructor(e, t = 1) { super(); ((this.isLight = !0), (this.type = "Light"), (this.color = new re(e)), (this.intensity = t)); } dispose() {} copy(e, t) { return (super.copy(e, t), this.color.copy(e.color), (this.intensity = e.intensity), this); } toJSON(e) { let t = super.toJSON(e); if (((t.object.color = this.color.getHex()), (t.object.intensity = this.intensity), this.groundColor !== void 0)) t.object.groundColor = this.groundColor.getHex(); if (this.distance !== void 0) t.object.distance = this.distance; if (this.angle !== void 0) t.object.angle = this.angle; if (this.decay !== void 0) t.object.decay = this.decay; if (this.penumbra !== void 0) t.object.penumbra = this.penumbra; if (this.shadow !== void 0) t.object.shadow = this.shadow.toJSON(); if (this.target !== void 0) t.object.target = this.target.uuid; return t; } } var rl = new ue(), pu = new E(), mu = new E(); class ua { constructor(e) { ((this.camera = e), (this.intensity = 1), (this.bias = 0), (this.normalBias = 0), (this.radius = 1), (this.blurSamples = 8), (this.mapSize = new ve(512, 512)), (this.mapType = 1009), (this.map = null), (this.mapPass = null), (this.matrix = new ue()), (this.autoUpdate = !0), (this.needsUpdate = !1), (this._frustum = new qr()), (this._frameExtents = new ve(1, 1)), (this._viewportCount = 1), (this._viewports = [new Ye(0, 0, 1, 1)])); } getViewportCount() { return this._viewportCount; } getFrustum() { return this._frustum; } updateMatrices(e) { let t = this.camera, n = this.matrix; if ( (pu.setFromMatrixPosition(e.matrixWorld), t.position.copy(pu), mu.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(mu), t.updateMatrixWorld(), rl.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(rl, t.coordinateSystem, t.reversedDepth), t.reversedDepth) ) n.set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1); else n.set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 0.5, 0.5, 0, 0, 0, 1); n.multiply(rl); } getViewport(e) { return this._viewports[e]; } getFrameExtents() { return this._frameExtents; } dispose() { if (this.map) this.map.dispose(); if (this.mapPass) this.mapPass.dispose(); } copy(e) { return ( (this.camera = e.camera.clone()), (this.intensity = e.intensity), (this.bias = e.bias), (this.radius = e.radius), (this.autoUpdate = e.autoUpdate), (this.needsUpdate = e.needsUpdate), (this.normalBias = e.normalBias), (this.blurSamples = e.blurSamples), this.mapSize.copy(e.mapSize), this ); } clone() { return new this.constructor().copy(this); } toJSON() { let e = {}; if (this.intensity !== 1) e.intensity = this.intensity; if (this.bias !== 0) e.bias = this.bias; if (this.normalBias !== 0) e.normalBias = this.normalBias; if (this.radius !== 1) e.radius = this.radius; if (this.mapSize.x !== 512 || this.mapSize.y !== 512) e.mapSize = this.mapSize.toArray(); return ((e.camera = this.camera.toJSON(!1).object), delete e.camera.matrix, e); } } class Td extends ua { constructor() { super(new It(50, 1, 0.5, 500)); ((this.isSpotLightShadow = !0), (this.focus = 1), (this.aspect = 1)); } updateMatrices(e) { let t = this.camera, n = ls * 2 * e.angle * this.focus, i = (this.mapSize.width / this.mapSize.height) * this.aspect, s = e.distance || t.far; if (n !== t.fov || i !== t.aspect || s !== t.far) ((t.fov = n), (t.aspect = i), (t.far = s), t.updateProjectionMatrix()); super.updateMatrices(e); } copy(e) { return (super.copy(e), (this.focus = e.focus), this); } } class Yi extends or { constructor(e, t, n = 0, i = Math.PI / 3, s = 0, r = 2) { super(e, t); ((this.isSpotLight = !0), (this.type = "SpotLight"), this.position.copy(it.DEFAULT_UP), this.updateMatrix(), (this.target = new it()), (this.distance = n), (this.angle = i), (this.penumbra = s), (this.decay = r), (this.map = null), (this.shadow = new Td())); } get power() { return this.intensity * Math.PI; } set power(e) { this.intensity = e / Math.PI; } dispose() { this.shadow.dispose(); } copy(e, t) { return ( super.copy(e, t), (this.distance = e.distance), (this.angle = e.angle), (this.penumbra = e.penumbra), (this.decay = e.decay), (this.target = e.target.clone()), (this.shadow = e.shadow.clone()), this ); } } var gu = new ue(), Ar = new E(), ol = new E(); class Ed extends ua { constructor() { super(new It(90, 1, 0.5, 500)); ((this.isPointLightShadow = !0), (this._frameExtents = new ve(4, 2)), (this._viewportCount = 6), (this._viewports = [ new Ye(2, 1, 1, 1), new Ye(0, 1, 1, 1), new Ye(3, 1, 1, 1), new Ye(1, 1, 1, 1), new Ye(3, 0, 1, 1), new Ye(1, 0, 1, 1), ]), (this._cubeDirections = [ new E(1, 0, 0), new E(-1, 0, 0), new E(0, 0, 1), new E(0, 0, -1), new E(0, 1, 0), new E(0, -1, 0), ]), (this._cubeUps = [ new E(0, 1, 0), new E(0, 1, 0), new E(0, 1, 0), new E(0, 1, 0), new E(0, 0, 1), new E(0, 0, -1), ])); } updateMatrices(e, t = 0) { let n = this.camera, i = this.matrix, s = e.distance || n.far; if (s !== n.far) ((n.far = s), n.updateProjectionMatrix()); (Ar.setFromMatrixPosition(e.matrixWorld), n.position.copy(Ar), ol.copy(n.position), ol.add(this._cubeDirections[t]), n.up.copy(this._cubeUps[t]), n.lookAt(ol), n.updateMatrixWorld(), i.makeTranslation(-Ar.x, -Ar.y, -Ar.z), gu.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this._frustum.setFromProjectionMatrix(gu, n.coordinateSystem, n.reversedDepth)); } } class wi extends or { constructor(e, t, n = 0, i = 2) { super(e, t); ((this.isPointLight = !0), (this.type = "PointLight"), (this.distance = n), (this.decay = i), (this.shadow = new Ed())); } get power() { return this.intensity * 4 * Math.PI; } set power(e) { this.intensity = e / (4 * Math.PI); } dispose() { this.shadow.dispose(); } copy(e, t) { return ( super.copy(e, t), (this.distance = e.distance), (this.decay = e.decay), (this.shadow = e.shadow.clone()), this ); } } class ar extends na { constructor(e = -1, t = 1, n = 1, i = -1, s = 0.1, r = 2000) { super(); ((this.isOrthographicCamera = !0), (this.type = "OrthographicCamera"), (this.zoom = 1), (this.view = null), (this.left = e), (this.right = t), (this.top = n), (this.bottom = i), (this.near = s), (this.far = r), this.updateProjectionMatrix()); } copy(e, t) { return ( super.copy(e, t), (this.left = e.left), (this.right = e.right), (this.top = e.top), (this.bottom = e.bottom), (this.near = e.near), (this.far = e.far), (this.zoom = e.zoom), (this.view = e.view === null ? null : Object.assign({}, e.view)), this ); } setViewOffset(e, t, n, i, s, r) { if (this.view === null) this.view = { enabled: !0, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 }; ((this.view.enabled = !0), (this.view.fullWidth = e), (this.view.fullHeight = t), (this.view.offsetX = n), (this.view.offsetY = i), (this.view.width = s), (this.view.height = r), this.updateProjectionMatrix()); } clearViewOffset() { if (this.view !== null) this.view.enabled = !1; this.updateProjectionMatrix(); } updateProjectionMatrix() { let e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, i = (this.top + this.bottom) / 2, s = n - e, r = n + e, o = i + t, a = i - t; if (this.view !== null && this.view.enabled) { let l = (this.right - this.left) / this.view.fullWidth / this.zoom, c = (this.top - this.bottom) / this.view.fullHeight / this.zoom; ((s += l * this.view.offsetX), (r = s + l * this.view.width), (o -= c * this.view.offsetY), (a = o - c * this.view.height)); } (this.projectionMatrix.makeOrthographic(s, r, o, a, this.near, this.far, this.coordinateSystem, this.reversedDepth), this.projectionMatrixInverse.copy(this.projectionMatrix).invert()); } toJSON(e) { let t = super.toJSON(e); if ( ((t.object.zoom = this.zoom), (t.object.left = this.left), (t.object.right = this.right), (t.object.top = this.top), (t.object.bottom = this.bottom), (t.object.near = this.near), (t.object.far = this.far), this.view !== null) ) t.object.view = Object.assign({}, this.view); return t; } } class Ad extends ua { constructor() { super(new ar(-5, 5, 5, -5, 0.5, 500)); this.isDirectionalLightShadow = !0; } } class Qn extends or { constructor(e, t) { super(e, t); ((this.isDirectionalLight = !0), (this.type = "DirectionalLight"), this.position.copy(it.DEFAULT_UP), this.updateMatrix(), (this.target = new it()), (this.shadow = new Ad())); } dispose() { this.shadow.dispose(); } copy(e) { return (super.copy(e), (this.target = e.target.clone()), (this.shadow = e.shadow.clone()), this); } } class lr extends or { constructor(e, t) { super(e, t); ((this.isAmbientLight = !0), (this.type = "AmbientLight")); } } class ei { static extractUrlBase(e) { let t = e.lastIndexOf("/"); if (t === -1) return "./"; return e.slice(0, t + 1); } static resolveURL(e, t) { if (typeof e !== "string" || e === "") return ""; if (/^https?:\/\//i.test(t) && /^\//.test(e)) t = t.replace(/(^https?:\/\/[^\/]+).*/i, "$1"); if (/^(https?:)?\/\//i.test(e)) return e; if (/^data:.*,.*$/i.test(e)) return e; if (/^blob:.*$/i.test(e)) return e; return t + e; } } var al = new WeakMap(); class da extends nn { constructor(e) { super(e); if (((this.isImageBitmapLoader = !0), typeof createImageBitmap > "u")) console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."); if (typeof fetch > "u") console.warn("THREE.ImageBitmapLoader: fetch() not supported."); ((this.options = { premultiplyAlpha: "none" }), (this._abortController = new AbortController())); } setOptions(e) { return ((this.options = e), this); } load(e, t, n, i) { if (e === void 0) e = ""; if (this.path !== void 0) e = this.path + e; e = this.manager.resolveURL(e); let s = this, r = Xn.get(`image-bitmap:${e}`); if (r !== void 0) { if ((s.manager.itemStart(e), r.then)) { r.then((l) => { if (al.has(r) === !0) { if (i) i(al.get(r)); (s.manager.itemError(e), s.manager.itemEnd(e)); } else { if (t) t(l); return (s.manager.itemEnd(e), l); } }); return; } return ( setTimeout(function () { if (t) t(r); s.manager.itemEnd(e); }, 0), r ); } let o = {}; ((o.credentials = this.crossOrigin === "anonymous" ? "same-origin" : "include"), (o.headers = this.requestHeader), (o.signal = typeof AbortSignal.any === "function" ? AbortSignal.any([this._abortController.signal, this.manager.abortController.signal]) : this._abortController.signal)); let a = fetch(e, o) .then(function (l) { return l.blob(); }) .then(function (l) { return createImageBitmap(l, Object.assign(s.options, { colorSpaceConversion: "none" })); }) .then(function (l) { if ((Xn.add(`image-bitmap:${e}`, l), t)) t(l); return (s.manager.itemEnd(e), l); }) .catch(function (l) { if (i) i(l); (al.set(a, l), Xn.remove(`image-bitmap:${e}`), s.manager.itemError(e), s.manager.itemEnd(e)); }); (Xn.add(`image-bitmap:${e}`, a), s.manager.itemStart(e)); } abort() { return (this._abortController.abort(), (this._abortController = new AbortController()), this); } } class vc extends It { constructor(e = []) { super(); ((this.isArrayCamera = !0), (this.isMultiViewCamera = !1), (this.cameras = e)); } } class _c { constructor(e, t, n) { ((this.binding = e), (this.valueSize = n)); let i, s, r; switch (t) { case "quaternion": ((i = this._slerp), (s = this._slerpAdditive), (r = this._setAdditiveIdentityQuaternion), (this.buffer = new Float64Array(n * 6)), (this._workIndex = 5)); break; case "string": case "bool": ((i = this._select), (s = this._select), (r = this._setAdditiveIdentityOther), (this.buffer = Array(n * 5))); break; default: ((i = this._lerp), (s = this._lerpAdditive), (r = this._setAdditiveIdentityNumeric), (this.buffer = new Float64Array(n * 5))); } ((this._mixBufferRegion = i), (this._mixBufferRegionAdditive = s), (this._setIdentity = r), (this._origIndex = 3), (this._addIndex = 4), (this.cumulativeWeight = 0), (this.cumulativeWeightAdditive = 0), (this.useCount = 0), (this.referenceCount = 0)); } accumulate(e, t) { let n = this.buffer, i = this.valueSize, s = e * i + i, r = this.cumulativeWeight; if (r === 0) { for (let o = 0; o !== i; ++o) n[s + o] = n[o]; r = t; } else { r += t; let o = t / r; this._mixBufferRegion(n, s, 0, o, i); } this.cumulativeWeight = r; } accumulateAdditive(e) { let t = this.buffer, n = this.valueSize, i = n * this._addIndex; if (this.cumulativeWeightAdditive === 0) this._setIdentity(); (this._mixBufferRegionAdditive(t, i, 0, e, n), (this.cumulativeWeightAdditive += e)); } apply(e) { let t = this.valueSize, n = this.buffer, i = e * t + t, s = this.cumulativeWeight, r = this.cumulativeWeightAdditive, o = this.binding; if (((this.cumulativeWeight = 0), (this.cumulativeWeightAdditive = 0), s < 1)) { let a = t * this._origIndex; this._mixBufferRegion(n, i, a, 1 - s, t); } if (r > 0) this._mixBufferRegionAdditive(n, i, this._addIndex * t, 1, t); for (let a = t, l = t + t; a !== l; ++a) if (n[a] !== n[a + t]) { o.setValue(n, i); break; } } saveOriginalState() { let e = this.binding, t = this.buffer, n = this.valueSize, i = n * this._origIndex; e.getValue(t, i); for (let s = n, r = i; s !== r; ++s) t[s] = t[i + (s % n)]; (this._setIdentity(), (this.cumulativeWeight = 0), (this.cumulativeWeightAdditive = 0)); } restoreOriginalState() { let e = this.valueSize * 3; this.binding.setValue(this.buffer, e); } _setAdditiveIdentityNumeric() { let e = this._addIndex * this.valueSize, t = e + this.valueSize; for (let n = e; n < t; n++) this.buffer[n] = 0; } _setAdditiveIdentityQuaternion() { (this._setAdditiveIdentityNumeric(), (this.buffer[this._addIndex * this.valueSize + 3] = 1)); } _setAdditiveIdentityOther() { let e = this._origIndex * this.valueSize, t = this._addIndex * this.valueSize; for (let n = 0; n < this.valueSize; n++) this.buffer[t + n] = this.buffer[e + n]; } _select(e, t, n, i, s) { if (i >= 0.5) for (let r = 0; r !== s; ++r) e[t + r] = e[n + r]; } _slerp(e, t, n, i) { Ne.slerpFlat(e, t, e, t, e, n, i); } _slerpAdditive(e, t, n, i, s) { let r = this._workIndex * s; (Ne.multiplyQuaternionsFlat(e, r, e, t, e, n), Ne.slerpFlat(e, t, e, t, e, r, i)); } _lerp(e, t, n, i, s) { let r = 1 - i; for (let o = 0; o !== s; ++o) { let a = t + o; e[a] = e[a] * r + e[n + o] * i; } } _lerpAdditive(e, t, n, i, s) { for (let r = 0; r !== s; ++r) { let o = t + r; e[o] = e[o] + e[n + r] * i; } } } var Sc = "\\[\\]\\.:\\/", r0 = new RegExp("[" + Sc + "]", "g"), bc = "[^" + Sc + "]", o0 = "[^" + Sc.replace("\\.", "") + "]", a0 = /((?:WC+[\/:])*)/.source.replace("WC", bc), l0 = /(WCOD+)?/.source.replace("WCOD", o0), c0 = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", bc), h0 = /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", bc), u0 = new RegExp("^" + a0 + l0 + c0 + h0 + "$"), d0 = ["material", "materials", "bones", "map"]; class Rd { constructor(e, t, n) { let i = n || $e.parseTrackName(t); ((this._targetGroup = e), (this._bindings = e.subscribe_(t, i))); } getValue(e, t) { this.bind(); let n = this._targetGroup.nCachedObjects_, i = this._bindings[n]; if (i !== void 0) i.getValue(e, t); } setValue(e, t) { let n = this._bindings; for (let i = this._targetGroup.nCachedObjects_, s = n.length; i !== s; ++i) n[i].setValue(e, t); } bind() { let e = this._bindings; for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t) e[t].bind(); } unbind() { let e = this._bindings; for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t) e[t].unbind(); } } class $e { constructor(e, t, n) { ((this.path = t), (this.parsedPath = n || $e.parseTrackName(t)), (this.node = $e.findNode(e, this.parsedPath.nodeName)), (this.rootNode = e), (this.getValue = this._getValue_unbound), (this.setValue = this._setValue_unbound)); } static create(e, t, n) { if (!(e && e.isAnimationObjectGroup)) return new $e(e, t, n); else return new $e.Composite(e, t, n); } static sanitizeNodeName(e) { return e.replace(/\s/g, "_").replace(r0, ""); } static parseTrackName(e) { let t = u0.exec(e); if (t === null) throw Error("PropertyBinding: Cannot parse trackName: " + e); let n = { nodeName: t[2], objectName: t[3], objectIndex: t[4], propertyName: t[5], propertyIndex: t[6] }, i = n.nodeName && n.nodeName.lastIndexOf("."); if (i !== void 0 && i !== -1) { let s = n.nodeName.substring(i + 1); if (d0.indexOf(s) !== -1) ((n.nodeName = n.nodeName.substring(0, i)), (n.objectName = s)); } if (n.propertyName === null || n.propertyName.length === 0) throw Error("PropertyBinding: can not parse propertyName from trackName: " + e); return n; } static findNode(e, t) { if (t === void 0 || t === "" || t === "." || t === -1 || t === e.name || t === e.uuid) return e; if (e.skeleton) { let n = e.skeleton.getBoneByName(t); if (n !== void 0) return n; } if (e.children) { let n = function (s) { for (let r = 0; r < s.length; r++) { let o = s[r]; if (o.name === t || o.uuid === t) return o; let a = n(o.children); if (a) return a; } return null; }, i = n(e.children); if (i) return i; } return null; } _getValue_unavailable() {} _setValue_unavailable() {} _getValue_direct(e, t) { e[t] = this.targetObject[this.propertyName]; } _getValue_array(e, t) { let n = this.resolvedProperty; for (let i = 0, s = n.length; i !== s; ++i) e[t++] = n[i]; } _getValue_arrayElement(e, t) { e[t] = this.resolvedProperty[this.propertyIndex]; } _getValue_toArray(e, t) { this.resolvedProperty.toArray(e, t); } _setValue_direct(e, t) { this.targetObject[this.propertyName] = e[t]; } _setValue_direct_setNeedsUpdate(e, t) { ((this.targetObject[this.propertyName] = e[t]), (this.targetObject.needsUpdate = !0)); } _setValue_direct_setMatrixWorldNeedsUpdate(e, t) { ((this.targetObject[this.propertyName] = e[t]), (this.targetObject.matrixWorldNeedsUpdate = !0)); } _setValue_array(e, t) { let n = this.resolvedProperty; for (let i = 0, s = n.length; i !== s; ++i) n[i] = e[t++]; } _setValue_array_setNeedsUpdate(e, t) { let n = this.resolvedProperty; for (let i = 0, s = n.length; i !== s; ++i) n[i] = e[t++]; this.targetObject.needsUpdate = !0; } _setValue_array_setMatrixWorldNeedsUpdate(e, t) { let n = this.resolvedProperty; for (let i = 0, s = n.length; i !== s; ++i) n[i] = e[t++]; this.targetObject.matrixWorldNeedsUpdate = !0; } _setValue_arrayElement(e, t) { this.resolvedProperty[this.propertyIndex] = e[t]; } _setValue_arrayElement_setNeedsUpdate(e, t) { ((this.resolvedProperty[this.propertyIndex] = e[t]), (this.targetObject.needsUpdate = !0)); } _setValue_arrayElement_setMatrixWorldNeedsUpdate(e, t) { ((this.resolvedProperty[this.propertyIndex] = e[t]), (this.targetObject.matrixWorldNeedsUpdate = !0)); } _setValue_fromArray(e, t) { this.resolvedProperty.fromArray(e, t); } _setValue_fromArray_setNeedsUpdate(e, t) { (this.resolvedProperty.fromArray(e, t), (this.targetObject.needsUpdate = !0)); } _setValue_fromArray_setMatrixWorldNeedsUpdate(e, t) { (this.resolvedProperty.fromArray(e, t), (this.targetObject.matrixWorldNeedsUpdate = !0)); } _getValue_unbound(e, t) { (this.bind(), this.getValue(e, t)); } _setValue_unbound(e, t) { (this.bind(), this.setValue(e, t)); } bind() { let e = this.node, t = this.parsedPath, { objectName: n, propertyName: i, propertyIndex: s } = t; if (!e) ((e = $e.findNode(this.rootNode, t.nodeName)), (this.node = e)); if (((this.getValue = this._getValue_unavailable), (this.setValue = this._setValue_unavailable), !e)) { console.warn("THREE.PropertyBinding: No target node found for track: " + this.path + "."); return; } if (n) { let l = t.objectIndex; switch (n) { case "materials": if (!e.material) { console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this); return; } if (!e.material.materials) { console.error( "THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this, ); return; } e = e.material.materials; break; case "bones": if (!e.skeleton) { console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.", this); return; } e = e.skeleton.bones; for (let c = 0; c < e.length; c++) if (e[c].name === l) { l = c; break; } break; case "map": if ("map" in e) { e = e.map; break; } if (!e.material) { console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this); return; } if (!e.material.map) { console.error( "THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.", this, ); return; } e = e.material.map; break; default: if (e[n] === void 0) { console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.", this); return; } e = e[n]; } if (l !== void 0) { if (e[l] === void 0) { console.error( "THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, e, ); return; } e = e[l]; } } let r = e[i]; if (r === void 0) { let l = t.nodeName; console.error( "THREE.PropertyBinding: Trying to update property for track: " + l + "." + i + " but it wasn't found.", e, ); return; } let o = this.Versioning.None; if (((this.targetObject = e), e.isMaterial === !0)) o = this.Versioning.NeedsUpdate; else if (e.isObject3D === !0) o = this.Versioning.MatrixWorldNeedsUpdate; let a = this.BindingType.Direct; if (s !== void 0) { if (i === "morphTargetInfluences") { if (!e.geometry) { console.error( "THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this, ); return; } if (!e.geometry.morphAttributes) { console.error( "THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this, ); return; } if (e.morphTargetDictionary[s] !== void 0) s = e.morphTargetDictionary[s]; } ((a = this.BindingType.ArrayElement), (this.resolvedProperty = r), (this.propertyIndex = s)); } else if (r.fromArray !== void 0 && r.toArray !== void 0) ((a = this.BindingType.HasFromToArray), (this.resolvedProperty = r)); else if (Array.isArray(r)) ((a = this.BindingType.EntireArray), (this.resolvedProperty = r)); else this.propertyName = i; ((this.getValue = this.GetterByBindingType[a]), (this.setValue = this.SetterByBindingTypeAndVersioning[a][o])); } unbind() { ((this.node = null), (this.getValue = this._getValue_unbound), (this.setValue = this._setValue_unbound)); } } $e.Composite = Rd; $e.prototype.BindingType = { Direct: 0, EntireArray: 1, ArrayElement: 2, HasFromToArray: 3 }; $e.prototype.Versioning = { None: 0, NeedsUpdate: 1, MatrixWorldNeedsUpdate: 2 }; $e.prototype.GetterByBindingType = [ $e.prototype._getValue_direct, $e.prototype._getValue_array, $e.prototype._getValue_arrayElement, $e.prototype._getValue_toArray, ]; $e.prototype.SetterByBindingTypeAndVersioning = [ [ $e.prototype._setValue_direct, $e.prototype._setValue_direct_setNeedsUpdate, $e.prototype._setValue_direct_setMatrixWorldNeedsUpdate, ], [ $e.prototype._setValue_array, $e.prototype._setValue_array_setNeedsUpdate, $e.prototype._setValue_array_setMatrixWorldNeedsUpdate, ], [ $e.prototype._setValue_arrayElement, $e.prototype._setValue_arrayElement_setNeedsUpdate, $e.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate, ], [ $e.prototype._setValue_fromArray, $e.prototype._setValue_fromArray_setNeedsUpdate, $e.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate, ], ]; class Mc { constructor(e, t, n = null, i = t.blendMode) { ((this._mixer = e), (this._clip = t), (this._localRoot = n), (this.blendMode = i)); let s = t.tracks, r = s.length, o = Array(r), a = { endingStart: 2400, endingEnd: 2400 }; for (let l = 0; l !== r; ++l) { let c = s[l].createInterpolant(null); ((o[l] = c), (c.settings = a)); } ((this._interpolantSettings = a), (this._interpolants = o), (this._propertyBindings = Array(r)), (this._cacheIndex = null), (this._byClipCacheIndex = null), (this._timeScaleInterpolant = null), (this._weightInterpolant = null), (this.loop = 2201), (this._loopCount = -1), (this._startTime = null), (this.time = 0), (this.timeScale = 1), (this._effectiveTimeScale = 1), (this.weight = 1), (this._effectiveWeight = 1), (this.repetitions = 1 / 0), (this.paused = !1), (this.enabled = !0), (this.clampWhenFinished = !1), (this.zeroSlopeAtStart = !0), (this.zeroSlopeAtEnd = !0)); } play() { return (this._mixer._activateAction(this), this); } stop() { return (this._mixer._deactivateAction(this), this.reset()); } reset() { return ( (this.paused = !1), (this.enabled = !0), (this.time = 0), (this._loopCount = -1), (this._startTime = null), this.stopFading().stopWarping() ); } isRunning() { return ( this.enabled && !this.paused && this.timeScale !== 0 && this._startTime === null && this._mixer._isActiveAction(this) ); } isScheduled() { return this._mixer._isActiveAction(this); } startAt(e) { return ((this._startTime = e), this); } setLoop(e, t) { return ((this.loop = e), (this.repetitions = t), this); } setEffectiveWeight(e) { return ((this.weight = e), (this._effectiveWeight = this.enabled ? e : 0), this.stopFading()); } getEffectiveWeight() { return this._effectiveWeight; } fadeIn(e) { return this._scheduleFading(e, 0, 1); } fadeOut(e) { return this._scheduleFading(e, 1, 0); } crossFadeFrom(e, t, n = !1) { if ((e.fadeOut(t), this.fadeIn(t), n === !0)) { let i = this._clip.duration, s = e._clip.duration, r = s / i, o = i / s; (e.warp(1, r, t), this.warp(o, 1, t)); } return this; } crossFadeTo(e, t, n = !1) { return e.crossFadeFrom(this, t, n); } stopFading() { let e = this._weightInterpolant; if (e !== null) ((this._weightInterpolant = null), this._mixer._takeBackControlInterpolant(e)); return this; } setEffectiveTimeScale(e) { return ((this.timeScale = e), (this._effectiveTimeScale = this.paused ? 0 : e), this.stopWarping()); } getEffectiveTimeScale() { return this._effectiveTimeScale; } setDuration(e) { return ((this.timeScale = this._clip.duration / e), this.stopWarping()); } syncWith(e) { return ((this.time = e.time), (this.timeScale = e.timeScale), this.stopWarping()); } halt(e) { return this.warp(this._effectiveTimeScale, 0, e); } warp(e, t, n) { let i = this._mixer, s = i.time, r = this.timeScale, o = this._timeScaleInterpolant; if (o === null) ((o = i._lendControlInterpolant()), (this._timeScaleInterpolant = o)); let a = o.parameterPositions, l = o.sampleValues; return ((a[0] = s), (a[1] = s + n), (l[0] = e / r), (l[1] = t / r), this); } stopWarping() { let e = this._timeScaleInterpolant; if (e !== null) ((this._timeScaleInterpolant = null), this._mixer._takeBackControlInterpolant(e)); return this; } getMixer() { return this._mixer; } getClip() { return this._clip; } getRoot() { return this._localRoot || this._mixer._root; } _update(e, t, n, i) { if (!this.enabled) { this._updateWeight(e); return; } let s = this._startTime; if (s !== null) { let a = (e - s) * n; if (a < 0 || n === 0) t = 0; else ((this._startTime = null), (t = n * a)); } t *= this._updateTimeScale(e); let r = this._updateTime(t), o = this._updateWeight(e); if (o > 0) { let a = this._interpolants, l = this._propertyBindings; switch (this.blendMode) { case 2501: for (let c = 0, h = a.length; c !== h; ++c) (a[c].evaluate(r), l[c].accumulateAdditive(o)); break; case 2500: default: for (let c = 0, h = a.length; c !== h; ++c) (a[c].evaluate(r), l[c].accumulate(i, o)); } } } _updateWeight(e) { let t = 0; if (this.enabled) { t = this.weight; let n = this._weightInterpolant; if (n !== null) { let i = n.evaluate(e)[0]; if (((t *= i), e > n.parameterPositions[1])) { if ((this.stopFading(), i === 0)) this.enabled = !1; } } } return ((this._effectiveWeight = t), t); } _updateTimeScale(e) { let t = 0; if (!this.paused) { t = this.timeScale; let n = this._timeScaleInterpolant; if (n !== null) { let i = n.evaluate(e)[0]; if (((t *= i), e > n.parameterPositions[1])) if ((this.stopWarping(), t === 0)) this.paused = !0; else this.timeScale = t; } } return ((this._effectiveTimeScale = t), t); } _updateTime(e) { let t = this._clip.duration, n = this.loop, i = this.time + e, s = this._loopCount, r = n === 2202; if (e === 0) { if (s === -1) return i; return r && (s & 1) === 1 ? t - i : i; } if (n === 2200) { if (s === -1) ((this._loopCount = 0), this._setEndings(!0, !0, !1)); e: { if (i >= t) i = t; else if (i < 0) i = 0; else { this.time = i; break e; } if (this.clampWhenFinished) this.paused = !0; else this.enabled = !1; ((this.time = i), this._mixer.dispatchEvent({ type: "finished", action: this, direction: e < 0 ? -1 : 1 })); } } else { if (s === -1) if (e >= 0) ((s = 0), this._setEndings(!0, this.repetitions === 0, r)); else this._setEndings(this.repetitions === 0, !0, r); if (i >= t || i < 0) { let o = Math.floor(i / t); ((i -= t * o), (s += Math.abs(o))); let a = this.repetitions - s; if (a <= 0) { if (this.clampWhenFinished) this.paused = !0; else this.enabled = !1; ((i = e > 0 ? t : 0), (this.time = i), this._mixer.dispatchEvent({ type: "finished", action: this, direction: e > 0 ? 1 : -1 })); } else { if (a === 1) { let l = e < 0; this._setEndings(l, !l, r); } else this._setEndings(!1, !1, r); ((this._loopCount = s), (this.time = i), this._mixer.dispatchEvent({ type: "loop", action: this, loopDelta: o })); } } else this.time = i; if (r && (s & 1) === 1) return t - i; } return i; } _setEndings(e, t, n) { let i = this._interpolantSettings; if (n) ((i.endingStart = 2401), (i.endingEnd = 2401)); else { if (e) i.endingStart = this.zeroSlopeAtStart ? 2401 : 2400; else i.endingStart = 2402; if (t) i.endingEnd = this.zeroSlopeAtEnd ? 2401 : 2400; else i.endingEnd = 2402; } } _scheduleFading(e, t, n) { let i = this._mixer, s = i.time, r = this._weightInterpolant; if (r === null) ((r = i._lendControlInterpolant()), (this._weightInterpolant = r)); let o = r.parameterPositions, a = r.sampleValues; return ((o[0] = s), (a[0] = t), (o[1] = s + e), (a[1] = n), this); } } var f0 = new Float32Array(1); class fa extends jn { constructor(e) { super(); ((this._root = e), this._initMemoryManager(), (this._accuIndex = 0), (this.time = 0), (this.timeScale = 1)); } _bindAction(e, t) { let n = e._localRoot || this._root, i = e._clip.tracks, s = i.length, { _propertyBindings: r, _interpolants: o } = e, a = n.uuid, l = this._bindingsByRootAndName, c = l[a]; if (c === void 0) ((c = {}), (l[a] = c)); for (let h = 0; h !== s; ++h) { let u = i[h], d = u.name, f = c[d]; if (f !== void 0) (++f.referenceCount, (r[h] = f)); else { if (((f = r[h]), f !== void 0)) { if (f._cacheIndex === null) (++f.referenceCount, this._addInactiveBinding(f, a, d)); continue; } let m = t && t._propertyBindings[h].binding.parsedPath; ((f = new _c($e.create(n, d, m), u.ValueTypeName, u.getValueSize())), ++f.referenceCount, this._addInactiveBinding(f, a, d), (r[h] = f)); } o[h].resultBuffer = f.buffer; } } _activateAction(e) { if (!this._isActiveAction(e)) { if (e._cacheIndex === null) { let n = (e._localRoot || this._root).uuid, i = e._clip.uuid, s = this._actionsByClip[i]; (this._bindAction(e, s && s.knownActions[0]), this._addInactiveAction(e, i, n)); } let t = e._propertyBindings; for (let n = 0, i = t.length; n !== i; ++n) { let s = t[n]; if (s.useCount++ === 0) (this._lendBinding(s), s.saveOriginalState()); } this._lendAction(e); } } _deactivateAction(e) { if (this._isActiveAction(e)) { let t = e._propertyBindings; for (let n = 0, i = t.length; n !== i; ++n) { let s = t[n]; if (--s.useCount === 0) (s.restoreOriginalState(), this._takeBackBinding(s)); } this._takeBackAction(e); } } _initMemoryManager() { ((this._actions = []), (this._nActiveActions = 0), (this._actionsByClip = {}), (this._bindings = []), (this._nActiveBindings = 0), (this._bindingsByRootAndName = {}), (this._controlInterpolants = []), (this._nActiveControlInterpolants = 0)); let e = this; this.stats = { actions: { get total() { return e._actions.length; }, get inUse() { return e._nActiveActions; }, }, bindings: { get total() { return e._bindings.length; }, get inUse() { return e._nActiveBindings; }, }, controlInterpolants: { get total() { return e._controlInterpolants.length; }, get inUse() { return e._nActiveControlInterpolants; }, }, }; } _isActiveAction(e) { let t = e._cacheIndex; return t !== null && t < this._nActiveActions; } _addInactiveAction(e, t, n) { let i = this._actions, s = this._actionsByClip, r = s[t]; if (r === void 0) ((r = { knownActions: [e], actionByRoot: {} }), (e._byClipCacheIndex = 0), (s[t] = r)); else { let o = r.knownActions; ((e._byClipCacheIndex = o.length), o.push(e)); } ((e._cacheIndex = i.length), i.push(e), (r.actionByRoot[n] = e)); } _removeInactiveAction(e) { let t = this._actions, n = t[t.length - 1], i = e._cacheIndex; ((n._cacheIndex = i), (t[i] = n), t.pop(), (e._cacheIndex = null)); let s = e._clip.uuid, r = this._actionsByClip, o = r[s], a = o.knownActions, l = a[a.length - 1], c = e._byClipCacheIndex; ((l._byClipCacheIndex = c), (a[c] = l), a.pop(), (e._byClipCacheIndex = null)); let h = o.actionByRoot, u = (e._localRoot || this._root).uuid; if ((delete h[u], a.length === 0)) delete r[s]; this._removeInactiveBindingsForAction(e); } _removeInactiveBindingsForAction(e) { let t = e._propertyBindings; for (let n = 0, i = t.length; n !== i; ++n) { let s = t[n]; if (--s.referenceCount === 0) this._removeInactiveBinding(s); } } _lendAction(e) { let t = this._actions, n = e._cacheIndex, i = this._nActiveActions++, s = t[i]; ((e._cacheIndex = i), (t[i] = e), (s._cacheIndex = n), (t[n] = s)); } _takeBackAction(e) { let t = this._actions, n = e._cacheIndex, i = --this._nActiveActions, s = t[i]; ((e._cacheIndex = i), (t[i] = e), (s._cacheIndex = n), (t[n] = s)); } _addInactiveBinding(e, t, n) { let i = this._bindingsByRootAndName, s = this._bindings, r = i[t]; if (r === void 0) ((r = {}), (i[t] = r)); ((r[n] = e), (e._cacheIndex = s.length), s.push(e)); } _removeInactiveBinding(e) { let t = this._bindings, n = e.binding, i = n.rootNode.uuid, s = n.path, r = this._bindingsByRootAndName, o = r[i], a = t[t.length - 1], l = e._cacheIndex; if (((a._cacheIndex = l), (t[l] = a), t.pop(), delete o[s], Object.keys(o).length === 0)) delete r[i]; } _lendBinding(e) { let t = this._bindings, n = e._cacheIndex, i = this._nActiveBindings++, s = t[i]; ((e._cacheIndex = i), (t[i] = e), (s._cacheIndex = n), (t[n] = s)); } _takeBackBinding(e) { let t = this._bindings, n = e._cacheIndex, i = --this._nActiveBindings, s = t[i]; ((e._cacheIndex = i), (t[i] = e), (s._cacheIndex = n), (t[n] = s)); } _lendControlInterpolant() { let e = this._controlInterpolants, t = this._nActiveControlInterpolants++, n = e[t]; if (n === void 0) ((n = new ca(new Float32Array(2), new Float32Array(2), 1, f0)), (n.__cacheIndex = t), (e[t] = n)); return n; } _takeBackControlInterpolant(e) { let t = this._controlInterpolants, n = e.__cacheIndex, i = --this._nActiveControlInterpolants, s = t[i]; ((e.__cacheIndex = i), (t[i] = e), (s.__cacheIndex = n), (t[n] = s)); } clipAction(e, t, n) { let i = t || this._root, s = i.uuid, r = typeof e === "string" ? Di.findByName(i, e) : e, o = r !== null ? r.uuid : e, a = this._actionsByClip[o], l = null; if (n === void 0) if (r !== null) n = r.blendMode; else n = 2500; if (a !== void 0) { let h = a.actionByRoot[s]; if (h !== void 0 && h.blendMode === n) return h; if (((l = a.knownActions[0]), r === null)) r = l._clip; } if (r === null) return null; let c = new Mc(this, r, t, n); return (this._bindAction(c, l), this._addInactiveAction(c, o, s), c); } existingAction(e, t) { let n = t || this._root, i = n.uuid, s = typeof e === "string" ? Di.findByName(n, e) : e, r = s ? s.uuid : e, o = this._actionsByClip[r]; if (o !== void 0) return o.actionByRoot[i] || null; return null; } stopAllAction() { let e = this._actions, t = this._nActiveActions; for (let n = t - 1; n >= 0; --n) e[n].stop(); return this; } update(e) { e *= this.timeScale; let t = this._actions, n = this._nActiveActions, i = (this.time += e), s = Math.sign(e), r = (this._accuIndex ^= 1); for (let l = 0; l !== n; ++l) t[l]._update(i, e, s, r); let o = this._bindings, a = this._nActiveBindings; for (let l = 0; l !== a; ++l) o[l].apply(r); return this; } setTime(e) { this.time = 0; for (let t = 0; t < this._actions.length; t++) this._actions[t].time = 0; return this.update(e); } getRoot() { return this._root; } uncacheClip(e) { let t = this._actions, n = e.uuid, i = this._actionsByClip, s = i[n]; if (s !== void 0) { let r = s.knownActions; for (let o = 0, a = r.length; o !== a; ++o) { let l = r[o]; this._deactivateAction(l); let c = l._cacheIndex, h = t[t.length - 1]; ((l._cacheIndex = null), (l._byClipCacheIndex = null), (h._cacheIndex = c), (t[c] = h), t.pop(), this._removeInactiveBindingsForAction(l)); } delete i[n]; } } uncacheRoot(e) { let t = e.uuid, n = this._actionsByClip; for (let r in n) { let o = n[r].actionByRoot, a = o[t]; if (a !== void 0) (this._deactivateAction(a), this._removeInactiveAction(a)); } let i = this._bindingsByRootAndName, s = i[t]; if (s !== void 0) for (let r in s) { let o = s[r]; (o.restoreOriginalState(), this._removeInactiveBinding(o)); } } uncacheAction(e, t) { let n = this.existingAction(e, t); if (n !== null) (this._deactivateAction(n), this._removeInactiveAction(n)); } } var yu = new ue(); class pa { constructor(e, t, n = 0, i = 1 / 0) { ((this.ray = new zn(e, t)), (this.near = n), (this.far = i), (this.camera = null), (this.layers = new Vr()), (this.params = { Mesh: {}, Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} })); } set(e, t) { this.ray.set(e, t); } setFromCamera(e, t) { if (t.isPerspectiveCamera) (this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(e.x, e.y, 0.5).unproject(t).sub(this.ray.origin).normalize(), (this.camera = t)); else if (t.isOrthographicCamera) (this.ray.origin.set(e.x, e.y, (t.near + t.far) / (t.near - t.far)).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld), (this.camera = t)); else console.error("THREE.Raycaster: Unsupported camera type: " + t.type); } setFromXRController(e) { return ( yu.identity().extractRotation(e.matrixWorld), this.ray.origin.setFromMatrixPosition(e.matrixWorld), this.ray.direction.set(0, 0, -1).applyMatrix4(yu), this ); } intersectObject(e, t = !0, n = []) { return (ul(e, this, n, t), n.sort(xu), n); } intersectObjects(e, t = !0, n = []) { for (let i = 0, s = e.length; i < s; i++) ul(e[i], this, n, t); return (n.sort(xu), n); } } function xu(e, t) { return e.distance - t.distance; } function ul(e, t, n, i) { let s = !0; if (e.layers.test(t.layers)) { if (e.raycast(t, n) === !1) s = !1; } if (s === !0 && i === !0) { let r = e.children; for (let o = 0, a = r.length; o < a; o++) ul(r[o], t, n, !0); } } class ji { constructor(e = 1, t = 0, n = 0) { ((this.radius = e), (this.phi = t), (this.theta = n)); } set(e, t, n) { return ((this.radius = e), (this.phi = t), (this.theta = n), this); } copy(e) { return ((this.radius = e.radius), (this.phi = e.phi), (this.theta = e.theta), this); } makeSafe() { return ((this.phi = qe(this.phi, 0.000001, Math.PI - 0.000001)), this); } setFromVector3(e) { return this.setFromCartesianCoords(e.x, e.y, e.z); } setFromCartesianCoords(e, t, n) { if (((this.radius = Math.sqrt(e * e + t * t + n * n)), this.radius === 0)) ((this.theta = 0), (this.phi = 0)); else ((this.theta = Math.atan2(e, n)), (this.phi = Math.acos(qe(t / this.radius, -1, 1)))); return this; } clone() { return new this.constructor().copy(this); } } class ma extends jn { constructor(e, t = null) { super(); ((this.object = e), (this.domElement = t), (this.enabled = !0), (this.state = -1), (this.keys = {}), (this.mouseButtons = { LEFT: null, MIDDLE: null, RIGHT: null }), (this.touches = { ONE: null, TWO: null })); } connect(e) { if (e === void 0) { console.warn("THREE.Controls: connect() now requires an element."); return; } if (this.domElement !== null) this.disconnect(); this.domElement = e; } disconnect() {} dispose() {} update() {} } function wc(e, t, n, i) { let s = p0(i); switch (n) { case 1021: return e * t; case 1028: return ((e * t) / s.components) * s.byteLength; case 1029: return ((e * t) / s.components) * s.byteLength; case 1030: return ((e * t * 2) / s.components) * s.byteLength; case 1031: return ((e * t * 2) / s.components) * s.byteLength; case 1022: return ((e * t * 3) / s.components) * s.byteLength; case 1023: return ((e * t * 4) / s.components) * s.byteLength; case 1033: return ((e * t * 4) / s.components) * s.byteLength; case 33776: case 33777: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 8; case 33778: case 33779: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 16; case 35841: case 35843: return (Math.max(e, 16) * Math.max(t, 8)) / 4; case 35840: case 35842: return (Math.max(e, 8) * Math.max(t, 8)) / 2; case 36196: case 37492: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 8; case 37496: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 16; case 37808: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 16; case 37809: return Math.floor((e + 4) / 5) * Math.floor((t + 3) / 4) * 16; case 37810: return Math.floor((e + 4) / 5) * Math.floor((t + 4) / 5) * 16; case 37811: return Math.floor((e + 5) / 6) * Math.floor((t + 4) / 5) * 16; case 37812: return Math.floor((e + 5) / 6) * Math.floor((t + 5) / 6) * 16; case 37813: return Math.floor((e + 7) / 8) * Math.floor((t + 4) / 5) * 16; case 37814: return Math.floor((e + 7) / 8) * Math.floor((t + 5) / 6) * 16; case 37815: return Math.floor((e + 7) / 8) * Math.floor((t + 7) / 8) * 16; case 37816: return Math.floor((e + 9) / 10) * Math.floor((t + 4) / 5) * 16; case 37817: return Math.floor((e + 9) / 10) * Math.floor((t + 5) / 6) * 16; case 37818: return Math.floor((e + 9) / 10) * Math.floor((t + 7) / 8) * 16; case 37819: return Math.floor((e + 9) / 10) * Math.floor((t + 9) / 10) * 16; case 37820: return Math.floor((e + 11) / 12) * Math.floor((t + 9) / 10) * 16; case 37821: return Math.floor((e + 11) / 12) * Math.floor((t + 11) / 12) * 16; case 36492: case 36494: case 36495: return Math.ceil(e / 4) * Math.ceil(t / 4) * 16; case 36283: case 36284: return Math.ceil(e / 4) * Math.ceil(t / 4) * 8; case 36285: case 36286: return Math.ceil(e / 4) * Math.ceil(t / 4) * 16; } throw Error(`Unable to determine texture byte length for ${n} format.`); } function p0(e) { switch (e) { case 1009: case 1010: return { byteLength: 1, components: 1 }; case 1012: case 1011: case 1016: return { byteLength: 2, components: 1 }; case 1017: case 1018: return { byteLength: 2, components: 4 }; case 1014: case 1013: case 1015: return { byteLength: 4, components: 1 }; case 35902: case 35899: return { byteLength: 4, components: 3 }; } throw Error(`Unknown texture type ${e}.`); } if (typeof __THREE_DEVTOOLS__ < "u") __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: { revision: "180" } })); if (typeof window < "u") if (window.__THREE__) console.warn("WARNING: Multiple instances of Three.js being imported."); else window.__THREE__ = "180"; function Jd() { let e = null, t = !1, n = null, i = null; function s(r, o) { (n(r, o), (i = e.requestAnimationFrame(s))); } return { start: function () { if (t === !0) return; if (n === null) return; ((i = e.requestAnimationFrame(s)), (t = !0)); }, stop: function () { (e.cancelAnimationFrame(i), (t = !1)); }, setAnimationLoop: function (r) { n = r; }, setContext: function (r) { e = r; }, }; } function m0(e) { let t = new WeakMap(); function n(a, l) { let { array: c, usage: h } = a, u = c.byteLength, d = e.createBuffer(); (e.bindBuffer(l, d), e.bufferData(l, c, h), a.onUploadCallback()); let f; if (c instanceof Float32Array) f = e.FLOAT; else if (typeof Float16Array < "u" && c instanceof Float16Array) f = e.HALF_FLOAT; else if (c instanceof Uint16Array) if (a.isFloat16BufferAttribute) f = e.HALF_FLOAT; else f = e.UNSIGNED_SHORT; else if (c instanceof Int16Array) f = e.SHORT; else if (c instanceof Uint32Array) f = e.UNSIGNED_INT; else if (c instanceof Int32Array) f = e.INT; else if (c instanceof Int8Array) f = e.BYTE; else if (c instanceof Uint8Array) f = e.UNSIGNED_BYTE; else if (c instanceof Uint8ClampedArray) f = e.UNSIGNED_BYTE; else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: " + c); return { buffer: d, type: f, bytesPerElement: c.BYTES_PER_ELEMENT, version: a.version, size: u }; } function i(a, l, c) { let { array: h, updateRanges: u } = l; if ((e.bindBuffer(c, a), u.length === 0)) e.bufferSubData(c, 0, h); else { u.sort((f, m) => f.start - m.start); let d = 0; for (let f = 1; f < u.length; f++) { let m = u[d], y = u[f]; if (y.start <= m.start + m.count + 1) m.count = Math.max(m.count, y.start + y.count - m.start); else (++d, (u[d] = y)); } u.length = d + 1; for (let f = 0, m = u.length; f < m; f++) { let y = u[f]; e.bufferSubData(c, y.start * h.BYTES_PER_ELEMENT, h, y.start, y.count); } l.clearUpdateRanges(); } l.onUploadCallback(); } function s(a) { if (a.isInterleavedBufferAttribute) a = a.data; return t.get(a); } function r(a) { if (a.isInterleavedBufferAttribute) a = a.data; let l = t.get(a); if (l) (e.deleteBuffer(l.buffer), t.delete(a)); } function o(a, l) { if (a.isInterleavedBufferAttribute) a = a.data; if (a.isGLBufferAttribute) { let h = t.get(a); if (!h || h.version < a.version) t.set(a, { buffer: a.buffer, type: a.type, bytesPerElement: a.elementSize, version: a.version }); return; } let c = t.get(a); if (c === void 0) t.set(a, n(a, l)); else if (c.version < a.version) { if (c.size !== a.array.byteLength) throw Error( "THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.", ); (i(c.buffer, a, l), (c.version = a.version)); } } return { get: s, remove: r, update: o }; } var g0 = `#ifdef USE_ALPHAHASH if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; #endif`, y0 = `#ifdef USE_ALPHAHASH const float ALPHA_HASH_SCALE = 0.05; float hash2D( vec2 value ) { return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); } float hash3D( vec3 value ) { return hash2D( vec2( hash2D( value.xy ), value.z ) ); } float getAlphaHashThreshold( vec3 position ) { float maxDeriv = max( length( dFdx( position.xyz ) ), length( dFdy( position.xyz ) ) ); float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); vec2 pixScales = vec2( exp2( floor( log2( pixScale ) ) ), exp2( ceil( log2( pixScale ) ) ) ); vec2 alpha = vec2( hash3D( floor( pixScales.x * position.xyz ) ), hash3D( floor( pixScales.y * position.xyz ) ) ); float lerpFactor = fract( log2( pixScale ) ); float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; float a = min( lerpFactor, 1.0 - lerpFactor ); vec3 cases = vec3( x * x / ( 2.0 * a * ( 1.0 - a ) ), ( x - 0.5 * a ) / ( 1.0 - a ), 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) ); float threshold = ( x < ( 1.0 - a ) ) ? ( ( x < a ) ? cases.x : cases.y ) : cases.z; return clamp( threshold , 1.0e-6, 1.0 ); } #endif`, x0 = `#ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; #endif`, v0 = `#ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`, _0 = `#ifdef USE_ALPHATEST #ifdef ALPHA_TO_COVERAGE diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); if ( diffuseColor.a == 0.0 ) discard; #else if ( diffuseColor.a < alphaTest ) discard; #endif #endif`, S0 = `#ifdef USE_ALPHATEST uniform float alphaTest; #endif`, b0 = `#ifdef USE_AOMAP float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; reflectedLight.indirectDiffuse *= ambientOcclusion; #if defined( USE_CLEARCOAT ) clearcoatSpecularIndirect *= ambientOcclusion; #endif #if defined( USE_SHEEN ) sheenSpecularIndirect *= ambientOcclusion; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); #endif #endif`, M0 = `#ifdef USE_AOMAP uniform sampler2D aoMap; uniform float aoMapIntensity; #endif`, w0 = `#ifdef USE_BATCHING #if ! defined( GL_ANGLE_multi_draw ) #define gl_DrawID _gl_DrawID uniform int _gl_DrawID; #endif uniform highp sampler2D batchingTexture; uniform highp usampler2D batchingIdTexture; mat4 getBatchingMatrix( const in float i ) { int size = textureSize( batchingTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } float getIndirectIndex( const in int i ) { int size = textureSize( batchingIdTexture, 0 ).x; int x = i % size; int y = i / size; return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r ); } #endif #ifdef USE_BATCHING_COLOR uniform sampler2D batchingColorTexture; vec3 getBatchingColor( const in float i ) { int size = textureSize( batchingColorTexture, 0 ).x; int j = int( i ); int x = j % size; int y = j / size; return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb; } #endif`, T0 = `#ifdef USE_BATCHING mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); #endif`, E0 = `vec3 transformed = vec3( position ); #ifdef USE_ALPHAHASH vPosition = vec3( position ); #endif`, A0 = `vec3 objectNormal = vec3( normal ); #ifdef USE_TANGENT vec3 objectTangent = vec3( tangent.xyz ); #endif`, R0 = `float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( specularColor, 1.0, dotVH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } // validated`, L0 = `#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252 ); vec3 Fresnel0ToIor( vec3 fresnel0 ) { vec3 sqrtF0 = sqrt( fresnel0 ); return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); } vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); } float IorToFresnel0( float transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); } vec3 evalSensitivity( float OPD, vec3 shift ) { float phase = 2.0 * PI * OPD * 1.0e-9; vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); xyz /= 1.0685e-7; vec3 rgb = XYZ_TO_REC709 * xyz; return rgb; } vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { vec3 I; float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); float cosTheta2Sq = 1.0 - sinTheta2Sq; if ( cosTheta2Sq < 0.0 ) { return vec3( 1.0 ); } float cosTheta2 = sqrt( cosTheta2Sq ); float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); float R12 = F_Schlick( R0, 1.0, cosTheta1 ); float T121 = 1.0 - R12; float phi12 = 0.0; if ( iridescenceIOR < outsideIOR ) phi12 = PI; float phi21 = PI - phi12; vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); vec3 phi23 = vec3( 0.0 ); if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; vec3 phi = vec3( phi21 ) + phi23; vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); vec3 r123 = sqrt( R123 ); vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); vec3 C0 = R12 + Rs; I = C0; vec3 Cm = Rs - T121; for ( int m = 1; m <= 2; ++ m ) { Cm *= r123; vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); I += Cm * Sm; } return max( I, vec3( 0.0 ) ); } #endif`, C0 = `#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vBumpMapUv ); vec2 dSTdy = dFdy( vBumpMapUv ); float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`, I0 = `#if NUM_CLIPPING_PLANES > 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; float clipOpacity = 1.0; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); if ( clipOpacity == 0.0 ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES float unionClipOpacity = 1.0; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); } #pragma unroll_loop_end clipOpacity *= 1.0 - unionClipOpacity; #endif diffuseColor.a *= clipOpacity; if ( diffuseColor.a == 0.0 ) discard; #else #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif #endif`, P0 = `#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`, D0 = `#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`, U0 = `#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`, N0 = `#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`, F0 = `#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`, O0 = `#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`, k0 = `#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif #ifdef USE_BATCHING_COLOR vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); vColor.xyz *= batchingColor.xyz; #endif`, z0 = `#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`, H0 = `#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`, B0 = `vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif #ifdef USE_BATCHING mat3 bm = mat3( batchingMatrix ); transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); transformedNormal = bm * transformedNormal; #ifdef USE_TANGENT transformedTangent = bm * transformedTangent; #endif #endif #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); transformedNormal = im * transformedNormal; #ifdef USE_TANGENT transformedTangent = im * transformedTangent; #endif #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`, G0 = `#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`, V0 = `#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`, W0 = `#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`, X0 = `#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`, q0 = "gl_FragColor = linearToOutputTexel( gl_FragColor );", Y0 = `vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`, j0 = `#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`, Z0 = `#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`, K0 = `#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`, $0 = `#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`, J0 = `#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`, Q0 = `#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`, eg = `#ifdef USE_FOG varying float vFogDepth; #endif`, tg = `#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`, ng = `#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`, ig = `#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`, sg = `#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`, rg = `LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`, og = `varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`, ag = `uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; #endif vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = pointLight.position - geometryPosition; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = spotLight.position - geometryPosition; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`, lg = `#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`, cg = `ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`, hg = `varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`, ug = `BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`, dg = `varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`, fg = `PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`, pg = `struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`, mg = ` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`, gg = `#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`, yg = `#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`, xg = `#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`, vg = `#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`, _g = `#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`, Sg = `#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`, bg = `#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`, Mg = `#ifdef USE_MAP uniform sampler2D map; #endif`, wg = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`, Tg = `#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`, Eg = `float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`, Ag = `#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`, Rg = `#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } #endif`, Lg = `#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`, Cg = `#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #endif`, Ig = `#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; #endif uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #endif`, Pg = `#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #endif`, Dg = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal *= faceDirection; #endif #endif #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, #if defined( USE_NORMALMAP ) vNormalMapUv #elif defined( USE_CLEARCOAT_NORMALMAP ) vClearcoatNormalMapUv #else vUv #endif ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 nonPerturbedNormal = normal;`, Ug = `#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`, Ng = `#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`, Fg = `#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`, Og = `#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`, kg = `#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( uv.st ); vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } #endif`, zg = `#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`, Hg = `#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`, Bg = `#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif`, Gg = `#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`, Vg = `#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, Wg = `vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; const float Inv255 = 1. / 255.; const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); vec4 packDepthToRGBA( const in float v ) { if( v <= 0.0 ) return vec4( 0., 0., 0., 0. ); if( v >= 1.0 ) return vec4( 1., 1., 1., 1. ); float vuf; float af = modf( v * PackFactors.a, vuf ); float bf = modf( vuf * ShiftRight8, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); } vec3 packDepthToRGB( const in float v ) { if( v <= 0.0 ) return vec3( 0., 0., 0. ); if( v >= 1.0 ) return vec3( 1., 1., 1. ); float vuf; float bf = modf( v * PackFactors.b, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec3( vuf * Inv255, gf * PackUpscale, bf ); } vec2 packDepthToRG( const in float v ) { if( v <= 0.0 ) return vec2( 0., 0. ); if( v >= 1.0 ) return vec2( 1., 1. ); float vuf; float gf = modf( v * 256., vuf ); return vec2( vuf * Inv255, gf ); } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors4 ); } float unpackRGBToDepth( const in vec3 v ) { return dot( v, UnpackFactors3 ); } float unpackRGToDepth( const in vec2 v ) { return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; } vec4 pack2HalfToRGBA( const in vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( const in vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`, Xg = `#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`, qg = `vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`, Yg = `#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`, jg = `#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`, Zg = `float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`, Kg = `#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`, $g = `#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { float depth = unpackRGBAToDepth( texture2D( depths, uv ) ); #ifdef USE_REVERSED_DEPTH_BUFFER return step( depth, compare ); #else return step( compare, depth ); #endif } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow( sampler2D shadow, vec2 uv, float compare ) { float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); #ifdef USE_REVERSED_DEPTH_BUFFER float hard_shadow = step( distribution.x, compare ); #else float hard_shadow = step( compare, distribution.x ); #endif if ( hard_shadow != 1.0 ) { float distance = compare - distribution.x; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return mix( 1.0, shadow, shadowIntensity ); } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; float lightToPositionLength = length( lightToPosition ); if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; shadow = ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif`, Jg = `#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`, Qg = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`, ey = `float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`, ty = `#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`, ny = `#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; mat4 getBoneMatrix( const in float i ) { int size = textureSize( boneTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } #endif`, iy = `#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`, sy = `#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`, ry = `float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`, oy = `#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`, ay = `#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`, ly = `#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 CineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) ); const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) ); vec3 agxDefaultContrastApprox( vec3 x ) { vec3 x2 = x * x; vec3 x4 = x2 * x2; return + 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232; } vec3 AgXToneMapping( vec3 color ) { const mat3 AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) ); const mat3 AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) ); const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; color *= toneMappingExposure; color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; color = AgXInsetMatrix * color; color = max( color, 1e-10 ); color = log2( color ); color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); color = clamp( color, 0.0, 1.0 ); color = agxDefaultContrastApprox( color ); color = AgXOutsetMatrix * color; color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); color = LINEAR_REC2020_TO_LINEAR_SRGB * color; color = clamp( color, 0.0, 1.0 ); return color; } vec3 NeutralToneMapping( vec3 color ) { const float StartCompression = 0.8 - 0.04; const float Desaturation = 0.15; color *= toneMappingExposure; float x = min( color.r, min( color.g, color.b ) ); float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; color -= offset; float peak = max( color.r, max( color.g, color.b ) ); if ( peak < StartCompression ) return color; float d = 1. - StartCompression; float newPeak = 1. - d * d / ( peak + d - StartCompression ); color *= newPeak / peak; float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } vec3 CustomToneMapping( vec3 color ) { return color; }`, cy = `#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`, hy = `#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; float w0( float a ) { return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); } float w1( float a ) { return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); } float w2( float a ){ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); } float w3( float a ) { return ( 1.0 / 6.0 ) * ( a * a * a ); } float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } float h0( float a ) { return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); } float h1( float a ) { return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); } vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { uv = uv * texelSize.zw + 0.5; vec2 iuv = floor( uv ); vec2 fuv = fract( uv ); float g0x = g0( fuv.x ); float g1x = g1( fuv.x ); float h0x = h0( fuv.x ); float h1x = h1( fuv.x ); float h0y = h0( fuv.y ); float h1y = h1( fuv.y ); vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); } vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); vec2 fLodSizeInv = 1.0 / fLodSize; vec2 cLodSizeInv = 1.0 / cLodSize; vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); return mix( fSample, cSample, fract( lod ) ); } vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec4 transmittedLight; vec3 transmittance; #ifdef USE_DISPERSION float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); for ( int i = 0; i < 3; i ++ ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); transmittedLight[ i ] = transmissionSample[ i ]; transmittedLight.a += transmissionSample.a; transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; } transmittedLight.a /= 3.0; #else vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); #endif vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } #endif`, uy = `#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP varying vec2 vNormalMapUv; #endif #ifdef USE_EMISSIVEMAP varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SHEEN_COLORMAP varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_SPECULARMAP varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`, dy = `#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP uniform mat3 mapTransform; varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP uniform mat3 alphaMapTransform; varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP uniform mat3 lightMapTransform; varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP uniform mat3 aoMapTransform; varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP uniform mat3 bumpMapTransform; varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP uniform mat3 normalMapTransform; varying vec2 vNormalMapUv; #endif #ifdef USE_DISPLACEMENTMAP uniform mat3 displacementMapTransform; varying vec2 vDisplacementMapUv; #endif #ifdef USE_EMISSIVEMAP uniform mat3 emissiveMapTransform; varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP uniform mat3 metalnessMapTransform; varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP uniform mat3 roughnessMapTransform; varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP uniform mat3 anisotropyMapTransform; varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP uniform mat3 clearcoatMapTransform; varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform mat3 clearcoatNormalMapTransform; varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform mat3 clearcoatRoughnessMapTransform; varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_SHEEN_COLORMAP uniform mat3 sheenColorMapTransform; varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform mat3 sheenRoughnessMapTransform; varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP uniform mat3 iridescenceMapTransform; varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform mat3 iridescenceThicknessMapTransform; varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SPECULARMAP uniform mat3 specularMapTransform; varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP uniform mat3 specularColorMapTransform; varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform mat3 specularIntensityMapTransform; varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`, fy = `#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; #endif #ifdef USE_ALPHAMAP vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; #endif #ifdef USE_LIGHTMAP vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; #endif #ifdef USE_AOMAP vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; #endif #ifdef USE_BUMPMAP vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; #endif #ifdef USE_NORMALMAP vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_DISPLACEMENTMAP vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; #endif #ifdef USE_EMISSIVEMAP vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; #endif #ifdef USE_METALNESSMAP vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ROUGHNESSMAP vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ANISOTROPYMAP vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOATMAP vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_NORMALMAP vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCEMAP vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_COLORMAP vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_ROUGHNESSMAP vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULARMAP vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_COLORMAP vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_INTENSITYMAP vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; #endif #ifdef USE_TRANSMISSIONMAP vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; #endif`, py = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`, my = `varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`, gy = `uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`, yy = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`, xy = `#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`, vy = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`, _y = `uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`, Sy = `#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`, by = `#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include #ifdef USE_REVERSED_DEPTH_BUFFER float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; #else float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; #endif #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`, My = `#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`, wy = `#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`, Ty = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`, Ey = `uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`, Ay = `uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`, Ry = `uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`, Ly = `#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`, Cy = `uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`, Iy = `#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`; var Py = `#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`, Dy = `#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`, Uy = `#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`, Ny = `#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`, Fy = `#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`, Oy = `#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`, ky = `#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`, zy = `#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`, Hy = `#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_DISPERSION uniform float dispersion; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`, By = `#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`, Gy = `#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`, Vy = `uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`, Wy = `uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`, Xy = `#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`, qy = `uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`, Yy = `uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix[ 3 ]; vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`, jy = `uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`, Ve = { alphahash_fragment: g0, alphahash_pars_fragment: y0, alphamap_fragment: x0, alphamap_pars_fragment: v0, alphatest_fragment: _0, alphatest_pars_fragment: S0, aomap_fragment: b0, aomap_pars_fragment: M0, batching_pars_vertex: w0, batching_vertex: T0, begin_vertex: E0, beginnormal_vertex: A0, bsdfs: R0, iridescence_fragment: L0, bumpmap_pars_fragment: C0, clipping_planes_fragment: I0, clipping_planes_pars_fragment: P0, clipping_planes_pars_vertex: D0, clipping_planes_vertex: U0, color_fragment: N0, color_pars_fragment: F0, color_pars_vertex: O0, color_vertex: k0, common: z0, cube_uv_reflection_fragment: H0, defaultnormal_vertex: B0, displacementmap_pars_vertex: G0, displacementmap_vertex: V0, emissivemap_fragment: W0, emissivemap_pars_fragment: X0, colorspace_fragment: q0, colorspace_pars_fragment: Y0, envmap_fragment: j0, envmap_common_pars_fragment: Z0, envmap_pars_fragment: K0, envmap_pars_vertex: $0, envmap_physical_pars_fragment: lg, envmap_vertex: J0, fog_vertex: Q0, fog_pars_vertex: eg, fog_fragment: tg, fog_pars_fragment: ng, gradientmap_pars_fragment: ig, lightmap_pars_fragment: sg, lights_lambert_fragment: rg, lights_lambert_pars_fragment: og, lights_pars_begin: ag, lights_toon_fragment: cg, lights_toon_pars_fragment: hg, lights_phong_fragment: ug, lights_phong_pars_fragment: dg, lights_physical_fragment: fg, lights_physical_pars_fragment: pg, lights_fragment_begin: mg, lights_fragment_maps: gg, lights_fragment_end: yg, logdepthbuf_fragment: xg, logdepthbuf_pars_fragment: vg, logdepthbuf_pars_vertex: _g, logdepthbuf_vertex: Sg, map_fragment: bg, map_pars_fragment: Mg, map_particle_fragment: wg, map_particle_pars_fragment: Tg, metalnessmap_fragment: Eg, metalnessmap_pars_fragment: Ag, morphinstance_vertex: Rg, morphcolor_vertex: Lg, morphnormal_vertex: Cg, morphtarget_pars_vertex: Ig, morphtarget_vertex: Pg, normal_fragment_begin: Dg, normal_fragment_maps: Ug, normal_pars_fragment: Ng, normal_pars_vertex: Fg, normal_vertex: Og, normalmap_pars_fragment: kg, clearcoat_normal_fragment_begin: zg, clearcoat_normal_fragment_maps: Hg, clearcoat_pars_fragment: Bg, iridescence_pars_fragment: Gg, opaque_fragment: Vg, packing: Wg, premultiplied_alpha_fragment: Xg, project_vertex: qg, dithering_fragment: Yg, dithering_pars_fragment: jg, roughnessmap_fragment: Zg, roughnessmap_pars_fragment: Kg, shadowmap_pars_fragment: $g, shadowmap_pars_vertex: Jg, shadowmap_vertex: Qg, shadowmask_pars_fragment: ey, skinbase_vertex: ty, skinning_pars_vertex: ny, skinning_vertex: iy, skinnormal_vertex: sy, specularmap_fragment: ry, specularmap_pars_fragment: oy, tonemapping_fragment: ay, tonemapping_pars_fragment: ly, transmission_fragment: cy, transmission_pars_fragment: hy, uv_pars_fragment: uy, uv_pars_vertex: dy, uv_vertex: fy, worldpos_vertex: py, background_vert: my, background_frag: gy, backgroundCube_vert: yy, backgroundCube_frag: xy, cube_vert: vy, cube_frag: _y, depth_vert: Sy, depth_frag: by, distanceRGBA_vert: My, distanceRGBA_frag: wy, equirect_vert: Ty, equirect_frag: Ey, linedashed_vert: Ay, linedashed_frag: Ry, meshbasic_vert: Ly, meshbasic_frag: Cy, meshlambert_vert: Iy, meshlambert_frag: Py, meshmatcap_vert: Dy, meshmatcap_frag: Uy, meshnormal_vert: Ny, meshnormal_frag: Fy, meshphong_vert: Oy, meshphong_frag: ky, meshphysical_vert: zy, meshphysical_frag: Hy, meshtoon_vert: By, meshtoon_frag: Gy, points_vert: Vy, points_frag: Wy, shadow_vert: Xy, shadow_frag: qy, sprite_vert: Yy, sprite_frag: jy, }, he = { common: { diffuse: { value: new re(16777215) }, opacity: { value: 1 }, map: { value: null }, mapTransform: { value: new Be() }, alphaMap: { value: null }, alphaMapTransform: { value: new Be() }, alphaTest: { value: 0 }, }, specularmap: { specularMap: { value: null }, specularMapTransform: { value: new Be() } }, envmap: { envMap: { value: null }, envMapRotation: { value: new Be() }, flipEnvMap: { value: -1 }, reflectivity: { value: 1 }, ior: { value: 1.5 }, refractionRatio: { value: 0.98 }, }, aomap: { aoMap: { value: null }, aoMapIntensity: { value: 1 }, aoMapTransform: { value: new Be() } }, lightmap: { lightMap: { value: null }, lightMapIntensity: { value: 1 }, lightMapTransform: { value: new Be() } }, bumpmap: { bumpMap: { value: null }, bumpMapTransform: { value: new Be() }, bumpScale: { value: 1 } }, normalmap: { normalMap: { value: null }, normalMapTransform: { value: new Be() }, normalScale: { value: new ve(1, 1) }, }, displacementmap: { displacementMap: { value: null }, displacementMapTransform: { value: new Be() }, displacementScale: { value: 1 }, displacementBias: { value: 0 }, }, emissivemap: { emissiveMap: { value: null }, emissiveMapTransform: { value: new Be() } }, metalnessmap: { metalnessMap: { value: null }, metalnessMapTransform: { value: new Be() } }, roughnessmap: { roughnessMap: { value: null }, roughnessMapTransform: { value: new Be() } }, gradientmap: { gradientMap: { value: null } }, fog: { fogDensity: { value: 0.00025 }, fogNear: { value: 1 }, fogFar: { value: 2000 }, fogColor: { value: new re(16777215) }, }, lights: { ambientLightColor: { value: [] }, lightProbe: { value: [] }, directionalLights: { value: [], properties: { direction: {}, color: {} } }, directionalLightShadows: { value: [], properties: { shadowIntensity: 1, shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {} }, }, directionalShadowMap: { value: [] }, directionalShadowMatrix: { value: [] }, spotLights: { value: [], properties: { color: {}, position: {}, direction: {}, distance: {}, coneCos: {}, penumbraCos: {}, decay: {} }, }, spotLightShadows: { value: [], properties: { shadowIntensity: 1, shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {} }, }, spotLightMap: { value: [] }, spotShadowMap: { value: [] }, spotLightMatrix: { value: [] }, pointLights: { value: [], properties: { color: {}, position: {}, decay: {}, distance: {} } }, pointLightShadows: { value: [], properties: { shadowIntensity: 1, shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {}, shadowCameraNear: {}, shadowCameraFar: {}, }, }, pointShadowMap: { value: [] }, pointShadowMatrix: { value: [] }, hemisphereLights: { value: [], properties: { direction: {}, skyColor: {}, groundColor: {} } }, rectAreaLights: { value: [], properties: { color: {}, position: {}, width: {}, height: {} } }, ltc_1: { value: null }, ltc_2: { value: null }, }, points: { diffuse: { value: new re(16777215) }, opacity: { value: 1 }, size: { value: 1 }, scale: { value: 1 }, map: { value: null }, alphaMap: { value: null }, alphaMapTransform: { value: new Be() }, alphaTest: { value: 0 }, uvTransform: { value: new Be() }, }, sprite: { diffuse: { value: new re(16777215) }, opacity: { value: 1 }, center: { value: new ve(0.5, 0.5) }, rotation: { value: 0 }, map: { value: null }, mapTransform: { value: new Be() }, alphaMap: { value: null }, alphaMapTransform: { value: new Be() }, alphaTest: { value: 0 }, }, }, ti = { basic: { uniforms: jt([he.common, he.specularmap, he.envmap, he.aomap, he.lightmap, he.fog]), vertexShader: Ve.meshbasic_vert, fragmentShader: Ve.meshbasic_frag, }, lambert: { uniforms: jt([ he.common, he.specularmap, he.envmap, he.aomap, he.lightmap, he.emissivemap, he.bumpmap, he.normalmap, he.displacementmap, he.fog, he.lights, { emissive: { value: new re(0) } }, ]), vertexShader: Ve.meshlambert_vert, fragmentShader: Ve.meshlambert_frag, }, phong: { uniforms: jt([ he.common, he.specularmap, he.envmap, he.aomap, he.lightmap, he.emissivemap, he.bumpmap, he.normalmap, he.displacementmap, he.fog, he.lights, { emissive: { value: new re(0) }, specular: { value: new re(1118481) }, shininess: { value: 30 } }, ]), vertexShader: Ve.meshphong_vert, fragmentShader: Ve.meshphong_frag, }, standard: { uniforms: jt([ he.common, he.envmap, he.aomap, he.lightmap, he.emissivemap, he.bumpmap, he.normalmap, he.displacementmap, he.roughnessmap, he.metalnessmap, he.fog, he.lights, { emissive: { value: new re(0) }, roughness: { value: 1 }, metalness: { value: 0 }, envMapIntensity: { value: 1 }, }, ]), vertexShader: Ve.meshphysical_vert, fragmentShader: Ve.meshphysical_frag, }, toon: { uniforms: jt([ he.common, he.aomap, he.lightmap, he.emissivemap, he.bumpmap, he.normalmap, he.displacementmap, he.gradientmap, he.fog, he.lights, { emissive: { value: new re(0) } }, ]), vertexShader: Ve.meshtoon_vert, fragmentShader: Ve.meshtoon_frag, }, matcap: { uniforms: jt([he.common, he.bumpmap, he.normalmap, he.displacementmap, he.fog, { matcap: { value: null } }]), vertexShader: Ve.meshmatcap_vert, fragmentShader: Ve.meshmatcap_frag, }, points: { uniforms: jt([he.points, he.fog]), vertexShader: Ve.points_vert, fragmentShader: Ve.points_frag }, dashed: { uniforms: jt([he.common, he.fog, { scale: { value: 1 }, dashSize: { value: 1 }, totalSize: { value: 2 } }]), vertexShader: Ve.linedashed_vert, fragmentShader: Ve.linedashed_frag, }, depth: { uniforms: jt([he.common, he.displacementmap]), vertexShader: Ve.depth_vert, fragmentShader: Ve.depth_frag, }, normal: { uniforms: jt([he.common, he.bumpmap, he.normalmap, he.displacementmap, { opacity: { value: 1 } }]), vertexShader: Ve.meshnormal_vert, fragmentShader: Ve.meshnormal_frag, }, sprite: { uniforms: jt([he.sprite, he.fog]), vertexShader: Ve.sprite_vert, fragmentShader: Ve.sprite_frag }, background: { uniforms: { uvTransform: { value: new Be() }, t2D: { value: null }, backgroundIntensity: { value: 1 } }, vertexShader: Ve.background_vert, fragmentShader: Ve.background_frag, }, backgroundCube: { uniforms: { envMap: { value: null }, flipEnvMap: { value: -1 }, backgroundBlurriness: { value: 0 }, backgroundIntensity: { value: 1 }, backgroundRotation: { value: new Be() }, }, vertexShader: Ve.backgroundCube_vert, fragmentShader: Ve.backgroundCube_frag, }, cube: { uniforms: { tCube: { value: null }, tFlip: { value: -1 }, opacity: { value: 1 } }, vertexShader: Ve.cube_vert, fragmentShader: Ve.cube_frag, }, equirect: { uniforms: { tEquirect: { value: null } }, vertexShader: Ve.equirect_vert, fragmentShader: Ve.equirect_frag, }, distanceRGBA: { uniforms: jt([ he.common, he.displacementmap, { referencePosition: { value: new E() }, nearDistance: { value: 1 }, farDistance: { value: 1000 } }, ]), vertexShader: Ve.distanceRGBA_vert, fragmentShader: Ve.distanceRGBA_frag, }, shadow: { uniforms: jt([he.lights, he.fog, { color: { value: new re(0) }, opacity: { value: 1 } }]), vertexShader: Ve.shadow_vert, fragmentShader: Ve.shadow_frag, }, }; ti.physical = { uniforms: jt([ ti.standard.uniforms, { clearcoat: { value: 0 }, clearcoatMap: { value: null }, clearcoatMapTransform: { value: new Be() }, clearcoatNormalMap: { value: null }, clearcoatNormalMapTransform: { value: new Be() }, clearcoatNormalScale: { value: new ve(1, 1) }, clearcoatRoughness: { value: 0 }, clearcoatRoughnessMap: { value: null }, clearcoatRoughnessMapTransform: { value: new Be() }, dispersion: { value: 0 }, iridescence: { value: 0 }, iridescenceMap: { value: null }, iridescenceMapTransform: { value: new Be() }, iridescenceIOR: { value: 1.3 }, iridescenceThicknessMinimum: { value: 100 }, iridescenceThicknessMaximum: { value: 400 }, iridescenceThicknessMap: { value: null }, iridescenceThicknessMapTransform: { value: new Be() }, sheen: { value: 0 }, sheenColor: { value: new re(0) }, sheenColorMap: { value: null }, sheenColorMapTransform: { value: new Be() }, sheenRoughness: { value: 1 }, sheenRoughnessMap: { value: null }, sheenRoughnessMapTransform: { value: new Be() }, transmission: { value: 0 }, transmissionMap: { value: null }, transmissionMapTransform: { value: new Be() }, transmissionSamplerSize: { value: new ve() }, transmissionSamplerMap: { value: null }, thickness: { value: 0 }, thicknessMap: { value: null }, thicknessMapTransform: { value: new Be() }, attenuationDistance: { value: 0 }, attenuationColor: { value: new re(0) }, specularColor: { value: new re(1, 1, 1) }, specularColorMap: { value: null }, specularColorMapTransform: { value: new Be() }, specularIntensity: { value: 1 }, specularIntensityMap: { value: null }, specularIntensityMapTransform: { value: new Be() }, anisotropyVector: { value: new ve() }, anisotropyMap: { value: null }, anisotropyMapTransform: { value: new Be() }, }, ]), vertexShader: Ve.meshphysical_vert, fragmentShader: Ve.meshphysical_frag, }; var ga = { r: 0, b: 0, g: 0 }, xs = new tt(), Zy = new ue(); function Ky(e, t, n, i, s, r, o) { let a = new re(0), l = r === !0 ? 0 : 1, c, h, u = null, d = 0, f = null; function m(x) { let w = x.isScene === !0 ? x.background : null; if (w && w.isTexture) w = (x.backgroundBlurriness > 0 ? n : t).get(w); return w; } function y(x) { let w = !1, L = m(x); if (L === null) g(a, l); else if (L && L.isColor) (g(L, 1), (w = !0)); let b = e.xr.getEnvironmentBlendMode(); if (b === "additive") i.buffers.color.setClear(0, 0, 0, 1, o); else if (b === "alpha-blend") i.buffers.color.setClear(0, 0, 0, 0, o); if (e.autoClear || w) (i.buffers.depth.setTest(!0), i.buffers.depth.setMask(!0), i.buffers.color.setMask(!0), e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil)); } function p(x, w) { let L = m(w); if (L && (L.isCubeTexture || L.mapping === Or)) { if (h === void 0) ((h = new st( new Hi(1, 1, 1), new Zn({ name: "BackgroundCubeMaterial", uniforms: ps(ti.backgroundCube.uniforms), vertexShader: ti.backgroundCube.vertexShader, fragmentShader: ti.backgroundCube.fragmentShader, side: Gt, depthTest: !1, depthWrite: !1, fog: !1, allowOverride: !1, }), )), h.geometry.deleteAttribute("normal"), h.geometry.deleteAttribute("uv"), (h.onBeforeRender = function (b, R, F) { this.matrixWorld.copyPosition(F.matrixWorld); }), Object.defineProperty(h.material, "envMap", { get: function () { return this.uniforms.envMap.value; }, }), s.update(h)); if ( (xs.copy(w.backgroundRotation), (xs.x *= -1), (xs.y *= -1), (xs.z *= -1), L.isCubeTexture && L.isRenderTargetTexture === !1) ) ((xs.y *= -1), (xs.z *= -1)); if ( ((h.material.uniforms.envMap.value = L), (h.material.uniforms.flipEnvMap.value = L.isCubeTexture && L.isRenderTargetTexture === !1 ? -1 : 1), (h.material.uniforms.backgroundBlurriness.value = w.backgroundBlurriness), (h.material.uniforms.backgroundIntensity.value = w.backgroundIntensity), h.material.uniforms.backgroundRotation.value.setFromMatrix4(Zy.makeRotationFromEuler(xs)), (h.material.toneMapped = ke.getTransfer(L.colorSpace) !== xt), u !== L || d !== L.version || f !== e.toneMapping) ) ((h.material.needsUpdate = !0), (u = L), (d = L.version), (f = e.toneMapping)); (h.layers.enableAll(), x.unshift(h, h.geometry, h.material, 0, 0, null)); } else if (L && L.isTexture) { if (c === void 0) ((c = new st( new Vi(2, 2), new Zn({ name: "BackgroundMaterial", uniforms: ps(ti.background.uniforms), vertexShader: ti.background.vertexShader, fragmentShader: ti.background.fragmentShader, side: Fi, depthTest: !1, depthWrite: !1, fog: !1, allowOverride: !1, }), )), c.geometry.deleteAttribute("normal"), Object.defineProperty(c.material, "map", { get: function () { return this.uniforms.t2D.value; }, }), s.update(c)); if ( ((c.material.uniforms.t2D.value = L), (c.material.uniforms.backgroundIntensity.value = w.backgroundIntensity), (c.material.toneMapped = ke.getTransfer(L.colorSpace) !== xt), L.matrixAutoUpdate === !0) ) L.updateMatrix(); if ((c.material.uniforms.uvTransform.value.copy(L.matrix), u !== L || d !== L.version || f !== e.toneMapping)) ((c.material.needsUpdate = !0), (u = L), (d = L.version), (f = e.toneMapping)); (c.layers.enableAll(), x.unshift(c, c.geometry, c.material, 0, 0, null)); } } function g(x, w) { (x.getRGB(ga, cc(e)), i.buffers.color.setClear(ga.r, ga.g, ga.b, w, o)); } function _() { if (h !== void 0) (h.geometry.dispose(), h.material.dispose(), (h = void 0)); if (c !== void 0) (c.geometry.dispose(), c.material.dispose(), (c = void 0)); } return { getClearColor: function () { return a; }, setClearColor: function (x, w = 1) { (a.set(x), (l = w), g(a, l)); }, getClearAlpha: function () { return l; }, setClearAlpha: function (x) { ((l = x), g(a, l)); }, render: y, addToRenderList: p, dispose: _, }; } function $y(e, t) { let n = e.getParameter(e.MAX_VERTEX_ATTRIBS), i = {}, s = d(null), r = s, o = !1; function a(T, I, G, q, B) { let Z = !1, W = u(q, G, I); if (r !== W) ((r = W), c(r.object)); if (((Z = f(T, q, G, B)), Z)) m(T, q, G, B); if (B !== null) t.update(B, e.ELEMENT_ARRAY_BUFFER); if (Z || o) { if (((o = !1), w(T, I, G, q), B !== null)) e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, t.get(B).buffer); } } function l() { return e.createVertexArray(); } function c(T) { return e.bindVertexArray(T); } function h(T) { return e.deleteVertexArray(T); } function u(T, I, G) { let q = G.wireframe === !0, B = i[T.id]; if (B === void 0) ((B = {}), (i[T.id] = B)); let Z = B[I.id]; if (Z === void 0) ((Z = {}), (B[I.id] = Z)); let W = Z[q]; if (W === void 0) ((W = d(l())), (Z[q] = W)); return W; } function d(T) { let I = [], G = [], q = []; for (let B = 0; B < n; B++) ((I[B] = 0), (G[B] = 0), (q[B] = 0)); return { geometry: null, program: null, wireframe: !1, newAttributes: I, enabledAttributes: G, attributeDivisors: q, object: T, attributes: {}, index: null, }; } function f(T, I, G, q) { let B = r.attributes, Z = I.attributes, W = 0, K = G.getAttributes(); for (let V in K) if (K[V].location >= 0) { let ce = B[V], Pe = Z[V]; if (Pe === void 0) { if (V === "instanceMatrix" && T.instanceMatrix) Pe = T.instanceMatrix; if (V === "instanceColor" && T.instanceColor) Pe = T.instanceColor; } if (ce === void 0) return !0; if (ce.attribute !== Pe) return !0; if (Pe && ce.data !== Pe.data) return !0; W++; } if (r.attributesNum !== W) return !0; if (r.index !== q) return !0; return !1; } function m(T, I, G, q) { let B = {}, Z = I.attributes, W = 0, K = G.getAttributes(); for (let V in K) if (K[V].location >= 0) { let ce = Z[V]; if (ce === void 0) { if (V === "instanceMatrix" && T.instanceMatrix) ce = T.instanceMatrix; if (V === "instanceColor" && T.instanceColor) ce = T.instanceColor; } let Pe = {}; if (((Pe.attribute = ce), ce && ce.data)) Pe.data = ce.data; ((B[V] = Pe), W++); } ((r.attributes = B), (r.attributesNum = W), (r.index = q)); } function y() { let T = r.newAttributes; for (let I = 0, G = T.length; I < G; I++) T[I] = 0; } function p(T) { g(T, 0); } function g(T, I) { let G = r.newAttributes, q = r.enabledAttributes, B = r.attributeDivisors; if (((G[T] = 1), q[T] === 0)) (e.enableVertexAttribArray(T), (q[T] = 1)); if (B[T] !== I) (e.vertexAttribDivisor(T, I), (B[T] = I)); } function _() { let T = r.newAttributes, I = r.enabledAttributes; for (let G = 0, q = I.length; G < q; G++) if (I[G] !== T[G]) (e.disableVertexAttribArray(G), (I[G] = 0)); } function x(T, I, G, q, B, Z, W) { if (W === !0) e.vertexAttribIPointer(T, I, G, B, Z); else e.vertexAttribPointer(T, I, G, q, B, Z); } function w(T, I, G, q) { y(); let B = q.attributes, Z = G.getAttributes(), W = I.defaultAttributeValues; for (let K in Z) { let V = Z[K]; if (V.location >= 0) { let se = B[K]; if (se === void 0) { if (K === "instanceMatrix" && T.instanceMatrix) se = T.instanceMatrix; if (K === "instanceColor" && T.instanceColor) se = T.instanceColor; } if (se !== void 0) { let ce = se.normalized, Pe = se.itemSize, We = t.get(se); if (We === void 0) continue; let { buffer: rt, type: Ke, bytesPerElement: k } = We, J = Ke === e.INT || Ke === e.UNSIGNED_INT || se.gpuType === yl; if (se.isInterleavedBufferAttribute) { let ee = se.data, ae = ee.stride, ge = se.offset; if (ee.isInstancedInterleavedBuffer) { for (let Ee = 0; Ee < V.locationSize; Ee++) g(V.location + Ee, ee.meshPerAttribute); if (T.isInstancedMesh !== !0 && q._maxInstanceCount === void 0) q._maxInstanceCount = ee.meshPerAttribute * ee.count; } else for (let Ee = 0; Ee < V.locationSize; Ee++) p(V.location + Ee); e.bindBuffer(e.ARRAY_BUFFER, rt); for (let Ee = 0; Ee < V.locationSize; Ee++) x(V.location + Ee, Pe / V.locationSize, Ke, ce, ae * k, (ge + (Pe / V.locationSize) * Ee) * k, J); } else { if (se.isInstancedBufferAttribute) { for (let ee = 0; ee < V.locationSize; ee++) g(V.location + ee, se.meshPerAttribute); if (T.isInstancedMesh !== !0 && q._maxInstanceCount === void 0) q._maxInstanceCount = se.meshPerAttribute * se.count; } else for (let ee = 0; ee < V.locationSize; ee++) p(V.location + ee); e.bindBuffer(e.ARRAY_BUFFER, rt); for (let ee = 0; ee < V.locationSize; ee++) x(V.location + ee, Pe / V.locationSize, Ke, ce, Pe * k, (Pe / V.locationSize) * ee * k, J); } } else if (W !== void 0) { let ce = W[K]; if (ce !== void 0) switch (ce.length) { case 2: e.vertexAttrib2fv(V.location, ce); break; case 3: e.vertexAttrib3fv(V.location, ce); break; case 4: e.vertexAttrib4fv(V.location, ce); break; default: e.vertexAttrib1fv(V.location, ce); } } } } _(); } function L() { F(); for (let T in i) { let I = i[T]; for (let G in I) { let q = I[G]; for (let B in q) (h(q[B].object), delete q[B]); delete I[G]; } delete i[T]; } } function b(T) { if (i[T.id] === void 0) return; let I = i[T.id]; for (let G in I) { let q = I[G]; for (let B in q) (h(q[B].object), delete q[B]); delete I[G]; } delete i[T.id]; } function R(T) { for (let I in i) { let G = i[I]; if (G[T.id] === void 0) continue; let q = G[T.id]; for (let B in q) (h(q[B].object), delete q[B]); delete G[T.id]; } } function F() { if ((M(), (o = !0), r === s)) return; ((r = s), c(r.object)); } function M() { ((s.geometry = null), (s.program = null), (s.wireframe = !1)); } return { setup: a, reset: F, resetDefaultState: M, dispose: L, releaseStatesOfGeometry: b, releaseStatesOfProgram: R, initAttributes: y, enableAttribute: p, disableUnusedAttributes: _, }; } function Jy(e, t, n) { let i; function s(c) { i = c; } function r(c, h) { (e.drawArrays(i, c, h), n.update(h, i, 1)); } function o(c, h, u) { if (u === 0) return; (e.drawArraysInstanced(i, c, h, u), n.update(h, i, u)); } function a(c, h, u) { if (u === 0) return; t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i, c, 0, h, 0, u); let f = 0; for (let m = 0; m < u; m++) f += h[m]; n.update(f, i, 1); } function l(c, h, u, d) { if (u === 0) return; let f = t.get("WEBGL_multi_draw"); if (f === null) for (let m = 0; m < c.length; m++) o(c[m], h[m], d[m]); else { f.multiDrawArraysInstancedWEBGL(i, c, 0, h, 0, d, 0, u); let m = 0; for (let y = 0; y < u; y++) m += h[y] * d[y]; n.update(m, i, 1); } } ((this.setMode = s), (this.render = r), (this.renderInstances = o), (this.renderMultiDraw = a), (this.renderMultiDrawInstances = l)); } function Qy(e, t, n, i) { let s; function r() { if (s !== void 0) return s; if (t.has("EXT_texture_filter_anisotropic") === !0) { let R = t.get("EXT_texture_filter_anisotropic"); s = e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT); } else s = 0; return s; } function o(R) { if (R !== Yn && i.convert(R) !== e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)) return !1; return !0; } function a(R) { let F = R === zr && (t.has("EXT_color_buffer_half_float") || t.has("EXT_color_buffer_float")); if (R !== ki && i.convert(R) !== e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE) && R !== zi && !F) return !1; return !0; } function l(R) { if (R === "highp") { if ( e.getShaderPrecisionFormat(e.VERTEX_SHADER, e.HIGH_FLOAT).precision > 0 && e.getShaderPrecisionFormat(e.FRAGMENT_SHADER, e.HIGH_FLOAT).precision > 0 ) return "highp"; R = "mediump"; } if (R === "mediump") { if ( e.getShaderPrecisionFormat(e.VERTEX_SHADER, e.MEDIUM_FLOAT).precision > 0 && e.getShaderPrecisionFormat(e.FRAGMENT_SHADER, e.MEDIUM_FLOAT).precision > 0 ) return "mediump"; } return "lowp"; } let c = n.precision !== void 0 ? n.precision : "highp", h = l(c); if (h !== c) (console.warn("THREE.WebGLRenderer:", c, "not supported, using", h, "instead."), (c = h)); let u = n.logarithmicDepthBuffer === !0, d = n.reversedDepthBuffer === !0 && t.has("EXT_clip_control"), f = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), m = e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS), y = e.getParameter(e.MAX_TEXTURE_SIZE), p = e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE), g = e.getParameter(e.MAX_VERTEX_ATTRIBS), _ = e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS), x = e.getParameter(e.MAX_VARYING_VECTORS), w = e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS), L = m > 0, b = e.getParameter(e.MAX_SAMPLES); return { isWebGL2: !0, getMaxAnisotropy: r, getMaxPrecision: l, textureFormatReadable: o, textureTypeReadable: a, precision: c, logarithmicDepthBuffer: u, reversedDepthBuffer: d, maxTextures: f, maxVertexTextures: m, maxTextureSize: y, maxCubemapSize: p, maxAttributes: g, maxVertexUniforms: _, maxVaryings: x, maxFragmentUniforms: w, vertexTextures: L, maxSamples: b, }; } function ex(e) { let t = this, n = null, i = 0, s = !1, r = !1, o = new mn(), a = new Be(), l = { value: null, needsUpdate: !1 }; ((this.uniform = l), (this.numPlanes = 0), (this.numIntersection = 0), (this.init = function (u, d) { let f = u.length !== 0 || d || i !== 0 || s; return ((s = d), (i = u.length), f); }), (this.beginShadows = function () { ((r = !0), h(null)); }), (this.endShadows = function () { r = !1; }), (this.setGlobalState = function (u, d) { n = h(u, d, 0); }), (this.setState = function (u, d, f) { let { clippingPlanes: m, clipIntersection: y, clipShadows: p } = u, g = e.get(u); if (!s || m === null || m.length === 0 || (r && !p)) if (r) h(null); else c(); else { let _ = r ? 0 : i, x = _ * 4, w = g.clippingState || null; ((l.value = w), (w = h(m, d, x, f))); for (let L = 0; L !== x; ++L) w[L] = n[L]; ((g.clippingState = w), (this.numIntersection = y ? this.numPlanes : 0), (this.numPlanes += _)); } })); function c() { if (l.value !== n) ((l.value = n), (l.needsUpdate = i > 0)); ((t.numPlanes = i), (t.numIntersection = 0)); } function h(u, d, f, m) { let y = u !== null ? u.length : 0, p = null; if (y !== 0) { if (((p = l.value), m !== !0 || p === null)) { let g = f + y * 4, _ = d.matrixWorldInverse; if ((a.getNormalMatrix(_), p === null || p.length < g)) p = new Float32Array(g); for (let x = 0, w = f; x !== y; ++x, w += 4) (o.copy(u[x]).applyMatrix4(_, a), o.normal.toArray(p, w), (p[w + 3] = o.constant)); } ((l.value = p), (l.needsUpdate = !0)); } return ((t.numPlanes = y), (t.numIntersection = 0), p); } } function tx(e) { let t = new WeakMap(); function n(o, a) { if (a === Zs) o.mapping = js; else if (a === Xo) o.mapping = us; return o; } function i(o) { if (o && o.isTexture) { let a = o.mapping; if (a === Zs || a === Xo) if (t.has(o)) { let l = t.get(o).texture; return n(l, o.mapping); } else { let l = o.image; if (l && l.height > 0) { let c = new uc(l.height); return ( c.fromEquirectangularTexture(e, o), t.set(o, c), o.addEventListener("dispose", s), n(c.texture, o.mapping) ); } else return null; } } return o; } function s(o) { let a = o.target; a.removeEventListener("dispose", s); let l = t.get(a); if (l !== void 0) (t.delete(a), l.dispose()); } function r() { t = new WeakMap(); } return { get: i, dispose: r }; } var hr = 4, Ld = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], Ss = 20, Tc = new ar(), Cd = new re(), Ec = null, Ac = 0, Rc = 0, Lc = !1, _s = (1 + Math.sqrt(5)) / 2, cr = 1 / _s, Id = [ new E(-_s, cr, 0), new E(_s, cr, 0), new E(-cr, 0, _s), new E(cr, 0, _s), new E(0, _s, -cr), new E(0, _s, cr), new E(-1, 1, -1), new E(1, 1, -1), new E(-1, 1, 1), new E(1, 1, 1), ], nx = new E(); class Zi { constructor(e) { ((this._renderer = e), (this._pingPongRenderTarget = null), (this._lodMax = 0), (this._cubeSize = 0), (this._lodPlanes = []), (this._sizeLods = []), (this._sigmas = []), (this._blurMaterial = null), (this._cubemapMaterial = null), (this._equirectMaterial = null), this._compileMaterial(this._blurMaterial)); } fromScene(e, t = 0, n = 0.1, i = 100, s = {}) { let { size: r = 256, position: o = nx } = s; ((Ec = this._renderer.getRenderTarget()), (Ac = this._renderer.getActiveCubeFace()), (Rc = this._renderer.getActiveMipmapLevel()), (Lc = this._renderer.xr.enabled), (this._renderer.xr.enabled = !1), this._setSize(r)); let a = this._allocateTargets(); if (((a.depthBuffer = !0), this._sceneToCubeUV(e, n, i, a, o), t > 0)) this._blur(a, 0, 0, t); return (this._applyPMREM(a), this._cleanup(a), a); } fromEquirectangular(e, t = null) { return this._fromTexture(e, t); } fromCubemap(e, t = null) { return this._fromTexture(e, t); } compileCubemapShader() { if (this._cubemapMaterial === null) ((this._cubemapMaterial = Ud()), this._compileMaterial(this._cubemapMaterial)); } compileEquirectangularShader() { if (this._equirectMaterial === null) ((this._equirectMaterial = Dd()), this._compileMaterial(this._equirectMaterial)); } dispose() { if ((this._dispose(), this._cubemapMaterial !== null)) this._cubemapMaterial.dispose(); if (this._equirectMaterial !== null) this._equirectMaterial.dispose(); } _setSize(e) { ((this._lodMax = Math.floor(Math.log2(e))), (this._cubeSize = Math.pow(2, this._lodMax))); } _dispose() { if (this._blurMaterial !== null) this._blurMaterial.dispose(); if (this._pingPongRenderTarget !== null) this._pingPongRenderTarget.dispose(); for (let e = 0; e < this._lodPlanes.length; e++) this._lodPlanes[e].dispose(); } _cleanup(e) { (this._renderer.setRenderTarget(Ec, Ac, Rc), (this._renderer.xr.enabled = Lc), (e.scissorTest = !1), ya(e, 0, 0, e.width, e.height)); } _fromTexture(e, t) { if (e.mapping === js || e.mapping === us) this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width); else this._setSize(e.image.width / 4); ((Ec = this._renderer.getRenderTarget()), (Ac = this._renderer.getActiveCubeFace()), (Rc = this._renderer.getActiveMipmapLevel()), (Lc = this._renderer.xr.enabled), (this._renderer.xr.enabled = !1)); let n = t || this._allocateTargets(); return (this._textureToCubeUV(e, n), this._applyPMREM(n), this._cleanup(n), n); } _allocateTargets() { let e = 3 * Math.max(this._cubeSize, 112), t = 4 * this._cubeSize, n = { magFilter: kn, minFilter: kn, generateMipmaps: !1, type: zr, format: Yn, colorSpace: Ut, depthBuffer: !1 }, i = Pd(e, t, n); if ( this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t ) { if (this._pingPongRenderTarget !== null) this._dispose(); this._pingPongRenderTarget = Pd(e, t, n); let { _lodMax: s } = this; (({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = ix(s)), (this._blurMaterial = sx(s, e, t))); } return i; } _compileMaterial(e) { let t = new st(this._lodPlanes[0], e); this._renderer.compile(t, Tc); } _sceneToCubeUV(e, t, n, i, s) { let a = new It(90, 1, t, n), l = [1, -1, 1, 1, 1, 1], c = [1, 1, 1, -1, -1, -1], h = this._renderer, { autoClear: u, toneMapping: d } = h; if ((h.getClearColor(Cd), (h.toneMapping = mi), (h.autoClear = !1), h.state.buffers.depth.getReversed())) (h.setRenderTarget(i), h.clearDepth(), h.setRenderTarget(null)); let m = new Wt({ name: "PMREM.Background", side: Gt, depthWrite: !1, depthTest: !1 }), y = new st(new Hi(), m), p = !1, g = e.background; if (g) { if (g.isColor) (m.color.copy(g), (e.background = null), (p = !0)); } else (m.color.copy(Cd), (p = !0)); for (let _ = 0; _ < 6; _++) { let x = _ % 3; if (x === 0) (a.up.set(0, l[_], 0), a.position.set(s.x, s.y, s.z), a.lookAt(s.x + c[_], s.y, s.z)); else if (x === 1) (a.up.set(0, 0, l[_]), a.position.set(s.x, s.y, s.z), a.lookAt(s.x, s.y + c[_], s.z)); else (a.up.set(0, l[_], 0), a.position.set(s.x, s.y, s.z), a.lookAt(s.x, s.y, s.z + c[_])); let w = this._cubeSize; if ((ya(i, x * w, _ > 2 ? w : 0, w, w), h.setRenderTarget(i), p)) h.render(y, a); h.render(e, a); } (y.geometry.dispose(), y.material.dispose(), (h.toneMapping = d), (h.autoClear = u), (e.background = g)); } _textureToCubeUV(e, t) { let n = this._renderer, i = e.mapping === js || e.mapping === us; if (i) { if (this._cubemapMaterial === null) this._cubemapMaterial = Ud(); this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1; } else if (this._equirectMaterial === null) this._equirectMaterial = Dd(); let s = i ? this._cubemapMaterial : this._equirectMaterial, r = new st(this._lodPlanes[0], s), o = s.uniforms; o.envMap.value = e; let a = this._cubeSize; (ya(t, 0, 0, 3 * a, 2 * a), n.setRenderTarget(t), n.render(r, Tc)); } _applyPMREM(e) { let t = this._renderer, n = t.autoClear; t.autoClear = !1; let i = this._lodPlanes.length; for (let s = 1; s < i; s++) { let r = Math.sqrt(this._sigmas[s] * this._sigmas[s] - this._sigmas[s - 1] * this._sigmas[s - 1]), o = Id[(i - s - 1) % Id.length]; this._blur(e, s - 1, s, r, o); } t.autoClear = n; } _blur(e, t, n, i, s) { let r = this._pingPongRenderTarget; (this._halfBlur(e, r, t, n, i, "latitudinal", s), this._halfBlur(r, e, n, n, i, "longitudinal", s)); } _halfBlur(e, t, n, i, s, r, o) { let a = this._renderer, l = this._blurMaterial; if (r !== "latitudinal" && r !== "longitudinal") console.error("blur direction must be either latitudinal or longitudinal!"); let c = 3, h = new st(this._lodPlanes[i], l), u = l.uniforms, d = this._sizeLods[n] - 1, f = isFinite(s) ? Math.PI / (2 * d) : (2 * Math.PI) / (2 * Ss - 1), m = s / f, y = isFinite(s) ? 1 + Math.floor(c * m) : Ss; if (y > Ss) console.warn( `sigmaRadians, ${s}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Ss}`, ); let p = [], g = 0; for (let b = 0; b < Ss; ++b) { let R = b / m, F = Math.exp((-R * R) / 2); if ((p.push(F), b === 0)) g += F; else if (b < y) g += 2 * F; } for (let b = 0; b < p.length; b++) p[b] = p[b] / g; if ( ((u.envMap.value = e.texture), (u.samples.value = y), (u.weights.value = p), (u.latitudinal.value = r === "latitudinal"), o) ) u.poleAxis.value = o; let { _lodMax: _ } = this; ((u.dTheta.value = f), (u.mipInt.value = _ - n)); let x = this._sizeLods[i], w = 3 * x * (i > _ - hr ? i - _ + hr : 0), L = 4 * (this._cubeSize - x); (ya(t, w, L, 3 * x, 2 * x), a.setRenderTarget(t), a.render(h, Tc)); } } function ix(e) { let t = [], n = [], i = [], s = e, r = e - hr + 1 + Ld.length; for (let o = 0; o < r; o++) { let a = Math.pow(2, s); n.push(a); let l = 1 / a; if (o > e - hr) l = Ld[o - e + hr - 1]; else if (o === 0) l = 0; i.push(l); let c = 1 / (a - 2), h = -c, u = 1 + c, d = [h, h, u, h, u, u, h, h, u, u, h, u], f = 6, m = 6, y = 3, p = 2, g = 1, _ = new Float32Array(y * m * f), x = new Float32Array(p * m * f), w = new Float32Array(g * m * f); for (let b = 0; b < f; b++) { let R = ((b % 3) * 2) / 3 - 1, F = b > 2 ? 0 : -1, M = [ R, F, 0, R + 0.6666666666666666, F, 0, R + 0.6666666666666666, F + 1, 0, R, F, 0, R + 0.6666666666666666, F + 1, 0, R, F + 1, 0, ]; (_.set(M, y * m * b), x.set(d, p * m * b)); let T = [b, b, b, b, b, b]; w.set(T, g * m * b); } let L = new Et(); if ( (L.setAttribute("position", new gt(_, y)), L.setAttribute("uv", new gt(x, p)), L.setAttribute("faceIndex", new gt(w, g)), t.push(L), s > hr) ) s--; } return { lodPlanes: t, sizeLods: n, sigmas: i }; } function Pd(e, t, n) { let i = new vi(e, t, n); return ((i.texture.mapping = Or), (i.texture.name = "PMREM.cubeUv"), (i.scissorTest = !0), i); } function ya(e, t, n, i, s) { (e.viewport.set(t, n, i, s), e.scissor.set(t, n, i, s)); } function sx(e, t, n) { let i = new Float32Array(Ss), s = new E(0, 1, 0); return new Zn({ name: "SphericalGaussianBlur", defines: { n: Ss, CUBEUV_TEXEL_WIDTH: 1 / t, CUBEUV_TEXEL_HEIGHT: 1 / n, CUBEUV_MAX_MIP: `${e}.0` }, uniforms: { envMap: { value: null }, samples: { value: 1 }, weights: { value: i }, latitudinal: { value: !1 }, dTheta: { value: 0 }, mipInt: { value: 0 }, poleAxis: { value: s }, }, vertexShader: Pc(), fragmentShader: ` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `, blending: Oi, depthTest: !1, depthWrite: !1, }); } function Dd() { return new Zn({ name: "EquirectangularToCubeUV", uniforms: { envMap: { value: null } }, vertexShader: Pc(), fragmentShader: ` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `, blending: Oi, depthTest: !1, depthWrite: !1, }); } function Ud() { return new Zn({ name: "CubemapToCubeUV", uniforms: { envMap: { value: null }, flipEnvMap: { value: -1 } }, vertexShader: Pc(), fragmentShader: ` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `, blending: Oi, depthTest: !1, depthWrite: !1, }); } function Pc() { return ` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `; } function rx(e) { let t = new WeakMap(), n = null; function i(a) { if (a && a.isTexture) { let l = a.mapping, c = l === Zs || l === Xo, h = l === js || l === us; if (c || h) { let u = t.get(a), d = u !== void 0 ? u.texture.pmremVersion : 0; if (a.isRenderTargetTexture && a.pmremVersion !== d) { if (n === null) n = new Zi(e); return ( (u = c ? n.fromEquirectangular(a, u) : n.fromCubemap(a, u)), (u.texture.pmremVersion = a.pmremVersion), t.set(a, u), u.texture ); } else if (u !== void 0) return u.texture; else { let f = a.image; if ((c && f && f.height > 0) || (h && f && s(f))) { if (n === null) n = new Zi(e); return ( (u = c ? n.fromEquirectangular(a) : n.fromCubemap(a)), (u.texture.pmremVersion = a.pmremVersion), t.set(a, u), a.addEventListener("dispose", r), u.texture ); } else return null; } } } return a; } function s(a) { let l = 0, c = 6; for (let h = 0; h < c; h++) if (a[h] !== void 0) l++; return l === c; } function r(a) { let l = a.target; l.removeEventListener("dispose", r); let c = t.get(l); if (c !== void 0) (t.delete(l), c.dispose()); } function o() { if (((t = new WeakMap()), n !== null)) (n.dispose(), (n = null)); } return { get: i, dispose: o }; } function ox(e) { let t = {}; function n(i) { if (t[i] !== void 0) return t[i]; let s; switch (i) { case "WEBGL_depth_texture": s = e.getExtension("WEBGL_depth_texture") || e.getExtension("MOZ_WEBGL_depth_texture") || e.getExtension("WEBKIT_WEBGL_depth_texture"); break; case "EXT_texture_filter_anisotropic": s = e.getExtension("EXT_texture_filter_anisotropic") || e.getExtension("MOZ_EXT_texture_filter_anisotropic") || e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"); break; case "WEBGL_compressed_texture_s3tc": s = e.getExtension("WEBGL_compressed_texture_s3tc") || e.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"); break; case "WEBGL_compressed_texture_pvrtc": s = e.getExtension("WEBGL_compressed_texture_pvrtc") || e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"); break; default: s = e.getExtension(i); } return ((t[i] = s), s); } return { has: function (i) { return n(i) !== null; }, init: function () { (n("EXT_color_buffer_float"), n("WEBGL_clip_cull_distance"), n("OES_texture_float_linear"), n("EXT_color_buffer_half_float"), n("WEBGL_multisampled_render_to_texture"), n("WEBGL_render_shared_exponent")); }, get: function (i) { let s = n(i); if (s === null) Ws("THREE.WebGLRenderer: " + i + " extension not supported."); return s; }, }; } function ax(e, t, n, i) { let s = {}, r = new WeakMap(); function o(u) { let d = u.target; if (d.index !== null) t.remove(d.index); for (let m in d.attributes) t.remove(d.attributes[m]); (d.removeEventListener("dispose", o), delete s[d.id]); let f = r.get(d); if (f) (t.remove(f), r.delete(d)); if ((i.releaseStatesOfGeometry(d), d.isInstancedBufferGeometry === !0)) delete d._maxInstanceCount; n.memory.geometries--; } function a(u, d) { if (s[d.id] === !0) return d; return (d.addEventListener("dispose", o), (s[d.id] = !0), n.memory.geometries++, d); } function l(u) { let d = u.attributes; for (let f in d) t.update(d[f], e.ARRAY_BUFFER); } function c(u) { let d = [], f = u.index, m = u.attributes.position, y = 0; if (f !== null) { let _ = f.array; y = f.version; for (let x = 0, w = _.length; x < w; x += 3) { let L = _[x + 0], b = _[x + 1], R = _[x + 2]; d.push(L, b, b, R, R, L); } } else if (m !== void 0) { let _ = m.array; y = m.version; for (let x = 0, w = _.length / 3 - 1; x < w; x += 3) { let L = x + 0, b = x + 1, R = x + 2; d.push(L, b, b, R, R, L); } } else return; let p = new (rc(d) ? ta : er)(d, 1); p.version = y; let g = r.get(u); if (g) t.remove(g); r.set(u, p); } function h(u) { let d = r.get(u); if (d) { let f = u.index; if (f !== null) { if (d.version < f.version) c(u); } } else c(u); return r.get(u); } return { get: a, update: l, getWireframeAttribute: h }; } function lx(e, t, n) { let i; function s(d) { i = d; } let r, o; function a(d) { ((r = d.type), (o = d.bytesPerElement)); } function l(d, f) { (e.drawElements(i, f, r, d * o), n.update(f, i, 1)); } function c(d, f, m) { if (m === 0) return; (e.drawElementsInstanced(i, f, r, d * o, m), n.update(f, i, m)); } function h(d, f, m) { if (m === 0) return; t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i, f, 0, r, d, 0, m); let p = 0; for (let g = 0; g < m; g++) p += f[g]; n.update(p, i, 1); } function u(d, f, m, y) { if (m === 0) return; let p = t.get("WEBGL_multi_draw"); if (p === null) for (let g = 0; g < d.length; g++) c(d[g] / o, f[g], y[g]); else { p.multiDrawElementsInstancedWEBGL(i, f, 0, r, d, 0, y, 0, m); let g = 0; for (let _ = 0; _ < m; _++) g += f[_] * y[_]; n.update(g, i, 1); } } ((this.setMode = s), (this.setIndex = a), (this.render = l), (this.renderInstances = c), (this.renderMultiDraw = h), (this.renderMultiDrawInstances = u)); } function cx(e) { let t = { geometries: 0, textures: 0 }, n = { frame: 0, calls: 0, triangles: 0, points: 0, lines: 0 }; function i(r, o, a) { switch ((n.calls++, o)) { case e.TRIANGLES: n.triangles += a * (r / 3); break; case e.LINES: n.lines += a * (r / 2); break; case e.LINE_STRIP: n.lines += a * (r - 1); break; case e.LINE_LOOP: n.lines += a * r; break; case e.POINTS: n.points += a * r; break; default: console.error("THREE.WebGLInfo: Unknown draw mode:", o); break; } } function s() { ((n.calls = 0), (n.triangles = 0), (n.points = 0), (n.lines = 0)); } return { memory: t, render: n, programs: null, autoReset: !0, reset: s, update: i }; } function hx(e, t, n) { let i = new WeakMap(), s = new Ye(); function r(o, a, l) { let c = o.morphTargetInfluences, h = a.morphAttributes.position || a.morphAttributes.normal || a.morphAttributes.color, u = h !== void 0 ? h.length : 0, d = i.get(a); if (d === void 0 || d.count !== u) { let M = function () { (R.dispose(), i.delete(a), a.removeEventListener("dispose", M)); }; if (d !== void 0) d.texture.dispose(); let f = a.morphAttributes.position !== void 0, m = a.morphAttributes.normal !== void 0, y = a.morphAttributes.color !== void 0, p = a.morphAttributes.position || [], g = a.morphAttributes.normal || [], _ = a.morphAttributes.color || [], x = 0; if (f === !0) x = 1; if (m === !0) x = 2; if (y === !0) x = 3; let w = a.attributes.position.count * x, L = 1; if (w > t.maxTextureSize) ((L = Math.ceil(w / t.maxTextureSize)), (w = t.maxTextureSize)); let b = new Float32Array(w * L * 4 * u), R = new ea(b, w, L, u); ((R.type = zi), (R.needsUpdate = !0)); let F = x * 4; for (let T = 0; T < u; T++) { let I = p[T], G = g[T], q = _[T], B = w * L * 4 * T; for (let Z = 0; Z < I.count; Z++) { let W = Z * F; if (f === !0) (s.fromBufferAttribute(I, Z), (b[B + W + 0] = s.x), (b[B + W + 1] = s.y), (b[B + W + 2] = s.z), (b[B + W + 3] = 0)); if (m === !0) (s.fromBufferAttribute(G, Z), (b[B + W + 4] = s.x), (b[B + W + 5] = s.y), (b[B + W + 6] = s.z), (b[B + W + 7] = 0)); if (y === !0) (s.fromBufferAttribute(q, Z), (b[B + W + 8] = s.x), (b[B + W + 9] = s.y), (b[B + W + 10] = s.z), (b[B + W + 11] = q.itemSize === 4 ? s.w : 1)); } } ((d = { count: u, texture: R, size: new ve(w, L) }), i.set(a, d), a.addEventListener("dispose", M)); } if (o.isInstancedMesh === !0 && o.morphTexture !== null) l.getUniforms().setValue(e, "morphTexture", o.morphTexture, n); else { let f = 0; for (let y = 0; y < c.length; y++) f += c[y]; let m = a.morphTargetsRelative ? 1 : 1 - f; (l.getUniforms().setValue(e, "morphTargetBaseInfluence", m), l.getUniforms().setValue(e, "morphTargetInfluences", c)); } (l.getUniforms().setValue(e, "morphTargetsTexture", d.texture, n), l.getUniforms().setValue(e, "morphTargetsTextureSize", d.size)); } return { update: r }; } function ux(e, t, n, i) { let s = new WeakMap(); function r(l) { let c = i.render.frame, h = l.geometry, u = t.get(l, h); if (s.get(u) !== c) (t.update(u), s.set(u, c)); if (l.isInstancedMesh) { if (l.hasEventListener("dispose", a) === !1) l.addEventListener("dispose", a); if (s.get(l) !== c) { if ((n.update(l.instanceMatrix, e.ARRAY_BUFFER), l.instanceColor !== null)) n.update(l.instanceColor, e.ARRAY_BUFFER); s.set(l, c); } } if (l.isSkinnedMesh) { let d = l.skeleton; if (s.get(d) !== c) (d.update(), s.set(d, c)); } return u; } function o() { s = new WeakMap(); } function a(l) { let c = l.target; if ((c.removeEventListener("dispose", a), n.remove(c.instanceMatrix), c.instanceColor !== null)) n.remove(c.instanceColor); } return { update: r, dispose: o }; } var Qd = new Rt(), Nd = new oa(1, 1), ef = new ea(), tf = new lc(), nf = new ia(), Fd = [], Od = [], kd = new Float32Array(16), zd = new Float32Array(9), Hd = new Float32Array(4); function ur(e, t, n) { let i = e[0]; if (i <= 0 || i > 0) return e; let s = t * n, r = Fd[s]; if (r === void 0) ((r = new Float32Array(s)), (Fd[s] = r)); if (t !== 0) { i.toArray(r, 0); for (let o = 1, a = 0; o !== t; ++o) ((a += n), e[o].toArray(r, a)); } return r; } function Nt(e, t) { if (e.length !== t.length) return !1; for (let n = 0, i = e.length; n < i; n++) if (e[n] !== t[n]) return !1; return !0; } function Ft(e, t) { for (let n = 0, i = t.length; n < i; n++) e[n] = t[n]; } function va(e, t) { let n = Od[t]; if (n === void 0) ((n = new Int32Array(t)), (Od[t] = n)); for (let i = 0; i !== t; ++i) n[i] = e.allocateTextureUnit(); return n; } function dx(e, t) { let n = this.cache; if (n[0] === t) return; (e.uniform1f(this.addr, t), (n[0] = t)); } function fx(e, t) { let n = this.cache; if (t.x !== void 0) { if (n[0] !== t.x || n[1] !== t.y) (e.uniform2f(this.addr, t.x, t.y), (n[0] = t.x), (n[1] = t.y)); } else { if (Nt(n, t)) return; (e.uniform2fv(this.addr, t), Ft(n, t)); } } function px(e, t) { let n = this.cache; if (t.x !== void 0) { if (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z) (e.uniform3f(this.addr, t.x, t.y, t.z), (n[0] = t.x), (n[1] = t.y), (n[2] = t.z)); } else if (t.r !== void 0) { if (n[0] !== t.r || n[1] !== t.g || n[2] !== t.b) (e.uniform3f(this.addr, t.r, t.g, t.b), (n[0] = t.r), (n[1] = t.g), (n[2] = t.b)); } else { if (Nt(n, t)) return; (e.uniform3fv(this.addr, t), Ft(n, t)); } } function mx(e, t) { let n = this.cache; if (t.x !== void 0) { if (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z || n[3] !== t.w) (e.uniform4f(this.addr, t.x, t.y, t.z, t.w), (n[0] = t.x), (n[1] = t.y), (n[2] = t.z), (n[3] = t.w)); } else { if (Nt(n, t)) return; (e.uniform4fv(this.addr, t), Ft(n, t)); } } function gx(e, t) { let n = this.cache, i = t.elements; if (i === void 0) { if (Nt(n, t)) return; (e.uniformMatrix2fv(this.addr, !1, t), Ft(n, t)); } else { if (Nt(n, i)) return; (Hd.set(i), e.uniformMatrix2fv(this.addr, !1, Hd), Ft(n, i)); } } function yx(e, t) { let n = this.cache, i = t.elements; if (i === void 0) { if (Nt(n, t)) return; (e.uniformMatrix3fv(this.addr, !1, t), Ft(n, t)); } else { if (Nt(n, i)) return; (zd.set(i), e.uniformMatrix3fv(this.addr, !1, zd), Ft(n, i)); } } function xx(e, t) { let n = this.cache, i = t.elements; if (i === void 0) { if (Nt(n, t)) return; (e.uniformMatrix4fv(this.addr, !1, t), Ft(n, t)); } else { if (Nt(n, i)) return; (kd.set(i), e.uniformMatrix4fv(this.addr, !1, kd), Ft(n, i)); } } function vx(e, t) { let n = this.cache; if (n[0] === t) return; (e.uniform1i(this.addr, t), (n[0] = t)); } function _x(e, t) { let n = this.cache; if (t.x !== void 0) { if (n[0] !== t.x || n[1] !== t.y) (e.uniform2i(this.addr, t.x, t.y), (n[0] = t.x), (n[1] = t.y)); } else { if (Nt(n, t)) return; (e.uniform2iv(this.addr, t), Ft(n, t)); } } function Sx(e, t) { let n = this.cache; if (t.x !== void 0) { if (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z) (e.uniform3i(this.addr, t.x, t.y, t.z), (n[0] = t.x), (n[1] = t.y), (n[2] = t.z)); } else { if (Nt(n, t)) return; (e.uniform3iv(this.addr, t), Ft(n, t)); } } function bx(e, t) { let n = this.cache; if (t.x !== void 0) { if (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z || n[3] !== t.w) (e.uniform4i(this.addr, t.x, t.y, t.z, t.w), (n[0] = t.x), (n[1] = t.y), (n[2] = t.z), (n[3] = t.w)); } else { if (Nt(n, t)) return; (e.uniform4iv(this.addr, t), Ft(n, t)); } } function Mx(e, t) { let n = this.cache; if (n[0] === t) return; (e.uniform1ui(this.addr, t), (n[0] = t)); } function wx(e, t) { let n = this.cache; if (t.x !== void 0) { if (n[0] !== t.x || n[1] !== t.y) (e.uniform2ui(this.addr, t.x, t.y), (n[0] = t.x), (n[1] = t.y)); } else { if (Nt(n, t)) return; (e.uniform2uiv(this.addr, t), Ft(n, t)); } } function Tx(e, t) { let n = this.cache; if (t.x !== void 0) { if (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z) (e.uniform3ui(this.addr, t.x, t.y, t.z), (n[0] = t.x), (n[1] = t.y), (n[2] = t.z)); } else { if (Nt(n, t)) return; (e.uniform3uiv(this.addr, t), Ft(n, t)); } } function Ex(e, t) { let n = this.cache; if (t.x !== void 0) { if (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z || n[3] !== t.w) (e.uniform4ui(this.addr, t.x, t.y, t.z, t.w), (n[0] = t.x), (n[1] = t.y), (n[2] = t.z), (n[3] = t.w)); } else { if (Nt(n, t)) return; (e.uniform4uiv(this.addr, t), Ft(n, t)); } } function Ax(e, t, n) { let i = this.cache, s = n.allocateTextureUnit(); if (i[0] !== s) (e.uniform1i(this.addr, s), (i[0] = s)); let r; if (this.type === e.SAMPLER_2D_SHADOW) ((Nd.compareFunction = tc), (r = Nd)); else r = Qd; n.setTexture2D(t || r, s); } function Rx(e, t, n) { let i = this.cache, s = n.allocateTextureUnit(); if (i[0] !== s) (e.uniform1i(this.addr, s), (i[0] = s)); n.setTexture3D(t || tf, s); } function Lx(e, t, n) { let i = this.cache, s = n.allocateTextureUnit(); if (i[0] !== s) (e.uniform1i(this.addr, s), (i[0] = s)); n.setTextureCube(t || nf, s); } function Cx(e, t, n) { let i = this.cache, s = n.allocateTextureUnit(); if (i[0] !== s) (e.uniform1i(this.addr, s), (i[0] = s)); n.setTexture2DArray(t || ef, s); } function Ix(e) { switch (e) { case 5126: return dx; case 35664: return fx; case 35665: return px; case 35666: return mx; case 35674: return gx; case 35675: return yx; case 35676: return xx; case 5124: case 35670: return vx; case 35667: case 35671: return _x; case 35668: case 35672: return Sx; case 35669: case 35673: return bx; case 5125: return Mx; case 36294: return wx; case 36295: return Tx; case 36296: return Ex; case 35678: case 36198: case 36298: case 36306: case 35682: return Ax; case 35679: case 36299: case 36307: return Rx; case 35680: case 36300: case 36308: case 36293: return Lx; case 36289: case 36303: case 36311: case 36292: return Cx; } } function Px(e, t) { e.uniform1fv(this.addr, t); } function Dx(e, t) { let n = ur(t, this.size, 2); e.uniform2fv(this.addr, n); } function Ux(e, t) { let n = ur(t, this.size, 3); e.uniform3fv(this.addr, n); } function Nx(e, t) { let n = ur(t, this.size, 4); e.uniform4fv(this.addr, n); } function Fx(e, t) { let n = ur(t, this.size, 4); e.uniformMatrix2fv(this.addr, !1, n); } function Ox(e, t) { let n = ur(t, this.size, 9); e.uniformMatrix3fv(this.addr, !1, n); } function kx(e, t) { let n = ur(t, this.size, 16); e.uniformMatrix4fv(this.addr, !1, n); } function zx(e, t) { e.uniform1iv(this.addr, t); } function Hx(e, t) { e.uniform2iv(this.addr, t); } function Bx(e, t) { e.uniform3iv(this.addr, t); } function Gx(e, t) { e.uniform4iv(this.addr, t); } function Vx(e, t) { e.uniform1uiv(this.addr, t); } function Wx(e, t) { e.uniform2uiv(this.addr, t); } function Xx(e, t) { e.uniform3uiv(this.addr, t); } function qx(e, t) { e.uniform4uiv(this.addr, t); } function Yx(e, t, n) { let i = this.cache, s = t.length, r = va(n, s); if (!Nt(i, r)) (e.uniform1iv(this.addr, r), Ft(i, r)); for (let o = 0; o !== s; ++o) n.setTexture2D(t[o] || Qd, r[o]); } function jx(e, t, n) { let i = this.cache, s = t.length, r = va(n, s); if (!Nt(i, r)) (e.uniform1iv(this.addr, r), Ft(i, r)); for (let o = 0; o !== s; ++o) n.setTexture3D(t[o] || tf, r[o]); } function Zx(e, t, n) { let i = this.cache, s = t.length, r = va(n, s); if (!Nt(i, r)) (e.uniform1iv(this.addr, r), Ft(i, r)); for (let o = 0; o !== s; ++o) n.setTextureCube(t[o] || nf, r[o]); } function Kx(e, t, n) { let i = this.cache, s = t.length, r = va(n, s); if (!Nt(i, r)) (e.uniform1iv(this.addr, r), Ft(i, r)); for (let o = 0; o !== s; ++o) n.setTexture2DArray(t[o] || ef, r[o]); } function $x(e) { switch (e) { case 5126: return Px; case 35664: return Dx; case 35665: return Ux; case 35666: return Nx; case 35674: return Fx; case 35675: return Ox; case 35676: return kx; case 5124: case 35670: return zx; case 35667: case 35671: return Hx; case 35668: case 35672: return Bx; case 35669: case 35673: return Gx; case 5125: return Vx; case 36294: return Wx; case 36295: return Xx; case 36296: return qx; case 35678: case 36198: case 36298: case 36306: case 35682: return Yx; case 35679: case 36299: case 36307: return jx; case 35680: case 36300: case 36308: case 36293: return Zx; case 36289: case 36303: case 36311: case 36292: return Kx; } } class sf { constructor(e, t, n) { ((this.id = e), (this.addr = n), (this.cache = []), (this.type = t.type), (this.setValue = Ix(t.type))); } } class rf { constructor(e, t, n) { ((this.id = e), (this.addr = n), (this.cache = []), (this.type = t.type), (this.size = t.size), (this.setValue = $x(t.type))); } } class of { constructor(e) { ((this.id = e), (this.seq = []), (this.map = {})); } setValue(e, t, n) { let i = this.seq; for (let s = 0, r = i.length; s !== r; ++s) { let o = i[s]; o.setValue(e, t[o.id], n); } } } var Cc = /(\w+)(\])?(\[|\.)?/g; function Bd(e, t) { (e.seq.push(t), (e.map[t.id] = t)); } function Jx(e, t, n) { let i = e.name, s = i.length; Cc.lastIndex = 0; while (!0) { let r = Cc.exec(i), o = Cc.lastIndex, a = r[1], l = r[2] === "]", c = r[3]; if (l) a = a | 0; if (c === void 0 || (c === "[" && o + 2 === s)) { Bd(n, c === void 0 ? new sf(a, e, t) : new rf(a, e, t)); break; } else { let u = n.map[a]; if (u === void 0) ((u = new of(a)), Bd(n, u)); n = u; } } } class Zr { constructor(e, t) { ((this.seq = []), (this.map = {})); let n = e.getProgramParameter(t, e.ACTIVE_UNIFORMS); for (let i = 0; i < n; ++i) { let s = e.getActiveUniform(t, i), r = e.getUniformLocation(t, s.name); Jx(s, r, this); } } setValue(e, t, n, i) { let s = this.map[t]; if (s !== void 0) s.setValue(e, n, i); } setOptional(e, t, n) { let i = t[n]; if (i !== void 0) this.setValue(e, n, i); } static upload(e, t, n, i) { for (let s = 0, r = t.length; s !== r; ++s) { let o = t[s], a = n[o.id]; if (a.needsUpdate !== !1) o.setValue(e, a.value, i); } } static seqWithValue(e, t) { let n = []; for (let i = 0, s = e.length; i !== s; ++i) { let r = e[i]; if (r.id in t) n.push(r); } return n; } } function Gd(e, t, n) { let i = e.createShader(t); return (e.shaderSource(i, n), e.compileShader(i), i); } var Qx = 37297, ev = 0; function tv(e, t) { let n = e.split(` `), i = [], s = Math.max(t - 6, 0), r = Math.min(t + 6, n.length); for (let o = s; o < r; o++) { let a = o + 1; i.push(`${a === t ? ">" : " "} ${a}: ${n[o]}`); } return i.join(` `); } var Vd = new Be(); function nv(e) { ke._getMatrix(Vd, ke.workingColorSpace, e); let t = `mat3( ${Vd.elements.map((n) => n.toFixed(4))} )`; switch (ke.getTransfer(e)) { case ec: return [t, "LinearTransferOETF"]; case xt: return [t, "sRGBTransferOETF"]; default: return (console.warn("THREE.WebGLProgram: Unsupported color space: ", e), [t, "LinearTransferOETF"]); } } function Wd(e, t, n) { let i = e.getShaderParameter(t, e.COMPILE_STATUS), r = (e.getShaderInfoLog(t) || "").trim(); if (i && r === "") return ""; let o = /ERROR: 0:(\d+)/.exec(r); if (o) { let a = parseInt(o[1]); return ( n.toUpperCase() + ` ` + r + ` ` + tv(e.getShaderSource(t), a) ); } else return r; } function iv(e, t) { let n = nv(t); return [`vec4 ${e}( vec4 value ) {`, ` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`, "}"].join(` `); } function sv(e, t) { let n; switch (t) { case Xu: n = "Linear"; break; case qu: n = "Reinhard"; break; case Yu: n = "Cineon"; break; case Ys: n = "ACESFilmic"; break; case Wo: n = "AgX"; break; case Fr: n = "Neutral"; break; case ju: n = "Custom"; break; default: (console.warn("THREE.WebGLProgram: Unsupported toneMapping:", t), (n = "Linear")); } return "vec3 " + e + "( vec3 color ) { return " + n + "ToneMapping( color ); }"; } var xa = new E(); function rv() { ke.getLuminanceCoefficients(xa); let e = xa.x.toFixed(4), t = xa.y.toFixed(4), n = xa.z.toFixed(4); return [ "float luminance( const in vec3 rgb ) {", ` const vec3 weights = vec3( ${e}, ${t}, ${n} );`, "\treturn dot( weights, rgb );", "}", ].join(` `); } function ov(e) { return [ e.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "", e.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : "", ].filter(jr).join(` `); } function av(e) { let t = []; for (let n in e) { let i = e[n]; if (i === !1) continue; t.push("#define " + n + " " + i); } return t.join(` `); } function lv(e, t) { let n = {}, i = e.getProgramParameter(t, e.ACTIVE_ATTRIBUTES); for (let s = 0; s < i; s++) { let r = e.getActiveAttrib(t, s), o = r.name, a = 1; if (r.type === e.FLOAT_MAT2) a = 2; if (r.type === e.FLOAT_MAT3) a = 3; if (r.type === e.FLOAT_MAT4) a = 4; n[o] = { type: r.type, location: e.getAttribLocation(t, o), locationSize: a }; } return n; } function jr(e) { return e !== ""; } function Xd(e, t) { let n = t.numSpotLightShadows + t.numSpotLightMaps - t.numSpotLightShadowsWithMaps; return e .replace(/NUM_DIR_LIGHTS/g, t.numDirLights) .replace(/NUM_SPOT_LIGHTS/g, t.numSpotLights) .replace(/NUM_SPOT_LIGHT_MAPS/g, t.numSpotLightMaps) .replace(/NUM_SPOT_LIGHT_COORDS/g, n) .replace(/NUM_RECT_AREA_LIGHTS/g, t.numRectAreaLights) .replace(/NUM_POINT_LIGHTS/g, t.numPointLights) .replace(/NUM_HEMI_LIGHTS/g, t.numHemiLights) .replace(/NUM_DIR_LIGHT_SHADOWS/g, t.numDirLightShadows) .replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, t.numSpotLightShadowsWithMaps) .replace(/NUM_SPOT_LIGHT_SHADOWS/g, t.numSpotLightShadows) .replace(/NUM_POINT_LIGHT_SHADOWS/g, t.numPointLightShadows); } function qd(e, t) { return e .replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes) .replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection); } var cv = /^[ \t]*#include +<([\w\d./]+)>/gm; function Ic(e) { return e.replace(cv, uv); } var hv = new Map(); function uv(e, t) { let n = Ve[t]; if (n === void 0) { let i = hv.get(t); if (i !== void 0) ((n = Ve[i]), console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', t, i)); else throw Error("Can not resolve #include <" + t + ">"); } return Ic(n); } var dv = /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g; function Yd(e) { return e.replace(dv, fv); } function fv(e, t, n, i) { let s = ""; for (let r = parseInt(t); r < parseInt(n); r++) s += i.replace(/\[\s*i\s*\]/g, "[ " + r + " ]").replace(/UNROLLED_LOOP_INDEX/g, r); return s; } function jd(e) { let t = `precision ${e.precision} float; precision ${e.precision} int; precision ${e.precision} sampler2D; precision ${e.precision} samplerCube; precision ${e.precision} sampler3D; precision ${e.precision} sampler2DArray; precision ${e.precision} sampler2DShadow; precision ${e.precision} samplerCubeShadow; precision ${e.precision} sampler2DArrayShadow; precision ${e.precision} isampler2D; precision ${e.precision} isampler3D; precision ${e.precision} isamplerCube; precision ${e.precision} isampler2DArray; precision ${e.precision} usampler2D; precision ${e.precision} usampler3D; precision ${e.precision} usamplerCube; precision ${e.precision} usampler2DArray; `; if (e.precision === "highp") t += ` #define HIGH_PRECISION`; else if (e.precision === "mediump") t += ` #define MEDIUM_PRECISION`; else if (e.precision === "lowp") t += ` #define LOW_PRECISION`; return t; } function pv(e) { let t = "SHADOWMAP_TYPE_BASIC"; if (e.shadowMapType === fl) t = "SHADOWMAP_TYPE_PCF"; else if (e.shadowMapType === Fo) t = "SHADOWMAP_TYPE_PCF_SOFT"; else if (e.shadowMapType === qn) t = "SHADOWMAP_TYPE_VSM"; return t; } function mv(e) { let t = "ENVMAP_TYPE_CUBE"; if (e.envMap) switch (e.envMapMode) { case js: case us: t = "ENVMAP_TYPE_CUBE"; break; case Or: t = "ENVMAP_TYPE_CUBE_UV"; break; } return t; } function gv(e) { let t = "ENVMAP_MODE_REFLECTION"; if (e.envMap) switch (e.envMapMode) { case us: t = "ENVMAP_MODE_REFRACTION"; break; } return t; } function yv(e) { let t = "ENVMAP_BLENDING_NONE"; if (e.envMap) switch (e.combine) { case Gu: t = "ENVMAP_BLENDING_MULTIPLY"; break; case Vu: t = "ENVMAP_BLENDING_MIX"; break; case Wu: t = "ENVMAP_BLENDING_ADD"; break; } return t; } function xv(e) { let t = e.envMapCubeUVHeight; if (t === null) return null; let n = Math.log2(t) - 2, i = 1 / t; return { texelWidth: 1 / (3 * Math.max(Math.pow(2, n), 112)), texelHeight: i, maxMip: n }; } function vv(e, t, n, i) { let s = e.getContext(), { defines: r, vertexShader: o, fragmentShader: a } = n, l = pv(n), c = mv(n), h = gv(n), u = yv(n), d = xv(n), f = ov(n), m = av(r), y = s.createProgram(), p, g, _ = n.glslVersion ? "#version " + n.glslVersion + ` ` : ""; if (n.isRawShaderMaterial) { if ( ((p = ["#define SHADER_TYPE " + n.shaderType, "#define SHADER_NAME " + n.shaderName, m].filter(jr).join(` `)), p.length > 0) ) p += ` `; if ( ((g = ["#define SHADER_TYPE " + n.shaderType, "#define SHADER_NAME " + n.shaderName, m].filter(jr).join(` `)), g.length > 0) ) g += ` `; } else ((p = [ jd(n), "#define SHADER_TYPE " + n.shaderType, "#define SHADER_NAME " + n.shaderName, m, n.extensionClipCullDistance ? "#define USE_CLIP_DISTANCE" : "", n.batching ? "#define USE_BATCHING" : "", n.batchingColor ? "#define USE_BATCHING_COLOR" : "", n.instancing ? "#define USE_INSTANCING" : "", n.instancingColor ? "#define USE_INSTANCING_COLOR" : "", n.instancingMorph ? "#define USE_INSTANCING_MORPH" : "", n.useFog && n.fog ? "#define USE_FOG" : "", n.useFog && n.fogExp2 ? "#define FOG_EXP2" : "", n.map ? "#define USE_MAP" : "", n.envMap ? "#define USE_ENVMAP" : "", n.envMap ? "#define " + h : "", n.lightMap ? "#define USE_LIGHTMAP" : "", n.aoMap ? "#define USE_AOMAP" : "", n.bumpMap ? "#define USE_BUMPMAP" : "", n.normalMap ? "#define USE_NORMALMAP" : "", n.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "", n.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "", n.displacementMap ? "#define USE_DISPLACEMENTMAP" : "", n.emissiveMap ? "#define USE_EMISSIVEMAP" : "", n.anisotropy ? "#define USE_ANISOTROPY" : "", n.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "", n.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", n.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", n.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", n.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "", n.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "", n.specularMap ? "#define USE_SPECULARMAP" : "", n.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "", n.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "", n.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", n.metalnessMap ? "#define USE_METALNESSMAP" : "", n.alphaMap ? "#define USE_ALPHAMAP" : "", n.alphaHash ? "#define USE_ALPHAHASH" : "", n.transmission ? "#define USE_TRANSMISSION" : "", n.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", n.thicknessMap ? "#define USE_THICKNESSMAP" : "", n.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "", n.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "", n.mapUv ? "#define MAP_UV " + n.mapUv : "", n.alphaMapUv ? "#define ALPHAMAP_UV " + n.alphaMapUv : "", n.lightMapUv ? "#define LIGHTMAP_UV " + n.lightMapUv : "", n.aoMapUv ? "#define AOMAP_UV " + n.aoMapUv : "", n.emissiveMapUv ? "#define EMISSIVEMAP_UV " + n.emissiveMapUv : "", n.bumpMapUv ? "#define BUMPMAP_UV " + n.bumpMapUv : "", n.normalMapUv ? "#define NORMALMAP_UV " + n.normalMapUv : "", n.displacementMapUv ? "#define DISPLACEMENTMAP_UV " + n.displacementMapUv : "", n.metalnessMapUv ? "#define METALNESSMAP_UV " + n.metalnessMapUv : "", n.roughnessMapUv ? "#define ROUGHNESSMAP_UV " + n.roughnessMapUv : "", n.anisotropyMapUv ? "#define ANISOTROPYMAP_UV " + n.anisotropyMapUv : "", n.clearcoatMapUv ? "#define CLEARCOATMAP_UV " + n.clearcoatMapUv : "", n.clearcoatNormalMapUv ? "#define CLEARCOAT_NORMALMAP_UV " + n.clearcoatNormalMapUv : "", n.clearcoatRoughnessMapUv ? "#define CLEARCOAT_ROUGHNESSMAP_UV " + n.clearcoatRoughnessMapUv : "", n.iridescenceMapUv ? "#define IRIDESCENCEMAP_UV " + n.iridescenceMapUv : "", n.iridescenceThicknessMapUv ? "#define IRIDESCENCE_THICKNESSMAP_UV " + n.iridescenceThicknessMapUv : "", n.sheenColorMapUv ? "#define SHEEN_COLORMAP_UV " + n.sheenColorMapUv : "", n.sheenRoughnessMapUv ? "#define SHEEN_ROUGHNESSMAP_UV " + n.sheenRoughnessMapUv : "", n.specularMapUv ? "#define SPECULARMAP_UV " + n.specularMapUv : "", n.specularColorMapUv ? "#define SPECULAR_COLORMAP_UV " + n.specularColorMapUv : "", n.specularIntensityMapUv ? "#define SPECULAR_INTENSITYMAP_UV " + n.specularIntensityMapUv : "", n.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + n.transmissionMapUv : "", n.thicknessMapUv ? "#define THICKNESSMAP_UV " + n.thicknessMapUv : "", n.vertexTangents && n.flatShading === !1 ? "#define USE_TANGENT" : "", n.vertexColors ? "#define USE_COLOR" : "", n.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", n.vertexUv1s ? "#define USE_UV1" : "", n.vertexUv2s ? "#define USE_UV2" : "", n.vertexUv3s ? "#define USE_UV3" : "", n.pointsUvs ? "#define USE_POINTS_UV" : "", n.flatShading ? "#define FLAT_SHADED" : "", n.skinning ? "#define USE_SKINNING" : "", n.morphTargets ? "#define USE_MORPHTARGETS" : "", n.morphNormals && n.flatShading === !1 ? "#define USE_MORPHNORMALS" : "", n.morphColors ? "#define USE_MORPHCOLORS" : "", n.morphTargetsCount > 0 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + n.morphTextureStride : "", n.morphTargetsCount > 0 ? "#define MORPHTARGETS_COUNT " + n.morphTargetsCount : "", n.doubleSided ? "#define DOUBLE_SIDED" : "", n.flipSided ? "#define FLIP_SIDED" : "", n.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", n.shadowMapEnabled ? "#define " + l : "", n.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "", n.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "", n.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "", n.reversedDepthBuffer ? "#define USE_REVERSED_DEPTH_BUFFER" : "", "uniform mat4 modelMatrix;", "uniform mat4 modelViewMatrix;", "uniform mat4 projectionMatrix;", "uniform mat4 viewMatrix;", "uniform mat3 normalMatrix;", "uniform vec3 cameraPosition;", "uniform bool isOrthographic;", "#ifdef USE_INSTANCING", "\tattribute mat4 instanceMatrix;", "#endif", "#ifdef USE_INSTANCING_COLOR", "\tattribute vec3 instanceColor;", "#endif", "#ifdef USE_INSTANCING_MORPH", "\tuniform sampler2D morphTexture;", "#endif", "attribute vec3 position;", "attribute vec3 normal;", "attribute vec2 uv;", "#ifdef USE_UV1", "\tattribute vec2 uv1;", "#endif", "#ifdef USE_UV2", "\tattribute vec2 uv2;", "#endif", "#ifdef USE_UV3", "\tattribute vec2 uv3;", "#endif", "#ifdef USE_TANGENT", "\tattribute vec4 tangent;", "#endif", "#if defined( USE_COLOR_ALPHA )", "\tattribute vec4 color;", "#elif defined( USE_COLOR )", "\tattribute vec3 color;", "#endif", "#ifdef USE_SKINNING", "\tattribute vec4 skinIndex;", "\tattribute vec4 skinWeight;", "#endif", ` `, ].filter(jr).join(` `)), (g = [ jd(n), "#define SHADER_TYPE " + n.shaderType, "#define SHADER_NAME " + n.shaderName, m, n.useFog && n.fog ? "#define USE_FOG" : "", n.useFog && n.fogExp2 ? "#define FOG_EXP2" : "", n.alphaToCoverage ? "#define ALPHA_TO_COVERAGE" : "", n.map ? "#define USE_MAP" : "", n.matcap ? "#define USE_MATCAP" : "", n.envMap ? "#define USE_ENVMAP" : "", n.envMap ? "#define " + c : "", n.envMap ? "#define " + h : "", n.envMap ? "#define " + u : "", d ? "#define CUBEUV_TEXEL_WIDTH " + d.texelWidth : "", d ? "#define CUBEUV_TEXEL_HEIGHT " + d.texelHeight : "", d ? "#define CUBEUV_MAX_MIP " + d.maxMip + ".0" : "", n.lightMap ? "#define USE_LIGHTMAP" : "", n.aoMap ? "#define USE_AOMAP" : "", n.bumpMap ? "#define USE_BUMPMAP" : "", n.normalMap ? "#define USE_NORMALMAP" : "", n.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "", n.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "", n.emissiveMap ? "#define USE_EMISSIVEMAP" : "", n.anisotropy ? "#define USE_ANISOTROPY" : "", n.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "", n.clearcoat ? "#define USE_CLEARCOAT" : "", n.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", n.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", n.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", n.dispersion ? "#define USE_DISPERSION" : "", n.iridescence ? "#define USE_IRIDESCENCE" : "", n.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "", n.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "", n.specularMap ? "#define USE_SPECULARMAP" : "", n.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "", n.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "", n.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", n.metalnessMap ? "#define USE_METALNESSMAP" : "", n.alphaMap ? "#define USE_ALPHAMAP" : "", n.alphaTest ? "#define USE_ALPHATEST" : "", n.alphaHash ? "#define USE_ALPHAHASH" : "", n.sheen ? "#define USE_SHEEN" : "", n.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "", n.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "", n.transmission ? "#define USE_TRANSMISSION" : "", n.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", n.thicknessMap ? "#define USE_THICKNESSMAP" : "", n.vertexTangents && n.flatShading === !1 ? "#define USE_TANGENT" : "", n.vertexColors || n.instancingColor || n.batchingColor ? "#define USE_COLOR" : "", n.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", n.vertexUv1s ? "#define USE_UV1" : "", n.vertexUv2s ? "#define USE_UV2" : "", n.vertexUv3s ? "#define USE_UV3" : "", n.pointsUvs ? "#define USE_POINTS_UV" : "", n.gradientMap ? "#define USE_GRADIENTMAP" : "", n.flatShading ? "#define FLAT_SHADED" : "", n.doubleSided ? "#define DOUBLE_SIDED" : "", n.flipSided ? "#define FLIP_SIDED" : "", n.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", n.shadowMapEnabled ? "#define " + l : "", n.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "", n.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "", n.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "", n.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "", n.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "", n.reversedDepthBuffer ? "#define USE_REVERSED_DEPTH_BUFFER" : "", "uniform mat4 viewMatrix;", "uniform vec3 cameraPosition;", "uniform bool isOrthographic;", n.toneMapping !== mi ? "#define TONE_MAPPING" : "", n.toneMapping !== mi ? Ve.tonemapping_pars_fragment : "", n.toneMapping !== mi ? sv("toneMapping", n.toneMapping) : "", n.dithering ? "#define DITHERING" : "", n.opaque ? "#define OPAQUE" : "", Ve.colorspace_pars_fragment, iv("linearToOutputTexel", n.outputColorSpace), rv(), n.useDepthPacking ? "#define DEPTH_PACKING " + n.depthPacking : "", ` `, ].filter(jr).join(` `))); if ( ((o = Ic(o)), (o = Xd(o, n)), (o = qd(o, n)), (a = Ic(a)), (a = Xd(a, n)), (a = qd(a, n)), (o = Yd(o)), (a = Yd(a)), n.isRawShaderMaterial !== !0) ) ((_ = `#version 300 es `), (p = [f, "#define attribute in", "#define varying out", "#define texture2D texture"].join(` `) + ` ` + p), (g = [ "#define varying in", n.glslVersion === nc ? "" : "layout(location = 0) out highp vec4 pc_fragColor;", n.glslVersion === nc ? "" : "#define gl_FragColor pc_fragColor", "#define gl_FragDepthEXT gl_FragDepth", "#define texture2D texture", "#define textureCube texture", "#define texture2DProj textureProj", "#define texture2DLodEXT textureLod", "#define texture2DProjLodEXT textureProjLod", "#define textureCubeLodEXT textureLod", "#define texture2DGradEXT textureGrad", "#define texture2DProjGradEXT textureProjGrad", "#define textureCubeGradEXT textureGrad", ].join(` `) + ` ` + g)); let x = _ + p + o, w = _ + g + a, L = Gd(s, s.VERTEX_SHADER, x), b = Gd(s, s.FRAGMENT_SHADER, w); if ((s.attachShader(y, L), s.attachShader(y, b), n.index0AttributeName !== void 0)) s.bindAttribLocation(y, 0, n.index0AttributeName); else if (n.morphTargets === !0) s.bindAttribLocation(y, 0, "position"); s.linkProgram(y); function R(I) { if (e.debug.checkShaderErrors) { let G = s.getProgramInfoLog(y) || "", q = s.getShaderInfoLog(L) || "", B = s.getShaderInfoLog(b) || "", Z = G.trim(), W = q.trim(), K = B.trim(), V = !0, se = !0; if (s.getProgramParameter(y, s.LINK_STATUS) === !1) if (((V = !1), typeof e.debug.onShaderError === "function")) e.debug.onShaderError(s, y, L, b); else { let ce = Wd(s, L, "vertex"), Pe = Wd(s, b, "fragment"); console.error( "THREE.WebGLProgram: Shader Error " + s.getError() + " - VALIDATE_STATUS " + s.getProgramParameter(y, s.VALIDATE_STATUS) + ` Material Name: ` + I.name + ` Material Type: ` + I.type + ` Program Info Log: ` + Z + ` ` + ce + ` ` + Pe, ); } else if (Z !== "") console.warn("THREE.WebGLProgram: Program Info Log:", Z); else if (W === "" || K === "") se = !1; if (se) I.diagnostics = { runnable: V, programLog: Z, vertexShader: { log: W, prefix: p }, fragmentShader: { log: K, prefix: g }, }; } (s.deleteShader(L), s.deleteShader(b), (F = new Zr(s, y)), (M = lv(s, y))); } let F; this.getUniforms = function () { if (F === void 0) R(this); return F; }; let M; this.getAttributes = function () { if (M === void 0) R(this); return M; }; let T = n.rendererExtensionParallelShaderCompile === !1; return ( (this.isReady = function () { if (T === !1) T = s.getProgramParameter(y, Qx); return T; }), (this.destroy = function () { (i.releaseStatesOfProgram(this), s.deleteProgram(y), (this.program = void 0)); }), (this.type = n.shaderType), (this.name = n.shaderName), (this.id = ev++), (this.cacheKey = t), (this.usedTimes = 1), (this.program = y), (this.vertexShader = L), (this.fragmentShader = b), this ); } var _v = 0; class af { constructor() { ((this.shaderCache = new Map()), (this.materialCache = new Map())); } update(e) { let { vertexShader: t, fragmentShader: n } = e, i = this._getShaderStage(t), s = this._getShaderStage(n), r = this._getShaderCacheForMaterial(e); if (r.has(i) === !1) (r.add(i), i.usedTimes++); if (r.has(s) === !1) (r.add(s), s.usedTimes++); return this; } remove(e) { let t = this.materialCache.get(e); for (let n of t) if ((n.usedTimes--, n.usedTimes === 0)) this.shaderCache.delete(n.code); return (this.materialCache.delete(e), this); } getVertexShaderID(e) { return this._getShaderStage(e.vertexShader).id; } getFragmentShaderID(e) { return this._getShaderStage(e.fragmentShader).id; } dispose() { (this.shaderCache.clear(), this.materialCache.clear()); } _getShaderCacheForMaterial(e) { let t = this.materialCache, n = t.get(e); if (n === void 0) ((n = new Set()), t.set(e, n)); return n; } _getShaderStage(e) { let t = this.shaderCache, n = t.get(e); if (n === void 0) ((n = new lf(e)), t.set(e, n)); return n; } } class lf { constructor(e) { ((this.id = _v++), (this.code = e), (this.usedTimes = 0)); } } function Sv(e, t, n, i, s, r, o) { let a = new Vr(), l = new af(), c = new Set(), h = [], { logarithmicDepthBuffer: u, vertexTextures: d, precision: f } = s, m = { MeshDepthMaterial: "depth", MeshDistanceMaterial: "distanceRGBA", MeshNormalMaterial: "normal", MeshBasicMaterial: "basic", MeshLambertMaterial: "lambert", MeshPhongMaterial: "phong", MeshToonMaterial: "toon", MeshStandardMaterial: "physical", MeshPhysicalMaterial: "physical", MeshMatcapMaterial: "matcap", LineBasicMaterial: "basic", LineDashedMaterial: "dashed", PointsMaterial: "points", ShadowMaterial: "shadow", SpriteMaterial: "sprite", }; function y(M) { if ((c.add(M), M === 0)) return "uv"; return `uv${M}`; } function p(M, T, I, G, q) { let B = G.fog, Z = q.geometry, W = M.isMeshStandardMaterial ? G.environment : null, K = (M.isMeshStandardMaterial ? n : t).get(M.envMap || W), V = !!K && K.mapping === Or ? K.image.height : null, se = m[M.type]; if (M.precision !== null) { if (((f = s.getMaxPrecision(M.precision)), f !== M.precision)) console.warn("THREE.WebGLProgram.getParameters:", M.precision, "not supported, using", f, "instead."); } let ce = Z.morphAttributes.position || Z.morphAttributes.normal || Z.morphAttributes.color, Pe = ce !== void 0 ? ce.length : 0, We = 0; if (Z.morphAttributes.position !== void 0) We = 1; if (Z.morphAttributes.normal !== void 0) We = 2; if (Z.morphAttributes.color !== void 0) We = 3; let rt, Ke, k, J; if (se) { let ht = ti[se]; ((rt = ht.vertexShader), (Ke = ht.fragmentShader)); } else ((rt = M.vertexShader), (Ke = M.fragmentShader), l.update(M), (k = l.getVertexShaderID(M)), (J = l.getFragmentShaderID(M))); let ee = e.getRenderTarget(), ae = e.state.buffers.depth.getReversed(), ge = q.isInstancedMesh === !0, Ee = q.isBatchedMesh === !0, vt = !!M.map, C = !!M.matcap, ot = !!K, Xe = !!M.aoMap, He = !!M.lightMap, we = !!M.bumpMap, St = !!M.normalMap, Le = !!M.displacementMap, De = !!M.emissiveMap, Bt = !!M.metalnessMap, kt = !!M.roughnessMap, Ct = M.anisotropy > 0, A = M.clearcoat > 0, v = M.dispersion > 0, O = M.iridescence > 0, Y = M.sheen > 0, Q = M.transmission > 0, X = Ct && !!M.anisotropyMap, xe = A && !!M.clearcoatMap, oe = A && !!M.clearcoatNormalMap, Te = A && !!M.clearcoatRoughnessMap, Fe = O && !!M.iridescenceMap, ie = O && !!M.iridescenceThicknessMap, pe = Y && !!M.sheenColorMap, Ae = Y && !!M.sheenRoughnessMap, Re = !!M.specularMap, me = !!M.specularColorMap, je = !!M.specularIntensityMap, P = Q && !!M.transmissionMap, de = Q && !!M.thicknessMap, le = !!M.gradientMap, _e = !!M.alphaMap, te = M.alphaTest > 0, j = !!M.alphaHash, be = !!M.extensions, Ge = mi; if (M.toneMapped) { if (ee === null || ee.isXRRenderTarget === !0) Ge = e.toneMapping; } let pt = { shaderID: se, shaderType: M.type, shaderName: M.name, vertexShader: rt, fragmentShader: Ke, defines: M.defines, customVertexShaderID: k, customFragmentShaderID: J, isRawShaderMaterial: M.isRawShaderMaterial === !0, glslVersion: M.glslVersion, precision: f, batching: Ee, batchingColor: Ee && q._colorsTexture !== null, instancing: ge, instancingColor: ge && q.instanceColor !== null, instancingMorph: ge && q.morphTexture !== null, supportsVertexTextures: d, outputColorSpace: ee === null ? e.outputColorSpace : ee.isXRRenderTarget === !0 ? ee.texture.colorSpace : Ut, alphaToCoverage: !!M.alphaToCoverage, map: vt, matcap: C, envMap: ot, envMapMode: ot && K.mapping, envMapCubeUVHeight: V, aoMap: Xe, lightMap: He, bumpMap: we, normalMap: St, displacementMap: d && Le, emissiveMap: De, normalMapObjectSpace: St && M.normalMapType === rd, normalMapTangentSpace: St && M.normalMapType === sd, metalnessMap: Bt, roughnessMap: kt, anisotropy: Ct, anisotropyMap: X, clearcoat: A, clearcoatMap: xe, clearcoatNormalMap: oe, clearcoatRoughnessMap: Te, dispersion: v, iridescence: O, iridescenceMap: Fe, iridescenceThicknessMap: ie, sheen: Y, sheenColorMap: pe, sheenRoughnessMap: Ae, specularMap: Re, specularColorMap: me, specularIntensityMap: je, transmission: Q, transmissionMap: P, thicknessMap: de, gradientMap: le, opaque: M.transparent === !1 && M.blending === Ur && M.alphaToCoverage === !1, alphaMap: _e, alphaTest: te, alphaHash: j, combine: M.combine, mapUv: vt && y(M.map.channel), aoMapUv: Xe && y(M.aoMap.channel), lightMapUv: He && y(M.lightMap.channel), bumpMapUv: we && y(M.bumpMap.channel), normalMapUv: St && y(M.normalMap.channel), displacementMapUv: Le && y(M.displacementMap.channel), emissiveMapUv: De && y(M.emissiveMap.channel), metalnessMapUv: Bt && y(M.metalnessMap.channel), roughnessMapUv: kt && y(M.roughnessMap.channel), anisotropyMapUv: X && y(M.anisotropyMap.channel), clearcoatMapUv: xe && y(M.clearcoatMap.channel), clearcoatNormalMapUv: oe && y(M.clearcoatNormalMap.channel), clearcoatRoughnessMapUv: Te && y(M.clearcoatRoughnessMap.channel), iridescenceMapUv: Fe && y(M.iridescenceMap.channel), iridescenceThicknessMapUv: ie && y(M.iridescenceThicknessMap.channel), sheenColorMapUv: pe && y(M.sheenColorMap.channel), sheenRoughnessMapUv: Ae && y(M.sheenRoughnessMap.channel), specularMapUv: Re && y(M.specularMap.channel), specularColorMapUv: me && y(M.specularColorMap.channel), specularIntensityMapUv: je && y(M.specularIntensityMap.channel), transmissionMapUv: P && y(M.transmissionMap.channel), thicknessMapUv: de && y(M.thicknessMap.channel), alphaMapUv: _e && y(M.alphaMap.channel), vertexTangents: !!Z.attributes.tangent && (St || Ct), vertexColors: M.vertexColors, vertexAlphas: M.vertexColors === !0 && !!Z.attributes.color && Z.attributes.color.itemSize === 4, pointsUvs: q.isPoints === !0 && !!Z.attributes.uv && (vt || _e), fog: !!B, useFog: M.fog === !0, fogExp2: !!B && B.isFogExp2, flatShading: M.flatShading === !0 && M.wireframe === !1, sizeAttenuation: M.sizeAttenuation === !0, logarithmicDepthBuffer: u, reversedDepthBuffer: ae, skinning: q.isSkinnedMesh === !0, morphTargets: Z.morphAttributes.position !== void 0, morphNormals: Z.morphAttributes.normal !== void 0, morphColors: Z.morphAttributes.color !== void 0, morphTargetsCount: Pe, morphTextureStride: We, numDirLights: T.directional.length, numPointLights: T.point.length, numSpotLights: T.spot.length, numSpotLightMaps: T.spotLightMap.length, numRectAreaLights: T.rectArea.length, numHemiLights: T.hemi.length, numDirLightShadows: T.directionalShadowMap.length, numPointLightShadows: T.pointShadowMap.length, numSpotLightShadows: T.spotShadowMap.length, numSpotLightShadowsWithMaps: T.numSpotLightShadowsWithMaps, numLightProbes: T.numLightProbes, numClippingPlanes: o.numPlanes, numClipIntersection: o.numIntersection, dithering: M.dithering, shadowMapEnabled: e.shadowMap.enabled && I.length > 0, shadowMapType: e.shadowMap.type, toneMapping: Ge, decodeVideoTexture: vt && M.map.isVideoTexture === !0 && ke.getTransfer(M.map.colorSpace) === xt, decodeVideoTextureEmissive: De && M.emissiveMap.isVideoTexture === !0 && ke.getTransfer(M.emissiveMap.colorSpace) === xt, premultipliedAlpha: M.premultipliedAlpha, doubleSided: M.side === Yt, flipSided: M.side === Gt, useDepthPacking: M.depthPacking >= 0, depthPacking: M.depthPacking || 0, index0AttributeName: M.index0AttributeName, extensionClipCullDistance: be && M.extensions.clipCullDistance === !0 && i.has("WEBGL_clip_cull_distance"), extensionMultiDraw: ((be && M.extensions.multiDraw === !0) || Ee) && i.has("WEBGL_multi_draw"), rendererExtensionParallelShaderCompile: i.has("KHR_parallel_shader_compile"), customProgramCacheKey: M.customProgramCacheKey(), }; return ((pt.vertexUv1s = c.has(1)), (pt.vertexUv2s = c.has(2)), (pt.vertexUv3s = c.has(3)), c.clear(), pt); } function g(M) { let T = []; if (M.shaderID) T.push(M.shaderID); else (T.push(M.customVertexShaderID), T.push(M.customFragmentShaderID)); if (M.defines !== void 0) for (let I in M.defines) (T.push(I), T.push(M.defines[I])); if (M.isRawShaderMaterial === !1) (_(T, M), x(T, M), T.push(e.outputColorSpace)); return (T.push(M.customProgramCacheKey), T.join()); } function _(M, T) { (M.push(T.precision), M.push(T.outputColorSpace), M.push(T.envMapMode), M.push(T.envMapCubeUVHeight), M.push(T.mapUv), M.push(T.alphaMapUv), M.push(T.lightMapUv), M.push(T.aoMapUv), M.push(T.bumpMapUv), M.push(T.normalMapUv), M.push(T.displacementMapUv), M.push(T.emissiveMapUv), M.push(T.metalnessMapUv), M.push(T.roughnessMapUv), M.push(T.anisotropyMapUv), M.push(T.clearcoatMapUv), M.push(T.clearcoatNormalMapUv), M.push(T.clearcoatRoughnessMapUv), M.push(T.iridescenceMapUv), M.push(T.iridescenceThicknessMapUv), M.push(T.sheenColorMapUv), M.push(T.sheenRoughnessMapUv), M.push(T.specularMapUv), M.push(T.specularColorMapUv), M.push(T.specularIntensityMapUv), M.push(T.transmissionMapUv), M.push(T.thicknessMapUv), M.push(T.combine), M.push(T.fogExp2), M.push(T.sizeAttenuation), M.push(T.morphTargetsCount), M.push(T.morphAttributeCount), M.push(T.numDirLights), M.push(T.numPointLights), M.push(T.numSpotLights), M.push(T.numSpotLightMaps), M.push(T.numHemiLights), M.push(T.numRectAreaLights), M.push(T.numDirLightShadows), M.push(T.numPointLightShadows), M.push(T.numSpotLightShadows), M.push(T.numSpotLightShadowsWithMaps), M.push(T.numLightProbes), M.push(T.shadowMapType), M.push(T.toneMapping), M.push(T.numClippingPlanes), M.push(T.numClipIntersection), M.push(T.depthPacking)); } function x(M, T) { if ((a.disableAll(), T.supportsVertexTextures)) a.enable(0); if (T.instancing) a.enable(1); if (T.instancingColor) a.enable(2); if (T.instancingMorph) a.enable(3); if (T.matcap) a.enable(4); if (T.envMap) a.enable(5); if (T.normalMapObjectSpace) a.enable(6); if (T.normalMapTangentSpace) a.enable(7); if (T.clearcoat) a.enable(8); if (T.iridescence) a.enable(9); if (T.alphaTest) a.enable(10); if (T.vertexColors) a.enable(11); if (T.vertexAlphas) a.enable(12); if (T.vertexUv1s) a.enable(13); if (T.vertexUv2s) a.enable(14); if (T.vertexUv3s) a.enable(15); if (T.vertexTangents) a.enable(16); if (T.anisotropy) a.enable(17); if (T.alphaHash) a.enable(18); if (T.batching) a.enable(19); if (T.dispersion) a.enable(20); if (T.batchingColor) a.enable(21); if (T.gradientMap) a.enable(22); if ((M.push(a.mask), a.disableAll(), T.fog)) a.enable(0); if (T.useFog) a.enable(1); if (T.flatShading) a.enable(2); if (T.logarithmicDepthBuffer) a.enable(3); if (T.reversedDepthBuffer) a.enable(4); if (T.skinning) a.enable(5); if (T.morphTargets) a.enable(6); if (T.morphNormals) a.enable(7); if (T.morphColors) a.enable(8); if (T.premultipliedAlpha) a.enable(9); if (T.shadowMapEnabled) a.enable(10); if (T.doubleSided) a.enable(11); if (T.flipSided) a.enable(12); if (T.useDepthPacking) a.enable(13); if (T.dithering) a.enable(14); if (T.transmission) a.enable(15); if (T.sheen) a.enable(16); if (T.opaque) a.enable(17); if (T.pointsUvs) a.enable(18); if (T.decodeVideoTexture) a.enable(19); if (T.decodeVideoTextureEmissive) a.enable(20); if (T.alphaToCoverage) a.enable(21); M.push(a.mask); } function w(M) { let T = m[M.type], I; if (T) { let G = ti[T]; I = gd.clone(G.uniforms); } else I = M.uniforms; return I; } function L(M, T) { let I; for (let G = 0, q = h.length; G < q; G++) { let B = h[G]; if (B.cacheKey === T) { ((I = B), ++I.usedTimes); break; } } if (I === void 0) ((I = new vv(e, T, M, r)), h.push(I)); return I; } function b(M) { if (--M.usedTimes === 0) { let T = h.indexOf(M); ((h[T] = h[h.length - 1]), h.pop(), M.destroy()); } } function R(M) { l.remove(M); } function F() { l.dispose(); } return { getParameters: p, getProgramCacheKey: g, getUniforms: w, acquireProgram: L, releaseProgram: b, releaseShaderCache: R, programs: h, dispose: F, }; } function bv() { let e = new WeakMap(); function t(o) { return e.has(o); } function n(o) { let a = e.get(o); if (a === void 0) ((a = {}), e.set(o, a)); return a; } function i(o) { e.delete(o); } function s(o, a, l) { e.get(o)[a] = l; } function r() { e = new WeakMap(); } return { has: t, get: n, remove: i, update: s, dispose: r }; } function Mv(e, t) { if (e.groupOrder !== t.groupOrder) return e.groupOrder - t.groupOrder; else if (e.renderOrder !== t.renderOrder) return e.renderOrder - t.renderOrder; else if (e.material.id !== t.material.id) return e.material.id - t.material.id; else if (e.z !== t.z) return e.z - t.z; else return e.id - t.id; } function Zd(e, t) { if (e.groupOrder !== t.groupOrder) return e.groupOrder - t.groupOrder; else if (e.renderOrder !== t.renderOrder) return e.renderOrder - t.renderOrder; else if (e.z !== t.z) return t.z - e.z; else return e.id - t.id; } function Kd() { let e = [], t = 0, n = [], i = [], s = []; function r() { ((t = 0), (n.length = 0), (i.length = 0), (s.length = 0)); } function o(u, d, f, m, y, p) { let g = e[t]; if (g === void 0) ((g = { id: u.id, object: u, geometry: d, material: f, groupOrder: m, renderOrder: u.renderOrder, z: y, group: p, }), (e[t] = g)); else ((g.id = u.id), (g.object = u), (g.geometry = d), (g.material = f), (g.groupOrder = m), (g.renderOrder = u.renderOrder), (g.z = y), (g.group = p)); return (t++, g); } function a(u, d, f, m, y, p) { let g = o(u, d, f, m, y, p); if (f.transmission > 0) i.push(g); else if (f.transparent === !0) s.push(g); else n.push(g); } function l(u, d, f, m, y, p) { let g = o(u, d, f, m, y, p); if (f.transmission > 0) i.unshift(g); else if (f.transparent === !0) s.unshift(g); else n.unshift(g); } function c(u, d) { if (n.length > 1) n.sort(u || Mv); if (i.length > 1) i.sort(d || Zd); if (s.length > 1) s.sort(d || Zd); } function h() { for (let u = t, d = e.length; u < d; u++) { let f = e[u]; if (f.id === null) break; ((f.id = null), (f.object = null), (f.geometry = null), (f.material = null), (f.group = null)); } } return { opaque: n, transmissive: i, transparent: s, init: r, push: a, unshift: l, finish: h, sort: c }; } function wv() { let e = new WeakMap(); function t(i, s) { let r = e.get(i), o; if (r === void 0) ((o = new Kd()), e.set(i, [o])); else if (s >= r.length) ((o = new Kd()), r.push(o)); else o = r[s]; return o; } function n() { e = new WeakMap(); } return { get: t, dispose: n }; } function Tv() { let e = {}; return { get: function (t) { if (e[t.id] !== void 0) return e[t.id]; let n; switch (t.type) { case "DirectionalLight": n = { direction: new E(), color: new re() }; break; case "SpotLight": n = { position: new E(), direction: new E(), color: new re(), distance: 0, coneCos: 0, penumbraCos: 0, decay: 0, }; break; case "PointLight": n = { position: new E(), color: new re(), distance: 0, decay: 0 }; break; case "HemisphereLight": n = { direction: new E(), skyColor: new re(), groundColor: new re() }; break; case "RectAreaLight": n = { color: new re(), position: new E(), halfWidth: new E(), halfHeight: new E() }; break; } return ((e[t.id] = n), n); }, }; } function Ev() { let e = {}; return { get: function (t) { if (e[t.id] !== void 0) return e[t.id]; let n; switch (t.type) { case "DirectionalLight": n = { shadowIntensity: 1, shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new ve() }; break; case "SpotLight": n = { shadowIntensity: 1, shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new ve() }; break; case "PointLight": n = { shadowIntensity: 1, shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new ve(), shadowCameraNear: 1, shadowCameraFar: 1000, }; break; } return ((e[t.id] = n), n); }, }; } var Av = 0; function Rv(e, t) { return (t.castShadow ? 2 : 0) - (e.castShadow ? 2 : 0) + (t.map ? 1 : 0) - (e.map ? 1 : 0); } function Lv(e) { let t = new Tv(), n = Ev(), i = { version: 0, hash: { directionalLength: -1, pointLength: -1, spotLength: -1, rectAreaLength: -1, hemiLength: -1, numDirectionalShadows: -1, numPointShadows: -1, numSpotShadows: -1, numSpotMaps: -1, numLightProbes: -1, }, ambient: [0, 0, 0], probe: [], directional: [], directionalShadow: [], directionalShadowMap: [], directionalShadowMatrix: [], spot: [], spotLightMap: [], spotShadow: [], spotShadowMap: [], spotLightMatrix: [], rectArea: [], rectAreaLTC1: null, rectAreaLTC2: null, point: [], pointShadow: [], pointShadowMap: [], pointShadowMatrix: [], hemi: [], numSpotLightShadowsWithMaps: 0, numLightProbes: 0, }; for (let c = 0; c < 9; c++) i.probe.push(new E()); let s = new E(), r = new ue(), o = new ue(); function a(c) { let h = 0, u = 0, d = 0; for (let M = 0; M < 9; M++) i.probe[M].set(0, 0, 0); let f = 0, m = 0, y = 0, p = 0, g = 0, _ = 0, x = 0, w = 0, L = 0, b = 0, R = 0; c.sort(Rv); for (let M = 0, T = c.length; M < T; M++) { let I = c[M], { color: G, intensity: q, distance: B } = I, Z = I.shadow && I.shadow.map ? I.shadow.map.texture : null; if (I.isAmbientLight) ((h += G.r * q), (u += G.g * q), (d += G.b * q)); else if (I.isLightProbe) { for (let W = 0; W < 9; W++) i.probe[W].addScaledVector(I.sh.coefficients[W], q); R++; } else if (I.isDirectionalLight) { let W = t.get(I); if ((W.color.copy(I.color).multiplyScalar(I.intensity), I.castShadow)) { let K = I.shadow, V = n.get(I); ((V.shadowIntensity = K.intensity), (V.shadowBias = K.bias), (V.shadowNormalBias = K.normalBias), (V.shadowRadius = K.radius), (V.shadowMapSize = K.mapSize), (i.directionalShadow[f] = V), (i.directionalShadowMap[f] = Z), (i.directionalShadowMatrix[f] = I.shadow.matrix), _++); } ((i.directional[f] = W), f++); } else if (I.isSpotLight) { let W = t.get(I); (W.position.setFromMatrixPosition(I.matrixWorld), W.color.copy(G).multiplyScalar(q), (W.distance = B), (W.coneCos = Math.cos(I.angle)), (W.penumbraCos = Math.cos(I.angle * (1 - I.penumbra))), (W.decay = I.decay), (i.spot[y] = W)); let K = I.shadow; if (I.map) { if (((i.spotLightMap[L] = I.map), L++, K.updateMatrices(I), I.castShadow)) b++; } if (((i.spotLightMatrix[y] = K.matrix), I.castShadow)) { let V = n.get(I); ((V.shadowIntensity = K.intensity), (V.shadowBias = K.bias), (V.shadowNormalBias = K.normalBias), (V.shadowRadius = K.radius), (V.shadowMapSize = K.mapSize), (i.spotShadow[y] = V), (i.spotShadowMap[y] = Z), w++); } y++; } else if (I.isRectAreaLight) { let W = t.get(I); (W.color.copy(G).multiplyScalar(q), W.halfWidth.set(I.width * 0.5, 0, 0), W.halfHeight.set(0, I.height * 0.5, 0), (i.rectArea[p] = W), p++); } else if (I.isPointLight) { let W = t.get(I); if ( (W.color.copy(I.color).multiplyScalar(I.intensity), (W.distance = I.distance), (W.decay = I.decay), I.castShadow) ) { let K = I.shadow, V = n.get(I); ((V.shadowIntensity = K.intensity), (V.shadowBias = K.bias), (V.shadowNormalBias = K.normalBias), (V.shadowRadius = K.radius), (V.shadowMapSize = K.mapSize), (V.shadowCameraNear = K.camera.near), (V.shadowCameraFar = K.camera.far), (i.pointShadow[m] = V), (i.pointShadowMap[m] = Z), (i.pointShadowMatrix[m] = I.shadow.matrix), x++); } ((i.point[m] = W), m++); } else if (I.isHemisphereLight) { let W = t.get(I); (W.skyColor.copy(I.color).multiplyScalar(q), W.groundColor.copy(I.groundColor).multiplyScalar(q), (i.hemi[g] = W), g++); } } if (p > 0) if (e.has("OES_texture_float_linear") === !0) ((i.rectAreaLTC1 = he.LTC_FLOAT_1), (i.rectAreaLTC2 = he.LTC_FLOAT_2)); else ((i.rectAreaLTC1 = he.LTC_HALF_1), (i.rectAreaLTC2 = he.LTC_HALF_2)); ((i.ambient[0] = h), (i.ambient[1] = u), (i.ambient[2] = d)); let F = i.hash; if ( F.directionalLength !== f || F.pointLength !== m || F.spotLength !== y || F.rectAreaLength !== p || F.hemiLength !== g || F.numDirectionalShadows !== _ || F.numPointShadows !== x || F.numSpotShadows !== w || F.numSpotMaps !== L || F.numLightProbes !== R ) ((i.directional.length = f), (i.spot.length = y), (i.rectArea.length = p), (i.point.length = m), (i.hemi.length = g), (i.directionalShadow.length = _), (i.directionalShadowMap.length = _), (i.pointShadow.length = x), (i.pointShadowMap.length = x), (i.spotShadow.length = w), (i.spotShadowMap.length = w), (i.directionalShadowMatrix.length = _), (i.pointShadowMatrix.length = x), (i.spotLightMatrix.length = w + L - b), (i.spotLightMap.length = L), (i.numSpotLightShadowsWithMaps = b), (i.numLightProbes = R), (F.directionalLength = f), (F.pointLength = m), (F.spotLength = y), (F.rectAreaLength = p), (F.hemiLength = g), (F.numDirectionalShadows = _), (F.numPointShadows = x), (F.numSpotShadows = w), (F.numSpotMaps = L), (F.numLightProbes = R), (i.version = Av++)); } function l(c, h) { let u = 0, d = 0, f = 0, m = 0, y = 0, p = h.matrixWorldInverse; for (let g = 0, _ = c.length; g < _; g++) { let x = c[g]; if (x.isDirectionalLight) { let w = i.directional[u]; (w.direction.setFromMatrixPosition(x.matrixWorld), s.setFromMatrixPosition(x.target.matrixWorld), w.direction.sub(s), w.direction.transformDirection(p), u++); } else if (x.isSpotLight) { let w = i.spot[f]; (w.position.setFromMatrixPosition(x.matrixWorld), w.position.applyMatrix4(p), w.direction.setFromMatrixPosition(x.matrixWorld), s.setFromMatrixPosition(x.target.matrixWorld), w.direction.sub(s), w.direction.transformDirection(p), f++); } else if (x.isRectAreaLight) { let w = i.rectArea[m]; (w.position.setFromMatrixPosition(x.matrixWorld), w.position.applyMatrix4(p), o.identity(), r.copy(x.matrixWorld), r.premultiply(p), o.extractRotation(r), w.halfWidth.set(x.width * 0.5, 0, 0), w.halfHeight.set(0, x.height * 0.5, 0), w.halfWidth.applyMatrix4(o), w.halfHeight.applyMatrix4(o), m++); } else if (x.isPointLight) { let w = i.point[d]; (w.position.setFromMatrixPosition(x.matrixWorld), w.position.applyMatrix4(p), d++); } else if (x.isHemisphereLight) { let w = i.hemi[y]; (w.direction.setFromMatrixPosition(x.matrixWorld), w.direction.transformDirection(p), y++); } } } return { setup: a, setupView: l, state: i }; } function $d(e) { let t = new Lv(e), n = [], i = []; function s(h) { ((c.camera = h), (n.length = 0), (i.length = 0)); } function r(h) { n.push(h); } function o(h) { i.push(h); } function a() { t.setup(n); } function l(h) { t.setupView(n, h); } let c = { lightsArray: n, shadowsArray: i, camera: null, lights: t, transmissionRenderTarget: {} }; return { init: s, state: c, setupLights: a, setupLightsView: l, pushLight: r, pushShadow: o }; } function Cv(e) { let t = new WeakMap(); function n(s, r = 0) { let o = t.get(s), a; if (o === void 0) ((a = new $d(e)), t.set(s, [a])); else if (r >= o.length) ((a = new $d(e)), o.push(a)); else a = o[r]; return a; } function i() { t = new WeakMap(); } return { get: n, dispose: i }; } var Iv = `void main() { gl_Position = vec4( position, 1.0 ); }`, Pv = `uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`; function Dv(e, t, n) { let i = new qr(), s = new ve(), r = new ve(), o = new Ye(), a = new dc({ depthPacking: id }), l = new fc(), c = {}, h = n.maxTextureSize, u = { [Fi]: Gt, [Gt]: Fi, [Yt]: Yt }, d = new Zn({ defines: { VSM_SAMPLES: 8 }, uniforms: { shadow_pass: { value: null }, resolution: { value: new ve() }, radius: { value: 4 } }, vertexShader: Iv, fragmentShader: Pv, }), f = d.clone(); f.defines.HORIZONTAL_PASS = 1; let m = new Et(); m.setAttribute("position", new gt(new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]), 3)); let y = new st(m, d), p = this; ((this.enabled = !1), (this.autoUpdate = !0), (this.needsUpdate = !1), (this.type = fl)); let g = this.type; this.render = function (b, R, F) { if (p.enabled === !1) return; if (p.autoUpdate === !1 && p.needsUpdate === !1) return; if (b.length === 0) return; let M = e.getRenderTarget(), T = e.getActiveCubeFace(), I = e.getActiveMipmapLevel(), G = e.state; if ((G.setBlending(Oi), G.buffers.depth.getReversed() === !0)) G.buffers.color.setClear(0, 0, 0, 0); else G.buffers.color.setClear(1, 1, 1, 1); (G.buffers.depth.setTest(!0), G.setScissorTest(!1)); let q = g !== qn && this.type === qn, B = g === qn && this.type !== qn; for (let Z = 0, W = b.length; Z < W; Z++) { let K = b[Z], V = K.shadow; if (V === void 0) { console.warn("THREE.WebGLShadowMap:", K, "has no shadow."); continue; } if (V.autoUpdate === !1 && V.needsUpdate === !1) continue; s.copy(V.mapSize); let se = V.getFrameExtents(); if ((s.multiply(se), r.copy(V.mapSize), s.x > h || s.y > h)) { if (s.x > h) ((r.x = Math.floor(h / se.x)), (s.x = r.x * se.x), (V.mapSize.x = r.x)); if (s.y > h) ((r.y = Math.floor(h / se.y)), (s.y = r.y * se.y), (V.mapSize.y = r.y)); } if (V.map === null || q === !0 || B === !0) { let Pe = this.type !== qn ? { minFilter: gi, magFilter: gi } : {}; if (V.map !== null) V.map.dispose(); ((V.map = new vi(s.x, s.y, Pe)), (V.map.texture.name = K.name + ".shadowMap"), V.camera.updateProjectionMatrix()); } (e.setRenderTarget(V.map), e.clear()); let ce = V.getViewportCount(); for (let Pe = 0; Pe < ce; Pe++) { let We = V.getViewport(Pe); (o.set(r.x * We.x, r.y * We.y, r.x * We.z, r.y * We.w), G.viewport(o), V.updateMatrices(K, Pe), (i = V.getFrustum()), w(R, F, V.camera, K, this.type)); } if (V.isPointLightShadow !== !0 && this.type === qn) _(V, F); V.needsUpdate = !1; } ((g = this.type), (p.needsUpdate = !1), e.setRenderTarget(M, T, I)); }; function _(b, R) { let F = t.update(y); if (d.defines.VSM_SAMPLES !== b.blurSamples) ((d.defines.VSM_SAMPLES = b.blurSamples), (f.defines.VSM_SAMPLES = b.blurSamples), (d.needsUpdate = !0), (f.needsUpdate = !0)); if (b.mapPass === null) b.mapPass = new vi(s.x, s.y); ((d.uniforms.shadow_pass.value = b.map.texture), (d.uniforms.resolution.value = b.mapSize), (d.uniforms.radius.value = b.radius), e.setRenderTarget(b.mapPass), e.clear(), e.renderBufferDirect(R, null, F, d, y, null), (f.uniforms.shadow_pass.value = b.mapPass.texture), (f.uniforms.resolution.value = b.mapSize), (f.uniforms.radius.value = b.radius), e.setRenderTarget(b.map), e.clear(), e.renderBufferDirect(R, null, F, f, y, null)); } function x(b, R, F, M) { let T = null, I = F.isPointLight === !0 ? b.customDistanceMaterial : b.customDepthMaterial; if (I !== void 0) T = I; else if ( ((T = F.isPointLight === !0 ? l : a), (e.localClippingEnabled && R.clipShadows === !0 && Array.isArray(R.clippingPlanes) && R.clippingPlanes.length !== 0) || (R.displacementMap && R.displacementScale !== 0) || (R.alphaMap && R.alphaTest > 0) || (R.map && R.alphaTest > 0) || R.alphaToCoverage === !0) ) { let G = T.uuid, q = R.uuid, B = c[G]; if (B === void 0) ((B = {}), (c[G] = B)); let Z = B[q]; if (Z === void 0) ((Z = T.clone()), (B[q] = Z), R.addEventListener("dispose", L)); T = Z; } if (((T.visible = R.visible), (T.wireframe = R.wireframe), M === qn)) T.side = R.shadowSide !== null ? R.shadowSide : R.side; else T.side = R.shadowSide !== null ? R.shadowSide : u[R.side]; if ( ((T.alphaMap = R.alphaMap), (T.alphaTest = R.alphaToCoverage === !0 ? 0.5 : R.alphaTest), (T.map = R.map), (T.clipShadows = R.clipShadows), (T.clippingPlanes = R.clippingPlanes), (T.clipIntersection = R.clipIntersection), (T.displacementMap = R.displacementMap), (T.displacementScale = R.displacementScale), (T.displacementBias = R.displacementBias), (T.wireframeLinewidth = R.wireframeLinewidth), (T.linewidth = R.linewidth), F.isPointLight === !0 && T.isMeshDistanceMaterial === !0) ) { let G = e.properties.get(T); G.light = F; } return T; } function w(b, R, F, M, T) { if (b.visible === !1) return; if (b.layers.test(R.layers) && (b.isMesh || b.isLine || b.isPoints)) { if ((b.castShadow || (b.receiveShadow && T === qn)) && (!b.frustumCulled || i.intersectsObject(b))) { b.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse, b.matrixWorld); let q = t.update(b), B = b.material; if (Array.isArray(B)) { let Z = q.groups; for (let W = 0, K = Z.length; W < K; W++) { let V = Z[W], se = B[V.materialIndex]; if (se && se.visible) { let ce = x(b, se, M, T); (b.onBeforeShadow(e, b, R, F, q, ce, V), e.renderBufferDirect(F, null, q, ce, b, V), b.onAfterShadow(e, b, R, F, q, ce, V)); } } } else if (B.visible) { let Z = x(b, B, M, T); (b.onBeforeShadow(e, b, R, F, q, Z, null), e.renderBufferDirect(F, null, q, Z, b, null), b.onAfterShadow(e, b, R, F, q, Z, null)); } } } let G = b.children; for (let q = 0, B = G.length; q < B; q++) w(G[q], R, F, M, T); } function L(b) { b.target.removeEventListener("dispose", L); for (let F in c) { let M = c[F], T = b.target.uuid; if (T in M) (M[T].dispose(), delete M[T]); } } } var Uv = { [Oo]: ko, [zo]: Go, [Ho]: Vo, [Nr]: Bo, [ko]: Oo, [Go]: zo, [Vo]: Ho, [Bo]: Nr }; function Nv(e, t) { function n() { let P = !1, de = new Ye(), le = null, _e = new Ye(0, 0, 0, 0); return { setMask: function (te) { if (le !== te && !P) (e.colorMask(te, te, te, te), (le = te)); }, setLocked: function (te) { P = te; }, setClear: function (te, j, be, Ge, pt) { if (pt === !0) ((te *= Ge), (j *= Ge), (be *= Ge)); if ((de.set(te, j, be, Ge), _e.equals(de) === !1)) (e.clearColor(te, j, be, Ge), _e.copy(de)); }, reset: function () { ((P = !1), (le = null), _e.set(-1, 0, 0, 0)); }, }; } function i() { let P = !1, de = !1, le = null, _e = null, te = null; return { setReversed: function (j) { if (de !== j) { let be = t.get("EXT_clip_control"); if (j) be.clipControlEXT(be.LOWER_LEFT_EXT, be.ZERO_TO_ONE_EXT); else be.clipControlEXT(be.LOWER_LEFT_EXT, be.NEGATIVE_ONE_TO_ONE_EXT); de = j; let Ge = te; ((te = null), this.setClear(Ge)); } }, getReversed: function () { return de; }, setTest: function (j) { if (j) ee(e.DEPTH_TEST); else ae(e.DEPTH_TEST); }, setMask: function (j) { if (le !== j && !P) (e.depthMask(j), (le = j)); }, setFunc: function (j) { if (de) j = Uv[j]; if (_e !== j) { switch (j) { case Oo: e.depthFunc(e.NEVER); break; case ko: e.depthFunc(e.ALWAYS); break; case zo: e.depthFunc(e.LESS); break; case Nr: e.depthFunc(e.LEQUAL); break; case Ho: e.depthFunc(e.EQUAL); break; case Bo: e.depthFunc(e.GEQUAL); break; case Go: e.depthFunc(e.GREATER); break; case Vo: e.depthFunc(e.NOTEQUAL); break; default: e.depthFunc(e.LEQUAL); } _e = j; } }, setLocked: function (j) { P = j; }, setClear: function (j) { if (te !== j) { if (de) j = 1 - j; (e.clearDepth(j), (te = j)); } }, reset: function () { ((P = !1), (le = null), (_e = null), (te = null), (de = !1)); }, }; } function s() { let P = !1, de = null, le = null, _e = null, te = null, j = null, be = null, Ge = null, pt = null; return { setTest: function (ht) { if (!P) if (ht) ee(e.STENCIL_TEST); else ae(e.STENCIL_TEST); }, setMask: function (ht) { if (de !== ht && !P) (e.stencilMask(ht), (de = ht)); }, setFunc: function (ht, Vn, Wn) { if (le !== ht || _e !== Vn || te !== Wn) (e.stencilFunc(ht, Vn, Wn), (le = ht), (_e = Vn), (te = Wn)); }, setOp: function (ht, Vn, Wn) { if (j !== ht || be !== Vn || Ge !== Wn) (e.stencilOp(ht, Vn, Wn), (j = ht), (be = Vn), (Ge = Wn)); }, setLocked: function (ht) { P = ht; }, setClear: function (ht) { if (pt !== ht) (e.clearStencil(ht), (pt = ht)); }, reset: function () { ((P = !1), (de = null), (le = null), (_e = null), (te = null), (j = null), (be = null), (Ge = null), (pt = null)); }, }; } let r = new n(), o = new i(), a = new s(), l = new WeakMap(), c = new WeakMap(), h = {}, u = {}, d = new WeakMap(), f = [], m = null, y = !1, p = null, g = null, _ = null, x = null, w = null, L = null, b = null, R = new re(0, 0, 0), F = 0, M = !1, T = null, I = null, G = null, q = null, B = null, Z = e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS), W = !1, K = 0, V = e.getParameter(e.VERSION); if (V.indexOf("WebGL") !== -1) ((K = parseFloat(/^WebGL (\d)/.exec(V)[1])), (W = K >= 1)); else if (V.indexOf("OpenGL ES") !== -1) ((K = parseFloat(/^OpenGL ES (\d)/.exec(V)[1])), (W = K >= 2)); let se = null, ce = {}, Pe = e.getParameter(e.SCISSOR_BOX), We = e.getParameter(e.VIEWPORT), rt = new Ye().fromArray(Pe), Ke = new Ye().fromArray(We); function k(P, de, le, _e) { let te = new Uint8Array(4), j = e.createTexture(); (e.bindTexture(P, j), e.texParameteri(P, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(P, e.TEXTURE_MAG_FILTER, e.NEAREST)); for (let be = 0; be < le; be++) if (P === e.TEXTURE_3D || P === e.TEXTURE_2D_ARRAY) e.texImage3D(de, 0, e.RGBA, 1, 1, _e, 0, e.RGBA, e.UNSIGNED_BYTE, te); else e.texImage2D(de + be, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, te); return j; } let J = {}; ((J[e.TEXTURE_2D] = k(e.TEXTURE_2D, e.TEXTURE_2D, 1)), (J[e.TEXTURE_CUBE_MAP] = k(e.TEXTURE_CUBE_MAP, e.TEXTURE_CUBE_MAP_POSITIVE_X, 6)), (J[e.TEXTURE_2D_ARRAY] = k(e.TEXTURE_2D_ARRAY, e.TEXTURE_2D_ARRAY, 1, 1)), (J[e.TEXTURE_3D] = k(e.TEXTURE_3D, e.TEXTURE_3D, 1, 1)), r.setClear(0, 0, 0, 1), o.setClear(1), a.setClear(0), ee(e.DEPTH_TEST), o.setFunc(Nr), we(!1), St(dl), ee(e.CULL_FACE), Xe(Oi)); function ee(P) { if (h[P] !== !0) (e.enable(P), (h[P] = !0)); } function ae(P) { if (h[P] !== !1) (e.disable(P), (h[P] = !1)); } function ge(P, de) { if (u[P] !== de) { if ((e.bindFramebuffer(P, de), (u[P] = de), P === e.DRAW_FRAMEBUFFER)) u[e.FRAMEBUFFER] = de; if (P === e.FRAMEBUFFER) u[e.DRAW_FRAMEBUFFER] = de; return !0; } return !1; } function Ee(P, de) { let le = f, _e = !1; if (P) { if (((le = d.get(de)), le === void 0)) ((le = []), d.set(de, le)); let te = P.textures; if (le.length !== te.length || le[0] !== e.COLOR_ATTACHMENT0) { for (let j = 0, be = te.length; j < be; j++) le[j] = e.COLOR_ATTACHMENT0 + j; ((le.length = te.length), (_e = !0)); } } else if (le[0] !== e.BACK) ((le[0] = e.BACK), (_e = !0)); if (_e) e.drawBuffers(le); } function vt(P) { if (m !== P) return (e.useProgram(P), (m = P), !0); return !1; } let C = { [qs]: e.FUNC_ADD, [Mu]: e.FUNC_SUBTRACT, [wu]: e.FUNC_REVERSE_SUBTRACT }; ((C[Tu] = e.MIN), (C[Eu] = e.MAX)); let ot = { [Au]: e.ZERO, [Ru]: e.ONE, [Lu]: e.SRC_COLOR, [Iu]: e.SRC_ALPHA, [Ou]: e.SRC_ALPHA_SATURATE, [Nu]: e.DST_COLOR, [Du]: e.DST_ALPHA, [Cu]: e.ONE_MINUS_SRC_COLOR, [Pu]: e.ONE_MINUS_SRC_ALPHA, [Fu]: e.ONE_MINUS_DST_COLOR, [Uu]: e.ONE_MINUS_DST_ALPHA, [ku]: e.CONSTANT_COLOR, [zu]: e.ONE_MINUS_CONSTANT_COLOR, [Hu]: e.CONSTANT_ALPHA, [Bu]: e.ONE_MINUS_CONSTANT_ALPHA, }; function Xe(P, de, le, _e, te, j, be, Ge, pt, ht) { if (P === Oi) { if (y === !0) (ae(e.BLEND), (y = !1)); return; } if (y === !1) (ee(e.BLEND), (y = !0)); if (P !== bu) { if (P !== p || ht !== M) { if (g !== qs || w !== qs) (e.blendEquation(e.FUNC_ADD), (g = qs), (w = qs)); if (ht) switch (P) { case Ur: e.blendFuncSeparate(e.ONE, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA); break; case pl: e.blendFunc(e.ONE, e.ONE); break; case ml: e.blendFuncSeparate(e.ZERO, e.ONE_MINUS_SRC_COLOR, e.ZERO, e.ONE); break; case gl: e.blendFuncSeparate(e.DST_COLOR, e.ONE_MINUS_SRC_ALPHA, e.ZERO, e.ONE); break; default: console.error("THREE.WebGLState: Invalid blending: ", P); break; } else switch (P) { case Ur: e.blendFuncSeparate(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA); break; case pl: e.blendFuncSeparate(e.SRC_ALPHA, e.ONE, e.ONE, e.ONE); break; case ml: console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true"); break; case gl: console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true"); break; default: console.error("THREE.WebGLState: Invalid blending: ", P); break; } ((_ = null), (x = null), (L = null), (b = null), R.set(0, 0, 0), (F = 0), (p = P), (M = ht)); } return; } if (((te = te || de), (j = j || le), (be = be || _e), de !== g || te !== w)) (e.blendEquationSeparate(C[de], C[te]), (g = de), (w = te)); if (le !== _ || _e !== x || j !== L || be !== b) (e.blendFuncSeparate(ot[le], ot[_e], ot[j], ot[be]), (_ = le), (x = _e), (L = j), (b = be)); if (Ge.equals(R) === !1 || pt !== F) (e.blendColor(Ge.r, Ge.g, Ge.b, pt), R.copy(Ge), (F = pt)); ((p = P), (M = !1)); } function He(P, de) { P.side === Yt ? ae(e.CULL_FACE) : ee(e.CULL_FACE); let le = P.side === Gt; if (de) le = !le; (we(le), P.blending === Ur && P.transparent === !1 ? Xe(Oi) : Xe( P.blending, P.blendEquation, P.blendSrc, P.blendDst, P.blendEquationAlpha, P.blendSrcAlpha, P.blendDstAlpha, P.blendColor, P.blendAlpha, P.premultipliedAlpha, ), o.setFunc(P.depthFunc), o.setTest(P.depthTest), o.setMask(P.depthWrite), r.setMask(P.colorWrite)); let _e = P.stencilWrite; if ((a.setTest(_e), _e)) (a.setMask(P.stencilWriteMask), a.setFunc(P.stencilFunc, P.stencilRef, P.stencilFuncMask), a.setOp(P.stencilFail, P.stencilZFail, P.stencilZPass)); (De(P.polygonOffset, P.polygonOffsetFactor, P.polygonOffsetUnits), P.alphaToCoverage === !0 ? ee(e.SAMPLE_ALPHA_TO_COVERAGE) : ae(e.SAMPLE_ALPHA_TO_COVERAGE)); } function we(P) { if (T !== P) { if (P) e.frontFace(e.CW); else e.frontFace(e.CCW); T = P; } } function St(P) { if (P !== _u) { if ((ee(e.CULL_FACE), P !== I)) if (P === dl) e.cullFace(e.BACK); else if (P === Su) e.cullFace(e.FRONT); else e.cullFace(e.FRONT_AND_BACK); } else ae(e.CULL_FACE); I = P; } function Le(P) { if (P !== G) { if (W) e.lineWidth(P); G = P; } } function De(P, de, le) { if (P) { if ((ee(e.POLYGON_OFFSET_FILL), q !== de || B !== le)) (e.polygonOffset(de, le), (q = de), (B = le)); } else ae(e.POLYGON_OFFSET_FILL); } function Bt(P) { if (P) ee(e.SCISSOR_TEST); else ae(e.SCISSOR_TEST); } function kt(P) { if (P === void 0) P = e.TEXTURE0 + Z - 1; if (se !== P) (e.activeTexture(P), (se = P)); } function Ct(P, de, le) { if (le === void 0) if (se === null) le = e.TEXTURE0 + Z - 1; else le = se; let _e = ce[le]; if (_e === void 0) ((_e = { type: void 0, texture: void 0 }), (ce[le] = _e)); if (_e.type !== P || _e.texture !== de) { if (se !== le) (e.activeTexture(le), (se = le)); (e.bindTexture(P, de || J[P]), (_e.type = P), (_e.texture = de)); } } function A() { let P = ce[se]; if (P !== void 0 && P.type !== void 0) (e.bindTexture(P.type, null), (P.type = void 0), (P.texture = void 0)); } function v() { try { e.compressedTexImage2D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function O() { try { e.compressedTexImage3D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function Y() { try { e.texSubImage2D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function Q() { try { e.texSubImage3D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function X() { try { e.compressedTexSubImage2D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function xe() { try { e.compressedTexSubImage3D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function oe() { try { e.texStorage2D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function Te() { try { e.texStorage3D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function Fe() { try { e.texImage2D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function ie() { try { e.texImage3D(...arguments); } catch (P) { console.error("THREE.WebGLState:", P); } } function pe(P) { if (rt.equals(P) === !1) (e.scissor(P.x, P.y, P.z, P.w), rt.copy(P)); } function Ae(P) { if (Ke.equals(P) === !1) (e.viewport(P.x, P.y, P.z, P.w), Ke.copy(P)); } function Re(P, de) { let le = c.get(de); if (le === void 0) ((le = new WeakMap()), c.set(de, le)); let _e = le.get(P); if (_e === void 0) ((_e = e.getUniformBlockIndex(de, P.name)), le.set(P, _e)); } function me(P, de) { let _e = c.get(de).get(P); if (l.get(de) !== _e) (e.uniformBlockBinding(de, _e, P.__bindingPointIndex), l.set(de, _e)); } function je() { (e.disable(e.BLEND), e.disable(e.CULL_FACE), e.disable(e.DEPTH_TEST), e.disable(e.POLYGON_OFFSET_FILL), e.disable(e.SCISSOR_TEST), e.disable(e.STENCIL_TEST), e.disable(e.SAMPLE_ALPHA_TO_COVERAGE), e.blendEquation(e.FUNC_ADD), e.blendFunc(e.ONE, e.ZERO), e.blendFuncSeparate(e.ONE, e.ZERO, e.ONE, e.ZERO), e.blendColor(0, 0, 0, 0), e.colorMask(!0, !0, !0, !0), e.clearColor(0, 0, 0, 0), e.depthMask(!0), e.depthFunc(e.LESS), o.setReversed(!1), e.clearDepth(1), e.stencilMask(4294967295), e.stencilFunc(e.ALWAYS, 0, 4294967295), e.stencilOp(e.KEEP, e.KEEP, e.KEEP), e.clearStencil(0), e.cullFace(e.BACK), e.frontFace(e.CCW), e.polygonOffset(0, 0), e.activeTexture(e.TEXTURE0), e.bindFramebuffer(e.FRAMEBUFFER, null), e.bindFramebuffer(e.DRAW_FRAMEBUFFER, null), e.bindFramebuffer(e.READ_FRAMEBUFFER, null), e.useProgram(null), e.lineWidth(1), e.scissor(0, 0, e.canvas.width, e.canvas.height), e.viewport(0, 0, e.canvas.width, e.canvas.height), (h = {}), (se = null), (ce = {}), (u = {}), (d = new WeakMap()), (f = []), (m = null), (y = !1), (p = null), (g = null), (_ = null), (x = null), (w = null), (L = null), (b = null), (R = new re(0, 0, 0)), (F = 0), (M = !1), (T = null), (I = null), (G = null), (q = null), (B = null), rt.set(0, 0, e.canvas.width, e.canvas.height), Ke.set(0, 0, e.canvas.width, e.canvas.height), r.reset(), o.reset(), a.reset()); } return { buffers: { color: r, depth: o, stencil: a }, enable: ee, disable: ae, bindFramebuffer: ge, drawBuffers: Ee, useProgram: vt, setBlending: Xe, setMaterial: He, setFlipSided: we, setCullFace: St, setLineWidth: Le, setPolygonOffset: De, setScissorTest: Bt, activeTexture: kt, bindTexture: Ct, unbindTexture: A, compressedTexImage2D: v, compressedTexImage3D: O, texImage2D: Fe, texImage3D: ie, updateUBOMapping: Re, uniformBlockBinding: me, texStorage2D: oe, texStorage3D: Te, texSubImage2D: Y, texSubImage3D: Q, compressedTexSubImage2D: X, compressedTexSubImage3D: xe, scissor: pe, viewport: Ae, reset: je, }; } function Fv(e, t, n, i, s, r, o) { let a = t.has("WEBGL_multisampled_render_to_texture") ? t.get("WEBGL_multisampled_render_to_texture") : null, l = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), c = new ve(), h = new WeakMap(), u, d = new WeakMap(), f = !1; try { f = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null; } catch (A) {} function m(A, v) { return f ? new OffscreenCanvas(A, v) : Vs("canvas"); } function y(A, v, O) { let Y = 1, Q = Ct(A); if (Q.width > O || Q.height > O) Y = O / Math.max(Q.width, Q.height); if (Y < 1) if ( (typeof HTMLImageElement < "u" && A instanceof HTMLImageElement) || (typeof HTMLCanvasElement < "u" && A instanceof HTMLCanvasElement) || (typeof ImageBitmap < "u" && A instanceof ImageBitmap) || (typeof VideoFrame < "u" && A instanceof VideoFrame) ) { let X = Math.floor(Y * Q.width), xe = Math.floor(Y * Q.height); if (u === void 0) u = m(X, xe); let oe = v ? m(X, xe) : u; return ( (oe.width = X), (oe.height = xe), oe.getContext("2d").drawImage(A, 0, 0, X, xe), console.warn( "THREE.WebGLRenderer: Texture has been resized from (" + Q.width + "x" + Q.height + ") to (" + X + "x" + xe + ").", ), oe ); } else { if ("data" in A) console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + Q.width + "x" + Q.height + ")."); return A; } return A; } function p(A) { return A.generateMipmaps; } function g(A) { e.generateMipmap(A); } function _(A) { if (A.isWebGLCubeRenderTarget) return e.TEXTURE_CUBE_MAP; if (A.isWebGL3DRenderTarget) return e.TEXTURE_3D; if (A.isWebGLArrayRenderTarget || A.isCompressedArrayTexture) return e.TEXTURE_2D_ARRAY; return e.TEXTURE_2D; } function x(A, v, O, Y, Q = !1) { if (A !== null) { if (e[A] !== void 0) return e[A]; console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + A + "'"); } let X = v; if (v === e.RED) { if (O === e.FLOAT) X = e.R32F; if (O === e.HALF_FLOAT) X = e.R16F; if (O === e.UNSIGNED_BYTE) X = e.R8; } if (v === e.RED_INTEGER) { if (O === e.UNSIGNED_BYTE) X = e.R8UI; if (O === e.UNSIGNED_SHORT) X = e.R16UI; if (O === e.UNSIGNED_INT) X = e.R32UI; if (O === e.BYTE) X = e.R8I; if (O === e.SHORT) X = e.R16I; if (O === e.INT) X = e.R32I; } if (v === e.RG) { if (O === e.FLOAT) X = e.RG32F; if (O === e.HALF_FLOAT) X = e.RG16F; if (O === e.UNSIGNED_BYTE) X = e.RG8; } if (v === e.RG_INTEGER) { if (O === e.UNSIGNED_BYTE) X = e.RG8UI; if (O === e.UNSIGNED_SHORT) X = e.RG16UI; if (O === e.UNSIGNED_INT) X = e.RG32UI; if (O === e.BYTE) X = e.RG8I; if (O === e.SHORT) X = e.RG16I; if (O === e.INT) X = e.RG32I; } if (v === e.RGB_INTEGER) { if (O === e.UNSIGNED_BYTE) X = e.RGB8UI; if (O === e.UNSIGNED_SHORT) X = e.RGB16UI; if (O === e.UNSIGNED_INT) X = e.RGB32UI; if (O === e.BYTE) X = e.RGB8I; if (O === e.SHORT) X = e.RGB16I; if (O === e.INT) X = e.RGB32I; } if (v === e.RGBA_INTEGER) { if (O === e.UNSIGNED_BYTE) X = e.RGBA8UI; if (O === e.UNSIGNED_SHORT) X = e.RGBA16UI; if (O === e.UNSIGNED_INT) X = e.RGBA32UI; if (O === e.BYTE) X = e.RGBA8I; if (O === e.SHORT) X = e.RGBA16I; if (O === e.INT) X = e.RGBA32I; } if (v === e.RGB) { if (O === e.UNSIGNED_INT_5_9_9_9_REV) X = e.RGB9_E5; if (O === e.UNSIGNED_INT_10F_11F_11F_REV) X = e.R11F_G11F_B10F; } if (v === e.RGBA) { let xe = Q ? ec : ke.getTransfer(Y); if (O === e.FLOAT) X = e.RGBA32F; if (O === e.HALF_FLOAT) X = e.RGBA16F; if (O === e.UNSIGNED_BYTE) X = xe === xt ? e.SRGB8_ALPHA8 : e.RGBA8; if (O === e.UNSIGNED_SHORT_4_4_4_4) X = e.RGBA4; if (O === e.UNSIGNED_SHORT_5_5_5_1) X = e.RGB5_A1; } if (X === e.R16F || X === e.R32F || X === e.RG16F || X === e.RG32F || X === e.RGBA16F || X === e.RGBA32F) t.get("EXT_color_buffer_float"); return X; } function w(A, v) { let O; if (A) { if (v === null || v === $s || v === Js) O = e.DEPTH24_STENCIL8; else if (v === zi) O = e.DEPTH32F_STENCIL8; else if (v === kr) ((O = e.DEPTH24_STENCIL8), console.warn( "DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.", )); } else if (v === null || v === $s || v === Js) O = e.DEPTH_COMPONENT24; else if (v === zi) O = e.DEPTH_COMPONENT32F; else if (v === kr) O = e.DEPTH_COMPONENT16; return O; } function L(A, v) { if (p(A) === !0 || (A.isFramebufferTexture && A.minFilter !== gi && A.minFilter !== kn)) return Math.log2(Math.max(v.width, v.height)) + 1; else if (A.mipmaps !== void 0 && A.mipmaps.length > 0) return A.mipmaps.length; else if (A.isCompressedTexture && Array.isArray(A.image)) return v.mipmaps.length; else return 1; } function b(A) { let v = A.target; if ((v.removeEventListener("dispose", b), F(v), v.isVideoTexture)) h.delete(v); } function R(A) { let v = A.target; (v.removeEventListener("dispose", R), T(v)); } function F(A) { let v = i.get(A); if (v.__webglInit === void 0) return; let O = A.source, Y = d.get(O); if (Y) { let Q = Y[v.__cacheKey]; if ((Q.usedTimes--, Q.usedTimes === 0)) M(A); if (Object.keys(Y).length === 0) d.delete(O); } i.remove(A); } function M(A) { let v = i.get(A); e.deleteTexture(v.__webglTexture); let O = A.source, Y = d.get(O); (delete Y[v.__cacheKey], o.memory.textures--); } function T(A) { let v = i.get(A); if (A.depthTexture) (A.depthTexture.dispose(), i.remove(A.depthTexture)); if (A.isWebGLCubeRenderTarget) for (let Y = 0; Y < 6; Y++) { if (Array.isArray(v.__webglFramebuffer[Y])) for (let Q = 0; Q < v.__webglFramebuffer[Y].length; Q++) e.deleteFramebuffer(v.__webglFramebuffer[Y][Q]); else e.deleteFramebuffer(v.__webglFramebuffer[Y]); if (v.__webglDepthbuffer) e.deleteRenderbuffer(v.__webglDepthbuffer[Y]); } else { if (Array.isArray(v.__webglFramebuffer)) for (let Y = 0; Y < v.__webglFramebuffer.length; Y++) e.deleteFramebuffer(v.__webglFramebuffer[Y]); else e.deleteFramebuffer(v.__webglFramebuffer); if (v.__webglDepthbuffer) e.deleteRenderbuffer(v.__webglDepthbuffer); if (v.__webglMultisampledFramebuffer) e.deleteFramebuffer(v.__webglMultisampledFramebuffer); if (v.__webglColorRenderbuffer) { for (let Y = 0; Y < v.__webglColorRenderbuffer.length; Y++) if (v.__webglColorRenderbuffer[Y]) e.deleteRenderbuffer(v.__webglColorRenderbuffer[Y]); } if (v.__webglDepthRenderbuffer) e.deleteRenderbuffer(v.__webglDepthRenderbuffer); } let O = A.textures; for (let Y = 0, Q = O.length; Y < Q; Y++) { let X = i.get(O[Y]); if (X.__webglTexture) (e.deleteTexture(X.__webglTexture), o.memory.textures--); i.remove(O[Y]); } i.remove(A); } let I = 0; function G() { I = 0; } function q() { let A = I; if (A >= s.maxTextures) console.warn( "THREE.WebGLTextures: Trying to use " + A + " texture units while this GPU supports only " + s.maxTextures, ); return ((I += 1), A); } function B(A) { let v = []; return ( v.push(A.wrapS), v.push(A.wrapT), v.push(A.wrapR || 0), v.push(A.magFilter), v.push(A.minFilter), v.push(A.anisotropy), v.push(A.internalFormat), v.push(A.format), v.push(A.type), v.push(A.generateMipmaps), v.push(A.premultiplyAlpha), v.push(A.flipY), v.push(A.unpackAlignment), v.push(A.colorSpace), v.join() ); } function Z(A, v) { let O = i.get(A); if (A.isVideoTexture) Bt(A); if (A.isRenderTargetTexture === !1 && A.isExternalTexture !== !0 && A.version > 0 && O.__version !== A.version) { let Y = A.image; if (Y === null) console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found."); else if (Y.complete === !1) console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete"); else { J(O, A, v); return; } } else if (A.isExternalTexture) O.__webglTexture = A.sourceTexture ? A.sourceTexture : null; n.bindTexture(e.TEXTURE_2D, O.__webglTexture, e.TEXTURE0 + v); } function W(A, v) { let O = i.get(A); if (A.isRenderTargetTexture === !1 && A.version > 0 && O.__version !== A.version) { J(O, A, v); return; } n.bindTexture(e.TEXTURE_2D_ARRAY, O.__webglTexture, e.TEXTURE0 + v); } function K(A, v) { let O = i.get(A); if (A.isRenderTargetTexture === !1 && A.version > 0 && O.__version !== A.version) { J(O, A, v); return; } n.bindTexture(e.TEXTURE_3D, O.__webglTexture, e.TEXTURE0 + v); } function V(A, v) { let O = i.get(A); if (A.version > 0 && O.__version !== A.version) { ee(O, A, v); return; } n.bindTexture(e.TEXTURE_CUBE_MAP, O.__webglTexture, e.TEXTURE0 + v); } let se = { [On]: e.REPEAT, [ds]: e.CLAMP_TO_EDGE, [qo]: e.MIRRORED_REPEAT }, ce = { [gi]: e.NEAREST, [Yo]: e.NEAREST_MIPMAP_NEAREST, [fs]: e.NEAREST_MIPMAP_LINEAR, [kn]: e.LINEAR, [Ks]: e.LINEAR_MIPMAP_NEAREST, [yi]: e.LINEAR_MIPMAP_LINEAR, }, Pe = { [od]: e.NEVER, [dd]: e.ALWAYS, [ad]: e.LESS, [tc]: e.LEQUAL, [ld]: e.EQUAL, [ud]: e.GEQUAL, [cd]: e.GREATER, [hd]: e.NOTEQUAL, }; function We(A, v) { if ( v.type === zi && t.has("OES_texture_float_linear") === !1 && (v.magFilter === kn || v.magFilter === Ks || v.magFilter === fs || v.magFilter === yi || v.minFilter === kn || v.minFilter === Ks || v.minFilter === fs || v.minFilter === yi) ) console.warn( "THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.", ); if ( (e.texParameteri(A, e.TEXTURE_WRAP_S, se[v.wrapS]), e.texParameteri(A, e.TEXTURE_WRAP_T, se[v.wrapT]), A === e.TEXTURE_3D || A === e.TEXTURE_2D_ARRAY) ) e.texParameteri(A, e.TEXTURE_WRAP_R, se[v.wrapR]); if ( (e.texParameteri(A, e.TEXTURE_MAG_FILTER, ce[v.magFilter]), e.texParameteri(A, e.TEXTURE_MIN_FILTER, ce[v.minFilter]), v.compareFunction) ) (e.texParameteri(A, e.TEXTURE_COMPARE_MODE, e.COMPARE_REF_TO_TEXTURE), e.texParameteri(A, e.TEXTURE_COMPARE_FUNC, Pe[v.compareFunction])); if (t.has("EXT_texture_filter_anisotropic") === !0) { if (v.magFilter === gi) return; if (v.minFilter !== fs && v.minFilter !== yi) return; if (v.type === zi && t.has("OES_texture_float_linear") === !1) return; if (v.anisotropy > 1 || i.get(v).__currentAnisotropy) { let O = t.get("EXT_texture_filter_anisotropic"); (e.texParameterf(A, O.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(v.anisotropy, s.getMaxAnisotropy())), (i.get(v).__currentAnisotropy = v.anisotropy)); } } } function rt(A, v) { let O = !1; if (A.__webglInit === void 0) ((A.__webglInit = !0), v.addEventListener("dispose", b)); let Y = v.source, Q = d.get(Y); if (Q === void 0) ((Q = {}), d.set(Y, Q)); let X = B(v); if (X !== A.__cacheKey) { if (Q[X] === void 0) ((Q[X] = { texture: e.createTexture(), usedTimes: 0 }), o.memory.textures++, (O = !0)); Q[X].usedTimes++; let xe = Q[A.__cacheKey]; if (xe !== void 0) { if ((Q[A.__cacheKey].usedTimes--, xe.usedTimes === 0)) M(v); } ((A.__cacheKey = X), (A.__webglTexture = Q[X].texture)); } return O; } function Ke(A, v, O) { return Math.floor(Math.floor(A / O) / v); } function k(A, v, O, Y) { let X = A.updateRanges; if (X.length === 0) n.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, v.width, v.height, O, Y, v.data); else { X.sort((ie, pe) => ie.start - pe.start); let xe = 0; for (let ie = 1; ie < X.length; ie++) { let pe = X[xe], Ae = X[ie], Re = pe.start + pe.count, me = Ke(Ae.start, v.width, 4), je = Ke(pe.start, v.width, 4); if (Ae.start <= Re + 1 && me === je && Ke(Ae.start + Ae.count - 1, v.width, 4) === me) pe.count = Math.max(pe.count, Ae.start + Ae.count - pe.start); else (++xe, (X[xe] = Ae)); } X.length = xe + 1; let oe = e.getParameter(e.UNPACK_ROW_LENGTH), Te = e.getParameter(e.UNPACK_SKIP_PIXELS), Fe = e.getParameter(e.UNPACK_SKIP_ROWS); e.pixelStorei(e.UNPACK_ROW_LENGTH, v.width); for (let ie = 0, pe = X.length; ie < pe; ie++) { let Ae = X[ie], Re = Math.floor(Ae.start / 4), me = Math.ceil(Ae.count / 4), je = Re % v.width, P = Math.floor(Re / v.width), de = me, le = 1; (e.pixelStorei(e.UNPACK_SKIP_PIXELS, je), e.pixelStorei(e.UNPACK_SKIP_ROWS, P), n.texSubImage2D(e.TEXTURE_2D, 0, je, P, de, 1, O, Y, v.data)); } (A.clearUpdateRanges(), e.pixelStorei(e.UNPACK_ROW_LENGTH, oe), e.pixelStorei(e.UNPACK_SKIP_PIXELS, Te), e.pixelStorei(e.UNPACK_SKIP_ROWS, Fe)); } } function J(A, v, O) { let Y = e.TEXTURE_2D; if (v.isDataArrayTexture || v.isCompressedArrayTexture) Y = e.TEXTURE_2D_ARRAY; if (v.isData3DTexture) Y = e.TEXTURE_3D; let Q = rt(A, v), X = v.source; n.bindTexture(Y, A.__webglTexture, e.TEXTURE0 + O); let xe = i.get(X); if (X.version !== xe.__version || Q === !0) { n.activeTexture(e.TEXTURE0 + O); let oe = ke.getPrimaries(ke.workingColorSpace), Te = v.colorSpace === xi ? null : ke.getPrimaries(v.colorSpace), Fe = v.colorSpace === xi || oe === Te ? e.NONE : e.BROWSER_DEFAULT_WEBGL; (e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, v.flipY), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, v.premultiplyAlpha), e.pixelStorei(e.UNPACK_ALIGNMENT, v.unpackAlignment), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, Fe)); let ie = y(v.image, !1, s.maxTextureSize); ie = kt(v, ie); let pe = r.convert(v.format, v.colorSpace), Ae = r.convert(v.type), Re = x(v.internalFormat, pe, Ae, v.colorSpace, v.isVideoTexture); We(Y, v); let me, je = v.mipmaps, P = v.isVideoTexture !== !0, de = xe.__version === void 0 || Q === !0, le = X.dataReady, _e = L(v, ie); if (v.isDepthTexture) { if (((Re = w(v.format === Hr, v.type)), de)) if (P) n.texStorage2D(e.TEXTURE_2D, 1, Re, ie.width, ie.height); else n.texImage2D(e.TEXTURE_2D, 0, Re, ie.width, ie.height, 0, pe, Ae, null); } else if (v.isDataTexture) if (je.length > 0) { if (P && de) n.texStorage2D(e.TEXTURE_2D, _e, Re, je[0].width, je[0].height); for (let te = 0, j = je.length; te < j; te++) if (((me = je[te]), P)) { if (le) n.texSubImage2D(e.TEXTURE_2D, te, 0, 0, me.width, me.height, pe, Ae, me.data); } else n.texImage2D(e.TEXTURE_2D, te, Re, me.width, me.height, 0, pe, Ae, me.data); v.generateMipmaps = !1; } else if (P) { if (de) n.texStorage2D(e.TEXTURE_2D, _e, Re, ie.width, ie.height); if (le) k(v, ie, pe, Ae); } else n.texImage2D(e.TEXTURE_2D, 0, Re, ie.width, ie.height, 0, pe, Ae, ie.data); else if (v.isCompressedTexture) if (v.isCompressedArrayTexture) { if (P && de) n.texStorage3D(e.TEXTURE_2D_ARRAY, _e, Re, je[0].width, je[0].height, ie.depth); for (let te = 0, j = je.length; te < j; te++) if (((me = je[te]), v.format !== Yn)) if (pe !== null) if (P) { if (le) if (v.layerUpdates.size > 0) { let be = wc(me.width, me.height, v.format, v.type); for (let Ge of v.layerUpdates) { let pt = me.data.subarray( (Ge * be) / me.data.BYTES_PER_ELEMENT, ((Ge + 1) * be) / me.data.BYTES_PER_ELEMENT, ); n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY, te, 0, 0, Ge, me.width, me.height, 1, pe, pt); } v.clearLayerUpdates(); } else n.compressedTexSubImage3D( e.TEXTURE_2D_ARRAY, te, 0, 0, 0, me.width, me.height, ie.depth, pe, me.data, ); } else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY, te, Re, me.width, me.height, ie.depth, 0, me.data, 0, 0); else console.warn( "THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()", ); else if (P) { if (le) n.texSubImage3D(e.TEXTURE_2D_ARRAY, te, 0, 0, 0, me.width, me.height, ie.depth, pe, Ae, me.data); } else n.texImage3D(e.TEXTURE_2D_ARRAY, te, Re, me.width, me.height, ie.depth, 0, pe, Ae, me.data); } else { if (P && de) n.texStorage2D(e.TEXTURE_2D, _e, Re, je[0].width, je[0].height); for (let te = 0, j = je.length; te < j; te++) if (((me = je[te]), v.format !== Yn)) if (pe !== null) if (P) { if (le) n.compressedTexSubImage2D(e.TEXTURE_2D, te, 0, 0, me.width, me.height, pe, me.data); } else n.compressedTexImage2D(e.TEXTURE_2D, te, Re, me.width, me.height, 0, me.data); else console.warn( "THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()", ); else if (P) { if (le) n.texSubImage2D(e.TEXTURE_2D, te, 0, 0, me.width, me.height, pe, Ae, me.data); } else n.texImage2D(e.TEXTURE_2D, te, Re, me.width, me.height, 0, pe, Ae, me.data); } else if (v.isDataArrayTexture) if (P) { if (de) n.texStorage3D(e.TEXTURE_2D_ARRAY, _e, Re, ie.width, ie.height, ie.depth); if (le) if (v.layerUpdates.size > 0) { let te = wc(ie.width, ie.height, v.format, v.type); for (let j of v.layerUpdates) { let be = ie.data.subarray( (j * te) / ie.data.BYTES_PER_ELEMENT, ((j + 1) * te) / ie.data.BYTES_PER_ELEMENT, ); n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, j, ie.width, ie.height, 1, pe, Ae, be); } v.clearLayerUpdates(); } else n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, 0, ie.width, ie.height, ie.depth, pe, Ae, ie.data); } else n.texImage3D(e.TEXTURE_2D_ARRAY, 0, Re, ie.width, ie.height, ie.depth, 0, pe, Ae, ie.data); else if (v.isData3DTexture) if (P) { if (de) n.texStorage3D(e.TEXTURE_3D, _e, Re, ie.width, ie.height, ie.depth); if (le) n.texSubImage3D(e.TEXTURE_3D, 0, 0, 0, 0, ie.width, ie.height, ie.depth, pe, Ae, ie.data); } else n.texImage3D(e.TEXTURE_3D, 0, Re, ie.width, ie.height, ie.depth, 0, pe, Ae, ie.data); else if (v.isFramebufferTexture) { if (de) if (P) n.texStorage2D(e.TEXTURE_2D, _e, Re, ie.width, ie.height); else { let te = ie.width, j = ie.height; for (let be = 0; be < _e; be++) (n.texImage2D(e.TEXTURE_2D, be, Re, te, j, 0, pe, Ae, null), (te >>= 1), (j >>= 1)); } } else if (je.length > 0) { if (P && de) { let te = Ct(je[0]); n.texStorage2D(e.TEXTURE_2D, _e, Re, te.width, te.height); } for (let te = 0, j = je.length; te < j; te++) if (((me = je[te]), P)) { if (le) n.texSubImage2D(e.TEXTURE_2D, te, 0, 0, pe, Ae, me); } else n.texImage2D(e.TEXTURE_2D, te, Re, pe, Ae, me); v.generateMipmaps = !1; } else if (P) { if (de) { let te = Ct(ie); n.texStorage2D(e.TEXTURE_2D, _e, Re, te.width, te.height); } if (le) n.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, pe, Ae, ie); } else n.texImage2D(e.TEXTURE_2D, 0, Re, pe, Ae, ie); if (p(v)) g(Y); if (((xe.__version = X.version), v.onUpdate)) v.onUpdate(v); } A.__version = v.version; } function ee(A, v, O) { if (v.image.length !== 6) return; let Y = rt(A, v), Q = v.source; n.bindTexture(e.TEXTURE_CUBE_MAP, A.__webglTexture, e.TEXTURE0 + O); let X = i.get(Q); if (Q.version !== X.__version || Y === !0) { n.activeTexture(e.TEXTURE0 + O); let xe = ke.getPrimaries(ke.workingColorSpace), oe = v.colorSpace === xi ? null : ke.getPrimaries(v.colorSpace), Te = v.colorSpace === xi || xe === oe ? e.NONE : e.BROWSER_DEFAULT_WEBGL; (e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, v.flipY), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, v.premultiplyAlpha), e.pixelStorei(e.UNPACK_ALIGNMENT, v.unpackAlignment), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, Te)); let Fe = v.isCompressedTexture || v.image[0].isCompressedTexture, ie = v.image[0] && v.image[0].isDataTexture, pe = []; for (let j = 0; j < 6; j++) { if (!Fe && !ie) pe[j] = y(v.image[j], !0, s.maxCubemapSize); else pe[j] = ie ? v.image[j].image : v.image[j]; pe[j] = kt(v, pe[j]); } let Ae = pe[0], Re = r.convert(v.format, v.colorSpace), me = r.convert(v.type), je = x(v.internalFormat, Re, me, v.colorSpace), P = v.isVideoTexture !== !0, de = X.__version === void 0 || Y === !0, le = Q.dataReady, _e = L(v, Ae); We(e.TEXTURE_CUBE_MAP, v); let te; if (Fe) { if (P && de) n.texStorage2D(e.TEXTURE_CUBE_MAP, _e, je, Ae.width, Ae.height); for (let j = 0; j < 6; j++) { te = pe[j].mipmaps; for (let be = 0; be < te.length; be++) { let Ge = te[be]; if (v.format !== Yn) if (Re !== null) if (P) { if (le) n.compressedTexSubImage2D( e.TEXTURE_CUBE_MAP_POSITIVE_X + j, be, 0, 0, Ge.width, Ge.height, Re, Ge.data, ); } else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + j, be, je, Ge.width, Ge.height, 0, Ge.data); else console.warn( "THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()", ); else if (P) { if (le) n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + j, be, 0, 0, Ge.width, Ge.height, Re, me, Ge.data); } else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + j, be, je, Ge.width, Ge.height, 0, Re, me, Ge.data); } } } else { if (((te = v.mipmaps), P && de)) { if (te.length > 0) _e++; let j = Ct(pe[0]); n.texStorage2D(e.TEXTURE_CUBE_MAP, _e, je, j.width, j.height); } for (let j = 0; j < 6; j++) if (ie) { if (P) { if (le) n.texSubImage2D( e.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, 0, 0, pe[j].width, pe[j].height, Re, me, pe[j].data, ); } else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, je, pe[j].width, pe[j].height, 0, Re, me, pe[j].data); for (let be = 0; be < te.length; be++) { let pt = te[be].image[j].image; if (P) { if (le) n.texSubImage2D( e.TEXTURE_CUBE_MAP_POSITIVE_X + j, be + 1, 0, 0, pt.width, pt.height, Re, me, pt.data, ); } else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + j, be + 1, je, pt.width, pt.height, 0, Re, me, pt.data); } } else { if (P) { if (le) n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, 0, 0, Re, me, pe[j]); } else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, je, Re, me, pe[j]); for (let be = 0; be < te.length; be++) { let Ge = te[be]; if (P) { if (le) n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + j, be + 1, 0, 0, Re, me, Ge.image[j]); } else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + j, be + 1, je, Re, me, Ge.image[j]); } } } if (p(v)) g(e.TEXTURE_CUBE_MAP); if (((X.__version = Q.version), v.onUpdate)) v.onUpdate(v); } A.__version = v.version; } function ae(A, v, O, Y, Q, X) { let xe = r.convert(O.format, O.colorSpace), oe = r.convert(O.type), Te = x(O.internalFormat, xe, oe, O.colorSpace), Fe = i.get(v), ie = i.get(O); if (((ie.__renderTarget = v), !Fe.__hasExternalTextures)) { let pe = Math.max(1, v.width >> X), Ae = Math.max(1, v.height >> X); if (Q === e.TEXTURE_3D || Q === e.TEXTURE_2D_ARRAY) n.texImage3D(Q, X, Te, pe, Ae, v.depth, 0, xe, oe, null); else n.texImage2D(Q, X, Te, pe, Ae, 0, xe, oe, null); } if ((n.bindFramebuffer(e.FRAMEBUFFER, A), De(v))) a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, Y, Q, ie.__webglTexture, 0, Le(v)); else if (Q === e.TEXTURE_2D || (Q >= e.TEXTURE_CUBE_MAP_POSITIVE_X && Q <= e.TEXTURE_CUBE_MAP_NEGATIVE_Z)) e.framebufferTexture2D(e.FRAMEBUFFER, Y, Q, ie.__webglTexture, X); n.bindFramebuffer(e.FRAMEBUFFER, null); } function ge(A, v, O) { if ((e.bindRenderbuffer(e.RENDERBUFFER, A), v.depthBuffer)) { let Y = v.depthTexture, Q = Y && Y.isDepthTexture ? Y.type : null, X = w(v.stencilBuffer, Q), xe = v.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, oe = Le(v); if (De(v)) a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, oe, X, v.width, v.height); else if (O) e.renderbufferStorageMultisample(e.RENDERBUFFER, oe, X, v.width, v.height); else e.renderbufferStorage(e.RENDERBUFFER, X, v.width, v.height); e.framebufferRenderbuffer(e.FRAMEBUFFER, xe, e.RENDERBUFFER, A); } else { let Y = v.textures; for (let Q = 0; Q < Y.length; Q++) { let X = Y[Q], xe = r.convert(X.format, X.colorSpace), oe = r.convert(X.type), Te = x(X.internalFormat, xe, oe, X.colorSpace), Fe = Le(v); if (O && De(v) === !1) e.renderbufferStorageMultisample(e.RENDERBUFFER, Fe, Te, v.width, v.height); else if (De(v)) a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, Fe, Te, v.width, v.height); else e.renderbufferStorage(e.RENDERBUFFER, Te, v.width, v.height); } } e.bindRenderbuffer(e.RENDERBUFFER, null); } function Ee(A, v) { if (v && v.isWebGLCubeRenderTarget) throw Error("Depth Texture with cube render targets is not supported"); if ((n.bindFramebuffer(e.FRAMEBUFFER, A), !(v.depthTexture && v.depthTexture.isDepthTexture))) throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture"); let Y = i.get(v.depthTexture); if ( ((Y.__renderTarget = v), !Y.__webglTexture || v.depthTexture.image.width !== v.width || v.depthTexture.image.height !== v.height) ) ((v.depthTexture.image.width = v.width), (v.depthTexture.image.height = v.height), (v.depthTexture.needsUpdate = !0)); Z(v.depthTexture, 0); let Q = Y.__webglTexture, X = Le(v); if (v.depthTexture.format === jo) if (De(v)) a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, e.DEPTH_ATTACHMENT, e.TEXTURE_2D, Q, 0, X); else e.framebufferTexture2D(e.FRAMEBUFFER, e.DEPTH_ATTACHMENT, e.TEXTURE_2D, Q, 0); else if (v.depthTexture.format === Hr) if (De(v)) a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, e.DEPTH_STENCIL_ATTACHMENT, e.TEXTURE_2D, Q, 0, X); else e.framebufferTexture2D(e.FRAMEBUFFER, e.DEPTH_STENCIL_ATTACHMENT, e.TEXTURE_2D, Q, 0); else throw Error("Unknown depthTexture format"); } function vt(A) { let v = i.get(A), O = A.isWebGLCubeRenderTarget === !0; if (v.__boundDepthTexture !== A.depthTexture) { let Y = A.depthTexture; if (v.__depthDisposeCallback) v.__depthDisposeCallback(); if (Y) { let Q = () => { (delete v.__boundDepthTexture, delete v.__depthDisposeCallback, Y.removeEventListener("dispose", Q)); }; (Y.addEventListener("dispose", Q), (v.__depthDisposeCallback = Q)); } v.__boundDepthTexture = Y; } if (A.depthTexture && !v.__autoAllocateDepthBuffer) { if (O) throw Error("target.depthTexture not supported in Cube render targets"); let Y = A.texture.mipmaps; if (Y && Y.length > 0) Ee(v.__webglFramebuffer[0], A); else Ee(v.__webglFramebuffer, A); } else if (O) { v.__webglDepthbuffer = []; for (let Y = 0; Y < 6; Y++) if ((n.bindFramebuffer(e.FRAMEBUFFER, v.__webglFramebuffer[Y]), v.__webglDepthbuffer[Y] === void 0)) ((v.__webglDepthbuffer[Y] = e.createRenderbuffer()), ge(v.__webglDepthbuffer[Y], A, !1)); else { let Q = A.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, X = v.__webglDepthbuffer[Y]; (e.bindRenderbuffer(e.RENDERBUFFER, X), e.framebufferRenderbuffer(e.FRAMEBUFFER, Q, e.RENDERBUFFER, X)); } } else { let Y = A.texture.mipmaps; if (Y && Y.length > 0) n.bindFramebuffer(e.FRAMEBUFFER, v.__webglFramebuffer[0]); else n.bindFramebuffer(e.FRAMEBUFFER, v.__webglFramebuffer); if (v.__webglDepthbuffer === void 0) ((v.__webglDepthbuffer = e.createRenderbuffer()), ge(v.__webglDepthbuffer, A, !1)); else { let Q = A.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, X = v.__webglDepthbuffer; (e.bindRenderbuffer(e.RENDERBUFFER, X), e.framebufferRenderbuffer(e.FRAMEBUFFER, Q, e.RENDERBUFFER, X)); } } n.bindFramebuffer(e.FRAMEBUFFER, null); } function C(A, v, O) { let Y = i.get(A); if (v !== void 0) ae(Y.__webglFramebuffer, A, A.texture, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, 0); if (O !== void 0) vt(A); } function ot(A) { let v = A.texture, O = i.get(A), Y = i.get(v); A.addEventListener("dispose", R); let Q = A.textures, X = A.isWebGLCubeRenderTarget === !0, xe = Q.length > 1; if (!xe) { if (Y.__webglTexture === void 0) Y.__webglTexture = e.createTexture(); ((Y.__version = v.version), o.memory.textures++); } if (X) { O.__webglFramebuffer = []; for (let oe = 0; oe < 6; oe++) if (v.mipmaps && v.mipmaps.length > 0) { O.__webglFramebuffer[oe] = []; for (let Te = 0; Te < v.mipmaps.length; Te++) O.__webglFramebuffer[oe][Te] = e.createFramebuffer(); } else O.__webglFramebuffer[oe] = e.createFramebuffer(); } else { if (v.mipmaps && v.mipmaps.length > 0) { O.__webglFramebuffer = []; for (let oe = 0; oe < v.mipmaps.length; oe++) O.__webglFramebuffer[oe] = e.createFramebuffer(); } else O.__webglFramebuffer = e.createFramebuffer(); if (xe) for (let oe = 0, Te = Q.length; oe < Te; oe++) { let Fe = i.get(Q[oe]); if (Fe.__webglTexture === void 0) ((Fe.__webglTexture = e.createTexture()), o.memory.textures++); } if (A.samples > 0 && De(A) === !1) { ((O.__webglMultisampledFramebuffer = e.createFramebuffer()), (O.__webglColorRenderbuffer = []), n.bindFramebuffer(e.FRAMEBUFFER, O.__webglMultisampledFramebuffer)); for (let oe = 0; oe < Q.length; oe++) { let Te = Q[oe]; ((O.__webglColorRenderbuffer[oe] = e.createRenderbuffer()), e.bindRenderbuffer(e.RENDERBUFFER, O.__webglColorRenderbuffer[oe])); let Fe = r.convert(Te.format, Te.colorSpace), ie = r.convert(Te.type), pe = x(Te.internalFormat, Fe, ie, Te.colorSpace, A.isXRRenderTarget === !0), Ae = Le(A); (e.renderbufferStorageMultisample(e.RENDERBUFFER, Ae, pe, A.width, A.height), e.framebufferRenderbuffer( e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + oe, e.RENDERBUFFER, O.__webglColorRenderbuffer[oe], )); } if ((e.bindRenderbuffer(e.RENDERBUFFER, null), A.depthBuffer)) ((O.__webglDepthRenderbuffer = e.createRenderbuffer()), ge(O.__webglDepthRenderbuffer, A, !0)); n.bindFramebuffer(e.FRAMEBUFFER, null); } } if (X) { (n.bindTexture(e.TEXTURE_CUBE_MAP, Y.__webglTexture), We(e.TEXTURE_CUBE_MAP, v)); for (let oe = 0; oe < 6; oe++) if (v.mipmaps && v.mipmaps.length > 0) for (let Te = 0; Te < v.mipmaps.length; Te++) ae(O.__webglFramebuffer[oe][Te], A, v, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + oe, Te); else ae(O.__webglFramebuffer[oe], A, v, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + oe, 0); if (p(v)) g(e.TEXTURE_CUBE_MAP); n.unbindTexture(); } else if (xe) { for (let oe = 0, Te = Q.length; oe < Te; oe++) { let Fe = Q[oe], ie = i.get(Fe), pe = e.TEXTURE_2D; if (A.isWebGL3DRenderTarget || A.isWebGLArrayRenderTarget) pe = A.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY; if ( (n.bindTexture(pe, ie.__webglTexture), We(pe, Fe), ae(O.__webglFramebuffer, A, Fe, e.COLOR_ATTACHMENT0 + oe, pe, 0), p(Fe)) ) g(pe); } n.unbindTexture(); } else { let oe = e.TEXTURE_2D; if (A.isWebGL3DRenderTarget || A.isWebGLArrayRenderTarget) oe = A.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY; if ((n.bindTexture(oe, Y.__webglTexture), We(oe, v), v.mipmaps && v.mipmaps.length > 0)) for (let Te = 0; Te < v.mipmaps.length; Te++) ae(O.__webglFramebuffer[Te], A, v, e.COLOR_ATTACHMENT0, oe, Te); else ae(O.__webglFramebuffer, A, v, e.COLOR_ATTACHMENT0, oe, 0); if (p(v)) g(oe); n.unbindTexture(); } if (A.depthBuffer) vt(A); } function Xe(A) { let v = A.textures; for (let O = 0, Y = v.length; O < Y; O++) { let Q = v[O]; if (p(Q)) { let X = _(A), xe = i.get(Q).__webglTexture; (n.bindTexture(X, xe), g(X), n.unbindTexture()); } } } let He = [], we = []; function St(A) { if (A.samples > 0) { if (De(A) === !1) { let { textures: v, width: O, height: Y } = A, Q = e.COLOR_BUFFER_BIT, X = A.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, xe = i.get(A), oe = v.length > 1; if (oe) for (let Fe = 0; Fe < v.length; Fe++) (n.bindFramebuffer(e.FRAMEBUFFER, xe.__webglMultisampledFramebuffer), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + Fe, e.RENDERBUFFER, null), n.bindFramebuffer(e.FRAMEBUFFER, xe.__webglFramebuffer), e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0 + Fe, e.TEXTURE_2D, null, 0)); n.bindFramebuffer(e.READ_FRAMEBUFFER, xe.__webglMultisampledFramebuffer); let Te = A.texture.mipmaps; if (Te && Te.length > 0) n.bindFramebuffer(e.DRAW_FRAMEBUFFER, xe.__webglFramebuffer[0]); else n.bindFramebuffer(e.DRAW_FRAMEBUFFER, xe.__webglFramebuffer); for (let Fe = 0; Fe < v.length; Fe++) { if (A.resolveDepthBuffer) { if (A.depthBuffer) Q |= e.DEPTH_BUFFER_BIT; if (A.stencilBuffer && A.resolveStencilBuffer) Q |= e.STENCIL_BUFFER_BIT; } if (oe) { e.framebufferRenderbuffer( e.READ_FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.RENDERBUFFER, xe.__webglColorRenderbuffer[Fe], ); let ie = i.get(v[Fe]).__webglTexture; e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, ie, 0); } if ((e.blitFramebuffer(0, 0, O, Y, 0, 0, O, Y, Q, e.NEAREST), l === !0)) { if ( ((He.length = 0), (we.length = 0), He.push(e.COLOR_ATTACHMENT0 + Fe), A.depthBuffer && A.resolveDepthBuffer === !1) ) (He.push(X), we.push(X), e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER, we)); e.invalidateFramebuffer(e.READ_FRAMEBUFFER, He); } } if ((n.bindFramebuffer(e.READ_FRAMEBUFFER, null), n.bindFramebuffer(e.DRAW_FRAMEBUFFER, null), oe)) for (let Fe = 0; Fe < v.length; Fe++) { (n.bindFramebuffer(e.FRAMEBUFFER, xe.__webglMultisampledFramebuffer), e.framebufferRenderbuffer( e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + Fe, e.RENDERBUFFER, xe.__webglColorRenderbuffer[Fe], )); let ie = i.get(v[Fe]).__webglTexture; (n.bindFramebuffer(e.FRAMEBUFFER, xe.__webglFramebuffer), e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0 + Fe, e.TEXTURE_2D, ie, 0)); } n.bindFramebuffer(e.DRAW_FRAMEBUFFER, xe.__webglMultisampledFramebuffer); } else if (A.depthBuffer && A.resolveDepthBuffer === !1 && l) { let v = A.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT; e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER, [v]); } } } function Le(A) { return Math.min(s.maxSamples, A.samples); } function De(A) { let v = i.get(A); return A.samples > 0 && t.has("WEBGL_multisampled_render_to_texture") === !0 && v.__useRenderToTexture !== !1; } function Bt(A) { let v = o.render.frame; if (h.get(A) !== v) (h.set(A, v), A.update()); } function kt(A, v) { let { colorSpace: O, format: Y, type: Q } = A; if (A.isCompressedTexture === !0 || A.isVideoTexture === !0) return v; if (O !== Ut && O !== xi) if (ke.getTransfer(O) === xt) { if (Y !== Yn || Q !== ki) console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."); } else console.error("THREE.WebGLTextures: Unsupported texture color space:", O); return v; } function Ct(A) { if (typeof HTMLImageElement < "u" && A instanceof HTMLImageElement) ((c.width = A.naturalWidth || A.width), (c.height = A.naturalHeight || A.height)); else if (typeof VideoFrame < "u" && A instanceof VideoFrame) ((c.width = A.displayWidth), (c.height = A.displayHeight)); else ((c.width = A.width), (c.height = A.height)); return c; } ((this.allocateTextureUnit = q), (this.resetTextureUnits = G), (this.setTexture2D = Z), (this.setTexture2DArray = W), (this.setTexture3D = K), (this.setTextureCube = V), (this.rebindTextures = C), (this.setupRenderTarget = ot), (this.updateRenderTargetMipmap = Xe), (this.updateMultisampleRenderTarget = St), (this.setupDepthRenderbuffer = vt), (this.setupFrameBufferTexture = ae), (this.useMultisampledRTT = De)); } function Ov(e, t) { function n(i, s = xi) { let r, o = ke.getTransfer(s); if (i === ki) return e.UNSIGNED_BYTE; if (i === xl) return e.UNSIGNED_SHORT_4_4_4_4; if (i === vl) return e.UNSIGNED_SHORT_5_5_5_1; if (i === $u) return e.UNSIGNED_INT_5_9_9_9_REV; if (i === Ju) return e.UNSIGNED_INT_10F_11F_11F_REV; if (i === Zu) return e.BYTE; if (i === Ku) return e.SHORT; if (i === kr) return e.UNSIGNED_SHORT; if (i === yl) return e.INT; if (i === $s) return e.UNSIGNED_INT; if (i === zi) return e.FLOAT; if (i === zr) return e.HALF_FLOAT; if (i === Qu) return e.ALPHA; if (i === ed) return e.RGB; if (i === Yn) return e.RGBA; if (i === jo) return e.DEPTH_COMPONENT; if (i === Hr) return e.DEPTH_STENCIL; if (i === td) return e.RED; if (i === _l) return e.RED_INTEGER; if (i === nd) return e.RG; if (i === Sl) return e.RG_INTEGER; if (i === bl) return e.RGBA_INTEGER; if (i === Zo || i === Ko || i === $o || i === Jo) if (o === xt) if (((r = t.get("WEBGL_compressed_texture_s3tc_srgb")), r !== null)) { if (i === Zo) return r.COMPRESSED_SRGB_S3TC_DXT1_EXT; if (i === Ko) return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; if (i === $o) return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; if (i === Jo) return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; } else return null; else if (((r = t.get("WEBGL_compressed_texture_s3tc")), r !== null)) { if (i === Zo) return r.COMPRESSED_RGB_S3TC_DXT1_EXT; if (i === Ko) return r.COMPRESSED_RGBA_S3TC_DXT1_EXT; if (i === $o) return r.COMPRESSED_RGBA_S3TC_DXT3_EXT; if (i === Jo) return r.COMPRESSED_RGBA_S3TC_DXT5_EXT; } else return null; if (i === Ml || i === wl || i === Tl || i === El) if (((r = t.get("WEBGL_compressed_texture_pvrtc")), r !== null)) { if (i === Ml) return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; if (i === wl) return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; if (i === Tl) return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; if (i === El) return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; } else return null; if (i === Al || i === Rl || i === Ll) if (((r = t.get("WEBGL_compressed_texture_etc")), r !== null)) { if (i === Al || i === Rl) return o === xt ? r.COMPRESSED_SRGB8_ETC2 : r.COMPRESSED_RGB8_ETC2; if (i === Ll) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : r.COMPRESSED_RGBA8_ETC2_EAC; } else return null; if ( i === Cl || i === Il || i === Pl || i === Dl || i === Ul || i === Nl || i === Fl || i === Ol || i === kl || i === zl || i === Hl || i === Bl || i === Gl || i === Vl ) if (((r = t.get("WEBGL_compressed_texture_astc")), r !== null)) { if (i === Cl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : r.COMPRESSED_RGBA_ASTC_4x4_KHR; if (i === Il) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : r.COMPRESSED_RGBA_ASTC_5x4_KHR; if (i === Pl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : r.COMPRESSED_RGBA_ASTC_5x5_KHR; if (i === Dl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : r.COMPRESSED_RGBA_ASTC_6x5_KHR; if (i === Ul) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : r.COMPRESSED_RGBA_ASTC_6x6_KHR; if (i === Nl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : r.COMPRESSED_RGBA_ASTC_8x5_KHR; if (i === Fl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : r.COMPRESSED_RGBA_ASTC_8x6_KHR; if (i === Ol) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : r.COMPRESSED_RGBA_ASTC_8x8_KHR; if (i === kl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : r.COMPRESSED_RGBA_ASTC_10x5_KHR; if (i === zl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : r.COMPRESSED_RGBA_ASTC_10x6_KHR; if (i === Hl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : r.COMPRESSED_RGBA_ASTC_10x8_KHR; if (i === Bl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : r.COMPRESSED_RGBA_ASTC_10x10_KHR; if (i === Gl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : r.COMPRESSED_RGBA_ASTC_12x10_KHR; if (i === Vl) return o === xt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : r.COMPRESSED_RGBA_ASTC_12x12_KHR; } else return null; if (i === Wl || i === Xl || i === ql) if (((r = t.get("EXT_texture_compression_bptc")), r !== null)) { if (i === Wl) return o === xt ? r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : r.COMPRESSED_RGBA_BPTC_UNORM_EXT; if (i === Xl) return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT; if (i === ql) return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT; } else return null; if (i === Yl || i === jl || i === Zl || i === Kl) if (((r = t.get("EXT_texture_compression_rgtc")), r !== null)) { if (i === Yl) return r.COMPRESSED_RED_RGTC1_EXT; if (i === jl) return r.COMPRESSED_SIGNED_RED_RGTC1_EXT; if (i === Zl) return r.COMPRESSED_RED_GREEN_RGTC2_EXT; if (i === Kl) return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT; } else return null; if (i === Js) return e.UNSIGNED_INT_24_8; return e[i] !== void 0 ? e[i] : null; } return { convert: n }; } var kv = ` void main() { gl_Position = vec4( position, 1.0 ); }`, zv = ` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; void main() { vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); if ( coord.x >= 1.0 ) { gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; } else { gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; } }`; class cf { constructor() { ((this.texture = null), (this.mesh = null), (this.depthNear = 0), (this.depthFar = 0)); } init(e, t) { if (this.texture === null) { let n = new aa(e.texture); if (e.depthNear !== t.depthNear || e.depthFar !== t.depthFar) ((this.depthNear = e.depthNear), (this.depthFar = e.depthFar)); this.texture = n; } } getMesh(e) { if (this.texture !== null) { if (this.mesh === null) { let t = e.cameras[0].viewport, n = new Zn({ vertexShader: kv, fragmentShader: zv, uniforms: { depthColor: { value: this.texture }, depthWidth: { value: t.z }, depthHeight: { value: t.w } }, }); this.mesh = new st(new Vi(20, 20), n); } } return this.mesh; } reset() { ((this.texture = null), (this.mesh = null)); } getDepthTexture() { return this.texture; } } class hf extends jn { constructor(e, t) { super(); let n = this, i = null, s = 1, r = null, o = "local-floor", a = 1, l = null, c = null, h = null, u = null, d = null, f = null, m = typeof XRWebGLBinding < "u", y = new cf(), p = {}, g = t.getContextAttributes(), _ = null, x = null, w = [], L = [], b = new ve(), R = null, F = new It(); F.viewport = new Ye(); let M = new It(); M.viewport = new Ye(); let T = [F, M], I = new vc(), G = null, q = null; ((this.cameraAutoUpdate = !0), (this.enabled = !1), (this.isPresenting = !1), (this.getController = function (k) { let J = w[k]; if (J === void 0) ((J = new Wr()), (w[k] = J)); return J.getTargetRaySpace(); }), (this.getControllerGrip = function (k) { let J = w[k]; if (J === void 0) ((J = new Wr()), (w[k] = J)); return J.getGripSpace(); }), (this.getHand = function (k) { let J = w[k]; if (J === void 0) ((J = new Wr()), (w[k] = J)); return J.getHandSpace(); })); function B(k) { let J = L.indexOf(k.inputSource); if (J === -1) return; let ee = w[J]; if (ee !== void 0) (ee.update(k.inputSource, k.frame, l || r), ee.dispatchEvent({ type: k.type, data: k.inputSource })); } function Z() { (i.removeEventListener("select", B), i.removeEventListener("selectstart", B), i.removeEventListener("selectend", B), i.removeEventListener("squeeze", B), i.removeEventListener("squeezestart", B), i.removeEventListener("squeezeend", B), i.removeEventListener("end", Z), i.removeEventListener("inputsourceschange", W)); for (let k = 0; k < w.length; k++) { let J = L[k]; if (J === null) continue; ((L[k] = null), w[k].disconnect(J)); } ((G = null), (q = null), y.reset()); for (let k in p) delete p[k]; (e.setRenderTarget(_), (d = null), (u = null), (h = null), (i = null), (x = null), Ke.stop(), (n.isPresenting = !1), e.setPixelRatio(R), e.setSize(b.width, b.height, !1), n.dispatchEvent({ type: "sessionend" })); } ((this.setFramebufferScaleFactor = function (k) { if (((s = k), n.isPresenting === !0)) console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting."); }), (this.setReferenceSpaceType = function (k) { if (((o = k), n.isPresenting === !0)) console.warn("THREE.WebXRManager: Cannot change reference space type while presenting."); }), (this.getReferenceSpace = function () { return l || r; }), (this.setReferenceSpace = function (k) { l = k; }), (this.getBaseLayer = function () { return u !== null ? u : d; }), (this.getBinding = function () { if (h === null && m) h = new XRWebGLBinding(i, t); return h; }), (this.getFrame = function () { return f; }), (this.getSession = function () { return i; }), (this.setSession = async function (k) { if (((i = k), i !== null)) { if ( ((_ = e.getRenderTarget()), i.addEventListener("select", B), i.addEventListener("selectstart", B), i.addEventListener("selectend", B), i.addEventListener("squeeze", B), i.addEventListener("squeezestart", B), i.addEventListener("squeezeend", B), i.addEventListener("end", Z), i.addEventListener("inputsourceschange", W), g.xrCompatible !== !0) ) await t.makeXRCompatible(); if (((R = e.getPixelRatio()), e.getSize(b), !(m && "createProjectionLayer" in XRWebGLBinding.prototype))) { let ee = { antialias: g.antialias, alpha: !0, depth: g.depth, stencil: g.stencil, framebufferScaleFactor: s, }; ((d = new XRWebGLLayer(i, t, ee)), i.updateRenderState({ baseLayer: d }), e.setPixelRatio(1), e.setSize(d.framebufferWidth, d.framebufferHeight, !1), (x = new vi(d.framebufferWidth, d.framebufferHeight, { format: Yn, type: ki, colorSpace: e.outputColorSpace, stencilBuffer: g.stencil, resolveDepthBuffer: d.ignoreDepthValues === !1, resolveStencilBuffer: d.ignoreDepthValues === !1, }))); } else { let ee = null, ae = null, ge = null; if (g.depth) ((ge = g.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24), (ee = g.stencil ? Hr : jo), (ae = g.stencil ? Js : $s)); let Ee = { colorFormat: t.RGBA8, depthFormat: ge, scaleFactor: s }; ((h = this.getBinding()), (u = h.createProjectionLayer(Ee)), i.updateRenderState({ layers: [u] }), e.setPixelRatio(1), e.setSize(u.textureWidth, u.textureHeight, !1), (x = new vi(u.textureWidth, u.textureHeight, { format: Yn, type: ki, depthTexture: new oa( u.textureWidth, u.textureHeight, ae, void 0, void 0, void 0, void 0, void 0, void 0, ee, ), stencilBuffer: g.stencil, colorSpace: e.outputColorSpace, samples: g.antialias ? 4 : 0, resolveDepthBuffer: u.ignoreDepthValues === !1, resolveStencilBuffer: u.ignoreDepthValues === !1, }))); } ((x.isXRRenderTarget = !0), this.setFoveation(a), (l = null), (r = await i.requestReferenceSpace(o)), Ke.setContext(i), Ke.start(), (n.isPresenting = !0), n.dispatchEvent({ type: "sessionstart" })); } }), (this.getEnvironmentBlendMode = function () { if (i !== null) return i.environmentBlendMode; }), (this.getDepthTexture = function () { return y.getDepthTexture(); })); function W(k) { for (let J = 0; J < k.removed.length; J++) { let ee = k.removed[J], ae = L.indexOf(ee); if (ae >= 0) ((L[ae] = null), w[ae].disconnect(ee)); } for (let J = 0; J < k.added.length; J++) { let ee = k.added[J], ae = L.indexOf(ee); if (ae === -1) { for (let Ee = 0; Ee < w.length; Ee++) if (Ee >= L.length) { (L.push(ee), (ae = Ee)); break; } else if (L[Ee] === null) { ((L[Ee] = ee), (ae = Ee)); break; } if (ae === -1) break; } let ge = w[ae]; if (ge) ge.connect(ee); } } let K = new E(), V = new E(); function se(k, J, ee) { (K.setFromMatrixPosition(J.matrixWorld), V.setFromMatrixPosition(ee.matrixWorld)); let ae = K.distanceTo(V), ge = J.projectionMatrix.elements, Ee = ee.projectionMatrix.elements, vt = ge[14] / (ge[10] - 1), C = ge[14] / (ge[10] + 1), ot = (ge[9] + 1) / ge[5], Xe = (ge[9] - 1) / ge[5], He = (ge[8] - 1) / ge[0], we = (Ee[8] + 1) / Ee[0], St = vt * He, Le = vt * we, De = ae / (-He + we), Bt = De * -He; if ( (J.matrixWorld.decompose(k.position, k.quaternion, k.scale), k.translateX(Bt), k.translateZ(De), k.matrixWorld.compose(k.position, k.quaternion, k.scale), k.matrixWorldInverse.copy(k.matrixWorld).invert(), ge[10] === -1) ) (k.projectionMatrix.copy(J.projectionMatrix), k.projectionMatrixInverse.copy(J.projectionMatrixInverse)); else { let kt = vt + De, Ct = C + De, A = St - Bt, v = Le + (ae - Bt), O = ((ot * C) / Ct) * kt, Y = ((Xe * C) / Ct) * kt; (k.projectionMatrix.makePerspective(A, v, O, Y, kt, Ct), k.projectionMatrixInverse.copy(k.projectionMatrix).invert()); } } function ce(k, J) { if (J === null) k.matrixWorld.copy(k.matrix); else k.matrixWorld.multiplyMatrices(J.matrixWorld, k.matrix); k.matrixWorldInverse.copy(k.matrixWorld).invert(); } this.updateCamera = function (k) { if (i === null) return; let { near: J, far: ee } = k; if (y.texture !== null) { if (y.depthNear > 0) J = y.depthNear; if (y.depthFar > 0) ee = y.depthFar; } if (((I.near = M.near = F.near = J), (I.far = M.far = F.far = ee), G !== I.near || q !== I.far)) (i.updateRenderState({ depthNear: I.near, depthFar: I.far }), (G = I.near), (q = I.far)); ((I.layers.mask = k.layers.mask | 6), (F.layers.mask = I.layers.mask & 3), (M.layers.mask = I.layers.mask & 5)); let ae = k.parent, ge = I.cameras; ce(I, ae); for (let Ee = 0; Ee < ge.length; Ee++) ce(ge[Ee], ae); if (ge.length === 2) se(I, F, M); else I.projectionMatrix.copy(F.projectionMatrix); Pe(k, I, ae); }; function Pe(k, J, ee) { if (ee === null) k.matrix.copy(J.matrixWorld); else (k.matrix.copy(ee.matrixWorld), k.matrix.invert(), k.matrix.multiply(J.matrixWorld)); if ( (k.matrix.decompose(k.position, k.quaternion, k.scale), k.updateMatrixWorld(!0), k.projectionMatrix.copy(J.projectionMatrix), k.projectionMatrixInverse.copy(J.projectionMatrixInverse), k.isPerspectiveCamera) ) ((k.fov = ls * 2 * Math.atan(1 / k.projectionMatrix.elements[5])), (k.zoom = 1)); } ((this.getCamera = function () { return I; }), (this.getFoveation = function () { if (u === null && d === null) return; return a; }), (this.setFoveation = function (k) { if (((a = k), u !== null)) u.fixedFoveation = k; if (d !== null && d.fixedFoveation !== void 0) d.fixedFoveation = k; }), (this.hasDepthSensing = function () { return y.texture !== null; }), (this.getDepthSensingMesh = function () { return y.getMesh(I); }), (this.getCameraTexture = function (k) { return p[k]; })); let We = null; function rt(k, J) { if (((c = J.getViewerPose(l || r)), (f = J), c !== null)) { let ee = c.views; if (d !== null) (e.setRenderTargetFramebuffer(x, d.framebuffer), e.setRenderTarget(x)); let ae = !1; if (ee.length !== I.cameras.length) ((I.cameras.length = 0), (ae = !0)); for (let C = 0; C < ee.length; C++) { let ot = ee[C], Xe = null; if (d !== null) Xe = d.getViewport(ot); else { let we = h.getViewSubImage(u, ot); if (((Xe = we.viewport), C === 0)) (e.setRenderTargetTextures(x, we.colorTexture, we.depthStencilTexture), e.setRenderTarget(x)); } let He = T[C]; if (He === void 0) ((He = new It()), He.layers.enable(C), (He.viewport = new Ye()), (T[C] = He)); if ( (He.matrix.fromArray(ot.transform.matrix), He.matrix.decompose(He.position, He.quaternion, He.scale), He.projectionMatrix.fromArray(ot.projectionMatrix), He.projectionMatrixInverse.copy(He.projectionMatrix).invert(), He.viewport.set(Xe.x, Xe.y, Xe.width, Xe.height), C === 0) ) (I.matrix.copy(He.matrix), I.matrix.decompose(I.position, I.quaternion, I.scale)); if (ae === !0) I.cameras.push(He); } let ge = i.enabledFeatures; if (ge && ge.includes("depth-sensing") && i.depthUsage == "gpu-optimized" && m) { h = n.getBinding(); let C = h.getDepthInformation(ee[0]); if (C && C.isValid && C.texture) y.init(C, i.renderState); } if (ge && ge.includes("camera-access") && m) { (e.state.unbindTexture(), (h = n.getBinding())); for (let C = 0; C < ee.length; C++) { let ot = ee[C].camera; if (ot) { let Xe = p[ot]; if (!Xe) ((Xe = new aa()), (p[ot] = Xe)); let He = h.getCameraImage(ot); Xe.sourceTexture = He; } } } } for (let ee = 0; ee < w.length; ee++) { let ae = L[ee], ge = w[ee]; if (ae !== null && ge !== void 0) ge.update(ae, J, l || r); } if (We) We(k, J); if (J.detectedPlanes) n.dispatchEvent({ type: "planesdetected", data: J }); f = null; } let Ke = new Jd(); (Ke.setAnimationLoop(rt), (this.setAnimationLoop = function (k) { We = k; }), (this.dispose = function () {})); } } var vs = new tt(), Hv = new ue(); function Bv(e, t) { function n(p, g) { if (p.matrixAutoUpdate === !0) p.updateMatrix(); g.value.copy(p.matrix); } function i(p, g) { if ((g.color.getRGB(p.fogColor.value, cc(e)), g.isFog)) ((p.fogNear.value = g.near), (p.fogFar.value = g.far)); else if (g.isFogExp2) p.fogDensity.value = g.density; } function s(p, g, _, x, w) { if (g.isMeshBasicMaterial) r(p, g); else if (g.isMeshLambertMaterial) r(p, g); else if (g.isMeshToonMaterial) (r(p, g), u(p, g)); else if (g.isMeshPhongMaterial) (r(p, g), h(p, g)); else if (g.isMeshStandardMaterial) { if ((r(p, g), d(p, g), g.isMeshPhysicalMaterial)) f(p, g, w); } else if (g.isMeshMatcapMaterial) (r(p, g), m(p, g)); else if (g.isMeshDepthMaterial) r(p, g); else if (g.isMeshDistanceMaterial) (r(p, g), y(p, g)); else if (g.isMeshNormalMaterial) r(p, g); else if (g.isLineBasicMaterial) { if ((o(p, g), g.isLineDashedMaterial)) a(p, g); } else if (g.isPointsMaterial) l(p, g, _, x); else if (g.isSpriteMaterial) c(p, g); else if (g.isShadowMaterial) (p.color.value.copy(g.color), (p.opacity.value = g.opacity)); else if (g.isShaderMaterial) g.uniformsNeedUpdate = !1; } function r(p, g) { if (((p.opacity.value = g.opacity), g.color)) p.diffuse.value.copy(g.color); if (g.emissive) p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity); if (g.map) ((p.map.value = g.map), n(g.map, p.mapTransform)); if (g.alphaMap) ((p.alphaMap.value = g.alphaMap), n(g.alphaMap, p.alphaMapTransform)); if (g.bumpMap) { if ( ((p.bumpMap.value = g.bumpMap), n(g.bumpMap, p.bumpMapTransform), (p.bumpScale.value = g.bumpScale), g.side === Gt) ) p.bumpScale.value *= -1; } if (g.normalMap) { if ( ((p.normalMap.value = g.normalMap), n(g.normalMap, p.normalMapTransform), p.normalScale.value.copy(g.normalScale), g.side === Gt) ) p.normalScale.value.negate(); } if (g.displacementMap) ((p.displacementMap.value = g.displacementMap), n(g.displacementMap, p.displacementMapTransform), (p.displacementScale.value = g.displacementScale), (p.displacementBias.value = g.displacementBias)); if (g.emissiveMap) ((p.emissiveMap.value = g.emissiveMap), n(g.emissiveMap, p.emissiveMapTransform)); if (g.specularMap) ((p.specularMap.value = g.specularMap), n(g.specularMap, p.specularMapTransform)); if (g.alphaTest > 0) p.alphaTest.value = g.alphaTest; let _ = t.get(g), { envMap: x, envMapRotation: w } = _; if (x) { if ( ((p.envMap.value = x), vs.copy(w), (vs.x *= -1), (vs.y *= -1), (vs.z *= -1), x.isCubeTexture && x.isRenderTargetTexture === !1) ) ((vs.y *= -1), (vs.z *= -1)); (p.envMapRotation.value.setFromMatrix4(Hv.makeRotationFromEuler(vs)), (p.flipEnvMap.value = x.isCubeTexture && x.isRenderTargetTexture === !1 ? -1 : 1), (p.reflectivity.value = g.reflectivity), (p.ior.value = g.ior), (p.refractionRatio.value = g.refractionRatio)); } if (g.lightMap) ((p.lightMap.value = g.lightMap), (p.lightMapIntensity.value = g.lightMapIntensity), n(g.lightMap, p.lightMapTransform)); if (g.aoMap) ((p.aoMap.value = g.aoMap), (p.aoMapIntensity.value = g.aoMapIntensity), n(g.aoMap, p.aoMapTransform)); } function o(p, g) { if ((p.diffuse.value.copy(g.color), (p.opacity.value = g.opacity), g.map)) ((p.map.value = g.map), n(g.map, p.mapTransform)); } function a(p, g) { ((p.dashSize.value = g.dashSize), (p.totalSize.value = g.dashSize + g.gapSize), (p.scale.value = g.scale)); } function l(p, g, _, x) { if ( (p.diffuse.value.copy(g.color), (p.opacity.value = g.opacity), (p.size.value = g.size * _), (p.scale.value = x * 0.5), g.map) ) ((p.map.value = g.map), n(g.map, p.uvTransform)); if (g.alphaMap) ((p.alphaMap.value = g.alphaMap), n(g.alphaMap, p.alphaMapTransform)); if (g.alphaTest > 0) p.alphaTest.value = g.alphaTest; } function c(p, g) { if ((p.diffuse.value.copy(g.color), (p.opacity.value = g.opacity), (p.rotation.value = g.rotation), g.map)) ((p.map.value = g.map), n(g.map, p.mapTransform)); if (g.alphaMap) ((p.alphaMap.value = g.alphaMap), n(g.alphaMap, p.alphaMapTransform)); if (g.alphaTest > 0) p.alphaTest.value = g.alphaTest; } function h(p, g) { (p.specular.value.copy(g.specular), (p.shininess.value = Math.max(g.shininess, 0.0001))); } function u(p, g) { if (g.gradientMap) p.gradientMap.value = g.gradientMap; } function d(p, g) { if (((p.metalness.value = g.metalness), g.metalnessMap)) ((p.metalnessMap.value = g.metalnessMap), n(g.metalnessMap, p.metalnessMapTransform)); if (((p.roughness.value = g.roughness), g.roughnessMap)) ((p.roughnessMap.value = g.roughnessMap), n(g.roughnessMap, p.roughnessMapTransform)); if (g.envMap) p.envMapIntensity.value = g.envMapIntensity; } function f(p, g, _) { if (((p.ior.value = g.ior), g.sheen > 0)) { if ( (p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen), (p.sheenRoughness.value = g.sheenRoughness), g.sheenColorMap) ) ((p.sheenColorMap.value = g.sheenColorMap), n(g.sheenColorMap, p.sheenColorMapTransform)); if (g.sheenRoughnessMap) ((p.sheenRoughnessMap.value = g.sheenRoughnessMap), n(g.sheenRoughnessMap, p.sheenRoughnessMapTransform)); } if (g.clearcoat > 0) { if (((p.clearcoat.value = g.clearcoat), (p.clearcoatRoughness.value = g.clearcoatRoughness), g.clearcoatMap)) ((p.clearcoatMap.value = g.clearcoatMap), n(g.clearcoatMap, p.clearcoatMapTransform)); if (g.clearcoatRoughnessMap) ((p.clearcoatRoughnessMap.value = g.clearcoatRoughnessMap), n(g.clearcoatRoughnessMap, p.clearcoatRoughnessMapTransform)); if (g.clearcoatNormalMap) { if ( ((p.clearcoatNormalMap.value = g.clearcoatNormalMap), n(g.clearcoatNormalMap, p.clearcoatNormalMapTransform), p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale), g.side === Gt) ) p.clearcoatNormalScale.value.negate(); } } if (g.dispersion > 0) p.dispersion.value = g.dispersion; if (g.iridescence > 0) { if ( ((p.iridescence.value = g.iridescence), (p.iridescenceIOR.value = g.iridescenceIOR), (p.iridescenceThicknessMinimum.value = g.iridescenceThicknessRange[0]), (p.iridescenceThicknessMaximum.value = g.iridescenceThicknessRange[1]), g.iridescenceMap) ) ((p.iridescenceMap.value = g.iridescenceMap), n(g.iridescenceMap, p.iridescenceMapTransform)); if (g.iridescenceThicknessMap) ((p.iridescenceThicknessMap.value = g.iridescenceThicknessMap), n(g.iridescenceThicknessMap, p.iridescenceThicknessMapTransform)); } if (g.transmission > 0) { if ( ((p.transmission.value = g.transmission), (p.transmissionSamplerMap.value = _.texture), p.transmissionSamplerSize.value.set(_.width, _.height), g.transmissionMap) ) ((p.transmissionMap.value = g.transmissionMap), n(g.transmissionMap, p.transmissionMapTransform)); if (((p.thickness.value = g.thickness), g.thicknessMap)) ((p.thicknessMap.value = g.thicknessMap), n(g.thicknessMap, p.thicknessMapTransform)); ((p.attenuationDistance.value = g.attenuationDistance), p.attenuationColor.value.copy(g.attenuationColor)); } if (g.anisotropy > 0) { if ( (p.anisotropyVector.value.set( g.anisotropy * Math.cos(g.anisotropyRotation), g.anisotropy * Math.sin(g.anisotropyRotation), ), g.anisotropyMap) ) ((p.anisotropyMap.value = g.anisotropyMap), n(g.anisotropyMap, p.anisotropyMapTransform)); } if ( ((p.specularIntensity.value = g.specularIntensity), p.specularColor.value.copy(g.specularColor), g.specularColorMap) ) ((p.specularColorMap.value = g.specularColorMap), n(g.specularColorMap, p.specularColorMapTransform)); if (g.specularIntensityMap) ((p.specularIntensityMap.value = g.specularIntensityMap), n(g.specularIntensityMap, p.specularIntensityMapTransform)); } function m(p, g) { if (g.matcap) p.matcap.value = g.matcap; } function y(p, g) { let _ = t.get(g).light; (p.referencePosition.value.setFromMatrixPosition(_.matrixWorld), (p.nearDistance.value = _.shadow.camera.near), (p.farDistance.value = _.shadow.camera.far)); } return { refreshFogUniforms: i, refreshMaterialUniforms: s }; } function Gv(e, t, n, i) { let s = {}, r = {}, o = [], a = e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS); function l(_, x) { let w = x.program; i.uniformBlockBinding(_, w); } function c(_, x) { let w = s[_.id]; if (w === void 0) (m(_), (w = h(_)), (s[_.id] = w), _.addEventListener("dispose", p)); let L = x.program; i.updateUBOMapping(_, L); let b = t.render.frame; if (r[_.id] !== b) (d(_), (r[_.id] = b)); } function h(_) { let x = u(); _.__bindingPointIndex = x; let w = e.createBuffer(), { __size: L, usage: b } = _; return ( e.bindBuffer(e.UNIFORM_BUFFER, w), e.bufferData(e.UNIFORM_BUFFER, L, b), e.bindBuffer(e.UNIFORM_BUFFER, null), e.bindBufferBase(e.UNIFORM_BUFFER, x, w), w ); } function u() { for (let _ = 0; _ < a; _++) if (o.indexOf(_) === -1) return (o.push(_), _); return (console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0); } function d(_) { let x = s[_.id], { uniforms: w, __cache: L } = _; e.bindBuffer(e.UNIFORM_BUFFER, x); for (let b = 0, R = w.length; b < R; b++) { let F = Array.isArray(w[b]) ? w[b] : [w[b]]; for (let M = 0, T = F.length; M < T; M++) { let I = F[M]; if (f(I, b, M, L) === !0) { let G = I.__offset, q = Array.isArray(I.value) ? I.value : [I.value], B = 0; for (let Z = 0; Z < q.length; Z++) { let W = q[Z], K = y(W); if (typeof W === "number" || typeof W === "boolean") ((I.__data[0] = W), e.bufferSubData(e.UNIFORM_BUFFER, G + B, I.__data)); else if (W.isMatrix3) ((I.__data[0] = W.elements[0]), (I.__data[1] = W.elements[1]), (I.__data[2] = W.elements[2]), (I.__data[3] = 0), (I.__data[4] = W.elements[3]), (I.__data[5] = W.elements[4]), (I.__data[6] = W.elements[5]), (I.__data[7] = 0), (I.__data[8] = W.elements[6]), (I.__data[9] = W.elements[7]), (I.__data[10] = W.elements[8]), (I.__data[11] = 0)); else (W.toArray(I.__data, B), (B += K.storage / Float32Array.BYTES_PER_ELEMENT)); } e.bufferSubData(e.UNIFORM_BUFFER, G, I.__data); } } } e.bindBuffer(e.UNIFORM_BUFFER, null); } function f(_, x, w, L) { let b = _.value, R = x + "_" + w; if (L[R] === void 0) { if (typeof b === "number" || typeof b === "boolean") L[R] = b; else L[R] = b.clone(); return !0; } else { let F = L[R]; if (typeof b === "number" || typeof b === "boolean") { if (F !== b) return ((L[R] = b), !0); } else if (F.equals(b) === !1) return (F.copy(b), !0); } return !1; } function m(_) { let x = _.uniforms, w = 0, L = 16; for (let R = 0, F = x.length; R < F; R++) { let M = Array.isArray(x[R]) ? x[R] : [x[R]]; for (let T = 0, I = M.length; T < I; T++) { let G = M[T], q = Array.isArray(G.value) ? G.value : [G.value]; for (let B = 0, Z = q.length; B < Z; B++) { let W = q[B], K = y(W), V = w % L, se = V % K.boundary, ce = V + se; if (((w += se), ce !== 0 && L - ce < K.storage)) w += L - ce; ((G.__data = new Float32Array(K.storage / Float32Array.BYTES_PER_ELEMENT)), (G.__offset = w), (w += K.storage)); } } } let b = w % L; if (b > 0) w += L - b; return ((_.__size = w), (_.__cache = {}), this); } function y(_) { let x = { boundary: 0, storage: 0 }; if (typeof _ === "number" || typeof _ === "boolean") ((x.boundary = 4), (x.storage = 4)); else if (_.isVector2) ((x.boundary = 8), (x.storage = 8)); else if (_.isVector3 || _.isColor) ((x.boundary = 16), (x.storage = 12)); else if (_.isVector4) ((x.boundary = 16), (x.storage = 16)); else if (_.isMatrix3) ((x.boundary = 48), (x.storage = 48)); else if (_.isMatrix4) ((x.boundary = 64), (x.storage = 64)); else if (_.isTexture) console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."); else console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", _); return x; } function p(_) { let x = _.target; x.removeEventListener("dispose", p); let w = o.indexOf(x.__bindingPointIndex); (o.splice(w, 1), e.deleteBuffer(s[x.id]), delete s[x.id], delete r[x.id]); } function g() { for (let _ in s) e.deleteBuffer(s[_]); ((o = []), (s = {}), (r = {})); } return { bind: l, update: c, dispose: g }; } class Dc { constructor(e = {}) { let { canvas: t = fd(), context: n = null, depth: i = !0, stencil: s = !1, alpha: r = !1, antialias: o = !1, premultipliedAlpha: a = !0, preserveDrawingBuffer: l = !1, powerPreference: c = "default", failIfMajorPerformanceCaveat: h = !1, reversedDepthBuffer: u = !1, } = e; this.isWebGLRenderer = !0; let d; if (n !== null) { if (typeof WebGLRenderingContext < "u" && n instanceof WebGLRenderingContext) throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163."); d = n.getContextAttributes().alpha; } else d = r; let f = new Uint32Array(4), m = new Int32Array(4), y = null, p = null, g = [], _ = []; ((this.domElement = t), (this.debug = { checkShaderErrors: !0, onShaderError: null }), (this.autoClear = !0), (this.autoClearColor = !0), (this.autoClearDepth = !0), (this.autoClearStencil = !0), (this.sortObjects = !0), (this.clippingPlanes = []), (this.localClippingEnabled = !1), (this.toneMapping = mi), (this.toneMappingExposure = 1), (this.transmissionResolutionScale = 1)); let x = this, w = !1; this._outputColorSpace = lt; let L = 0, b = 0, R = null, F = -1, M = null, T = new Ye(), I = new Ye(), G = null, q = new re(0), B = 0, { width: Z, height: W } = t, K = 1, V = null, se = null, ce = new Ye(0, 0, Z, W), Pe = new Ye(0, 0, Z, W), We = !1, rt = new qr(), Ke = !1, k = !1, J = new ue(), ee = new E(), ae = new Ye(), ge = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 }, Ee = !1; function vt() { return R === null ? K : 1; } let C = n; function ot(S, U) { return t.getContext(S, U); } try { let S = { alpha: !0, depth: i, stencil: s, antialias: o, premultipliedAlpha: a, preserveDrawingBuffer: l, powerPreference: c, failIfMajorPerformanceCaveat: h, }; if ("setAttribute" in t) t.setAttribute("data-engine", `three.js r${vu}`); if ( (t.addEventListener("webglcontextlost", de, !1), t.addEventListener("webglcontextrestored", le, !1), t.addEventListener("webglcontextcreationerror", _e, !1), C === null) ) { if (((C = ot("webgl2", S)), C === null)) if (ot("webgl2")) throw Error("Error creating WebGL context with your selected attributes."); else throw Error("Error creating WebGL context."); } } catch (S) { throw (console.error("THREE.WebGLRenderer: " + S.message), S); } let Xe, He, we, St, Le, De, Bt, kt, Ct, A, v, O, Y, Q, X, xe, oe, Te, Fe, ie, pe, Ae, Re, me; function je() { if ( ((Xe = new ox(C)), Xe.init(), (Ae = new Ov(C, Xe)), (He = new Qy(C, Xe, e, Ae)), (we = new Nv(C, Xe)), He.reversedDepthBuffer && u) ) we.buffers.depth.setReversed(!0); ((St = new cx(C)), (Le = new bv()), (De = new Fv(C, Xe, we, Le, He, Ae, St)), (Bt = new tx(x)), (kt = new rx(x)), (Ct = new m0(C)), (Re = new $y(C, Ct)), (A = new ax(C, Ct, St, Re)), (v = new ux(C, A, Ct, St)), (Fe = new hx(C, He, De)), (xe = new ex(Le)), (O = new Sv(x, Bt, kt, Xe, He, Re, xe)), (Y = new Bv(x, Le)), (Q = new wv()), (X = new Cv(Xe)), (Te = new Ky(x, Bt, kt, we, v, d, a)), (oe = new Dv(x, v, He)), (me = new Gv(C, St, He, we)), (ie = new Jy(C, Xe, St)), (pe = new lx(C, Xe, St)), (St.programs = O.programs), (x.capabilities = He), (x.extensions = Xe), (x.properties = Le), (x.renderLists = Q), (x.shadowMap = oe), (x.state = we), (x.info = St)); } je(); let P = new hf(x, C); ((this.xr = P), (this.getContext = function () { return C; }), (this.getContextAttributes = function () { return C.getContextAttributes(); }), (this.forceContextLoss = function () { let S = Xe.get("WEBGL_lose_context"); if (S) S.loseContext(); }), (this.forceContextRestore = function () { let S = Xe.get("WEBGL_lose_context"); if (S) S.restoreContext(); }), (this.getPixelRatio = function () { return K; }), (this.setPixelRatio = function (S) { if (S === void 0) return; ((K = S), this.setSize(Z, W, !1)); }), (this.getSize = function (S) { return S.set(Z, W); }), (this.setSize = function (S, U, z = !0) { if (P.isPresenting) { console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."); return; } if (((Z = S), (W = U), (t.width = Math.floor(S * K)), (t.height = Math.floor(U * K)), z === !0)) ((t.style.width = S + "px"), (t.style.height = U + "px")); this.setViewport(0, 0, S, U); }), (this.getDrawingBufferSize = function (S) { return S.set(Z * K, W * K).floor(); }), (this.setDrawingBufferSize = function (S, U, z) { ((Z = S), (W = U), (K = z), (t.width = Math.floor(S * z)), (t.height = Math.floor(U * z)), this.setViewport(0, 0, S, U)); }), (this.getCurrentViewport = function (S) { return S.copy(T); }), (this.getViewport = function (S) { return S.copy(ce); }), (this.setViewport = function (S, U, z, H) { if (S.isVector4) ce.set(S.x, S.y, S.z, S.w); else ce.set(S, U, z, H); we.viewport(T.copy(ce).multiplyScalar(K).round()); }), (this.getScissor = function (S) { return S.copy(Pe); }), (this.setScissor = function (S, U, z, H) { if (S.isVector4) Pe.set(S.x, S.y, S.z, S.w); else Pe.set(S, U, z, H); we.scissor(I.copy(Pe).multiplyScalar(K).round()); }), (this.getScissorTest = function () { return We; }), (this.setScissorTest = function (S) { we.setScissorTest((We = S)); }), (this.setOpaqueSort = function (S) { V = S; }), (this.setTransparentSort = function (S) { se = S; }), (this.getClearColor = function (S) { return S.copy(Te.getClearColor()); }), (this.setClearColor = function () { Te.setClearColor(...arguments); }), (this.getClearAlpha = function () { return Te.getClearAlpha(); }), (this.setClearAlpha = function () { Te.setClearAlpha(...arguments); }), (this.clear = function (S = !0, U = !0, z = !0) { let H = 0; if (S) { let N = !1; if (R !== null) { let ne = R.texture.format; N = ne === bl || ne === Sl || ne === _l; } if (N) { let ne = R.texture.type, fe = ne === ki || ne === $s || ne === kr || ne === Js || ne === xl || ne === vl, Se = Te.getClearColor(), ye = Te.getClearAlpha(), { r: Ue, g: Oe, b: Ce } = Se; if (fe) ((f[0] = Ue), (f[1] = Oe), (f[2] = Ce), (f[3] = ye), C.clearBufferuiv(C.COLOR, 0, f)); else ((m[0] = Ue), (m[1] = Oe), (m[2] = Ce), (m[3] = ye), C.clearBufferiv(C.COLOR, 0, m)); } else H |= C.COLOR_BUFFER_BIT; } if (U) H |= C.DEPTH_BUFFER_BIT; if (z) ((H |= C.STENCIL_BUFFER_BIT), this.state.buffers.stencil.setMask(4294967295)); C.clear(H); }), (this.clearColor = function () { this.clear(!0, !1, !1); }), (this.clearDepth = function () { this.clear(!1, !0, !1); }), (this.clearStencil = function () { this.clear(!1, !1, !0); }), (this.dispose = function () { (t.removeEventListener("webglcontextlost", de, !1), t.removeEventListener("webglcontextrestored", le, !1), t.removeEventListener("webglcontextcreationerror", _e, !1), Te.dispose(), Q.dispose(), X.dispose(), Le.dispose(), Bt.dispose(), kt.dispose(), v.dispose(), Re.dispose(), me.dispose(), O.dispose(), P.dispose(), P.removeEventListener("sessionstart", Vn), P.removeEventListener("sessionend", Wn), ns.stop()); })); function de(S) { (S.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), (w = !0)); } function le() { (console.log("THREE.WebGLRenderer: Context Restored."), (w = !1)); let S = St.autoReset, U = oe.enabled, z = oe.autoUpdate, H = oe.needsUpdate, N = oe.type; (je(), (St.autoReset = S), (oe.enabled = U), (oe.autoUpdate = z), (oe.needsUpdate = H), (oe.type = N)); } function _e(S) { console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", S.statusMessage); } function te(S) { let U = S.target; (U.removeEventListener("dispose", te), j(U)); } function j(S) { (be(S), Le.remove(S)); } function be(S) { let U = Le.get(S).programs; if (U !== void 0) { if ( (U.forEach(function (z) { O.releaseProgram(z); }), S.isShaderMaterial) ) O.releaseShaderCache(S); } } this.renderBufferDirect = function (S, U, z, H, N, ne) { if (U === null) U = ge; let fe = N.isMesh && N.matrixWorld.determinant() < 0, Se = qp(S, U, z, H, N); we.setMaterial(H, fe); let ye = z.index, Ue = 1; if (H.wireframe === !0) { if (((ye = A.getWireframeAttribute(z)), ye === void 0)) return; Ue = 2; } let Oe = z.drawRange, Ce = z.attributes.position, et = Oe.start * Ue, ut = (Oe.start + Oe.count) * Ue; if (ne !== null) ((et = Math.max(et, ne.start * Ue)), (ut = Math.min(ut, (ne.start + ne.count) * Ue))); if (ye !== null) ((et = Math.max(et, 0)), (ut = Math.min(ut, ye.count))); else if (Ce !== void 0 && Ce !== null) ((et = Math.max(et, 0)), (ut = Math.min(ut, Ce.count))); let At = ut - et; if (At < 0 || At === 1 / 0) return; Re.setup(N, H, Se, z, ye); let _t, mt = ie; if (ye !== null) ((_t = Ct.get(ye)), (mt = pe), mt.setIndex(_t)); if (N.isMesh) if (H.wireframe === !0) (we.setLineWidth(H.wireframeLinewidth * vt()), mt.setMode(C.LINES)); else mt.setMode(C.TRIANGLES); else if (N.isLine) { let Ie = H.linewidth; if (Ie === void 0) Ie = 1; if ((we.setLineWidth(Ie * vt()), N.isLineSegments)) mt.setMode(C.LINES); else if (N.isLineLoop) mt.setMode(C.LINE_LOOP); else mt.setMode(C.LINE_STRIP); } else if (N.isPoints) mt.setMode(C.POINTS); else if (N.isSprite) mt.setMode(C.TRIANGLES); if (N.isBatchedMesh) if (N._multiDrawInstances !== null) (Ws( "THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.", ), mt.renderMultiDrawInstances( N._multiDrawStarts, N._multiDrawCounts, N._multiDrawCount, N._multiDrawInstances, )); else if (!Xe.get("WEBGL_multi_draw")) { let { _multiDrawStarts: Ie, _multiDrawCounts: Mt, _multiDrawCount: nt } = N, un = ye ? Ct.get(ye).bytesPerElement : 1, As = Le.get(H).currentProgram.getUniforms(); for (let dn = 0; dn < nt; dn++) (As.setValue(C, "_gl_DrawID", dn), mt.render(Ie[dn] / un, Mt[dn])); } else mt.renderMultiDraw(N._multiDrawStarts, N._multiDrawCounts, N._multiDrawCount); else if (N.isInstancedMesh) mt.renderInstances(et, At, N.count); else if (z.isInstancedBufferGeometry) { let Ie = z._maxInstanceCount !== void 0 ? z._maxInstanceCount : 1 / 0, Mt = Math.min(z.instanceCount, Ie); mt.renderInstances(et, At, Mt); } else mt.render(et, At); }; function Ge(S, U, z) { if (S.transparent === !0 && S.side === Yt && S.forceSinglePass === !1) ((S.side = Gt), (S.needsUpdate = !0), oo(S, U, z), (S.side = Fi), (S.needsUpdate = !0), oo(S, U, z), (S.side = Yt)); else oo(S, U, z); } ((this.compile = function (S, U, z = null) { if (z === null) z = S; if ( ((p = X.get(z)), p.init(U), _.push(p), z.traverseVisible(function (N) { if (N.isLight && N.layers.test(U.layers)) { if ((p.pushLight(N), N.castShadow)) p.pushShadow(N); } }), S !== z) ) S.traverseVisible(function (N) { if (N.isLight && N.layers.test(U.layers)) { if ((p.pushLight(N), N.castShadow)) p.pushShadow(N); } }); p.setupLights(); let H = new Set(); return ( S.traverse(function (N) { if (!(N.isMesh || N.isPoints || N.isLine || N.isSprite)) return; let ne = N.material; if (ne) if (Array.isArray(ne)) for (let fe = 0; fe < ne.length; fe++) { let Se = ne[fe]; (Ge(Se, z, N), H.add(Se)); } else (Ge(ne, z, N), H.add(ne)); }), (p = _.pop()), H ); }), (this.compileAsync = function (S, U, z = null) { let H = this.compile(S, U, z); return new Promise((N) => { function ne() { if ( (H.forEach(function (fe) { if (Le.get(fe).currentProgram.isReady()) H.delete(fe); }), H.size === 0) ) { N(S); return; } setTimeout(ne, 10); } if (Xe.get("KHR_parallel_shader_compile") !== null) ne(); else setTimeout(ne, 10); }); })); let pt = null; function ht(S) { if (pt) pt(S); } function Vn() { ns.stop(); } function Wn() { ns.start(); } let ns = new Jd(); if ((ns.setAnimationLoop(ht), typeof self < "u")) ns.setContext(self); ((this.setAnimationLoop = function (S) { ((pt = S), P.setAnimationLoop(S), S === null ? ns.stop() : ns.start()); }), P.addEventListener("sessionstart", Vn), P.addEventListener("sessionend", Wn), (this.render = function (S, U) { if (U !== void 0 && U.isCamera !== !0) { console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera."); return; } if (w === !0) return; if (S.matrixWorldAutoUpdate === !0) S.updateMatrixWorld(); if (U.parent === null && U.matrixWorldAutoUpdate === !0) U.updateMatrixWorld(); if (P.enabled === !0 && P.isPresenting === !0) { if (P.cameraAutoUpdate === !0) P.updateCamera(U); U = P.getCamera(); } if (S.isScene === !0) S.onBeforeRender(x, S, U, R); if ( ((p = X.get(S, _.length)), p.init(U), _.push(p), J.multiplyMatrices(U.projectionMatrix, U.matrixWorldInverse), rt.setFromProjectionMatrix(J, ic, U.reversedDepth), (k = this.localClippingEnabled), (Ke = xe.init(this.clippingPlanes, k)), (y = Q.get(S, g.length)), y.init(), g.push(y), P.enabled === !0 && P.isPresenting === !0) ) { let ne = x.xr.getDepthSensingMesh(); if (ne !== null) Da(ne, U, -1 / 0, x.sortObjects); } if ((Da(S, U, 0, x.sortObjects), y.finish(), x.sortObjects === !0)) y.sort(V, se); if (((Ee = P.enabled === !1 || P.isPresenting === !1 || P.hasDepthSensing() === !1), Ee)) Te.addToRenderList(y, S); if ((this.info.render.frame++, Ke === !0)) xe.beginShadows(); let z = p.state.shadowsArray; if ((oe.render(z, S, U), Ke === !0)) xe.endShadows(); if (this.info.autoReset === !0) this.info.reset(); let H = y.opaque, N = y.transmissive; if ((p.setupLights(), U.isArrayCamera)) { let ne = U.cameras; if (N.length > 0) for (let fe = 0, Se = ne.length; fe < Se; fe++) { let ye = ne[fe]; Rh(H, N, S, ye); } if (Ee) Te.render(S); for (let fe = 0, Se = ne.length; fe < Se; fe++) { let ye = ne[fe]; Ah(y, S, ye, ye.viewport); } } else { if (N.length > 0) Rh(H, N, S, U); if (Ee) Te.render(S); Ah(y, S, U); } if (R !== null && b === 0) (De.updateMultisampleRenderTarget(R), De.updateRenderTargetMipmap(R)); if (S.isScene === !0) S.onAfterRender(x, S, U); if ((Re.resetDefaultState(), (F = -1), (M = null), _.pop(), _.length > 0)) { if (((p = _[_.length - 1]), Ke === !0)) xe.setGlobalState(x.clippingPlanes, p.state.camera); } else p = null; if ((g.pop(), g.length > 0)) y = g[g.length - 1]; else y = null; })); function Da(S, U, z, H) { if (S.visible === !1) return; if (S.layers.test(U.layers)) { if (S.isGroup) z = S.renderOrder; else if (S.isLOD) { if (S.autoUpdate === !0) S.update(U); } else if (S.isLight) { if ((p.pushLight(S), S.castShadow)) p.pushShadow(S); } else if (S.isSprite) { if (!S.frustumCulled || rt.intersectsSprite(S)) { if (H) ae.setFromMatrixPosition(S.matrixWorld).applyMatrix4(J); let fe = v.update(S), Se = S.material; if (Se.visible) y.push(S, fe, Se, z, ae.z, null); } } else if (S.isMesh || S.isLine || S.isPoints) { if (!S.frustumCulled || rt.intersectsObject(S)) { let fe = v.update(S), Se = S.material; if (H) { if (S.boundingSphere !== void 0) { if (S.boundingSphere === null) S.computeBoundingSphere(); ae.copy(S.boundingSphere.center); } else { if (fe.boundingSphere === null) fe.computeBoundingSphere(); ae.copy(fe.boundingSphere.center); } ae.applyMatrix4(S.matrixWorld).applyMatrix4(J); } if (Array.isArray(Se)) { let ye = fe.groups; for (let Ue = 0, Oe = ye.length; Ue < Oe; Ue++) { let Ce = ye[Ue], et = Se[Ce.materialIndex]; if (et && et.visible) y.push(S, fe, et, z, ae.z, Ce); } } else if (Se.visible) y.push(S, fe, Se, z, ae.z, null); } } } let ne = S.children; for (let fe = 0, Se = ne.length; fe < Se; fe++) Da(ne[fe], U, z, H); } function Ah(S, U, z, H) { let { opaque: N, transmissive: ne, transparent: fe } = S; if ((p.setupLightsView(z), Ke === !0)) xe.setGlobalState(x.clippingPlanes, z); if (H) we.viewport(T.copy(H)); if (N.length > 0) ro(N, U, z); if (ne.length > 0) ro(ne, U, z); if (fe.length > 0) ro(fe, U, z); (we.buffers.depth.setTest(!0), we.buffers.depth.setMask(!0), we.buffers.color.setMask(!0), we.setPolygonOffset(!1)); } function Rh(S, U, z, H) { if ((z.isScene === !0 ? z.overrideMaterial : null) !== null) return; if (p.state.transmissionRenderTarget[H.id] === void 0) p.state.transmissionRenderTarget[H.id] = new vi(1, 1, { generateMipmaps: !0, type: Xe.has("EXT_color_buffer_half_float") || Xe.has("EXT_color_buffer_float") ? zr : ki, minFilter: yi, samples: 4, stencilBuffer: s, resolveDepthBuffer: !1, resolveStencilBuffer: !1, colorSpace: ke.workingColorSpace, }); let ne = p.state.transmissionRenderTarget[H.id], fe = H.viewport || T; ne.setSize(fe.z * x.transmissionResolutionScale, fe.w * x.transmissionResolutionScale); let Se = x.getRenderTarget(), ye = x.getActiveCubeFace(), Ue = x.getActiveMipmapLevel(); if ((x.setRenderTarget(ne), x.getClearColor(q), (B = x.getClearAlpha()), B < 1)) x.setClearColor(16777215, 0.5); if ((x.clear(), Ee)) Te.render(z); let Oe = x.toneMapping; x.toneMapping = mi; let Ce = H.viewport; if (H.viewport !== void 0) H.viewport = void 0; if ((p.setupLightsView(H), Ke === !0)) xe.setGlobalState(x.clippingPlanes, H); if ( (ro(S, z, H), De.updateMultisampleRenderTarget(ne), De.updateRenderTargetMipmap(ne), Xe.has("WEBGL_multisampled_render_to_texture") === !1) ) { let et = !1; for (let ut = 0, At = U.length; ut < At; ut++) { let _t = U[ut], { object: mt, geometry: Ie, material: Mt, group: nt } = _t; if (Mt.side === Yt && mt.layers.test(H.layers)) { let un = Mt.side; ((Mt.side = Gt), (Mt.needsUpdate = !0), Lh(mt, z, H, Ie, Mt, nt), (Mt.side = un), (Mt.needsUpdate = !0), (et = !0)); } } if (et === !0) (De.updateMultisampleRenderTarget(ne), De.updateRenderTargetMipmap(ne)); } if ((x.setRenderTarget(Se, ye, Ue), x.setClearColor(q, B), Ce !== void 0)) H.viewport = Ce; x.toneMapping = Oe; } function ro(S, U, z) { let H = U.isScene === !0 ? U.overrideMaterial : null; for (let N = 0, ne = S.length; N < ne; N++) { let fe = S[N], { object: Se, geometry: ye, group: Ue, material: Oe } = fe; if (Oe.allowOverride === !0 && H !== null) Oe = H; if (Se.layers.test(z.layers)) Lh(Se, U, z, ye, Oe, Ue); } } function Lh(S, U, z, H, N, ne) { if ( (S.onBeforeRender(x, U, z, H, N, ne), S.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse, S.matrixWorld), S.normalMatrix.getNormalMatrix(S.modelViewMatrix), N.onBeforeRender(x, U, z, H, S, ne), N.transparent === !0 && N.side === Yt && N.forceSinglePass === !1) ) ((N.side = Gt), (N.needsUpdate = !0), x.renderBufferDirect(z, U, H, N, S, ne), (N.side = Fi), (N.needsUpdate = !0), x.renderBufferDirect(z, U, H, N, S, ne), (N.side = Yt)); else x.renderBufferDirect(z, U, H, N, S, ne); S.onAfterRender(x, U, z, H, N, ne); } function oo(S, U, z) { if (U.isScene !== !0) U = ge; let H = Le.get(S), N = p.state.lights, ne = p.state.shadowsArray, fe = N.state.version, Se = O.getParameters(S, N.state, ne, U, z), ye = O.getProgramCacheKey(Se), Ue = H.programs; if ( ((H.environment = S.isMeshStandardMaterial ? U.environment : null), (H.fog = U.fog), (H.envMap = (S.isMeshStandardMaterial ? kt : Bt).get(S.envMap || H.environment)), (H.envMapRotation = H.environment !== null && S.envMap === null ? U.environmentRotation : S.envMapRotation), Ue === void 0) ) (S.addEventListener("dispose", te), (Ue = new Map()), (H.programs = Ue)); let Oe = Ue.get(ye); if (Oe !== void 0) { if (H.currentProgram === Oe && H.lightsStateVersion === fe) return (Ih(S, Se), Oe); } else ((Se.uniforms = O.getUniforms(S)), S.onBeforeCompile(Se, x), (Oe = O.acquireProgram(Se, ye)), Ue.set(ye, Oe), (H.uniforms = Se.uniforms)); let Ce = H.uniforms; if ((!S.isShaderMaterial && !S.isRawShaderMaterial) || S.clipping === !0) Ce.clippingPlanes = xe.uniform; if ((Ih(S, Se), (H.needsLights = jp(S)), (H.lightsStateVersion = fe), H.needsLights)) ((Ce.ambientLightColor.value = N.state.ambient), (Ce.lightProbe.value = N.state.probe), (Ce.directionalLights.value = N.state.directional), (Ce.directionalLightShadows.value = N.state.directionalShadow), (Ce.spotLights.value = N.state.spot), (Ce.spotLightShadows.value = N.state.spotShadow), (Ce.rectAreaLights.value = N.state.rectArea), (Ce.ltc_1.value = N.state.rectAreaLTC1), (Ce.ltc_2.value = N.state.rectAreaLTC2), (Ce.pointLights.value = N.state.point), (Ce.pointLightShadows.value = N.state.pointShadow), (Ce.hemisphereLights.value = N.state.hemi), (Ce.directionalShadowMap.value = N.state.directionalShadowMap), (Ce.directionalShadowMatrix.value = N.state.directionalShadowMatrix), (Ce.spotShadowMap.value = N.state.spotShadowMap), (Ce.spotLightMatrix.value = N.state.spotLightMatrix), (Ce.spotLightMap.value = N.state.spotLightMap), (Ce.pointShadowMap.value = N.state.pointShadowMap), (Ce.pointShadowMatrix.value = N.state.pointShadowMatrix)); return ((H.currentProgram = Oe), (H.uniformsList = null), Oe); } function Ch(S) { if (S.uniformsList === null) { let U = S.currentProgram.getUniforms(); S.uniformsList = Zr.seqWithValue(U.seq, S.uniforms); } return S.uniformsList; } function Ih(S, U) { let z = Le.get(S); ((z.outputColorSpace = U.outputColorSpace), (z.batching = U.batching), (z.batchingColor = U.batchingColor), (z.instancing = U.instancing), (z.instancingColor = U.instancingColor), (z.instancingMorph = U.instancingMorph), (z.skinning = U.skinning), (z.morphTargets = U.morphTargets), (z.morphNormals = U.morphNormals), (z.morphColors = U.morphColors), (z.morphTargetsCount = U.morphTargetsCount), (z.numClippingPlanes = U.numClippingPlanes), (z.numIntersection = U.numClipIntersection), (z.vertexAlphas = U.vertexAlphas), (z.vertexTangents = U.vertexTangents), (z.toneMapping = U.toneMapping)); } function qp(S, U, z, H, N) { if (U.isScene !== !0) U = ge; De.resetTextureUnits(); let ne = U.fog, fe = H.isMeshStandardMaterial ? U.environment : null, Se = R === null ? x.outputColorSpace : R.isXRRenderTarget === !0 ? R.texture.colorSpace : Ut, ye = (H.isMeshStandardMaterial ? kt : Bt).get(H.envMap || fe), Ue = H.vertexColors === !0 && !!z.attributes.color && z.attributes.color.itemSize === 4, Oe = !!z.attributes.tangent && (!!H.normalMap || H.anisotropy > 0), Ce = !!z.morphAttributes.position, et = !!z.morphAttributes.normal, ut = !!z.morphAttributes.color, At = mi; if (H.toneMapped) { if (R === null || R.isXRRenderTarget === !0) At = x.toneMapping; } let _t = z.morphAttributes.position || z.morphAttributes.normal || z.morphAttributes.color, mt = _t !== void 0 ? _t.length : 0, Ie = Le.get(H), Mt = p.state.lights; if (Ke === !0) { if (k === !0 || S !== M) { let Qt = S === M && H.id === F; xe.setState(H, S, Qt); } } let nt = !1; if (H.version === Ie.__version) { if (Ie.needsLights && Ie.lightsStateVersion !== Mt.state.version) nt = !0; else if (Ie.outputColorSpace !== Se) nt = !0; else if (N.isBatchedMesh && Ie.batching === !1) nt = !0; else if (!N.isBatchedMesh && Ie.batching === !0) nt = !0; else if (N.isBatchedMesh && Ie.batchingColor === !0 && N.colorTexture === null) nt = !0; else if (N.isBatchedMesh && Ie.batchingColor === !1 && N.colorTexture !== null) nt = !0; else if (N.isInstancedMesh && Ie.instancing === !1) nt = !0; else if (!N.isInstancedMesh && Ie.instancing === !0) nt = !0; else if (N.isSkinnedMesh && Ie.skinning === !1) nt = !0; else if (!N.isSkinnedMesh && Ie.skinning === !0) nt = !0; else if (N.isInstancedMesh && Ie.instancingColor === !0 && N.instanceColor === null) nt = !0; else if (N.isInstancedMesh && Ie.instancingColor === !1 && N.instanceColor !== null) nt = !0; else if (N.isInstancedMesh && Ie.instancingMorph === !0 && N.morphTexture === null) nt = !0; else if (N.isInstancedMesh && Ie.instancingMorph === !1 && N.morphTexture !== null) nt = !0; else if (Ie.envMap !== ye) nt = !0; else if (H.fog === !0 && Ie.fog !== ne) nt = !0; else if ( Ie.numClippingPlanes !== void 0 && (Ie.numClippingPlanes !== xe.numPlanes || Ie.numIntersection !== xe.numIntersection) ) nt = !0; else if (Ie.vertexAlphas !== Ue) nt = !0; else if (Ie.vertexTangents !== Oe) nt = !0; else if (Ie.morphTargets !== Ce) nt = !0; else if (Ie.morphNormals !== et) nt = !0; else if (Ie.morphColors !== ut) nt = !0; else if (Ie.toneMapping !== At) nt = !0; else if (Ie.morphTargetsCount !== mt) nt = !0; } else ((nt = !0), (Ie.__version = H.version)); let un = Ie.currentProgram; if (nt === !0) un = oo(H, U, N); let As = !1, dn = !1, vr = !1, wt = un.getUniforms(), _n = Ie.uniforms; if (we.useProgram(un.program)) ((As = !0), (dn = !0), (vr = !0)); if (H.id !== F) ((F = H.id), (dn = !0)); if (As || M !== S) { if (we.buffers.depth.getReversed() && S.reversedDepth !== !0) ((S._reversedDepth = !0), S.updateProjectionMatrix()); (wt.setValue(C, "projectionMatrix", S.projectionMatrix), wt.setValue(C, "viewMatrix", S.matrixWorldInverse)); let an = wt.map.cameraPosition; if (an !== void 0) an.setValue(C, ee.setFromMatrixPosition(S.matrixWorld)); if (He.logarithmicDepthBuffer) wt.setValue(C, "logDepthBufFC", 2 / (Math.log(S.far + 1) / Math.LN2)); if ( H.isMeshPhongMaterial || H.isMeshToonMaterial || H.isMeshLambertMaterial || H.isMeshBasicMaterial || H.isMeshStandardMaterial || H.isShaderMaterial ) wt.setValue(C, "isOrthographic", S.isOrthographicCamera === !0); if (M !== S) ((M = S), (dn = !0), (vr = !0)); } if (N.isSkinnedMesh) { (wt.setOptional(C, N, "bindMatrix"), wt.setOptional(C, N, "bindMatrixInverse")); let Qt = N.skeleton; if (Qt) { if (Qt.boneTexture === null) Qt.computeBoneTexture(); wt.setValue(C, "boneTexture", Qt.boneTexture, De); } } if (N.isBatchedMesh) { if ( (wt.setOptional(C, N, "batchingTexture"), wt.setValue(C, "batchingTexture", N._matricesTexture, De), wt.setOptional(C, N, "batchingIdTexture"), wt.setValue(C, "batchingIdTexture", N._indirectTexture, De), wt.setOptional(C, N, "batchingColorTexture"), N._colorsTexture !== null) ) wt.setValue(C, "batchingColorTexture", N._colorsTexture, De); } let Sn = z.morphAttributes; if (Sn.position !== void 0 || Sn.normal !== void 0 || Sn.color !== void 0) Fe.update(N, z, un); if (dn || Ie.receiveShadow !== N.receiveShadow) ((Ie.receiveShadow = N.receiveShadow), wt.setValue(C, "receiveShadow", N.receiveShadow)); if (H.isMeshGouraudMaterial && H.envMap !== null) ((_n.envMap.value = ye), (_n.flipEnvMap.value = ye.isCubeTexture && ye.isRenderTargetTexture === !1 ? -1 : 1)); if (H.isMeshStandardMaterial && H.envMap === null && U.environment !== null) _n.envMapIntensity.value = U.environmentIntensity; if (dn) { if ((wt.setValue(C, "toneMappingExposure", x.toneMappingExposure), Ie.needsLights)) Yp(_n, vr); if (ne && H.fog === !0) Y.refreshFogUniforms(_n, ne); (Y.refreshMaterialUniforms(_n, H, K, W, p.state.transmissionRenderTarget[S.id]), Zr.upload(C, Ch(Ie), _n, De)); } if (H.isShaderMaterial && H.uniformsNeedUpdate === !0) (Zr.upload(C, Ch(Ie), _n, De), (H.uniformsNeedUpdate = !1)); if (H.isSpriteMaterial) wt.setValue(C, "center", N.center); if ( (wt.setValue(C, "modelViewMatrix", N.modelViewMatrix), wt.setValue(C, "normalMatrix", N.normalMatrix), wt.setValue(C, "modelMatrix", N.matrixWorld), H.isShaderMaterial || H.isRawShaderMaterial) ) { let Qt = H.uniformsGroups; for (let an = 0, Ua = Qt.length; an < Ua; an++) { let is = Qt[an]; (me.update(is, un), me.bind(is, un)); } } return un; } function Yp(S, U) { ((S.ambientLightColor.needsUpdate = U), (S.lightProbe.needsUpdate = U), (S.directionalLights.needsUpdate = U), (S.directionalLightShadows.needsUpdate = U), (S.pointLights.needsUpdate = U), (S.pointLightShadows.needsUpdate = U), (S.spotLights.needsUpdate = U), (S.spotLightShadows.needsUpdate = U), (S.rectAreaLights.needsUpdate = U), (S.hemisphereLights.needsUpdate = U)); } function jp(S) { return ( S.isMeshLambertMaterial || S.isMeshToonMaterial || S.isMeshPhongMaterial || S.isMeshStandardMaterial || S.isShadowMaterial || (S.isShaderMaterial && S.lights === !0) ); } ((this.getActiveCubeFace = function () { return L; }), (this.getActiveMipmapLevel = function () { return b; }), (this.getRenderTarget = function () { return R; }), (this.setRenderTargetTextures = function (S, U, z) { let H = Le.get(S); if (((H.__autoAllocateDepthBuffer = S.resolveDepthBuffer === !1), H.__autoAllocateDepthBuffer === !1)) H.__useRenderToTexture = !1; ((Le.get(S.texture).__webglTexture = U), (Le.get(S.depthTexture).__webglTexture = H.__autoAllocateDepthBuffer ? void 0 : z), (H.__hasExternalTextures = !0)); }), (this.setRenderTargetFramebuffer = function (S, U) { let z = Le.get(S); ((z.__webglFramebuffer = U), (z.__useDefaultFramebuffer = U === void 0)); })); let Zp = C.createFramebuffer(); ((this.setRenderTarget = function (S, U = 0, z = 0) { ((R = S), (L = U), (b = z)); let H = !0, N = null, ne = !1, fe = !1; if (S) { let ye = Le.get(S); if (ye.__useDefaultFramebuffer !== void 0) (we.bindFramebuffer(C.FRAMEBUFFER, null), (H = !1)); else if (ye.__webglFramebuffer === void 0) De.setupRenderTarget(S); else if (ye.__hasExternalTextures) De.rebindTextures(S, Le.get(S.texture).__webglTexture, Le.get(S.depthTexture).__webglTexture); else if (S.depthBuffer) { let Ce = S.depthTexture; if (ye.__boundDepthTexture !== Ce) { if (Ce !== null && Le.has(Ce) && (S.width !== Ce.image.width || S.height !== Ce.image.height)) throw Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size."); De.setupDepthRenderbuffer(S); } } let Ue = S.texture; if (Ue.isData3DTexture || Ue.isDataArrayTexture || Ue.isCompressedArrayTexture) fe = !0; let Oe = Le.get(S).__webglFramebuffer; if (S.isWebGLCubeRenderTarget) { if (Array.isArray(Oe[U])) N = Oe[U][z]; else N = Oe[U]; ne = !0; } else if (S.samples > 0 && De.useMultisampledRTT(S) === !1) N = Le.get(S).__webglMultisampledFramebuffer; else if (Array.isArray(Oe)) N = Oe[z]; else N = Oe; (T.copy(S.viewport), I.copy(S.scissor), (G = S.scissorTest)); } else (T.copy(ce).multiplyScalar(K).floor(), I.copy(Pe).multiplyScalar(K).floor(), (G = We)); if (z !== 0) N = Zp; if (we.bindFramebuffer(C.FRAMEBUFFER, N) && H) we.drawBuffers(S, N); if ((we.viewport(T), we.scissor(I), we.setScissorTest(G), ne)) { let ye = Le.get(S.texture); C.framebufferTexture2D( C.FRAMEBUFFER, C.COLOR_ATTACHMENT0, C.TEXTURE_CUBE_MAP_POSITIVE_X + U, ye.__webglTexture, z, ); } else if (fe) { let ye = U; for (let Ue = 0; Ue < S.textures.length; Ue++) { let Oe = Le.get(S.textures[Ue]); C.framebufferTextureLayer(C.FRAMEBUFFER, C.COLOR_ATTACHMENT0 + Ue, Oe.__webglTexture, z, ye); } } else if (S !== null && z !== 0) { let ye = Le.get(S.texture); C.framebufferTexture2D(C.FRAMEBUFFER, C.COLOR_ATTACHMENT0, C.TEXTURE_2D, ye.__webglTexture, z); } F = -1; }), (this.readRenderTargetPixels = function (S, U, z, H, N, ne, fe, Se = 0) { if (!(S && S.isWebGLRenderTarget)) { console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); return; } let ye = Le.get(S).__webglFramebuffer; if (S.isWebGLCubeRenderTarget && fe !== void 0) ye = ye[fe]; if (ye) { we.bindFramebuffer(C.FRAMEBUFFER, ye); try { let Ue = S.textures[Se], { format: Oe, type: Ce } = Ue; if (!He.textureFormatReadable(Oe)) { console.error( "THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.", ); return; } if (!He.textureTypeReadable(Ce)) { console.error( "THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.", ); return; } if (U >= 0 && U <= S.width - H && z >= 0 && z <= S.height - N) { if (S.textures.length > 1) C.readBuffer(C.COLOR_ATTACHMENT0 + Se); C.readPixels(U, z, H, N, Ae.convert(Oe), Ae.convert(Ce), ne); } } finally { let Ue = R !== null ? Le.get(R).__webglFramebuffer : null; we.bindFramebuffer(C.FRAMEBUFFER, Ue); } } }), (this.readRenderTargetPixelsAsync = async function (S, U, z, H, N, ne, fe, Se = 0) { if (!(S && S.isWebGLRenderTarget)) throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); let ye = Le.get(S).__webglFramebuffer; if (S.isWebGLCubeRenderTarget && fe !== void 0) ye = ye[fe]; if (ye) if (U >= 0 && U <= S.width - H && z >= 0 && z <= S.height - N) { we.bindFramebuffer(C.FRAMEBUFFER, ye); let Ue = S.textures[Se], { format: Oe, type: Ce } = Ue; if (!He.textureFormatReadable(Oe)) throw Error( "THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.", ); if (!He.textureTypeReadable(Ce)) throw Error( "THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.", ); let et = C.createBuffer(); if ( (C.bindBuffer(C.PIXEL_PACK_BUFFER, et), C.bufferData(C.PIXEL_PACK_BUFFER, ne.byteLength, C.STREAM_READ), S.textures.length > 1) ) C.readBuffer(C.COLOR_ATTACHMENT0 + Se); C.readPixels(U, z, H, N, Ae.convert(Oe), Ae.convert(Ce), 0); let ut = R !== null ? Le.get(R).__webglFramebuffer : null; we.bindFramebuffer(C.FRAMEBUFFER, ut); let At = C.fenceSync(C.SYNC_GPU_COMMANDS_COMPLETE, 0); return ( C.flush(), await pd(C, At, 4), C.bindBuffer(C.PIXEL_PACK_BUFFER, et), C.getBufferSubData(C.PIXEL_PACK_BUFFER, 0, ne), C.deleteBuffer(et), C.deleteSync(At), ne ); } else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range."); }), (this.copyFramebufferToTexture = function (S, U = null, z = 0) { let H = Math.pow(2, -z), N = Math.floor(S.image.width * H), ne = Math.floor(S.image.height * H), fe = U !== null ? U.x : 0, Se = U !== null ? U.y : 0; (De.setTexture2D(S, 0), C.copyTexSubImage2D(C.TEXTURE_2D, z, 0, 0, fe, Se, N, ne), we.unbindTexture()); })); let Kp = C.createFramebuffer(), $p = C.createFramebuffer(); if ( ((this.copyTextureToTexture = function (S, U, z = null, H = null, N = 0, ne = null) { if (ne === null) if (N !== 0) (Ws( "WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels.", ), (ne = N), (N = 0)); else ne = 0; let fe, Se, ye, Ue, Oe, Ce, et, ut, At, _t = S.isCompressedTexture ? S.mipmaps[ne] : S.image; if (z !== null) ((fe = z.max.x - z.min.x), (Se = z.max.y - z.min.y), (ye = z.isBox3 ? z.max.z - z.min.z : 1), (Ue = z.min.x), (Oe = z.min.y), (Ce = z.isBox3 ? z.min.z : 0)); else { let Sn = Math.pow(2, -N); if (((fe = Math.floor(_t.width * Sn)), (Se = Math.floor(_t.height * Sn)), S.isDataArrayTexture)) ye = _t.depth; else if (S.isData3DTexture) ye = Math.floor(_t.depth * Sn); else ye = 1; ((Ue = 0), (Oe = 0), (Ce = 0)); } if (H !== null) ((et = H.x), (ut = H.y), (At = H.z)); else ((et = 0), (ut = 0), (At = 0)); let mt = Ae.convert(U.format), Ie = Ae.convert(U.type), Mt; if (U.isData3DTexture) (De.setTexture3D(U, 0), (Mt = C.TEXTURE_3D)); else if (U.isDataArrayTexture || U.isCompressedArrayTexture) (De.setTexture2DArray(U, 0), (Mt = C.TEXTURE_2D_ARRAY)); else (De.setTexture2D(U, 0), (Mt = C.TEXTURE_2D)); (C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, U.flipY), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, U.premultiplyAlpha), C.pixelStorei(C.UNPACK_ALIGNMENT, U.unpackAlignment)); let nt = C.getParameter(C.UNPACK_ROW_LENGTH), un = C.getParameter(C.UNPACK_IMAGE_HEIGHT), As = C.getParameter(C.UNPACK_SKIP_PIXELS), dn = C.getParameter(C.UNPACK_SKIP_ROWS), vr = C.getParameter(C.UNPACK_SKIP_IMAGES); (C.pixelStorei(C.UNPACK_ROW_LENGTH, _t.width), C.pixelStorei(C.UNPACK_IMAGE_HEIGHT, _t.height), C.pixelStorei(C.UNPACK_SKIP_PIXELS, Ue), C.pixelStorei(C.UNPACK_SKIP_ROWS, Oe), C.pixelStorei(C.UNPACK_SKIP_IMAGES, Ce)); let wt = S.isDataArrayTexture || S.isData3DTexture, _n = U.isDataArrayTexture || U.isData3DTexture; if (S.isDepthTexture) { let Sn = Le.get(S), Qt = Le.get(U), an = Le.get(Sn.__renderTarget), Ua = Le.get(Qt.__renderTarget); (we.bindFramebuffer(C.READ_FRAMEBUFFER, an.__webglFramebuffer), we.bindFramebuffer(C.DRAW_FRAMEBUFFER, Ua.__webglFramebuffer)); for (let is = 0; is < ye; is++) { if (wt) (C.framebufferTextureLayer(C.READ_FRAMEBUFFER, C.COLOR_ATTACHMENT0, Le.get(S).__webglTexture, N, Ce + is), C.framebufferTextureLayer( C.DRAW_FRAMEBUFFER, C.COLOR_ATTACHMENT0, Le.get(U).__webglTexture, ne, At + is, )); C.blitFramebuffer(Ue, Oe, fe, Se, et, ut, fe, Se, C.DEPTH_BUFFER_BIT, C.NEAREST); } (we.bindFramebuffer(C.READ_FRAMEBUFFER, null), we.bindFramebuffer(C.DRAW_FRAMEBUFFER, null)); } else if (N !== 0 || S.isRenderTargetTexture || Le.has(S)) { let Sn = Le.get(S), Qt = Le.get(U); (we.bindFramebuffer(C.READ_FRAMEBUFFER, Kp), we.bindFramebuffer(C.DRAW_FRAMEBUFFER, $p)); for (let an = 0; an < ye; an++) { if (wt) C.framebufferTextureLayer(C.READ_FRAMEBUFFER, C.COLOR_ATTACHMENT0, Sn.__webglTexture, N, Ce + an); else C.framebufferTexture2D(C.READ_FRAMEBUFFER, C.COLOR_ATTACHMENT0, C.TEXTURE_2D, Sn.__webglTexture, N); if (_n) C.framebufferTextureLayer(C.DRAW_FRAMEBUFFER, C.COLOR_ATTACHMENT0, Qt.__webglTexture, ne, At + an); else C.framebufferTexture2D(C.DRAW_FRAMEBUFFER, C.COLOR_ATTACHMENT0, C.TEXTURE_2D, Qt.__webglTexture, ne); if (N !== 0) C.blitFramebuffer(Ue, Oe, fe, Se, et, ut, fe, Se, C.COLOR_BUFFER_BIT, C.NEAREST); else if (_n) C.copyTexSubImage3D(Mt, ne, et, ut, At + an, Ue, Oe, fe, Se); else C.copyTexSubImage2D(Mt, ne, et, ut, Ue, Oe, fe, Se); } (we.bindFramebuffer(C.READ_FRAMEBUFFER, null), we.bindFramebuffer(C.DRAW_FRAMEBUFFER, null)); } else if (_n) if (S.isDataTexture || S.isData3DTexture) C.texSubImage3D(Mt, ne, et, ut, At, fe, Se, ye, mt, Ie, _t.data); else if (U.isCompressedArrayTexture) C.compressedTexSubImage3D(Mt, ne, et, ut, At, fe, Se, ye, mt, _t.data); else C.texSubImage3D(Mt, ne, et, ut, At, fe, Se, ye, mt, Ie, _t); else if (S.isDataTexture) C.texSubImage2D(C.TEXTURE_2D, ne, et, ut, fe, Se, mt, Ie, _t.data); else if (S.isCompressedTexture) C.compressedTexSubImage2D(C.TEXTURE_2D, ne, et, ut, _t.width, _t.height, mt, _t.data); else C.texSubImage2D(C.TEXTURE_2D, ne, et, ut, fe, Se, mt, Ie, _t); if ( (C.pixelStorei(C.UNPACK_ROW_LENGTH, nt), C.pixelStorei(C.UNPACK_IMAGE_HEIGHT, un), C.pixelStorei(C.UNPACK_SKIP_PIXELS, As), C.pixelStorei(C.UNPACK_SKIP_ROWS, dn), C.pixelStorei(C.UNPACK_SKIP_IMAGES, vr), ne === 0 && U.generateMipmaps) ) C.generateMipmap(Mt); we.unbindTexture(); }), (this.initRenderTarget = function (S) { if (Le.get(S).__webglFramebuffer === void 0) De.setupRenderTarget(S); }), (this.initTexture = function (S) { if (S.isCubeTexture) De.setTextureCube(S, 0); else if (S.isData3DTexture) De.setTexture3D(S, 0); else if (S.isDataArrayTexture || S.isCompressedArrayTexture) De.setTexture2DArray(S, 0); else De.setTexture2D(S, 0); we.unbindTexture(); }), (this.resetState = function () { ((L = 0), (b = 0), (R = null), we.reset(), Re.reset()); }), typeof __THREE_DEVTOOLS__ < "u") ) __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this })); } get coordinateSystem() { return ic; } get outputColorSpace() { return this._outputColorSpace; } set outputColorSpace(e) { this._outputColorSpace = e; let t = this.getContext(); ((t.drawingBufferColorSpace = ke._getDrawingBufferColorSpace(e)), (t.unpackColorSpace = ke._getUnpackColorSpace())); } } var uf = { type: "change" }, Fc = { type: "start" }, ff = { type: "end" }, _a = new zn(), df = new mn(), Vv = Math.cos(70 * bt.DEG2RAD), Ot = new E(), cn = 2 * Math.PI, dt = { NONE: -1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_PAN: 4, TOUCH_DOLLY_PAN: 5, TOUCH_DOLLY_ROTATE: 6, }, Nc = 0.000001; class Oc extends ma { constructor(e, t = null) { super(e, t); if ( ((this.state = dt.NONE), (this.target = new E()), (this.cursor = new E()), (this.minDistance = 0), (this.maxDistance = 1 / 0), (this.minZoom = 0), (this.maxZoom = 1 / 0), (this.minTargetRadius = 0), (this.maxTargetRadius = 1 / 0), (this.minPolarAngle = 0), (this.maxPolarAngle = Math.PI), (this.minAzimuthAngle = -1 / 0), (this.maxAzimuthAngle = 1 / 0), (this.enableDamping = !1), (this.dampingFactor = 0.05), (this.enableZoom = !0), (this.zoomSpeed = 1), (this.enableRotate = !0), (this.rotateSpeed = 1), (this.keyRotateSpeed = 1), (this.enablePan = !0), (this.panSpeed = 1), (this.screenSpacePanning = !0), (this.keyPanSpeed = 7), (this.zoomToCursor = !1), (this.autoRotate = !1), (this.autoRotateSpeed = 2), (this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }), (this.mouseButtons = { LEFT: Ui.ROTATE, MIDDLE: Ui.DOLLY, RIGHT: Ui.PAN }), (this.touches = { ONE: Ni.ROTATE, TWO: Ni.DOLLY_PAN }), (this.target0 = this.target.clone()), (this.position0 = this.object.position.clone()), (this.zoom0 = this.object.zoom), (this._domElementKeyEvents = null), (this._lastPosition = new E()), (this._lastQuaternion = new Ne()), (this._lastTargetPosition = new E()), (this._quat = new Ne().setFromUnitVectors(e.up, new E(0, 1, 0))), (this._quatInverse = this._quat.clone().invert()), (this._spherical = new ji()), (this._sphericalDelta = new ji()), (this._scale = 1), (this._panOffset = new E()), (this._rotateStart = new ve()), (this._rotateEnd = new ve()), (this._rotateDelta = new ve()), (this._panStart = new ve()), (this._panEnd = new ve()), (this._panDelta = new ve()), (this._dollyStart = new ve()), (this._dollyEnd = new ve()), (this._dollyDelta = new ve()), (this._dollyDirection = new E()), (this._mouse = new ve()), (this._performCursorZoom = !1), (this._pointers = []), (this._pointerPositions = {}), (this._controlActive = !1), (this._onPointerMove = Xv.bind(this)), (this._onPointerDown = Wv.bind(this)), (this._onPointerUp = qv.bind(this)), (this._onContextMenu = Qv.bind(this)), (this._onMouseWheel = Zv.bind(this)), (this._onKeyDown = Kv.bind(this)), (this._onTouchStart = $v.bind(this)), (this._onTouchMove = Jv.bind(this)), (this._onMouseDown = Yv.bind(this)), (this._onMouseMove = jv.bind(this)), (this._interceptControlDown = e_.bind(this)), (this._interceptControlUp = t_.bind(this)), this.domElement !== null) ) this.connect(this.domElement); this.update(); } connect(e) { (super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement .getRootNode() .addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), (this.domElement.style.touchAction = "none")); } disconnect() { (this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), (this.domElement.style.touchAction = "auto")); } dispose() { this.disconnect(); } getPolarAngle() { return this._spherical.phi; } getAzimuthalAngle() { return this._spherical.theta; } getDistance() { return this.object.position.distanceTo(this.target); } listenToKeyEvents(e) { (e.addEventListener("keydown", this._onKeyDown), (this._domElementKeyEvents = e)); } stopListenToKeyEvents() { if (this._domElementKeyEvents !== null) (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), (this._domElementKeyEvents = null)); } saveState() { (this.target0.copy(this.target), this.position0.copy(this.object.position), (this.zoom0 = this.object.zoom)); } reset() { (this.target.copy(this.target0), this.object.position.copy(this.position0), (this.object.zoom = this.zoom0), this.object.updateProjectionMatrix(), this.dispatchEvent(uf), this.update(), (this.state = dt.NONE)); } update(e = null) { let t = this.object.position; if ( (Ot.copy(t).sub(this.target), Ot.applyQuaternion(this._quat), this._spherical.setFromVector3(Ot), this.autoRotate && this.state === dt.NONE) ) this._rotateLeft(this._getAutoRotationAngle(e)); if (this.enableDamping) ((this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor), (this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor)); else ((this._spherical.theta += this._sphericalDelta.theta), (this._spherical.phi += this._sphericalDelta.phi)); let n = this.minAzimuthAngle, i = this.maxAzimuthAngle; if (isFinite(n) && isFinite(i)) { if (n < -Math.PI) n += cn; else if (n > Math.PI) n -= cn; if (i < -Math.PI) i += cn; else if (i > Math.PI) i -= cn; if (n <= i) this._spherical.theta = Math.max(n, Math.min(i, this._spherical.theta)); else this._spherical.theta = this._spherical.theta > (n + i) / 2 ? Math.max(n, this._spherical.theta) : Math.min(i, this._spherical.theta); } if ( ((this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi))), this._spherical.makeSafe(), this.enableDamping === !0) ) this.target.addScaledVector(this._panOffset, this.dampingFactor); else this.target.add(this._panOffset); (this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor)); let s = !1; if ((this.zoomToCursor && this._performCursorZoom) || this.object.isOrthographicCamera) this._spherical.radius = this._clampDistance(this._spherical.radius); else { let r = this._spherical.radius; ((this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale)), (s = r != this._spherical.radius)); } if ( (Ot.setFromSpherical(this._spherical), Ot.applyQuaternion(this._quatInverse), t.copy(this.target).add(Ot), this.object.lookAt(this.target), this.enableDamping === !0) ) ((this._sphericalDelta.theta *= 1 - this.dampingFactor), (this._sphericalDelta.phi *= 1 - this.dampingFactor), this._panOffset.multiplyScalar(1 - this.dampingFactor)); else (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)); if (this.zoomToCursor && this._performCursorZoom) { let r = null; if (this.object.isPerspectiveCamera) { let o = Ot.length(); r = this._clampDistance(o * this._scale); let a = o - r; (this.object.position.addScaledVector(this._dollyDirection, a), this.object.updateMatrixWorld(), (s = !!a)); } else if (this.object.isOrthographicCamera) { let o = new E(this._mouse.x, this._mouse.y, 0); o.unproject(this.object); let a = this.object.zoom; ((this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale))), this.object.updateProjectionMatrix(), (s = a !== this.object.zoom)); let l = new E(this._mouse.x, this._mouse.y, 0); (l.unproject(this.object), this.object.position.sub(l).add(o), this.object.updateMatrixWorld(), (r = Ot.length())); } else (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), (this.zoomToCursor = !1)); if (r !== null) if (this.screenSpacePanning) this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position); else if ( (_a.origin.copy(this.object.position), _a.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(_a.direction)) < Vv) ) this.object.lookAt(this.target); else (df.setFromNormalAndCoplanarPoint(this.object.up, this.target), _a.intersectPlane(df, this.target)); } else if (this.object.isOrthographicCamera) { let r = this.object.zoom; if ( ((this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale))), r !== this.object.zoom) ) (this.object.updateProjectionMatrix(), (s = !0)); } if ( ((this._scale = 1), (this._performCursorZoom = !1), s || this._lastPosition.distanceToSquared(this.object.position) > Nc || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > Nc || this._lastTargetPosition.distanceToSquared(this.target) > Nc) ) return ( this.dispatchEvent(uf), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0 ); return !1; } _getAutoRotationAngle(e) { if (e !== null) return (cn / 60) * this.autoRotateSpeed * e; else return (cn / 60 / 60) * this.autoRotateSpeed; } _getZoomScale(e) { let t = Math.abs(e * 0.01); return Math.pow(0.95, this.zoomSpeed * t); } _rotateLeft(e) { this._sphericalDelta.theta -= e; } _rotateUp(e) { this._sphericalDelta.phi -= e; } _panLeft(e, t) { (Ot.setFromMatrixColumn(t, 0), Ot.multiplyScalar(-e), this._panOffset.add(Ot)); } _panUp(e, t) { if (this.screenSpacePanning === !0) Ot.setFromMatrixColumn(t, 1); else (Ot.setFromMatrixColumn(t, 0), Ot.crossVectors(this.object.up, Ot)); (Ot.multiplyScalar(e), this._panOffset.add(Ot)); } _pan(e, t) { let n = this.domElement; if (this.object.isPerspectiveCamera) { let i = this.object.position; Ot.copy(i).sub(this.target); let s = Ot.length(); ((s *= Math.tan(((this.object.fov / 2) * Math.PI) / 180)), this._panLeft((2 * e * s) / n.clientHeight, this.object.matrix), this._panUp((2 * t * s) / n.clientHeight, this.object.matrix)); } else if (this.object.isOrthographicCamera) (this._panLeft( (e * (this.object.right - this.object.left)) / this.object.zoom / n.clientWidth, this.object.matrix, ), this._panUp( (t * (this.object.top - this.object.bottom)) / this.object.zoom / n.clientHeight, this.object.matrix, )); else (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), (this.enablePan = !1)); } _dollyOut(e) { if (this.object.isPerspectiveCamera || this.object.isOrthographicCamera) this._scale /= e; else (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), (this.enableZoom = !1)); } _dollyIn(e) { if (this.object.isPerspectiveCamera || this.object.isOrthographicCamera) this._scale *= e; else (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), (this.enableZoom = !1)); } _updateZoomParameters(e, t) { if (!this.zoomToCursor) return; this._performCursorZoom = !0; let n = this.domElement.getBoundingClientRect(), i = e - n.left, s = t - n.top, { width: r, height: o } = n; ((this._mouse.x = (i / r) * 2 - 1), (this._mouse.y = -(s / o) * 2 + 1), this._dollyDirection .set(this._mouse.x, this._mouse.y, 1) .unproject(this.object) .sub(this.object.position) .normalize()); } _clampDistance(e) { return Math.max(this.minDistance, Math.min(this.maxDistance, e)); } _handleMouseDownRotate(e) { this._rotateStart.set(e.clientX, e.clientY); } _handleMouseDownDolly(e) { (this._updateZoomParameters(e.clientX, e.clientX), this._dollyStart.set(e.clientX, e.clientY)); } _handleMouseDownPan(e) { this._panStart.set(e.clientX, e.clientY); } _handleMouseMoveRotate(e) { (this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed)); let t = this.domElement; (this._rotateLeft((cn * this._rotateDelta.x) / t.clientHeight), this._rotateUp((cn * this._rotateDelta.y) / t.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update()); } _handleMouseMoveDolly(e) { if ( (this._dollyEnd.set(e.clientX, e.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0) ) this._dollyOut(this._getZoomScale(this._dollyDelta.y)); else if (this._dollyDelta.y < 0) this._dollyIn(this._getZoomScale(this._dollyDelta.y)); (this._dollyStart.copy(this._dollyEnd), this.update()); } _handleMouseMovePan(e) { (this._panEnd.set(e.clientX, e.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update()); } _handleMouseWheel(e) { if ((this._updateZoomParameters(e.clientX, e.clientY), e.deltaY < 0)) this._dollyIn(this._getZoomScale(e.deltaY)); else if (e.deltaY > 0) this._dollyOut(this._getZoomScale(e.deltaY)); this.update(); } _handleKeyDown(e) { let t = !1; switch (e.code) { case this.keys.UP: if (e.ctrlKey || e.metaKey || e.shiftKey) { if (this.enableRotate) this._rotateUp((cn * this.keyRotateSpeed) / this.domElement.clientHeight); } else if (this.enablePan) this._pan(0, this.keyPanSpeed); t = !0; break; case this.keys.BOTTOM: if (e.ctrlKey || e.metaKey || e.shiftKey) { if (this.enableRotate) this._rotateUp((-cn * this.keyRotateSpeed) / this.domElement.clientHeight); } else if (this.enablePan) this._pan(0, -this.keyPanSpeed); t = !0; break; case this.keys.LEFT: if (e.ctrlKey || e.metaKey || e.shiftKey) { if (this.enableRotate) this._rotateLeft((cn * this.keyRotateSpeed) / this.domElement.clientHeight); } else if (this.enablePan) this._pan(this.keyPanSpeed, 0); t = !0; break; case this.keys.RIGHT: if (e.ctrlKey || e.metaKey || e.shiftKey) { if (this.enableRotate) this._rotateLeft((-cn * this.keyRotateSpeed) / this.domElement.clientHeight); } else if (this.enablePan) this._pan(-this.keyPanSpeed, 0); t = !0; break; } if (t) (e.preventDefault(), this.update()); } _handleTouchStartRotate(e) { if (this._pointers.length === 1) this._rotateStart.set(e.pageX, e.pageY); else { let t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), i = 0.5 * (e.pageY + t.y); this._rotateStart.set(n, i); } } _handleTouchStartPan(e) { if (this._pointers.length === 1) this._panStart.set(e.pageX, e.pageY); else { let t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), i = 0.5 * (e.pageY + t.y); this._panStart.set(n, i); } } _handleTouchStartDolly(e) { let t = this._getSecondPointerPosition(e), n = e.pageX - t.x, i = e.pageY - t.y, s = Math.sqrt(n * n + i * i); this._dollyStart.set(0, s); } _handleTouchStartDollyPan(e) { if (this.enableZoom) this._handleTouchStartDolly(e); if (this.enablePan) this._handleTouchStartPan(e); } _handleTouchStartDollyRotate(e) { if (this.enableZoom) this._handleTouchStartDolly(e); if (this.enableRotate) this._handleTouchStartRotate(e); } _handleTouchMoveRotate(e) { if (this._pointers.length == 1) this._rotateEnd.set(e.pageX, e.pageY); else { let n = this._getSecondPointerPosition(e), i = 0.5 * (e.pageX + n.x), s = 0.5 * (e.pageY + n.y); this._rotateEnd.set(i, s); } this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed); let t = this.domElement; (this._rotateLeft((cn * this._rotateDelta.x) / t.clientHeight), this._rotateUp((cn * this._rotateDelta.y) / t.clientHeight), this._rotateStart.copy(this._rotateEnd)); } _handleTouchMovePan(e) { if (this._pointers.length === 1) this._panEnd.set(e.pageX, e.pageY); else { let t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), i = 0.5 * (e.pageY + t.y); this._panEnd.set(n, i); } (this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd)); } _handleTouchMoveDolly(e) { let t = this._getSecondPointerPosition(e), n = e.pageX - t.x, i = e.pageY - t.y, s = Math.sqrt(n * n + i * i); (this._dollyEnd.set(0, s), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd)); let r = (e.pageX + t.x) * 0.5, o = (e.pageY + t.y) * 0.5; this._updateZoomParameters(r, o); } _handleTouchMoveDollyPan(e) { if (this.enableZoom) this._handleTouchMoveDolly(e); if (this.enablePan) this._handleTouchMovePan(e); } _handleTouchMoveDollyRotate(e) { if (this.enableZoom) this._handleTouchMoveDolly(e); if (this.enableRotate) this._handleTouchMoveRotate(e); } _addPointer(e) { this._pointers.push(e.pointerId); } _removePointer(e) { delete this._pointerPositions[e.pointerId]; for (let t = 0; t < this._pointers.length; t++) if (this._pointers[t] == e.pointerId) { this._pointers.splice(t, 1); return; } } _isTrackingPointer(e) { for (let t = 0; t < this._pointers.length; t++) if (this._pointers[t] == e.pointerId) return !0; return !1; } _trackPointer(e) { let t = this._pointerPositions[e.pointerId]; if (t === void 0) ((t = new ve()), (this._pointerPositions[e.pointerId] = t)); t.set(e.pageX, e.pageY); } _getSecondPointerPosition(e) { let t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0]; return this._pointerPositions[t]; } _customWheelEvent(e) { let t = e.deltaMode, n = { clientX: e.clientX, clientY: e.clientY, deltaY: e.deltaY }; switch (t) { case 1: n.deltaY *= 16; break; case 2: n.deltaY *= 100; break; } if (e.ctrlKey && !this._controlActive) n.deltaY *= 10; return n; } } function Wv(e) { if (this.enabled === !1) return; if (this._pointers.length === 0) (this.domElement.setPointerCapture(e.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)); if (this._isTrackingPointer(e)) return; if ((this._addPointer(e), e.pointerType === "touch")) this._onTouchStart(e); else this._onMouseDown(e); } function Xv(e) { if (this.enabled === !1) return; if (e.pointerType === "touch") this._onTouchMove(e); else this._onMouseMove(e); } function qv(e) { switch ((this._removePointer(e), this._pointers.length)) { case 0: (this.domElement.releasePointerCapture(e.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(ff), (this.state = dt.NONE)); break; case 1: let t = this._pointers[0], n = this._pointerPositions[t]; this._onTouchStart({ pointerId: t, pageX: n.x, pageY: n.y }); break; } } function Yv(e) { let t; switch (e.button) { case 0: t = this.mouseButtons.LEFT; break; case 1: t = this.mouseButtons.MIDDLE; break; case 2: t = this.mouseButtons.RIGHT; break; default: t = -1; } switch (t) { case Ui.DOLLY: if (this.enableZoom === !1) return; (this._handleMouseDownDolly(e), (this.state = dt.DOLLY)); break; case Ui.ROTATE: if (e.ctrlKey || e.metaKey || e.shiftKey) { if (this.enablePan === !1) return; (this._handleMouseDownPan(e), (this.state = dt.PAN)); } else { if (this.enableRotate === !1) return; (this._handleMouseDownRotate(e), (this.state = dt.ROTATE)); } break; case Ui.PAN: if (e.ctrlKey || e.metaKey || e.shiftKey) { if (this.enableRotate === !1) return; (this._handleMouseDownRotate(e), (this.state = dt.ROTATE)); } else { if (this.enablePan === !1) return; (this._handleMouseDownPan(e), (this.state = dt.PAN)); } break; default: this.state = dt.NONE; } if (this.state !== dt.NONE) this.dispatchEvent(Fc); } function jv(e) { switch (this.state) { case dt.ROTATE: if (this.enableRotate === !1) return; this._handleMouseMoveRotate(e); break; case dt.DOLLY: if (this.enableZoom === !1) return; this._handleMouseMoveDolly(e); break; case dt.PAN: if (this.enablePan === !1) return; this._handleMouseMovePan(e); break; } } function Zv(e) { if (this.enabled === !1 || this.enableZoom === !1 || this.state !== dt.NONE) return; (e.preventDefault(), this.dispatchEvent(Fc), this._handleMouseWheel(this._customWheelEvent(e)), this.dispatchEvent(ff)); } function Kv(e) { if (this.enabled === !1) return; this._handleKeyDown(e); } function $v(e) { switch ((this._trackPointer(e), this._pointers.length)) { case 1: switch (this.touches.ONE) { case Ni.ROTATE: if (this.enableRotate === !1) return; (this._handleTouchStartRotate(e), (this.state = dt.TOUCH_ROTATE)); break; case Ni.PAN: if (this.enablePan === !1) return; (this._handleTouchStartPan(e), (this.state = dt.TOUCH_PAN)); break; default: this.state = dt.NONE; } break; case 2: switch (this.touches.TWO) { case Ni.DOLLY_PAN: if (this.enableZoom === !1 && this.enablePan === !1) return; (this._handleTouchStartDollyPan(e), (this.state = dt.TOUCH_DOLLY_PAN)); break; case Ni.DOLLY_ROTATE: if (this.enableZoom === !1 && this.enableRotate === !1) return; (this._handleTouchStartDollyRotate(e), (this.state = dt.TOUCH_DOLLY_ROTATE)); break; default: this.state = dt.NONE; } break; default: this.state = dt.NONE; } if (this.state !== dt.NONE) this.dispatchEvent(Fc); } function Jv(e) { switch ((this._trackPointer(e), this.state)) { case dt.TOUCH_ROTATE: if (this.enableRotate === !1) return; (this._handleTouchMoveRotate(e), this.update()); break; case dt.TOUCH_PAN: if (this.enablePan === !1) return; (this._handleTouchMovePan(e), this.update()); break; case dt.TOUCH_DOLLY_PAN: if (this.enableZoom === !1 && this.enablePan === !1) return; (this._handleTouchMoveDollyPan(e), this.update()); break; case dt.TOUCH_DOLLY_ROTATE: if (this.enableZoom === !1 && this.enableRotate === !1) return; (this._handleTouchMoveDollyRotate(e), this.update()); break; default: this.state = dt.NONE; } } function Qv(e) { if (this.enabled === !1) return; e.preventDefault(); } function e_(e) { if (e.key === "Control") ((this._controlActive = !0), this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 })); } function t_(e) { if (e.key === "Control") ((this._controlActive = !1), this.domElement .getRootNode() .removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 })); } function kc(e, t) { if (t === Ql) return (console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), e); if (t === Qs || t === Br) { let n = e.getIndex(); if (n === null) { let o = [], a = e.getAttribute("position"); if (a !== void 0) { for (let l = 0; l < a.count; l++) o.push(l); (e.setIndex(o), (n = e.getIndex())); } else return ( console.error( "THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.", ), e ); } let i = n.count - 2, s = []; if (t === Qs) for (let o = 1; o <= i; o++) (s.push(n.getX(0)), s.push(n.getX(o)), s.push(n.getX(o + 1))); else for (let o = 0; o < i; o++) if (o % 2 === 0) (s.push(n.getX(o)), s.push(n.getX(o + 1)), s.push(n.getX(o + 2))); else (s.push(n.getX(o + 2)), s.push(n.getX(o + 1)), s.push(n.getX(o))); if (s.length / 3 !== i) console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles."); let r = e.clone(); return (r.setIndex(s), r.clearGroups(), r); } else return (console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", t), e); } class Wc extends nn { constructor(e) { super(e); ((this.dracoLoader = null), (this.ktx2Loader = null), (this.meshoptDecoder = null), (this.pluginCallbacks = []), this.register(function (t) { return new Sf(t); }), this.register(function (t) { return new bf(t); }), this.register(function (t) { return new If(t); }), this.register(function (t) { return new Pf(t); }), this.register(function (t) { return new Df(t); }), this.register(function (t) { return new wf(t); }), this.register(function (t) { return new Tf(t); }), this.register(function (t) { return new Ef(t); }), this.register(function (t) { return new Af(t); }), this.register(function (t) { return new _f(t); }), this.register(function (t) { return new Rf(t); }), this.register(function (t) { return new Mf(t); }), this.register(function (t) { return new Cf(t); }), this.register(function (t) { return new Lf(t); }), this.register(function (t) { return new xf(t); }), this.register(function (t) { return new Uf(t); }), this.register(function (t) { return new Nf(t); })); } load(e, t, n, i) { let s = this, r; if (this.resourcePath !== "") r = this.resourcePath; else if (this.path !== "") { let l = ei.extractUrlBase(e); r = ei.resolveURL(l, this.path); } else r = ei.extractUrlBase(e); this.manager.itemStart(e); let o = function (l) { if (i) i(l); else console.error(l); (s.manager.itemError(e), s.manager.itemEnd(e)); }, a = new $n(this.manager); (a.setPath(this.path), a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load( e, function (l) { try { s.parse( l, r, function (c) { (t(c), s.manager.itemEnd(e)); }, o, ); } catch (c) { o(c); } }, n, o, )); } setDRACOLoader(e) { return ((this.dracoLoader = e), this); } setKTX2Loader(e) { return ((this.ktx2Loader = e), this); } setMeshoptDecoder(e) { return ((this.meshoptDecoder = e), this); } register(e) { if (this.pluginCallbacks.indexOf(e) === -1) this.pluginCallbacks.push(e); return this; } unregister(e) { if (this.pluginCallbacks.indexOf(e) !== -1) this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1); return this; } parse(e, t, n, i) { let s, r = {}, o = {}, a = new TextDecoder(); if (typeof e === "string") s = JSON.parse(e); else if (e instanceof ArrayBuffer) if (a.decode(new Uint8Array(e, 0, 4)) === Ff) { try { r[Je.KHR_BINARY_GLTF] = new Of(e); } catch (h) { if (i) i(h); return; } s = JSON.parse(r[Je.KHR_BINARY_GLTF].content); } else s = JSON.parse(a.decode(e)); else s = e; if (s.asset === void 0 || s.asset.version[0] < 2) { if (i) i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")); return; } let l = new Gf(s, { path: t || this.resourcePath || "", crossOrigin: this.crossOrigin, requestHeader: this.requestHeader, manager: this.manager, ktx2Loader: this.ktx2Loader, meshoptDecoder: this.meshoptDecoder, }); l.fileLoader.setRequestHeader(this.requestHeader); for (let c = 0; c < this.pluginCallbacks.length; c++) { let h = this.pluginCallbacks[c](l); if (!h.name) console.error("THREE.GLTFLoader: Invalid plugin found: missing name"); ((o[h.name] = h), (r[h.name] = !0)); } if (s.extensionsUsed) for (let c = 0; c < s.extensionsUsed.length; ++c) { let h = s.extensionsUsed[c], u = s.extensionsRequired || []; switch (h) { case Je.KHR_MATERIALS_UNLIT: r[h] = new vf(); break; case Je.KHR_DRACO_MESH_COMPRESSION: r[h] = new kf(s, this.dracoLoader); break; case Je.KHR_TEXTURE_TRANSFORM: r[h] = new zf(); break; case Je.KHR_MESH_QUANTIZATION: r[h] = new Hf(); break; default: if (u.indexOf(h) >= 0 && o[h] === void 0) console.warn('THREE.GLTFLoader: Unknown extension "' + h + '".'); } } (l.setExtensions(r), l.setPlugins(o), l.parse(n, i)); } parseAsync(e, t) { let n = this; return new Promise(function (i, s) { n.parse(e, t, i, s); }); } } function n_() { let e = {}; return { get: function (t) { return e[t]; }, add: function (t, n) { e[t] = n; }, remove: function (t) { delete e[t]; }, removeAll: function () { e = {}; }, }; } var Je = { KHR_BINARY_GLTF: "KHR_binary_glTF", KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression", KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual", KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat", KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion", KHR_MATERIALS_IOR: "KHR_materials_ior", KHR_MATERIALS_SHEEN: "KHR_materials_sheen", KHR_MATERIALS_SPECULAR: "KHR_materials_specular", KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission", KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence", KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy", KHR_MATERIALS_UNLIT: "KHR_materials_unlit", KHR_MATERIALS_VOLUME: "KHR_materials_volume", KHR_TEXTURE_BASISU: "KHR_texture_basisu", KHR_TEXTURE_TRANSFORM: "KHR_texture_transform", KHR_MESH_QUANTIZATION: "KHR_mesh_quantization", KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength", EXT_MATERIALS_BUMP: "EXT_materials_bump", EXT_TEXTURE_WEBP: "EXT_texture_webp", EXT_TEXTURE_AVIF: "EXT_texture_avif", EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression", EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing", }; class xf { constructor(e) { ((this.parser = e), (this.name = Je.KHR_LIGHTS_PUNCTUAL), (this.cache = { refs: {}, uses: {} })); } _markDefs() { let e = this.parser, t = this.parser.json.nodes || []; for (let n = 0, i = t.length; n < i; n++) { let s = t[n]; if (s.extensions && s.extensions[this.name] && s.extensions[this.name].light !== void 0) e._addNodeRef(this.cache, s.extensions[this.name].light); } } _loadLight(e) { let t = this.parser, n = "light:" + e, i = t.cache.get(n); if (i) return i; let s = t.json, a = (((s.extensions && s.extensions[this.name]) || {}).lights || [])[e], l, c = new re(16777215); if (a.color !== void 0) c.setRGB(a.color[0], a.color[1], a.color[2], Ut); let h = a.range !== void 0 ? a.range : 0; switch (a.type) { case "directional": ((l = new Qn(c)), l.target.position.set(0, 0, -1), l.add(l.target)); break; case "point": ((l = new wi(c)), (l.distance = h)); break; case "spot": ((l = new Yi(c)), (l.distance = h), (a.spot = a.spot || {}), (a.spot.innerConeAngle = a.spot.innerConeAngle !== void 0 ? a.spot.innerConeAngle : 0), (a.spot.outerConeAngle = a.spot.outerConeAngle !== void 0 ? a.spot.outerConeAngle : Math.PI / 4), (l.angle = a.spot.outerConeAngle), (l.penumbra = 1 - a.spot.innerConeAngle / a.spot.outerConeAngle), l.target.position.set(0, 0, -1), l.add(l.target)); break; default: throw Error("THREE.GLTFLoader: Unexpected light type: " + a.type); } if ((l.position.set(0, 0, 0), ni(l, a), a.intensity !== void 0)) l.intensity = a.intensity; return ((l.name = t.createUniqueName(a.name || "light_" + e)), (i = Promise.resolve(l)), t.cache.add(n, i), i); } getDependency(e, t) { if (e !== "light") return; return this._loadLight(t); } createNodeAttachment(e) { let t = this, n = this.parser, s = n.json.nodes[e], o = ((s.extensions && s.extensions[this.name]) || {}).light; if (o === void 0) return null; return this._loadLight(o).then(function (a) { return n._getNodeRef(t.cache, o, a); }); } } class vf { constructor() { this.name = Je.KHR_MATERIALS_UNLIT; } getMaterialType() { return Wt; } extendParams(e, t, n) { let i = []; ((e.color = new re(1, 1, 1)), (e.opacity = 1)); let s = t.pbrMetallicRoughness; if (s) { if (Array.isArray(s.baseColorFactor)) { let r = s.baseColorFactor; (e.color.setRGB(r[0], r[1], r[2], Ut), (e.opacity = r[3])); } if (s.baseColorTexture !== void 0) i.push(n.assignTexture(e, "map", s.baseColorTexture, lt)); } return Promise.all(i); } } class _f { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_EMISSIVE_STRENGTH)); } extendMaterialParams(e, t) { let i = this.parser.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = i.extensions[this.name].emissiveStrength; if (s !== void 0) t.emissiveIntensity = s; return Promise.resolve(); } } class Sf { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_CLEARCOAT)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = [], r = i.extensions[this.name]; if (r.clearcoatFactor !== void 0) t.clearcoat = r.clearcoatFactor; if (r.clearcoatTexture !== void 0) s.push(n.assignTexture(t, "clearcoatMap", r.clearcoatTexture)); if (r.clearcoatRoughnessFactor !== void 0) t.clearcoatRoughness = r.clearcoatRoughnessFactor; if (r.clearcoatRoughnessTexture !== void 0) s.push(n.assignTexture(t, "clearcoatRoughnessMap", r.clearcoatRoughnessTexture)); if (r.clearcoatNormalTexture !== void 0) { if ( (s.push(n.assignTexture(t, "clearcoatNormalMap", r.clearcoatNormalTexture)), r.clearcoatNormalTexture.scale !== void 0) ) { let o = r.clearcoatNormalTexture.scale; t.clearcoatNormalScale = new ve(o, o); } } return Promise.all(s); } } class bf { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_DISPERSION)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let i = this.parser.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = i.extensions[this.name]; return ((t.dispersion = s.dispersion !== void 0 ? s.dispersion : 0), Promise.resolve()); } } class Mf { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_IRIDESCENCE)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = [], r = i.extensions[this.name]; if (r.iridescenceFactor !== void 0) t.iridescence = r.iridescenceFactor; if (r.iridescenceTexture !== void 0) s.push(n.assignTexture(t, "iridescenceMap", r.iridescenceTexture)); if (r.iridescenceIor !== void 0) t.iridescenceIOR = r.iridescenceIor; if (t.iridescenceThicknessRange === void 0) t.iridescenceThicknessRange = [100, 400]; if (r.iridescenceThicknessMinimum !== void 0) t.iridescenceThicknessRange[0] = r.iridescenceThicknessMinimum; if (r.iridescenceThicknessMaximum !== void 0) t.iridescenceThicknessRange[1] = r.iridescenceThicknessMaximum; if (r.iridescenceThicknessTexture !== void 0) s.push(n.assignTexture(t, "iridescenceThicknessMap", r.iridescenceThicknessTexture)); return Promise.all(s); } } class wf { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_SHEEN)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = []; ((t.sheenColor = new re(0, 0, 0)), (t.sheenRoughness = 0), (t.sheen = 1)); let r = i.extensions[this.name]; if (r.sheenColorFactor !== void 0) { let o = r.sheenColorFactor; t.sheenColor.setRGB(o[0], o[1], o[2], Ut); } if (r.sheenRoughnessFactor !== void 0) t.sheenRoughness = r.sheenRoughnessFactor; if (r.sheenColorTexture !== void 0) s.push(n.assignTexture(t, "sheenColorMap", r.sheenColorTexture, lt)); if (r.sheenRoughnessTexture !== void 0) s.push(n.assignTexture(t, "sheenRoughnessMap", r.sheenRoughnessTexture)); return Promise.all(s); } } class Tf { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_TRANSMISSION)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = [], r = i.extensions[this.name]; if (r.transmissionFactor !== void 0) t.transmission = r.transmissionFactor; if (r.transmissionTexture !== void 0) s.push(n.assignTexture(t, "transmissionMap", r.transmissionTexture)); return Promise.all(s); } } class Ef { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_VOLUME)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = [], r = i.extensions[this.name]; if (((t.thickness = r.thicknessFactor !== void 0 ? r.thicknessFactor : 0), r.thicknessTexture !== void 0)) s.push(n.assignTexture(t, "thicknessMap", r.thicknessTexture)); t.attenuationDistance = r.attenuationDistance || 1 / 0; let o = r.attenuationColor || [1, 1, 1]; return ((t.attenuationColor = new re().setRGB(o[0], o[1], o[2], Ut)), Promise.all(s)); } } class Af { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_IOR)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let i = this.parser.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = i.extensions[this.name]; return ((t.ior = s.ior !== void 0 ? s.ior : 1.5), Promise.resolve()); } } class Rf { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_SPECULAR)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = [], r = i.extensions[this.name]; if (((t.specularIntensity = r.specularFactor !== void 0 ? r.specularFactor : 1), r.specularTexture !== void 0)) s.push(n.assignTexture(t, "specularIntensityMap", r.specularTexture)); let o = r.specularColorFactor || [1, 1, 1]; if (((t.specularColor = new re().setRGB(o[0], o[1], o[2], Ut)), r.specularColorTexture !== void 0)) s.push(n.assignTexture(t, "specularColorMap", r.specularColorTexture, lt)); return Promise.all(s); } } class Lf { constructor(e) { ((this.parser = e), (this.name = Je.EXT_MATERIALS_BUMP)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = [], r = i.extensions[this.name]; if (((t.bumpScale = r.bumpFactor !== void 0 ? r.bumpFactor : 1), r.bumpTexture !== void 0)) s.push(n.assignTexture(t, "bumpMap", r.bumpTexture)); return Promise.all(s); } } class Cf { constructor(e) { ((this.parser = e), (this.name = Je.KHR_MATERIALS_ANISOTROPY)); } getMaterialType(e) { let n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return null; return tn; } extendMaterialParams(e, t) { let n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); let s = [], r = i.extensions[this.name]; if (r.anisotropyStrength !== void 0) t.anisotropy = r.anisotropyStrength; if (r.anisotropyRotation !== void 0) t.anisotropyRotation = r.anisotropyRotation; if (r.anisotropyTexture !== void 0) s.push(n.assignTexture(t, "anisotropyMap", r.anisotropyTexture)); return Promise.all(s); } } class If { constructor(e) { ((this.parser = e), (this.name = Je.KHR_TEXTURE_BASISU)); } loadTexture(e) { let t = this.parser, n = t.json, i = n.textures[e]; if (!i.extensions || !i.extensions[this.name]) return null; let s = i.extensions[this.name], r = t.options.ktx2Loader; if (!r) if (n.extensionsRequired && n.extensionsRequired.indexOf(this.name) >= 0) throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures"); else return null; return t.loadTextureImage(e, s.source, r); } } class Pf { constructor(e) { ((this.parser = e), (this.name = Je.EXT_TEXTURE_WEBP)); } loadTexture(e) { let t = this.name, n = this.parser, i = n.json, s = i.textures[e]; if (!s.extensions || !s.extensions[t]) return null; let r = s.extensions[t], o = i.images[r.source], a = n.textureLoader; if (o.uri) { let l = n.options.manager.getHandler(o.uri); if (l !== null) a = l; } return n.loadTextureImage(e, r.source, a); } } class Df { constructor(e) { ((this.parser = e), (this.name = Je.EXT_TEXTURE_AVIF)); } loadTexture(e) { let t = this.name, n = this.parser, i = n.json, s = i.textures[e]; if (!s.extensions || !s.extensions[t]) return null; let r = s.extensions[t], o = i.images[r.source], a = n.textureLoader; if (o.uri) { let l = n.options.manager.getHandler(o.uri); if (l !== null) a = l; } return n.loadTextureImage(e, r.source, a); } } class Uf { constructor(e) { ((this.name = Je.EXT_MESHOPT_COMPRESSION), (this.parser = e)); } loadBufferView(e) { let t = this.parser.json, n = t.bufferViews[e]; if (n.extensions && n.extensions[this.name]) { let i = n.extensions[this.name], s = this.parser.getDependency("buffer", i.buffer), r = this.parser.options.meshoptDecoder; if (!r || !r.supported) if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0) throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files"); else return null; return s.then(function (o) { let a = i.byteOffset || 0, l = i.byteLength || 0, { count: c, byteStride: h } = i, u = new Uint8Array(o, a, l); if (r.decodeGltfBufferAsync) return r.decodeGltfBufferAsync(c, h, u, i.mode, i.filter).then(function (d) { return d.buffer; }); else return r.ready.then(function () { let d = new ArrayBuffer(c * h); return (r.decodeGltfBuffer(new Uint8Array(d), c, h, u, i.mode, i.filter), d); }); }); } else return null; } } class Nf { constructor(e) { ((this.name = Je.EXT_MESH_GPU_INSTANCING), (this.parser = e)); } createNodeMesh(e) { let t = this.parser.json, n = t.nodes[e]; if (!n.extensions || !n.extensions[this.name] || n.mesh === void 0) return null; let i = t.meshes[n.mesh]; for (let l of i.primitives) if (l.mode !== Tn.TRIANGLES && l.mode !== Tn.TRIANGLE_STRIP && l.mode !== Tn.TRIANGLE_FAN && l.mode !== void 0) return null; let r = n.extensions[this.name].attributes, o = [], a = {}; for (let l in r) o.push(this.parser.getDependency("accessor", r[l]).then((c) => ((a[l] = c), a[l]))); if (o.length < 1) return null; return ( o.push(this.parser.createNodeMesh(e)), Promise.all(o).then((l) => { let c = l.pop(), h = c.isGroup ? c.children : [c], u = l[0].count, d = []; for (let f of h) { let m = new ue(), y = new E(), p = new Ne(), g = new E(1, 1, 1), _ = new nr(f.geometry, f.material, u); for (let x = 0; x < u; x++) { if (a.TRANSLATION) y.fromBufferAttribute(a.TRANSLATION, x); if (a.ROTATION) p.fromBufferAttribute(a.ROTATION, x); if (a.SCALE) g.fromBufferAttribute(a.SCALE, x); _.setMatrixAt(x, m.compose(y, p, g)); } for (let x in a) if (x === "_COLOR_0") { let w = a[x]; _.instanceColor = new cs(w.array, w.itemSize, w.normalized); } else if (x !== "TRANSLATION" && x !== "ROTATION" && x !== "SCALE") f.geometry.setAttribute(x, a[x]); (it.prototype.copy.call(_, f), this.parser.assignFinalMaterial(_), d.push(_)); } if (c.isGroup) return (c.clear(), c.add(...d), c); return d[0]; }) ); } } var Ff = "glTF", Kr = 12, pf = { JSON: 1313821514, BIN: 5130562 }; class Of { constructor(e) { ((this.name = Je.KHR_BINARY_GLTF), (this.content = null), (this.body = null)); let t = new DataView(e, 0, Kr), n = new TextDecoder(); if ( ((this.header = { magic: n.decode(new Uint8Array(e.slice(0, 4))), version: t.getUint32(4, !0), length: t.getUint32(8, !0), }), this.header.magic !== Ff) ) throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header."); else if (this.header.version < 2) throw Error("THREE.GLTFLoader: Legacy binary file detected."); let i = this.header.length - Kr, s = new DataView(e, Kr), r = 0; while (r < i) { let o = s.getUint32(r, !0); r += 4; let a = s.getUint32(r, !0); if (((r += 4), a === pf.JSON)) { let l = new Uint8Array(e, Kr + r, o); this.content = n.decode(l); } else if (a === pf.BIN) { let l = Kr + r; this.body = e.slice(l, l + o); } r += o; } if (this.content === null) throw Error("THREE.GLTFLoader: JSON content not found."); } } class kf { constructor(e, t) { if (!t) throw Error("THREE.GLTFLoader: No DRACOLoader instance provided."); ((this.name = Je.KHR_DRACO_MESH_COMPRESSION), (this.json = e), (this.dracoLoader = t), this.dracoLoader.preload()); } decodePrimitive(e, t) { let n = this.json, i = this.dracoLoader, s = e.extensions[this.name].bufferView, r = e.extensions[this.name].attributes, o = {}, a = {}, l = {}; for (let c in r) { let h = Gc[c] || c.toLowerCase(); o[h] = r[c]; } for (let c in e.attributes) { let h = Gc[c] || c.toLowerCase(); if (r[c] !== void 0) { let u = n.accessors[e.attributes[c]], d = dr[u.componentType]; ((l[h] = d.name), (a[h] = u.normalized === !0)); } } return t.getDependency("bufferView", s).then(function (c) { return new Promise(function (h, u) { i.decodeDracoFile( c, function (d) { for (let f in d.attributes) { let m = d.attributes[f], y = a[f]; if (y !== void 0) m.normalized = y; } h(d); }, o, l, Ut, u, ); }); }); } } class zf { constructor() { this.name = Je.KHR_TEXTURE_TRANSFORM; } extendTexture(e, t) { if ( (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 ) return e; if (((e = e.clone()), t.texCoord !== void 0)) e.channel = t.texCoord; if (t.offset !== void 0) e.offset.fromArray(t.offset); if (t.rotation !== void 0) e.rotation = t.rotation; if (t.scale !== void 0) e.repeat.fromArray(t.scale); return ((e.needsUpdate = !0), e); } } class Hf { constructor() { this.name = Je.KHR_MESH_QUANTIZATION; } } class Xc extends Wi { constructor(e, t, n, i) { super(e, t, n, i); } copySampleValue_(e) { let t = this.resultBuffer, n = this.sampleValues, i = this.valueSize, s = e * i * 3 + i; for (let r = 0; r !== i; r++) t[r] = n[s + r]; return t; } interpolate_(e, t, n, i) { let s = this.resultBuffer, r = this.sampleValues, o = this.valueSize, a = o * 2, l = o * 3, c = i - t, h = (n - t) / c, u = h * h, d = u * h, f = e * l, m = f - l, y = -2 * d + 3 * u, p = d - u, g = 1 - y, _ = p - u + h; for (let x = 0; x !== o; x++) { let w = r[m + x + o], L = r[m + x + a] * c, b = r[f + x + o], R = r[f + x] * c; s[x] = g * w + _ * L + y * b + p * R; } return s; } } var i_ = new Ne(); class Bf extends Xc { interpolate_(e, t, n, i) { let s = super.interpolate_(e, t, n, i); return (i_.fromArray(s).normalize().toArray(s), s); } } var Tn = { FLOAT: 5126, FLOAT_MAT3: 35675, FLOAT_MAT4: 35676, FLOAT_VEC2: 35664, FLOAT_VEC3: 35665, FLOAT_VEC4: 35666, LINEAR: 9729, REPEAT: 10497, SAMPLER_2D: 35678, POINTS: 0, LINES: 1, LINE_LOOP: 2, LINE_STRIP: 3, TRIANGLES: 4, TRIANGLE_STRIP: 5, TRIANGLE_FAN: 6, UNSIGNED_BYTE: 5121, UNSIGNED_SHORT: 5123, }, dr = { 5120: Int8Array, 5121: Uint8Array, 5122: Int16Array, 5123: Uint16Array, 5125: Uint32Array, 5126: Float32Array, }, mf = { 9728: gi, 9729: kn, 9984: Yo, 9985: Ks, 9986: fs, 9987: yi }, gf = { 33071: ds, 33648: qo, 10497: On }, zc = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16 }, Gc = { POSITION: "position", NORMAL: "normal", TANGENT: "tangent", TEXCOORD_0: "uv", TEXCOORD_1: "uv1", TEXCOORD_2: "uv2", TEXCOORD_3: "uv3", COLOR_0: "color", WEIGHTS_0: "skinWeight", JOINTS_0: "skinIndex", }, Ki = { scale: "scale", translation: "position", rotation: "quaternion", weights: "morphTargetInfluences" }, s_ = { CUBICSPLINE: void 0, LINEAR: Qo, STEP: Jl }, Hc = { OPAQUE: "OPAQUE", MASK: "MASK", BLEND: "BLEND" }; function r_(e) { if (e.DefaultMaterial === void 0) e.DefaultMaterial = new Mi({ color: 16777215, emissive: 0, metalness: 1, roughness: 1, transparent: !1, depthTest: !0, side: Fi, }); return e.DefaultMaterial; } function bs(e, t, n) { for (let i in n.extensions) if (e[i] === void 0) ((t.userData.gltfExtensions = t.userData.gltfExtensions || {}), (t.userData.gltfExtensions[i] = n.extensions[i])); } function ni(e, t) { if (t.extras !== void 0) if (typeof t.extras === "object") Object.assign(e.userData, t.extras); else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + t.extras); } function o_(e, t, n) { let i = !1, s = !1, r = !1; for (let c = 0, h = t.length; c < h; c++) { let u = t[c]; if (u.POSITION !== void 0) i = !0; if (u.NORMAL !== void 0) s = !0; if (u.COLOR_0 !== void 0) r = !0; if (i && s && r) break; } if (!i && !s && !r) return Promise.resolve(e); let o = [], a = [], l = []; for (let c = 0, h = t.length; c < h; c++) { let u = t[c]; if (i) { let d = u.POSITION !== void 0 ? n.getDependency("accessor", u.POSITION) : e.attributes.position; o.push(d); } if (s) { let d = u.NORMAL !== void 0 ? n.getDependency("accessor", u.NORMAL) : e.attributes.normal; a.push(d); } if (r) { let d = u.COLOR_0 !== void 0 ? n.getDependency("accessor", u.COLOR_0) : e.attributes.color; l.push(d); } } return Promise.all([Promise.all(o), Promise.all(a), Promise.all(l)]).then(function (c) { let h = c[0], u = c[1], d = c[2]; if (i) e.morphAttributes.position = h; if (s) e.morphAttributes.normal = u; if (r) e.morphAttributes.color = d; return ((e.morphTargetsRelative = !0), e); }); } function a_(e, t) { if ((e.updateMorphTargets(), t.weights !== void 0)) for (let n = 0, i = t.weights.length; n < i; n++) e.morphTargetInfluences[n] = t.weights[n]; if (t.extras && Array.isArray(t.extras.targetNames)) { let n = t.extras.targetNames; if (e.morphTargetInfluences.length === n.length) { e.morphTargetDictionary = {}; for (let i = 0, s = n.length; i < s; i++) e.morphTargetDictionary[n[i]] = i; } else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names."); } } function l_(e) { let t, n = e.extensions && e.extensions[Je.KHR_DRACO_MESH_COMPRESSION]; if (n) t = "draco:" + n.bufferView + ":" + n.indices + ":" + Bc(n.attributes); else t = e.indices + ":" + Bc(e.attributes) + ":" + e.mode; if (e.targets !== void 0) for (let i = 0, s = e.targets.length; i < s; i++) t += ":" + Bc(e.targets[i]); return t; } function Bc(e) { let t = "", n = Object.keys(e).sort(); for (let i = 0, s = n.length; i < s; i++) t += n[i] + ":" + e[n[i]] + ";"; return t; } function Vc(e) { switch (e) { case Int8Array: return 0.007874015748031496; case Uint8Array: return 0.00392156862745098; case Int16Array: return 0.00003051850947599719; case Uint16Array: return 0.000015259021896696422; default: throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type."); } } function c_(e) { if (e.search(/\.jpe?g($|\?)/i) > 0 || e.search(/^data\:image\/jpeg/) === 0) return "image/jpeg"; if (e.search(/\.webp($|\?)/i) > 0 || e.search(/^data\:image\/webp/) === 0) return "image/webp"; if (e.search(/\.ktx2($|\?)/i) > 0 || e.search(/^data\:image\/ktx2/) === 0) return "image/ktx2"; return "image/png"; } var h_ = new ue(); class Gf { constructor(e = {}, t = {}) { ((this.json = e), (this.extensions = {}), (this.plugins = {}), (this.options = t), (this.cache = new n_()), (this.associations = new Map()), (this.primitiveCache = {}), (this.nodeCache = {}), (this.meshCache = { refs: {}, uses: {} }), (this.cameraCache = { refs: {}, uses: {} }), (this.lightCache = { refs: {}, uses: {} }), (this.sourceCache = {}), (this.textureCache = {}), (this.nodeNamesUsed = {})); let n = !1, i = -1, s = !1, r = -1; if (typeof navigator < "u") { let o = navigator.userAgent; n = /^((?!chrome|android).)*safari/i.test(o) === !0; let a = o.match(/Version\/(\d+)/); ((i = n && a ? parseInt(a[1], 10) : -1), (s = o.indexOf("Firefox") > -1), (r = s ? o.match(/Firefox\/([0-9]+)\./)[1] : -1)); } if (typeof createImageBitmap > "u" || (n && i < 17) || (s && r < 98)) this.textureLoader = new Jn(this.options.manager); else this.textureLoader = new da(this.options.manager); if ( (this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), (this.fileLoader = new $n(this.options.manager)), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials") ) this.fileLoader.setWithCredentials(!0); } setExtensions(e) { this.extensions = e; } setPlugins(e) { this.plugins = e; } parse(e, t) { let n = this, i = this.json, s = this.extensions; (this.cache.removeAll(), (this.nodeCache = {}), this._invokeAll(function (r) { return r._markDefs && r._markDefs(); }), Promise.all( this._invokeAll(function (r) { return r.beforeRoot && r.beforeRoot(); }), ) .then(function () { return Promise.all([n.getDependencies("scene"), n.getDependencies("animation"), n.getDependencies("camera")]); }) .then(function (r) { let o = { scene: r[0][i.scene || 0], scenes: r[0], animations: r[1], cameras: r[2], asset: i.asset, parser: n, userData: {}, }; return ( bs(s, o, i), ni(o, i), Promise.all( n._invokeAll(function (a) { return a.afterRoot && a.afterRoot(o); }), ).then(function () { for (let a of o.scenes) a.updateMatrixWorld(); e(o); }) ); }) .catch(t)); } _markDefs() { let e = this.json.nodes || [], t = this.json.skins || [], n = this.json.meshes || []; for (let i = 0, s = t.length; i < s; i++) { let r = t[i].joints; for (let o = 0, a = r.length; o < a; o++) e[r[o]].isBone = !0; } for (let i = 0, s = e.length; i < s; i++) { let r = e[i]; if (r.mesh !== void 0) { if ((this._addNodeRef(this.meshCache, r.mesh), r.skin !== void 0)) n[r.mesh].isSkinnedMesh = !0; } if (r.camera !== void 0) this._addNodeRef(this.cameraCache, r.camera); } } _addNodeRef(e, t) { if (t === void 0) return; if (e.refs[t] === void 0) e.refs[t] = e.uses[t] = 0; e.refs[t]++; } _getNodeRef(e, t, n) { if (e.refs[t] <= 1) return n; let i = n.clone(), s = (r, o) => { let a = this.associations.get(r); if (a != null) this.associations.set(o, a); for (let [l, c] of r.children.entries()) s(c, o.children[l]); }; return (s(n, i), (i.name += "_instance_" + e.uses[t]++), i); } _invokeOne(e) { let t = Object.values(this.plugins); t.push(this); for (let n = 0; n < t.length; n++) { let i = e(t[n]); if (i) return i; } return null; } _invokeAll(e) { let t = Object.values(this.plugins); t.unshift(this); let n = []; for (let i = 0; i < t.length; i++) { let s = e(t[i]); if (s) n.push(s); } return n; } getDependency(e, t) { let n = e + ":" + t, i = this.cache.get(n); if (!i) { switch (e) { case "scene": i = this.loadScene(t); break; case "node": i = this._invokeOne(function (s) { return s.loadNode && s.loadNode(t); }); break; case "mesh": i = this._invokeOne(function (s) { return s.loadMesh && s.loadMesh(t); }); break; case "accessor": i = this.loadAccessor(t); break; case "bufferView": i = this._invokeOne(function (s) { return s.loadBufferView && s.loadBufferView(t); }); break; case "buffer": i = this.loadBuffer(t); break; case "material": i = this._invokeOne(function (s) { return s.loadMaterial && s.loadMaterial(t); }); break; case "texture": i = this._invokeOne(function (s) { return s.loadTexture && s.loadTexture(t); }); break; case "skin": i = this.loadSkin(t); break; case "animation": i = this._invokeOne(function (s) { return s.loadAnimation && s.loadAnimation(t); }); break; case "camera": i = this.loadCamera(t); break; default: if ( ((i = this._invokeOne(function (s) { return s != this && s.getDependency && s.getDependency(e, t); })), !i) ) throw Error("Unknown type: " + e); break; } this.cache.add(n, i); } return i; } getDependencies(e) { let t = this.cache.get(e); if (!t) { let n = this, i = this.json[e + (e === "mesh" ? "es" : "s")] || []; ((t = Promise.all( i.map(function (s, r) { return n.getDependency(e, r); }), )), this.cache.add(e, t)); } return t; } loadBuffer(e) { let t = this.json.buffers[e], n = this.fileLoader; if (t.type && t.type !== "arraybuffer") throw Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported."); if (t.uri === void 0 && e === 0) return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body); let i = this.options; return new Promise(function (s, r) { n.load(ei.resolveURL(t.uri, i.path), s, void 0, function () { r(Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".')); }); }); } loadBufferView(e) { let t = this.json.bufferViews[e]; return this.getDependency("buffer", t.buffer).then(function (n) { let i = t.byteLength || 0, s = t.byteOffset || 0; return n.slice(s, s + i); }); } loadAccessor(e) { let t = this, n = this.json, i = this.json.accessors[e]; if (i.bufferView === void 0 && i.sparse === void 0) { let r = zc[i.type], o = dr[i.componentType], a = i.normalized === !0, l = new o(i.count * r); return Promise.resolve(new gt(l, r, a)); } let s = []; if (i.bufferView !== void 0) s.push(this.getDependency("bufferView", i.bufferView)); else s.push(null); if (i.sparse !== void 0) (s.push(this.getDependency("bufferView", i.sparse.indices.bufferView)), s.push(this.getDependency("bufferView", i.sparse.values.bufferView))); return Promise.all(s).then(function (r) { let o = r[0], a = zc[i.type], l = dr[i.componentType], c = l.BYTES_PER_ELEMENT, h = c * a, u = i.byteOffset || 0, d = i.bufferView !== void 0 ? n.bufferViews[i.bufferView].byteStride : void 0, f = i.normalized === !0, m, y; if (d && d !== h) { let p = Math.floor(u / d), g = "InterleavedBuffer:" + i.bufferView + ":" + i.componentType + ":" + p + ":" + i.count, _ = t.cache.get(g); if (!_) ((m = new l(o, p * d, (i.count * d) / c)), (_ = new Xr(m, d / c)), t.cache.add(g, _)); y = new tr(_, a, (u % d) / c, f); } else { if (o === null) m = new l(i.count * a); else m = new l(o, u, i.count * a); y = new gt(m, a, f); } if (i.sparse !== void 0) { let p = zc.SCALAR, g = dr[i.sparse.indices.componentType], _ = i.sparse.indices.byteOffset || 0, x = i.sparse.values.byteOffset || 0, w = new g(r[1], _, i.sparse.count * p), L = new l(r[2], x, i.sparse.count * a); if (o !== null) y = new gt(y.array.slice(), y.itemSize, y.normalized); y.normalized = !1; for (let b = 0, R = w.length; b < R; b++) { let F = w[b]; if ((y.setX(F, L[b * a]), a >= 2)) y.setY(F, L[b * a + 1]); if (a >= 3) y.setZ(F, L[b * a + 2]); if (a >= 4) y.setW(F, L[b * a + 3]); if (a >= 5) throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute."); } y.normalized = f; } return y; }); } loadTexture(e) { let t = this.json, n = this.options, s = t.textures[e].source, r = t.images[s], o = this.textureLoader; if (r.uri) { let a = n.manager.getHandler(r.uri); if (a !== null) o = a; } return this.loadTextureImage(e, s, o); } loadTextureImage(e, t, n) { let i = this, s = this.json, r = s.textures[e], o = s.images[t], a = (o.uri || o.bufferView) + ":" + r.sampler; if (this.textureCache[a]) return this.textureCache[a]; let l = this.loadImageSource(t, n) .then(function (c) { if ( ((c.flipY = !1), (c.name = r.name || o.name || ""), c.name === "" && typeof o.uri === "string" && o.uri.startsWith("data:image/") === !1) ) c.name = o.uri; let u = (s.samplers || {})[r.sampler] || {}; return ( (c.magFilter = mf[u.magFilter] || kn), (c.minFilter = mf[u.minFilter] || yi), (c.wrapS = gf[u.wrapS] || On), (c.wrapT = gf[u.wrapT] || On), (c.generateMipmaps = !c.isCompressedTexture && c.minFilter !== gi && c.minFilter !== kn), i.associations.set(c, { textures: e }), c ); }) .catch(function () { return null; }); return ((this.textureCache[a] = l), l); } loadImageSource(e, t) { let n = this, i = this.json, s = this.options; if (this.sourceCache[e] !== void 0) return this.sourceCache[e].then((h) => h.clone()); let r = i.images[e], o = self.URL || self.webkitURL, a = r.uri || "", l = !1; if (r.bufferView !== void 0) a = n.getDependency("bufferView", r.bufferView).then(function (h) { l = !0; let u = new Blob([h], { type: r.mimeType }); return ((a = o.createObjectURL(u)), a); }); else if (r.uri === void 0) throw Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView"); let c = Promise.resolve(a) .then(function (h) { return new Promise(function (u, d) { let f = u; if (t.isImageBitmapLoader === !0) f = function (m) { let y = new Rt(m); ((y.needsUpdate = !0), u(y)); }; t.load(ei.resolveURL(h, s.path), f, void 0, d); }); }) .then(function (h) { if (l === !0) o.revokeObjectURL(a); return (ni(h, r), (h.userData.mimeType = r.mimeType || c_(r.uri)), h); }) .catch(function (h) { throw (console.error("THREE.GLTFLoader: Couldn't load texture", a), h); }); return ((this.sourceCache[e] = c), c); } assignTexture(e, t, n, i) { let s = this; return this.getDependency("texture", n.index).then(function (r) { if (!r) return null; if (n.texCoord !== void 0 && n.texCoord > 0) ((r = r.clone()), (r.channel = n.texCoord)); if (s.extensions[Je.KHR_TEXTURE_TRANSFORM]) { let o = n.extensions !== void 0 ? n.extensions[Je.KHR_TEXTURE_TRANSFORM] : void 0; if (o) { let a = s.associations.get(r); ((r = s.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(r, o)), s.associations.set(r, a)); } } if (i !== void 0) r.colorSpace = i; return ((e[t] = r), r); }); } assignFinalMaterial(e) { let { geometry: t, material: n } = e, i = t.attributes.tangent === void 0, s = t.attributes.color !== void 0, r = t.attributes.normal === void 0; if (e.isPoints) { let o = "PointsMaterial:" + n.uuid, a = this.cache.get(o); if (!a) ((a = new ms()), Vt.prototype.copy.call(a, n), a.color.copy(n.color), (a.map = n.map), (a.sizeAttenuation = !1), this.cache.add(o, a)); n = a; } else if (e.isLine) { let o = "LineBasicMaterial:" + n.uuid, a = this.cache.get(o); if (!a) ((a = new bi()), Vt.prototype.copy.call(a, n), a.color.copy(n.color), (a.map = n.map), this.cache.add(o, a)); n = a; } if (i || s || r) { let o = "ClonedMaterial:" + n.uuid + ":"; if (i) o += "derivative-tangents:"; if (s) o += "vertex-colors:"; if (r) o += "flat-shading:"; let a = this.cache.get(o); if (!a) { if (((a = n.clone()), s)) a.vertexColors = !0; if (r) a.flatShading = !0; if (i) { if (a.normalScale) a.normalScale.y *= -1; if (a.clearcoatNormalScale) a.clearcoatNormalScale.y *= -1; } (this.cache.add(o, a), this.associations.set(a, this.associations.get(n))); } n = a; } e.material = n; } getMaterialType() { return Mi; } loadMaterial(e) { let t = this, n = this.json, i = this.extensions, s = n.materials[e], r, o = {}, a = s.extensions || {}, l = []; if (a[Je.KHR_MATERIALS_UNLIT]) { let h = i[Je.KHR_MATERIALS_UNLIT]; ((r = h.getMaterialType()), l.push(h.extendParams(o, s, t))); } else { let h = s.pbrMetallicRoughness || {}; if (((o.color = new re(1, 1, 1)), (o.opacity = 1), Array.isArray(h.baseColorFactor))) { let u = h.baseColorFactor; (o.color.setRGB(u[0], u[1], u[2], Ut), (o.opacity = u[3])); } if (h.baseColorTexture !== void 0) l.push(t.assignTexture(o, "map", h.baseColorTexture, lt)); if ( ((o.metalness = h.metallicFactor !== void 0 ? h.metallicFactor : 1), (o.roughness = h.roughnessFactor !== void 0 ? h.roughnessFactor : 1), h.metallicRoughnessTexture !== void 0) ) (l.push(t.assignTexture(o, "metalnessMap", h.metallicRoughnessTexture)), l.push(t.assignTexture(o, "roughnessMap", h.metallicRoughnessTexture))); ((r = this._invokeOne(function (u) { return u.getMaterialType && u.getMaterialType(e); })), l.push( Promise.all( this._invokeAll(function (u) { return u.extendMaterialParams && u.extendMaterialParams(e, o); }), ), )); } if (s.doubleSided === !0) o.side = Yt; let c = s.alphaMode || Hc.OPAQUE; if (c === Hc.BLEND) ((o.transparent = !0), (o.depthWrite = !1)); else if (((o.transparent = !1), c === Hc.MASK)) o.alphaTest = s.alphaCutoff !== void 0 ? s.alphaCutoff : 0.5; if (s.normalTexture !== void 0 && r !== Wt) { if ( (l.push(t.assignTexture(o, "normalMap", s.normalTexture)), (o.normalScale = new ve(1, 1)), s.normalTexture.scale !== void 0) ) { let h = s.normalTexture.scale; o.normalScale.set(h, h); } } if (s.occlusionTexture !== void 0 && r !== Wt) { if ((l.push(t.assignTexture(o, "aoMap", s.occlusionTexture)), s.occlusionTexture.strength !== void 0)) o.aoMapIntensity = s.occlusionTexture.strength; } if (s.emissiveFactor !== void 0 && r !== Wt) { let h = s.emissiveFactor; o.emissive = new re().setRGB(h[0], h[1], h[2], Ut); } if (s.emissiveTexture !== void 0 && r !== Wt) l.push(t.assignTexture(o, "emissiveMap", s.emissiveTexture, lt)); return Promise.all(l).then(function () { let h = new r(o); if (s.name) h.name = s.name; if ((ni(h, s), t.associations.set(h, { materials: e }), s.extensions)) bs(i, h, s); return h; }); } createUniqueName(e) { let t = $e.sanitizeNodeName(e || ""); if (t in this.nodeNamesUsed) return t + "_" + ++this.nodeNamesUsed[t]; else return ((this.nodeNamesUsed[t] = 0), t); } loadGeometries(e) { let t = this, n = this.extensions, i = this.primitiveCache; function s(o) { return n[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o, t).then(function (a) { return yf(a, o, t); }); } let r = []; for (let o = 0, a = e.length; o < a; o++) { let l = e[o], c = l_(l), h = i[c]; if (h) r.push(h.promise); else { let u; if (l.extensions && l.extensions[Je.KHR_DRACO_MESH_COMPRESSION]) u = s(l); else u = yf(new Et(), l, t); ((i[c] = { primitive: l, promise: u }), r.push(u)); } } return Promise.all(r); } loadMesh(e) { let t = this, n = this.json, i = this.extensions, s = n.meshes[e], r = s.primitives, o = []; for (let a = 0, l = r.length; a < l; a++) { let c = r[a].material === void 0 ? r_(this.cache) : this.getDependency("material", r[a].material); o.push(c); } return ( o.push(t.loadGeometries(r)), Promise.all(o).then(function (a) { let l = a.slice(0, a.length - 1), c = a[a.length - 1], h = []; for (let d = 0, f = c.length; d < f; d++) { let m = c[d], y = r[d], p, g = l[d]; if ( y.mode === Tn.TRIANGLES || y.mode === Tn.TRIANGLE_STRIP || y.mode === Tn.TRIANGLE_FAN || y.mode === void 0 ) { if (((p = s.isSkinnedMesh === !0 ? new Bi(m, g) : new st(m, g)), p.isSkinnedMesh === !0)) p.normalizeSkinWeights(); if (y.mode === Tn.TRIANGLE_STRIP) p.geometry = kc(p.geometry, Br); else if (y.mode === Tn.TRIANGLE_FAN) p.geometry = kc(p.geometry, Qs); } else if (y.mode === Tn.LINES) p = new ir(m, g); else if (y.mode === Tn.LINE_STRIP) p = new Gi(m, g); else if (y.mode === Tn.LINE_LOOP) p = new ra(m, g); else if (y.mode === Tn.POINTS) p = new sr(m, g); else throw Error("THREE.GLTFLoader: Primitive mode unsupported: " + y.mode); if (Object.keys(p.geometry.morphAttributes).length > 0) a_(p, s); if (((p.name = t.createUniqueName(s.name || "mesh_" + e)), ni(p, s), y.extensions)) bs(i, p, y); (t.assignFinalMaterial(p), h.push(p)); } for (let d = 0, f = h.length; d < f; d++) t.associations.set(h[d], { meshes: e, primitives: d }); if (h.length === 1) { if (s.extensions) bs(i, h[0], s); return h[0]; } let u = new gn(); if (s.extensions) bs(i, u, s); t.associations.set(u, { meshes: e }); for (let d = 0, f = h.length; d < f; d++) u.add(h[d]); return u; }) ); } loadCamera(e) { let t, n = this.json.cameras[e], i = n[n.type]; if (!i) { console.warn("THREE.GLTFLoader: Missing camera parameters."); return; } if (n.type === "perspective") t = new It(bt.radToDeg(i.yfov), i.aspectRatio || 1, i.znear || 1, i.zfar || 2000000); else if (n.type === "orthographic") t = new ar(-i.xmag, i.xmag, i.ymag, -i.ymag, i.znear, i.zfar); if (n.name) t.name = this.createUniqueName(n.name); return (ni(t, n), Promise.resolve(t)); } loadSkin(e) { let t = this.json.skins[e], n = []; for (let i = 0, s = t.joints.length; i < s; i++) n.push(this._loadNodeShallow(t.joints[i])); if (t.inverseBindMatrices !== void 0) n.push(this.getDependency("accessor", t.inverseBindMatrices)); else n.push(null); return Promise.all(n).then(function (i) { let s = i.pop(), r = i, o = [], a = []; for (let l = 0, c = r.length; l < c; l++) { let h = r[l]; if (h) { o.push(h); let u = new ue(); if (s !== null) u.fromArray(s.array, l * 16); a.push(u); } else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[l]); } return new Si(o, a); }); } loadAnimation(e) { let t = this.json, n = this, i = t.animations[e], s = i.name ? i.name : "animation_" + e, r = [], o = [], a = [], l = [], c = []; for (let h = 0, u = i.channels.length; h < u; h++) { let d = i.channels[h], f = i.samplers[d.sampler], m = d.target, y = m.node, p = i.parameters !== void 0 ? i.parameters[f.input] : f.input, g = i.parameters !== void 0 ? i.parameters[f.output] : f.output; if (m.node === void 0) continue; (r.push(this.getDependency("node", y)), o.push(this.getDependency("accessor", p)), a.push(this.getDependency("accessor", g)), l.push(f), c.push(m)); } return Promise.all([Promise.all(r), Promise.all(o), Promise.all(a), Promise.all(l), Promise.all(c)]).then( function (h) { let u = h[0], d = h[1], f = h[2], m = h[3], y = h[4], p = []; for (let _ = 0, x = u.length; _ < x; _++) { let w = u[_], L = d[_], b = f[_], R = m[_], F = y[_]; if (w === void 0) continue; if (w.updateMatrix) w.updateMatrix(); let M = n._createAnimationTracks(w, L, b, R, F); if (M) for (let T = 0; T < M.length; T++) p.push(M[T]); } let g = new Di(s, void 0, p); return (ni(g, i), g); }, ); } createNodeMesh(e) { let t = this.json, n = this, i = t.nodes[e]; if (i.mesh === void 0) return null; return n.getDependency("mesh", i.mesh).then(function (s) { let r = n._getNodeRef(n.meshCache, i.mesh, s); if (i.weights !== void 0) r.traverse(function (o) { if (!o.isMesh) return; for (let a = 0, l = i.weights.length; a < l; a++) o.morphTargetInfluences[a] = i.weights[a]; }); return r; }); } loadNode(e) { let t = this.json, n = this, i = t.nodes[e], s = n._loadNodeShallow(e), r = [], o = i.children || []; for (let l = 0, c = o.length; l < c; l++) r.push(n.getDependency("node", o[l])); let a = i.skin === void 0 ? Promise.resolve(null) : n.getDependency("skin", i.skin); return Promise.all([s, Promise.all(r), a]).then(function (l) { let c = l[0], h = l[1], u = l[2]; if (u !== null) c.traverse(function (d) { if (!d.isSkinnedMesh) return; d.bind(u, h_); }); for (let d = 0, f = h.length; d < f; d++) c.add(h[d]); return c; }); } _loadNodeShallow(e) { let t = this.json, n = this.extensions, i = this; if (this.nodeCache[e] !== void 0) return this.nodeCache[e]; let s = t.nodes[e], r = s.name ? i.createUniqueName(s.name) : "", o = [], a = i._invokeOne(function (l) { return l.createNodeMesh && l.createNodeMesh(e); }); if (a) o.push(a); if (s.camera !== void 0) o.push( i.getDependency("camera", s.camera).then(function (l) { return i._getNodeRef(i.cameraCache, s.camera, l); }), ); return ( i ._invokeAll(function (l) { return l.createNodeAttachment && l.createNodeAttachment(e); }) .forEach(function (l) { o.push(l); }), (this.nodeCache[e] = Promise.all(o).then(function (l) { let c; if (s.isBone === !0) c = new Kn(); else if (l.length > 1) c = new gn(); else if (l.length === 1) c = l[0]; else c = new it(); if (c !== l[0]) for (let h = 0, u = l.length; h < u; h++) c.add(l[h]); if (s.name) ((c.userData.name = s.name), (c.name = r)); if ((ni(c, s), s.extensions)) bs(n, c, s); if (s.matrix !== void 0) { let h = new ue(); (h.fromArray(s.matrix), c.applyMatrix4(h)); } else { if (s.translation !== void 0) c.position.fromArray(s.translation); if (s.rotation !== void 0) c.quaternion.fromArray(s.rotation); if (s.scale !== void 0) c.scale.fromArray(s.scale); } if (!i.associations.has(c)) i.associations.set(c, {}); else if (s.mesh !== void 0 && i.meshCache.refs[s.mesh] > 1) { let h = i.associations.get(c); i.associations.set(c, { ...h }); } return ((i.associations.get(c).nodes = e), c); })), this.nodeCache[e] ); } loadScene(e) { let t = this.extensions, n = this.json.scenes[e], i = this, s = new gn(); if (n.name) s.name = i.createUniqueName(n.name); if ((ni(s, n), n.extensions)) bs(t, s, n); let r = n.nodes || [], o = []; for (let a = 0, l = r.length; a < l; a++) o.push(i.getDependency("node", r[a])); return Promise.all(o).then(function (a) { for (let c = 0, h = a.length; c < h; c++) s.add(a[c]); let l = (c) => { let h = new Map(); for (let [u, d] of i.associations) if (u instanceof Vt || u instanceof Rt) h.set(u, d); return ( c.traverse((u) => { let d = i.associations.get(u); if (d != null) h.set(u, d); }), h ); }; return ((i.associations = l(s)), s); }); } _createAnimationTracks(e, t, n, i, s) { let r = [], o = e.name ? e.name : e.uuid, a = []; if (Ki[s.path] === Ki.weights) e.traverse(function (u) { if (u.morphTargetInfluences) a.push(u.name ? u.name : u.uuid); }); else a.push(o); let l; switch (Ki[s.path]) { case Ki.weights: l = Nn; break; case Ki.rotation: l = wn; break; case Ki.translation: case Ki.scale: l = Fn; break; default: switch (n.itemSize) { case 1: l = Nn; break; case 2: case 3: default: l = Fn; break; } break; } let c = i.interpolation !== void 0 ? s_[i.interpolation] : Qo, h = this._getArrayFromAccessor(n); for (let u = 0, d = a.length; u < d; u++) { let f = new l(a[u] + "." + Ki[s.path], t.array, h, c); if (i.interpolation === "CUBICSPLINE") this._createCubicSplineTrackInterpolant(f); r.push(f); } return r; } _getArrayFromAccessor(e) { let t = e.array; if (e.normalized) { let n = Vc(t.constructor), i = new Float32Array(t.length); for (let s = 0, r = t.length; s < r; s++) i[s] = t[s] * n; t = i; } return t; } _createCubicSplineTrackInterpolant(e) { ((e.createInterpolant = function (n) { return new (this instanceof wn ? Bf : Xc)(this.times, this.values, this.getValueSize() / 3, n); }), (e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0)); } } function u_(e, t, n) { let i = t.attributes, s = new ln(); if (i.POSITION !== void 0) { let a = n.json.accessors[i.POSITION], { min: l, max: c } = a; if (l !== void 0 && c !== void 0) { if ((s.set(new E(l[0], l[1], l[2]), new E(c[0], c[1], c[2])), a.normalized)) { let h = Vc(dr[a.componentType]); (s.min.multiplyScalar(h), s.max.multiplyScalar(h)); } } else { console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."); return; } } else return; let r = t.targets; if (r !== void 0) { let a = new E(), l = new E(); for (let c = 0, h = r.length; c < h; c++) { let u = r[c]; if (u.POSITION !== void 0) { let d = n.json.accessors[u.POSITION], { min: f, max: m } = d; if (f !== void 0 && m !== void 0) { if ( (l.setX(Math.max(Math.abs(f[0]), Math.abs(m[0]))), l.setY(Math.max(Math.abs(f[1]), Math.abs(m[1]))), l.setZ(Math.max(Math.abs(f[2]), Math.abs(m[2]))), d.normalized) ) { let y = Vc(dr[d.componentType]); l.multiplyScalar(y); } a.max(l); } else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."); } } s.expandByVector(a); } e.boundingBox = s; let o = new yn(); (s.getCenter(o.center), (o.radius = s.min.distanceTo(s.max) / 2), (e.boundingSphere = o)); } function yf(e, t, n) { let i = t.attributes, s = []; function r(o, a) { return n.getDependency("accessor", o).then(function (l) { e.setAttribute(a, l); }); } for (let o in i) { let a = Gc[o] || o.toLowerCase(); if (a in e.attributes) continue; s.push(r(i[o], a)); } if (t.indices !== void 0 && !e.index) { let o = n.getDependency("accessor", t.indices).then(function (a) { e.setIndex(a); }); s.push(o); } if (ke.workingColorSpace !== Ut && "COLOR_0" in i) console.warn( `THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ke.workingColorSpace}" not supported.`, ); return ( ni(e, t), u_(e, t, n), Promise.all(s).then(function () { return t.targets !== void 0 ? o_(e, t.targets, n) : e; }) ); } var qc = new WeakMap(); class Yc extends nn { constructor(e) { super(e); ((this.decoderPath = ""), (this.decoderConfig = {}), (this.decoderBinary = null), (this.decoderPending = null), (this.workerLimit = 4), (this.workerPool = []), (this.workerNextTaskID = 1), (this.workerSourceURL = ""), (this.defaultAttributeIDs = { position: "POSITION", normal: "NORMAL", color: "COLOR", uv: "TEX_COORD" }), (this.defaultAttributeTypes = { position: "Float32Array", normal: "Float32Array", color: "Float32Array", uv: "Float32Array", })); } setDecoderPath(e) { return ((this.decoderPath = e), this); } setDecoderConfig(e) { return ((this.decoderConfig = e), this); } setWorkerLimit(e) { return ((this.workerLimit = e), this); } load(e, t, n, i) { let s = new $n(this.manager); (s.setPath(this.path), s.setResponseType("arraybuffer"), s.setRequestHeader(this.requestHeader), s.setWithCredentials(this.withCredentials), s.load( e, (r) => { this.parse(r, t, i); }, n, i, )); } parse(e, t, n = () => {}) { this.decodeDracoFile(e, t, null, null, lt, n).catch(n); } decodeDracoFile(e, t, n, i, s = Ut, r = () => {}) { let o = { attributeIDs: n || this.defaultAttributeIDs, attributeTypes: i || this.defaultAttributeTypes, useUniqueIDs: !!n, vertexColorSpace: s, }; return this.decodeGeometry(e, o).then(t).catch(r); } decodeGeometry(e, t) { let n = JSON.stringify(t); if (qc.has(e)) { let a = qc.get(e); if (a.key === n) return a.promise; else if (e.byteLength === 0) throw Error( "THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.", ); } let i, s = this.workerNextTaskID++, r = e.byteLength, o = this._getWorker(s, r) .then( (a) => ( (i = a), new Promise((l, c) => { ((i._callbacks[s] = { resolve: l, reject: c }), i.postMessage({ type: "decode", id: s, taskConfig: t, buffer: e }, [e])); }) ), ) .then((a) => this._createGeometry(a.geometry)); return ( o .catch(() => !0) .then(() => { if (i && s) this._releaseTask(i, s); }), qc.set(e, { key: n, promise: o }), o ); } _createGeometry(e) { let t = new Et(); if (e.index) t.setIndex(new gt(e.index.array, 1)); for (let n = 0; n < e.attributes.length; n++) { let i = e.attributes[n], { name: s, array: r, itemSize: o } = i, a = new gt(r, o); if (s === "color") (this._assignVertexColorSpace(a, i.vertexColorSpace), (a.normalized = r instanceof Float32Array === !1)); t.setAttribute(s, a); } return t; } _assignVertexColorSpace(e, t) { if (t !== lt) return; let n = new re(); for (let i = 0, s = e.count; i < s; i++) (n.fromBufferAttribute(e, i), ke.colorSpaceToWorking(n, lt), e.setXYZ(i, n.r, n.g, n.b)); } _loadLibrary(e, t) { let n = new $n(this.manager); return ( n.setPath(this.decoderPath), n.setResponseType(t), n.setWithCredentials(this.withCredentials), new Promise((i, s) => { n.load(e, i, void 0, s); }) ); } preload() { return (this._initDecoder(), this); } _initDecoder() { if (this.decoderPending) return this.decoderPending; let e = typeof WebAssembly !== "object" || this.decoderConfig.type === "js", t = []; if (e) t.push(this._loadLibrary("draco_decoder.js", "text")); else (t.push(this._loadLibrary("draco_wasm_wrapper.js", "text")), t.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"))); return ( (this.decoderPending = Promise.all(t).then((n) => { let i = n[0]; if (!e) this.decoderConfig.wasmBinary = n[1]; let s = d_.toString(), r = ["/* draco decoder */", i, "", "/* worker */", s.substring(s.indexOf("{") + 1, s.lastIndexOf("}"))].join(` `); this.workerSourceURL = URL.createObjectURL(new Blob([r])); })), this.decoderPending ); } _getWorker(e, t) { return this._initDecoder().then(() => { if (this.workerPool.length < this.workerLimit) { let i = new Worker(this.workerSourceURL); ((i._callbacks = {}), (i._taskCosts = {}), (i._taskLoad = 0), i.postMessage({ type: "init", decoderConfig: this.decoderConfig }), (i.onmessage = function (s) { let r = s.data; switch (r.type) { case "decode": i._callbacks[r.id].resolve(r); break; case "error": i._callbacks[r.id].reject(r); break; default: console.error('THREE.DRACOLoader: Unexpected message, "' + r.type + '"'); } }), this.workerPool.push(i)); } else this.workerPool.sort(function (i, s) { return i._taskLoad > s._taskLoad ? -1 : 1; }); let n = this.workerPool[this.workerPool.length - 1]; return ((n._taskCosts[e] = t), (n._taskLoad += t), n); }); } _releaseTask(e, t) { ((e._taskLoad -= e._taskCosts[t]), delete e._callbacks[t], delete e._taskCosts[t]); } debug() { console.log( "Task load: ", this.workerPool.map((e) => e._taskLoad), ); } dispose() { for (let e = 0; e < this.workerPool.length; ++e) this.workerPool[e].terminate(); if (((this.workerPool.length = 0), this.workerSourceURL !== "")) URL.revokeObjectURL(this.workerSourceURL); return this; } } function d_() { let e, t; onmessage = function (o) { let a = o.data; switch (a.type) { case "init": ((e = a.decoderConfig), (t = new Promise(function (h) { ((e.onModuleLoaded = function (u) { h({ draco: u }); }), DracoDecoderModule(e)); }))); break; case "decode": let { buffer: l, taskConfig: c } = a; t.then((h) => { let u = h.draco, d = new u.Decoder(); try { let f = n(u, d, new Int8Array(l), c), m = f.attributes.map((y) => y.array.buffer); if (f.index) m.push(f.index.array.buffer); self.postMessage({ type: "decode", id: a.id, geometry: f }, m); } catch (f) { (console.error(f), self.postMessage({ type: "error", id: a.id, error: f.message })); } finally { u.destroy(d); } }); break; } }; function n(o, a, l, c) { let { attributeIDs: h, attributeTypes: u } = c, d, f, m = a.GetEncodedGeometryType(l); if (m === o.TRIANGULAR_MESH) ((d = new o.Mesh()), (f = a.DecodeArrayToMesh(l, l.byteLength, d))); else if (m === o.POINT_CLOUD) ((d = new o.PointCloud()), (f = a.DecodeArrayToPointCloud(l, l.byteLength, d))); else throw Error("THREE.DRACOLoader: Unexpected geometry type."); if (!f.ok() || d.ptr === 0) throw Error("THREE.DRACOLoader: Decoding failed: " + f.error_msg()); let y = { index: null, attributes: [] }; for (let p in h) { let g = self[u[p]], _, x; if (c.useUniqueIDs) ((x = h[p]), (_ = a.GetAttributeByUniqueId(d, x))); else { if (((x = a.GetAttributeId(d, o[h[p]])), x === -1)) continue; _ = a.GetAttribute(d, x); } let w = s(o, a, d, p, g, _); if (p === "color") w.vertexColorSpace = c.vertexColorSpace; y.attributes.push(w); } if (m === o.TRIANGULAR_MESH) y.index = i(o, a, d); return (o.destroy(d), y); } function i(o, a, l) { let h = l.num_faces() * 3, u = h * 4, d = o._malloc(u); a.GetTrianglesUInt32Array(l, u, d); let f = new Uint32Array(o.HEAPF32.buffer, d, h).slice(); return (o._free(d), { array: f, itemSize: 1 }); } function s(o, a, l, c, h, u) { let d = u.num_components(), m = l.num_points() * d, y = m * h.BYTES_PER_ELEMENT, p = r(o, h), g = o._malloc(y); a.GetAttributeDataArrayForAllPoints(l, u, p, y, g); let _ = new h(o.HEAPF32.buffer, g, m).slice(); return (o._free(g), { name: c, array: _, itemSize: d }); } function r(o, a) { switch (a) { case Float32Array: return o.DT_FLOAT32; case Int8Array: return o.DT_INT8; case Int16Array: return o.DT_INT16; case Int32Array: return o.DT_INT32; case Uint8Array: return o.DT_UINT8; case Uint16Array: return o.DT_UINT16; case Uint32Array: return o.DT_UINT32; } } } /*! fflate - fast JavaScript compression/decompression Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE version 0.8.2 */ var En = Uint8Array, fr = Uint16Array, f_ = Int32Array, Vf = new En([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0]), Wf = new En([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0]), p_ = new En([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), Xf = function (e, t) { var n = new fr(31); for (var i = 0; i < 31; ++i) n[i] = t += 1 << e[i - 1]; var s = new f_(n[30]); for (var i = 1; i < 30; ++i) for (var r = n[i]; r < n[i + 1]; ++r) s[r] = ((r - n[i]) << 5) | i; return { b: n, r: s }; }, qf = Xf(Vf, 2), { b: Yf, r: m_ } = qf; ((Yf[28] = 258), (m_[258] = 28)); var jf = Xf(Wf, 0), { b: g_, r: kM } = jf, Kc = new fr(32768); for (Qe = 0; Qe < 32768; ++Qe) ((ii = ((Qe & 43690) >> 1) | ((Qe & 21845) << 1)), (ii = ((ii & 52428) >> 2) | ((ii & 13107) << 2)), (ii = ((ii & 61680) >> 4) | ((ii & 3855) << 4)), (Kc[Qe] = (((ii & 65280) >> 8) | ((ii & 255) << 8)) >> 1)); var ii, Qe, $r = function (e, t, n) { var i = e.length, s = 0, r = new fr(t); for (; s < i; ++s) if (e[s]) ++r[e[s] - 1]; var o = new fr(t); for (s = 1; s < t; ++s) o[s] = (o[s - 1] + r[s - 1]) << 1; var a; if (n) { a = new fr(1 << t); var l = 15 - t; for (s = 0; s < i; ++s) if (e[s]) { var c = (s << 4) | e[s], h = t - e[s], u = o[e[s] - 1]++ << h; for (var d = u | ((1 << h) - 1); u <= d; ++u) a[Kc[u] >> l] = c; } } else { a = new fr(i); for (s = 0; s < i; ++s) if (e[s]) a[s] = Kc[o[e[s] - 1]++] >> (15 - e[s]); } return a; }, Jr = new En(288); for (Qe = 0; Qe < 144; ++Qe) Jr[Qe] = 8; var Qe; for (Qe = 144; Qe < 256; ++Qe) Jr[Qe] = 9; var Qe; for (Qe = 256; Qe < 280; ++Qe) Jr[Qe] = 7; var Qe; for (Qe = 280; Qe < 288; ++Qe) Jr[Qe] = 8; var Qe, Zf = new En(32); for (Qe = 0; Qe < 32; ++Qe) Zf[Qe] = 5; var Qe; var y_ = $r(Jr, 9, 1); var x_ = $r(Zf, 5, 1), jc = function (e) { var t = e[0]; for (var n = 1; n < e.length; ++n) if (e[n] > t) t = e[n]; return t; }, Hn = function (e, t, n) { var i = (t / 8) | 0; return ((e[i] | (e[i + 1] << 8)) >> (t & 7)) & n; }, Zc = function (e, t) { var n = (t / 8) | 0; return (e[n] | (e[n + 1] << 8) | (e[n + 2] << 16)) >> (t & 7); }, v_ = function (e) { return ((e + 7) / 8) | 0; }, __ = function (e, t, n) { if (t == null || t < 0) t = 0; if (n == null || n > e.length) n = e.length; return new En(e.subarray(t, n)); }; var S_ = [ "unexpected EOF", "invalid block type", "invalid length/literal", "invalid distance", "stream finished", "no stream handler", , "no callback", "invalid UTF-8 data", "extra field too long", "date not in range 1980-2099", "filename too long", "stream finishing", "invalid zip data", ], Bn = function (e, t, n) { var i = Error(t || S_[e]); if (((i.code = e), Error.captureStackTrace)) Error.captureStackTrace(i, Bn); if (!n) throw i; return i; }, b_ = function (e, t, n, i) { var s = e.length, r = i ? i.length : 0; if (!s || (t.f && !t.l)) return n || new En(0); var o = !n, a = o || t.i != 2, l = t.i; if (o) n = new En(s * 3); var c = function (vt) { var C = n.length; if (vt > C) { var ot = new En(Math.max(C * 2, vt)); (ot.set(n), (n = ot)); } }, h = t.f || 0, u = t.p || 0, d = t.b || 0, { l: f, d: m, m: y, n: p } = t, g = s * 8; do { if (!f) { h = Hn(e, u, 1); var _ = Hn(e, u + 1, 3); if (((u += 3), !_)) { var x = v_(u) + 4, w = e[x - 4] | (e[x - 3] << 8), L = x + w; if (L > s) { if (l) Bn(0); break; } if (a) c(d + w); (n.set(e.subarray(x, L), d), (t.b = d += w), (t.p = u = L * 8), (t.f = h)); continue; } else if (_ == 1) ((f = y_), (m = x_), (y = 9), (p = 5)); else if (_ == 2) { var b = Hn(e, u, 31) + 257, R = Hn(e, u + 10, 15) + 4, F = b + Hn(e, u + 5, 31) + 1; u += 14; var M = new En(F), T = new En(19); for (var I = 0; I < R; ++I) T[p_[I]] = Hn(e, u + I * 3, 7); u += R * 3; var G = jc(T), q = (1 << G) - 1, B = $r(T, G, 1); for (var I = 0; I < F;) { var Z = B[Hn(e, u, q)]; u += Z & 15; var x = Z >> 4; if (x < 16) M[I++] = x; else { var W = 0, K = 0; if (x == 16) ((K = 3 + Hn(e, u, 3)), (u += 2), (W = M[I - 1])); else if (x == 17) ((K = 3 + Hn(e, u, 7)), (u += 3)); else if (x == 18) ((K = 11 + Hn(e, u, 127)), (u += 7)); while (K--) M[I++] = W; } } var V = M.subarray(0, b), se = M.subarray(b); ((y = jc(V)), (p = jc(se)), (f = $r(V, y, 1)), (m = $r(se, p, 1))); } else Bn(1); if (u > g) { if (l) Bn(0); break; } } if (a) c(d + 131072); var ce = (1 << y) - 1, Pe = (1 << p) - 1, We = u; for (; ; We = u) { var W = f[Zc(e, u) & ce], rt = W >> 4; if (((u += W & 15), u > g)) { if (l) Bn(0); break; } if (!W) Bn(2); if (rt < 256) n[d++] = rt; else if (rt == 256) { ((We = u), (f = null)); break; } else { var Ke = rt - 254; if (rt > 264) { var I = rt - 257, k = Vf[I]; ((Ke = Hn(e, u, (1 << k) - 1) + Yf[I]), (u += k)); } var J = m[Zc(e, u) & Pe], ee = J >> 4; if (!J) Bn(3); u += J & 15; var se = g_[ee]; if (ee > 3) { var k = Wf[ee]; ((se += Zc(e, u) & ((1 << k) - 1)), (u += k)); } if (u > g) { if (l) Bn(0); break; } if (a) c(d + 131072); var ae = d + Ke; if (d < se) { var ge = r - se, Ee = Math.min(se, ae); if (ge + d < 0) Bn(3); for (; d < Ee; ++d) n[d] = i[ge + d]; } for (; d < ae; ++d) n[d] = n[d - se]; } } if (((t.l = f), (t.p = We), (t.b = d), (t.f = h), f)) ((h = 1), (t.m = y), (t.d = m), (t.n = p)); } while (!h); return d != n.length && o ? __(n, 0, d) : n.subarray(0, d); }; var M_ = new En(0); var w_ = function (e, t) { if ((e[0] & 15) != 8 || e[0] >> 4 > 7 || ((e[0] << 8) | e[1]) % 31) Bn(6, "invalid zlib data"); if (((e[1] >> 5) & 1) == +!t) Bn(6, "invalid zlib data: " + (e[1] & 32 ? "need" : "unexpected") + " dictionary"); return ((e[1] >> 3) & 4) + 2; }; function Kf(e, t) { return b_(e.subarray(w_(e, t && t.dictionary), -4), { i: 2 }, t && t.out, t && t.dictionary); } var T_ = typeof TextDecoder < "u" && new TextDecoder(), E_ = 0; try { (T_.decode(M_, { stream: !0 }), (E_ = 1)); } catch (e) {} function $f(e, t, n) { let i = n.length - e - 1; if (t >= n[i]) return i - 1; if (t <= n[e]) return e; let s = e, r = i, o = Math.floor((s + r) / 2); while (t < n[o] || t >= n[o + 1]) { if (t < n[o]) r = o; else s = o; o = Math.floor((s + r) / 2); } return o; } function R_(e, t, n, i) { let s = [], r = [], o = []; s[0] = 1; for (let a = 1; a <= n; ++a) { ((r[a] = t - i[e + 1 - a]), (o[a] = i[e + a] - t)); let l = 0; for (let c = 0; c < a; ++c) { let h = o[c + 1], u = r[a - c], d = s[c] / (h + u); ((s[c] = l + h * d), (l = u * d)); } s[a] = l; } return s; } function Jf(e, t, n, i) { let s = $f(e, i, t), r = R_(s, i, e, t), o = new Ye(0, 0, 0, 0); for (let a = 0; a <= e; ++a) { let l = n[s - e + a], c = r[a], h = l.w * c; ((o.x += l.x * h), (o.y += l.y * h), (o.z += l.z * h), (o.w += l.w * c)); } return o; } function L_(e, t, n, i, s) { let r = []; for (let u = 0; u <= n; ++u) r[u] = 0; let o = []; for (let u = 0; u <= i; ++u) o[u] = r.slice(0); let a = []; for (let u = 0; u <= n; ++u) a[u] = r.slice(0); a[0][0] = 1; let l = r.slice(0), c = r.slice(0); for (let u = 1; u <= n; ++u) { ((l[u] = t - s[e + 1 - u]), (c[u] = s[e + u] - t)); let d = 0; for (let f = 0; f < u; ++f) { let m = c[f + 1], y = l[u - f]; a[u][f] = m + y; let p = a[f][u - 1] / a[u][f]; ((a[f][u] = d + m * p), (d = y * p)); } a[u][u] = d; } for (let u = 0; u <= n; ++u) o[0][u] = a[u][n]; for (let u = 0; u <= n; ++u) { let d = 0, f = 1, m = []; for (let y = 0; y <= n; ++y) m[y] = r.slice(0); m[0][0] = 1; for (let y = 1; y <= i; ++y) { let p = 0, g = u - y, _ = n - y; if (u >= y) ((m[f][0] = m[d][0] / a[_ + 1][g]), (p = m[f][0] * a[g][_])); let x = g >= -1 ? 1 : -g, w = u - 1 <= _ ? y - 1 : n - u; for (let b = x; b <= w; ++b) ((m[f][b] = (m[d][b] - m[d][b - 1]) / a[_ + 1][g + b]), (p += m[f][b] * a[g + b][_])); if (u <= _) ((m[f][y] = -m[d][y - 1] / a[_ + 1][u]), (p += m[f][y] * a[u][_])); o[y][u] = p; let L = d; ((d = f), (f = L)); } } let h = n; for (let u = 1; u <= i; ++u) { for (let d = 0; d <= n; ++d) o[u][d] *= h; h *= n - u; } return o; } function C_(e, t, n, i, s) { let r = s < e ? s : e, o = [], a = $f(e, i, t), l = L_(a, i, e, r, t), c = []; for (let h = 0; h < n.length; ++h) { let u = n[h].clone(), d = u.w; ((u.x *= d), (u.y *= d), (u.z *= d), (c[h] = u)); } for (let h = 0; h <= r; ++h) { let u = c[a - e].clone().multiplyScalar(l[h][0]); for (let d = 1; d <= e; ++d) u.add(c[a - e + d].clone().multiplyScalar(l[h][d])); o[h] = u; } for (let h = r + 1; h <= s + 1; ++h) o[h] = new Ye(0, 0, 0); return o; } function I_(e, t) { let n = 1; for (let s = 2; s <= e; ++s) n *= s; let i = 1; for (let s = 2; s <= t; ++s) i *= s; for (let s = 2; s <= e - t; ++s) i *= s; return n / i; } function P_(e) { let t = e.length, n = [], i = []; for (let r = 0; r < t; ++r) { let o = e[r]; ((n[r] = new E(o.x, o.y, o.z)), (i[r] = o.w)); } let s = []; for (let r = 0; r < t; ++r) { let o = n[r].clone(); for (let a = 1; a <= r; ++a) o.sub(s[r - a].clone().multiplyScalar(I_(r, a) * i[a])); s[r] = o.divideScalar(i[0]); } return s; } function Qf(e, t, n, i, s) { let r = C_(e, t, n, i, s); return P_(r); } class $c extends la { constructor(e, t, n, i, s) { super(); let r = t ? t.length - 1 : 0, o = n ? n.length : 0; ((this.degree = e), (this.knots = t), (this.controlPoints = []), (this.startKnot = i || 0), (this.endKnot = s || r)); for (let a = 0; a < o; ++a) { let l = n[a]; this.controlPoints[a] = new Ye(l.x, l.y, l.z, l.w); } } getPoint(e, t = new E()) { let n = t, i = this.knots[this.startKnot] + e * (this.knots[this.endKnot] - this.knots[this.startKnot]), s = Jf(this.degree, this.knots, this.controlPoints, i); if (s.w !== 1) s.divideScalar(s.w); return n.set(s.x, s.y, s.z); } getTangent(e, t = new E()) { let n = t, i = this.knots[0] + e * (this.knots[this.knots.length - 1] - this.knots[0]), s = Qf(this.degree, this.knots, this.controlPoints, i, 1); return (n.copy(s[1]).normalize(), n); } toJSON() { let e = super.toJSON(); return ( (e.degree = this.degree), (e.knots = [...this.knots]), (e.controlPoints = this.controlPoints.map((t) => t.toArray())), (e.startKnot = this.startKnot), (e.endKnot = this.endKnot), e ); } fromJSON(e) { return ( super.fromJSON(e), (this.degree = e.degree), (this.knots = [...e.knots]), (this.controlPoints = e.controlPoints.map((t) => new Ye(t[0], t[1], t[2], t[3]))), (this.startKnot = e.startKnot), (this.endKnot = e.endKnot), this ); } } var Ze, Pt, sn; class ba extends nn { constructor(e) { super(e); } load(e, t, n, i) { let s = this, r = s.path === "" ? ei.extractUrlBase(e) : s.path, o = new $n(this.manager); (o.setPath(s.path), o.setResponseType("arraybuffer"), o.setRequestHeader(s.requestHeader), o.setWithCredentials(s.withCredentials), o.load( e, function (a) { try { t(s.parse(a, r)); } catch (l) { if (i) i(l); else console.error(l); s.manager.itemError(e); } }, n, i, )); } parse(e, t) { if (U_(e)) Ze = new rp().parse(e); else { let i = ap(e); if (!N_(i)) throw Error("THREE.FBXLoader: Unknown format."); if (ep(i) < 7000) throw Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + ep(i)); Ze = new sp().parse(i); } let n = new Jn(this.manager).setPath(this.resourcePath || t).setCrossOrigin(this.crossOrigin); return new tp(n, this.manager).parse(Ze); } } class tp { constructor(e, t) { ((this.textureLoader = e), (this.manager = t)); } parse() { Pt = this.parseConnections(); let e = this.parseImages(), t = this.parseTextures(e), n = this.parseMaterials(t), i = this.parseDeformers(), s = new np().parse(i); return (this.parseScene(i, s, n), sn); } parseConnections() { let e = new Map(); if ("Connections" in Ze) Ze.Connections.connections.forEach(function (n) { let i = n[0], s = n[1], r = n[2]; if (!e.has(i)) e.set(i, { parents: [], children: [] }); let o = { ID: s, relationship: r }; if ((e.get(i).parents.push(o), !e.has(s))) e.set(s, { parents: [], children: [] }); let a = { ID: i, relationship: r }; e.get(s).children.push(a); }); return e; } parseImages() { let e = {}, t = {}; if ("Video" in Ze.Objects) { let n = Ze.Objects.Video; for (let i in n) { let s = n[i], r = parseInt(i); if (((e[r] = s.RelativeFilename || s.Filename), "Content" in s)) { let o = s.Content instanceof ArrayBuffer && s.Content.byteLength > 0, a = typeof s.Content === "string" && s.Content !== ""; if (o || a) { let l = this.parseImage(n[i]); t[s.RelativeFilename || s.Filename] = l; } } } } for (let n in e) { let i = e[n]; if (t[i] !== void 0) e[n] = t[i]; else e[n] = e[n].split("\\").pop(); } return e; } parseImage(e) { let t = e.Content, n = e.RelativeFilename || e.Filename, i = n.slice(n.lastIndexOf(".") + 1).toLowerCase(), s; switch (i) { case "bmp": s = "image/bmp"; break; case "jpg": case "jpeg": s = "image/jpeg"; break; case "png": s = "image/png"; break; case "tif": s = "image/tiff"; break; case "tga": if (this.manager.getHandler(".tga") === null) console.warn("FBXLoader: TGA loader not found, skipping ", n); s = "image/tga"; break; case "webp": s = "image/webp"; break; default: console.warn('FBXLoader: Image type "' + i + '" is not supported.'); return; } if (typeof t === "string") return "data:" + s + ";base64," + t; else { let r = new Uint8Array(t); return window.URL.createObjectURL(new Blob([r], { type: s })); } } parseTextures(e) { let t = new Map(); if ("Texture" in Ze.Objects) { let n = Ze.Objects.Texture; for (let i in n) { let s = this.parseTexture(n[i], e); t.set(parseInt(i), s); } } return t; } parseTexture(e, t) { let n = this.loadTexture(e, t); ((n.ID = e.id), (n.name = e.attrName)); let { WrapModeU: i, WrapModeV: s } = e, r = i !== void 0 ? i.value : 0, o = s !== void 0 ? s.value : 0; if (((n.wrapS = r === 0 ? On : ds), (n.wrapT = o === 0 ? On : ds), "Scaling" in e)) { let a = e.Scaling.value; ((n.repeat.x = a[0]), (n.repeat.y = a[1])); } if ("Translation" in e) { let a = e.Translation.value; ((n.offset.x = a[0]), (n.offset.y = a[1])); } return n; } loadTexture(e, t) { let n = e.FileName.split(".").pop().toLowerCase(), i = this.manager.getHandler(`.${n}`); if (i === null) i = this.textureLoader; let s = i.path; if (!s) i.setPath(this.textureLoader.path); let r = Pt.get(e.id).children, o; if (r !== void 0 && r.length > 0 && t[r[0].ID] !== void 0) { if (((o = t[r[0].ID]), o.indexOf("blob:") === 0 || o.indexOf("data:") === 0)) i.setPath(void 0); } if (o === void 0) return (console.warn("FBXLoader: Undefined filename, creating placeholder texture."), new Rt()); let a = i.load(o); return (i.setPath(s), a); } parseMaterials(e) { let t = new Map(); if ("Material" in Ze.Objects) { let n = Ze.Objects.Material; for (let i in n) { let s = this.parseMaterial(n[i], e); if (s !== null) t.set(parseInt(i), s); } } return t; } parseMaterial(e, t) { let { id: n, attrName: i, ShadingModel: s } = e; if (typeof s === "object") s = s.value; if (!Pt.has(n)) return null; let r = this.parseParameters(e, t, n), o; switch (s.toLowerCase()) { case "phong": o = new ys(); break; case "lambert": o = new rr(); break; default: (console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.', s), (o = new ys())); break; } return (o.setValues(r), (o.name = i), o); } parseParameters(e, t, n) { let i = {}; if (e.BumpFactor) i.bumpScale = e.BumpFactor.value; if (e.Diffuse) i.color = ke.colorSpaceToWorking(new re().fromArray(e.Diffuse.value), lt); else if (e.DiffuseColor && (e.DiffuseColor.type === "Color" || e.DiffuseColor.type === "ColorRGB")) i.color = ke.colorSpaceToWorking(new re().fromArray(e.DiffuseColor.value), lt); if (e.DisplacementFactor) i.displacementScale = e.DisplacementFactor.value; if (e.Emissive) i.emissive = ke.colorSpaceToWorking(new re().fromArray(e.Emissive.value), lt); else if (e.EmissiveColor && (e.EmissiveColor.type === "Color" || e.EmissiveColor.type === "ColorRGB")) i.emissive = ke.colorSpaceToWorking(new re().fromArray(e.EmissiveColor.value), lt); if (e.EmissiveFactor) i.emissiveIntensity = parseFloat(e.EmissiveFactor.value); if ( ((i.opacity = 1 - (e.TransparencyFactor ? parseFloat(e.TransparencyFactor.value) : 0)), i.opacity === 1 || i.opacity === 0) ) { if (((i.opacity = e.Opacity ? parseFloat(e.Opacity.value) : null), i.opacity === null)) i.opacity = 1 - (e.TransparentColor ? parseFloat(e.TransparentColor.value[0]) : 0); } if (i.opacity < 1) i.transparent = !0; if (e.ReflectionFactor) i.reflectivity = e.ReflectionFactor.value; if (e.Shininess) i.shininess = e.Shininess.value; if (e.Specular) i.specular = ke.colorSpaceToWorking(new re().fromArray(e.Specular.value), lt); else if (e.SpecularColor && e.SpecularColor.type === "Color") i.specular = ke.colorSpaceToWorking(new re().fromArray(e.SpecularColor.value), lt); let s = this; return ( Pt.get(n).children.forEach(function (r) { let o = r.relationship; switch (o) { case "Bump": i.bumpMap = s.getTexture(t, r.ID); break; case "Maya|TEX_ao_map": i.aoMap = s.getTexture(t, r.ID); break; case "DiffuseColor": case "Maya|TEX_color_map": if (((i.map = s.getTexture(t, r.ID)), i.map !== void 0)) i.map.colorSpace = lt; break; case "DisplacementColor": i.displacementMap = s.getTexture(t, r.ID); break; case "EmissiveColor": if (((i.emissiveMap = s.getTexture(t, r.ID)), i.emissiveMap !== void 0)) i.emissiveMap.colorSpace = lt; break; case "NormalMap": case "Maya|TEX_normal_map": i.normalMap = s.getTexture(t, r.ID); break; case "ReflectionColor": if (((i.envMap = s.getTexture(t, r.ID)), i.envMap !== void 0)) ((i.envMap.mapping = Zs), (i.envMap.colorSpace = lt)); break; case "SpecularColor": if (((i.specularMap = s.getTexture(t, r.ID)), i.specularMap !== void 0)) i.specularMap.colorSpace = lt; break; case "TransparentColor": case "TransparencyFactor": ((i.alphaMap = s.getTexture(t, r.ID)), (i.transparent = !0)); break; case "AmbientColor": case "ShininessExponent": case "SpecularFactor": case "VectorDisplacementColor": default: console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.", o); break; } }), i ); } getTexture(e, t) { if ("LayeredTexture" in Ze.Objects && t in Ze.Objects.LayeredTexture) (console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."), (t = Pt.get(t).children[0].ID)); return e.get(t); } parseDeformers() { let e = {}, t = {}; if ("Deformer" in Ze.Objects) { let n = Ze.Objects.Deformer; for (let i in n) { let s = n[i], r = Pt.get(parseInt(i)); if (s.attrType === "Skin") { let o = this.parseSkeleton(r, n); if (((o.ID = i), r.parents.length > 1)) console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."); ((o.geometryID = r.parents[0].ID), (e[i] = o)); } else if (s.attrType === "BlendShape") { let o = { id: i }; if (((o.rawTargets = this.parseMorphTargets(r, n)), (o.id = i), r.parents.length > 1)) console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."); t[i] = o; } } } return { skeletons: e, morphTargets: t }; } parseSkeleton(e, t) { let n = []; return ( e.children.forEach(function (i) { let s = t[i.ID]; if (s.attrType !== "Cluster") return; let r = { ID: i.ID, indices: [], weights: [], transformLink: new ue().fromArray(s.TransformLink.a) }; if ("Indexes" in s) ((r.indices = s.Indexes.a), (r.weights = s.Weights.a)); n.push(r); }), { rawBones: n, bones: [] } ); } parseMorphTargets(e, t) { let n = []; for (let i = 0; i < e.children.length; i++) { let s = e.children[i], r = t[s.ID], o = { name: r.attrName, initialWeight: r.DeformPercent, id: r.id, fullWeights: r.FullWeights.a }; if (r.attrType !== "BlendShapeChannel") return; ((o.geoID = Pt.get(parseInt(s.ID)).children.filter(function (a) { return a.relationship === void 0; })[0].ID), n.push(o)); } return n; } parseScene(e, t, n) { sn = new gn(); let i = this.parseModels(e.skeletons, t, n), s = Ze.Objects.Model, r = this; (i.forEach(function (a) { let l = s[a.ID]; if ( (r.setLookAtProperties(a, l), Pt.get(a.ID).parents.forEach(function (h) { let u = i.get(h.ID); if (u !== void 0) u.add(a); }), a.parent === null) ) sn.add(a); }), this.bindSkeleton(e.skeletons, t, i), this.addGlobalSceneSettings(), sn.traverse(function (a) { if (a.userData.transformData) { if (a.parent) ((a.userData.transformData.parentMatrix = a.parent.matrix), (a.userData.transformData.parentMatrixWorld = a.parent.matrixWorld)); let l = op(a.userData.transformData); (a.applyMatrix4(l), a.updateWorldMatrix()); } })); let o = new ip().parse(); if (sn.children.length === 1 && sn.children[0].isGroup) ((sn.children[0].animations = o), (sn = sn.children[0])); sn.animations = o; } parseModels(e, t, n) { let i = new Map(), s = Ze.Objects.Model; for (let r in s) { let o = parseInt(r), a = s[r], l = Pt.get(o), c = this.buildSkeleton(l, e, o, a.attrName); if (!c) { switch (a.attrType) { case "Camera": c = this.createCamera(l); break; case "Light": c = this.createLight(l); break; case "Mesh": c = this.createMesh(l, t, n); break; case "NurbsCurve": c = this.createCurve(l, t); break; case "LimbNode": case "Root": c = new Kn(); break; case "Null": default: c = new gn(); break; } ((c.name = a.attrName ? $e.sanitizeNodeName(a.attrName) : ""), (c.userData.originalName = a.attrName), (c.ID = o)); } (this.getTransformData(c, a), i.set(o, c)); } return i; } buildSkeleton(e, t, n, i) { let s = null; return ( e.parents.forEach(function (r) { for (let o in t) { let a = t[o]; a.rawBones.forEach(function (l, c) { if (l.ID === r.ID) { let h = s; if ( ((s = new Kn()), s.matrixWorld.copy(l.transformLink), (s.name = i ? $e.sanitizeNodeName(i) : ""), (s.userData.originalName = i), (s.ID = n), (a.bones[c] = s), h !== null) ) s.add(h); } }); } }), s ); } createCamera(e) { let t, n; if ( (e.children.forEach(function (i) { let s = Ze.Objects.NodeAttribute[i.ID]; if (s !== void 0) n = s; }), n === void 0) ) t = new it(); else { let i = 0; if (n.CameraProjectionType !== void 0 && n.CameraProjectionType.value === 1) i = 1; let s = 1; if (n.NearPlane !== void 0) s = n.NearPlane.value / 1000; let r = 1000; if (n.FarPlane !== void 0) r = n.FarPlane.value / 1000; let { innerWidth: o, innerHeight: a } = window; if (n.AspectWidth !== void 0 && n.AspectHeight !== void 0) ((o = n.AspectWidth.value), (a = n.AspectHeight.value)); let l = o / a, c = 45; if (n.FieldOfView !== void 0) c = n.FieldOfView.value; let h = n.FocalLength ? n.FocalLength.value : null; switch (i) { case 0: if (((t = new It(c, l, s, r)), h !== null)) t.setFocalLength(h); break; case 1: (console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."), (t = new it())); break; default: (console.warn("THREE.FBXLoader: Unknown camera type " + i + "."), (t = new it())); break; } } return t; } createLight(e) { let t, n; if ( (e.children.forEach(function (i) { let s = Ze.Objects.NodeAttribute[i.ID]; if (s !== void 0) n = s; }), n === void 0) ) t = new it(); else { let i; if (n.LightType === void 0) i = 0; else i = n.LightType.value; let s = 16777215; if (n.Color !== void 0) s = ke.colorSpaceToWorking(new re().fromArray(n.Color.value), lt); let r = n.Intensity === void 0 ? 1 : n.Intensity.value / 100; if (n.CastLightOnObject !== void 0 && n.CastLightOnObject.value === 0) r = 0; let o = 0; if (n.FarAttenuationEnd !== void 0) if (n.EnableFarAttenuation !== void 0 && n.EnableFarAttenuation.value === 0) o = 0; else o = n.FarAttenuationEnd.value; let a = 1; switch (i) { case 0: t = new wi(s, r, o, a); break; case 1: t = new Qn(s, r); break; case 2: let l = Math.PI / 3; if (n.InnerAngle !== void 0) l = bt.degToRad(n.InnerAngle.value); let c = 0; if (n.OuterAngle !== void 0) ((c = bt.degToRad(n.OuterAngle.value)), (c = Math.max(c, 1))); t = new Yi(s, r, o, l, c, a); break; default: (console.warn("THREE.FBXLoader: Unknown light type " + n.LightType.value + ", defaulting to a PointLight."), (t = new wi(s, r))); break; } if (n.CastShadows !== void 0 && n.CastShadows.value === 1) t.castShadow = !0; } return t; } createMesh(e, t, n) { let i, s = null, r = null, o = []; if ( (e.children.forEach(function (a) { if (t.has(a.ID)) s = t.get(a.ID); if (n.has(a.ID)) o.push(n.get(a.ID)); }), o.length > 1) ) r = o; else if (o.length > 0) r = o[0]; else ((r = new ys({ name: nn.DEFAULT_MATERIAL_NAME, color: 13421772 })), o.push(r)); if ("color" in s.attributes) o.forEach(function (a) { a.vertexColors = !0; }); if (s.groups.length > 0) { let a = !1; for (let l = 0, c = s.groups.length; l < c; l++) { let h = s.groups[l]; if (h.materialIndex < 0 || h.materialIndex >= o.length) ((h.materialIndex = o.length), (a = !0)); } if (a) { let l = new ys(); o.push(l); } } if (s.FBX_Deformer) ((i = new Bi(s, r)), i.normalizeSkinWeights()); else i = new st(s, r); return i; } createCurve(e, t) { let n = e.children.reduce(function (s, r) { if (t.has(r.ID)) s = t.get(r.ID); return s; }, null), i = new bi({ name: nn.DEFAULT_MATERIAL_NAME, color: 3342591, linewidth: 1 }); return new Gi(n, i); } getTransformData(e, t) { let n = {}; if ("InheritType" in t) n.inheritType = parseInt(t.InheritType.value); if ("RotationOrder" in t) n.eulerOrder = Qr(t.RotationOrder.value); else n.eulerOrder = Qr(0); if ("Lcl_Translation" in t) n.translation = t.Lcl_Translation.value; if ("PreRotation" in t) n.preRotation = t.PreRotation.value; if ("Lcl_Rotation" in t) n.rotation = t.Lcl_Rotation.value; if ("PostRotation" in t) n.postRotation = t.PostRotation.value; if ("Lcl_Scaling" in t) n.scale = t.Lcl_Scaling.value; if ("ScalingOffset" in t) n.scalingOffset = t.ScalingOffset.value; if ("ScalingPivot" in t) n.scalingPivot = t.ScalingPivot.value; if ("RotationOffset" in t) n.rotationOffset = t.RotationOffset.value; if ("RotationPivot" in t) n.rotationPivot = t.RotationPivot.value; e.userData.transformData = n; } setLookAtProperties(e, t) { if ("LookAtProperty" in t) Pt.get(e.ID).children.forEach(function (i) { if (i.relationship === "LookAtProperty") { let s = Ze.Objects.Model[i.ID]; if ("Lcl_Translation" in s) { let r = s.Lcl_Translation.value; if (e.target !== void 0) (e.target.position.fromArray(r), sn.add(e.target)); else e.lookAt(new E().fromArray(r)); } } }); } bindSkeleton(e, t, n) { let i = this.parsePoseNodes(); for (let s in e) { let r = e[s]; Pt.get(parseInt(r.ID)).parents.forEach(function (a) { if (t.has(a.ID)) { let l = a.ID; Pt.get(l).parents.forEach(function (h) { if (n.has(h.ID)) n.get(h.ID).bind(new Si(r.bones), i[h.ID]); }); } }); } } parsePoseNodes() { let e = {}; if ("Pose" in Ze.Objects) { let t = Ze.Objects.Pose; for (let n in t) if (t[n].attrType === "BindPose" && t[n].NbPoseNodes > 0) { let i = t[n].PoseNode; if (Array.isArray(i)) i.forEach(function (s) { e[s.Node] = new ue().fromArray(s.Matrix.a); }); else e[i.Node] = new ue().fromArray(i.Matrix.a); } } return e; } addGlobalSceneSettings() { if ("GlobalSettings" in Ze) { if ("AmbientColor" in Ze.GlobalSettings) { let e = Ze.GlobalSettings.AmbientColor.value, t = e[0], n = e[1], i = e[2]; if (t !== 0 || n !== 0 || i !== 0) { let s = new re().setRGB(t, n, i, lt); sn.add(new lr(s, 1)); } } if ("UnitScaleFactor" in Ze.GlobalSettings) sn.userData.unitScaleFactor = Ze.GlobalSettings.UnitScaleFactor.value; } } } class np { constructor() { this.negativeMaterialIndices = !1; } parse(e) { let t = new Map(); if ("Geometry" in Ze.Objects) { let n = Ze.Objects.Geometry; for (let i in n) { let s = Pt.get(parseInt(i)), r = this.parseGeometry(s, n[i], e); t.set(parseInt(i), r); } } if (this.negativeMaterialIndices === !0) console.warn( "THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected.", ); return t; } parseGeometry(e, t, n) { switch (t.attrType) { case "Mesh": return this.parseMeshGeometry(e, t, n); case "NurbsCurve": return this.parseNurbsGeometry(t); } } parseMeshGeometry(e, t, n) { let i = n.skeletons, s = [], r = e.parents.map(function (h) { return Ze.Objects.Model[h.ID]; }); if (r.length === 0) return; let o = e.children.reduce(function (h, u) { if (i[u.ID] !== void 0) h = i[u.ID]; return h; }, null); e.children.forEach(function (h) { if (n.morphTargets[h.ID] !== void 0) s.push(n.morphTargets[h.ID]); }); let a = r[0], l = {}; if ("RotationOrder" in a) l.eulerOrder = Qr(a.RotationOrder.value); if ("InheritType" in a) l.inheritType = parseInt(a.InheritType.value); if ("GeometricTranslation" in a) l.translation = a.GeometricTranslation.value; if ("GeometricRotation" in a) l.rotation = a.GeometricRotation.value; if ("GeometricScaling" in a) l.scale = a.GeometricScaling.value; let c = op(l); return this.genGeometry(t, o, s, c); } genGeometry(e, t, n, i) { let s = new Et(); if (e.attrName) s.name = e.attrName; let r = this.parseGeoNode(e, t), o = this.genBuffers(r), a = new at(o.vertex, 3); if ((a.applyMatrix4(i), s.setAttribute("position", a), o.colors.length > 0)) s.setAttribute("color", new at(o.colors, 3)); if (t) (s.setAttribute("skinIndex", new er(o.weightsIndices, 4)), s.setAttribute("skinWeight", new at(o.vertexWeights, 4)), (s.FBX_Deformer = t)); if (o.normal.length > 0) { let l = new Be().getNormalMatrix(i), c = new at(o.normal, 3); (c.applyNormalMatrix(l), s.setAttribute("normal", c)); } if ( (o.uvs.forEach(function (l, c) { let h = c === 0 ? "uv" : `uv${c}`; s.setAttribute(h, new at(o.uvs[c], 2)); }), r.material && r.material.mappingType !== "AllSame") ) { let l = o.materialIndex[0], c = 0; if ( (o.materialIndex.forEach(function (h, u) { if (h !== l) (s.addGroup(c, u - c, l), (l = h), (c = u)); }), s.groups.length > 0) ) { let h = s.groups[s.groups.length - 1], u = h.start + h.count; if (u !== o.materialIndex.length) s.addGroup(u, o.materialIndex.length - u, l); } if (s.groups.length === 0) s.addGroup(0, o.materialIndex.length, o.materialIndex[0]); } return (this.addMorphTargets(s, e, n, i), s); } parseGeoNode(e, t) { let n = {}; if ( ((n.vertexPositions = e.Vertices !== void 0 ? e.Vertices.a : []), (n.vertexIndices = e.PolygonVertexIndex !== void 0 ? e.PolygonVertexIndex.a : []), e.LayerElementColor && e.LayerElementColor[0].Colors) ) n.color = this.parseVertexColors(e.LayerElementColor[0]); if (e.LayerElementMaterial) n.material = this.parseMaterialIndices(e.LayerElementMaterial[0]); if (e.LayerElementNormal) n.normal = this.parseNormals(e.LayerElementNormal[0]); if (e.LayerElementUV) { n.uv = []; let i = 0; while (e.LayerElementUV[i]) { if (e.LayerElementUV[i].UV) n.uv.push(this.parseUVs(e.LayerElementUV[i])); i++; } } if (((n.weightTable = {}), t !== null)) ((n.skeleton = t), t.rawBones.forEach(function (i, s) { i.indices.forEach(function (r, o) { if (n.weightTable[r] === void 0) n.weightTable[r] = []; n.weightTable[r].push({ id: s, weight: i.weights[o] }); }); })); return n; } genBuffers(e) { let t = { vertex: [], normal: [], colors: [], uvs: [], materialIndex: [], vertexWeights: [], weightsIndices: [] }, n = 0, i = 0, s = !1, r = [], o = [], a = [], l = [], c = [], h = [], u = this; return ( e.vertexIndices.forEach(function (d, f) { let m, y = !1; if (d < 0) ((d = d ^ -1), (y = !0)); let p = [], g = []; if ((r.push(d * 3, d * 3 + 1, d * 3 + 2), e.color)) { let _ = Sa(f, n, d, e.color); a.push(_[0], _[1], _[2]); } if (e.skeleton) { if (e.weightTable[d] !== void 0) e.weightTable[d].forEach(function (_) { (g.push(_.weight), p.push(_.id)); }); if (g.length > 4) { if (!s) (console.warn( "THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights.", ), (s = !0)); let _ = [0, 0, 0, 0], x = [0, 0, 0, 0]; (g.forEach(function (w, L) { let b = w, R = p[L]; x.forEach(function (F, M, T) { if (b > F) { ((T[M] = b), (b = F)); let I = _[M]; ((_[M] = R), (R = I)); } }); }), (p = _), (g = x)); } while (g.length < 4) (g.push(0), p.push(0)); for (let _ = 0; _ < 4; ++_) (c.push(g[_]), h.push(p[_])); } if (e.normal) { let _ = Sa(f, n, d, e.normal); o.push(_[0], _[1], _[2]); } if (e.material && e.material.mappingType !== "AllSame") { if (((m = Sa(f, n, d, e.material)[0]), m < 0)) ((u.negativeMaterialIndices = !0), (m = 0)); } if (e.uv) e.uv.forEach(function (_, x) { let w = Sa(f, n, d, _); if (l[x] === void 0) l[x] = []; (l[x].push(w[0]), l[x].push(w[1])); }); if ((i++, y)) (u.genFace(t, e, r, m, o, a, l, c, h, i), n++, (i = 0), (r = []), (o = []), (a = []), (l = []), (c = []), (h = [])); }), t ); } getNormalNewell(e) { let t = new E(0, 0, 0); for (let n = 0; n < e.length; n++) { let i = e[n], s = e[(n + 1) % e.length]; ((t.x += (i.y - s.y) * (i.z + s.z)), (t.y += (i.z - s.z) * (i.x + s.x)), (t.z += (i.x - s.x) * (i.y + s.y))); } return (t.normalize(), t); } getNormalTangentAndBitangent(e) { let t = this.getNormalNewell(e), i = (Math.abs(t.z) > 0.5 ? new E(0, 1, 0) : new E(0, 0, 1)).cross(t).normalize(), s = t.clone().cross(i).normalize(); return { normal: t, tangent: i, bitangent: s }; } flattenVertex(e, t, n) { return new ve(e.dot(t), e.dot(n)); } genFace(e, t, n, i, s, r, o, a, l, c) { let h; if (c > 3) { let u = [], d = t.baseVertexPositions || t.vertexPositions; for (let p = 0; p < n.length; p += 3) u.push(new E(d[n[p]], d[n[p + 1]], d[n[p + 2]])); let { tangent: f, bitangent: m } = this.getNormalTangentAndBitangent(u), y = []; for (let p of u) y.push(this.flattenVertex(p, f, m)); h = Yr.triangulateShape(y, []); } else h = [[0, 1, 2]]; for (let [u, d, f] of h) { if ( (e.vertex.push(t.vertexPositions[n[u * 3]]), e.vertex.push(t.vertexPositions[n[u * 3 + 1]]), e.vertex.push(t.vertexPositions[n[u * 3 + 2]]), e.vertex.push(t.vertexPositions[n[d * 3]]), e.vertex.push(t.vertexPositions[n[d * 3 + 1]]), e.vertex.push(t.vertexPositions[n[d * 3 + 2]]), e.vertex.push(t.vertexPositions[n[f * 3]]), e.vertex.push(t.vertexPositions[n[f * 3 + 1]]), e.vertex.push(t.vertexPositions[n[f * 3 + 2]]), t.skeleton) ) (e.vertexWeights.push(a[u * 4]), e.vertexWeights.push(a[u * 4 + 1]), e.vertexWeights.push(a[u * 4 + 2]), e.vertexWeights.push(a[u * 4 + 3]), e.vertexWeights.push(a[d * 4]), e.vertexWeights.push(a[d * 4 + 1]), e.vertexWeights.push(a[d * 4 + 2]), e.vertexWeights.push(a[d * 4 + 3]), e.vertexWeights.push(a[f * 4]), e.vertexWeights.push(a[f * 4 + 1]), e.vertexWeights.push(a[f * 4 + 2]), e.vertexWeights.push(a[f * 4 + 3]), e.weightsIndices.push(l[u * 4]), e.weightsIndices.push(l[u * 4 + 1]), e.weightsIndices.push(l[u * 4 + 2]), e.weightsIndices.push(l[u * 4 + 3]), e.weightsIndices.push(l[d * 4]), e.weightsIndices.push(l[d * 4 + 1]), e.weightsIndices.push(l[d * 4 + 2]), e.weightsIndices.push(l[d * 4 + 3]), e.weightsIndices.push(l[f * 4]), e.weightsIndices.push(l[f * 4 + 1]), e.weightsIndices.push(l[f * 4 + 2]), e.weightsIndices.push(l[f * 4 + 3])); if (t.color) (e.colors.push(r[u * 3]), e.colors.push(r[u * 3 + 1]), e.colors.push(r[u * 3 + 2]), e.colors.push(r[d * 3]), e.colors.push(r[d * 3 + 1]), e.colors.push(r[d * 3 + 2]), e.colors.push(r[f * 3]), e.colors.push(r[f * 3 + 1]), e.colors.push(r[f * 3 + 2])); if (t.material && t.material.mappingType !== "AllSame") (e.materialIndex.push(i), e.materialIndex.push(i), e.materialIndex.push(i)); if (t.normal) (e.normal.push(s[u * 3]), e.normal.push(s[u * 3 + 1]), e.normal.push(s[u * 3 + 2]), e.normal.push(s[d * 3]), e.normal.push(s[d * 3 + 1]), e.normal.push(s[d * 3 + 2]), e.normal.push(s[f * 3]), e.normal.push(s[f * 3 + 1]), e.normal.push(s[f * 3 + 2])); if (t.uv) t.uv.forEach(function (m, y) { if (e.uvs[y] === void 0) e.uvs[y] = []; (e.uvs[y].push(o[y][u * 2]), e.uvs[y].push(o[y][u * 2 + 1]), e.uvs[y].push(o[y][d * 2]), e.uvs[y].push(o[y][d * 2 + 1]), e.uvs[y].push(o[y][f * 2]), e.uvs[y].push(o[y][f * 2 + 1])); }); } } addMorphTargets(e, t, n, i) { if (n.length === 0) return; ((e.morphTargetsRelative = !0), (e.morphAttributes.position = [])); let s = this; n.forEach(function (r) { r.rawTargets.forEach(function (o) { let a = Ze.Objects.Geometry[o.geoID]; if (a !== void 0) s.genMorphGeometry(e, t, a, i, o.name); }); }); } genMorphGeometry(e, t, n, i, s) { let r = t.Vertices !== void 0 ? t.Vertices.a : [], o = t.PolygonVertexIndex !== void 0 ? t.PolygonVertexIndex.a : [], a = n.Vertices !== void 0 ? n.Vertices.a : [], l = n.Indexes !== void 0 ? n.Indexes.a : [], c = e.attributes.position.count * 3, h = new Float32Array(c); for (let m = 0; m < l.length; m++) { let y = l[m] * 3; ((h[y] = a[m * 3]), (h[y + 1] = a[m * 3 + 1]), (h[y + 2] = a[m * 3 + 2])); } let u = { vertexIndices: o, vertexPositions: h, baseVertexPositions: r }, d = this.genBuffers(u), f = new at(d.vertex, 3); ((f.name = s || n.attrName), f.applyMatrix4(i), e.morphAttributes.position.push(f)); } parseNormals(e) { let { MappingInformationType: t, ReferenceInformationType: n } = e, i = e.Normals.a, s = []; if (n === "IndexToDirect") { if ("NormalIndex" in e) s = e.NormalIndex.a; else if ("NormalsIndex" in e) s = e.NormalsIndex.a; } return { dataSize: 3, buffer: i, indices: s, mappingType: t, referenceType: n }; } parseUVs(e) { let { MappingInformationType: t, ReferenceInformationType: n } = e, i = e.UV.a, s = []; if (n === "IndexToDirect") s = e.UVIndex.a; return { dataSize: 2, buffer: i, indices: s, mappingType: t, referenceType: n }; } parseVertexColors(e) { let { MappingInformationType: t, ReferenceInformationType: n } = e, i = e.Colors.a, s = []; if (n === "IndexToDirect") s = e.ColorIndex.a; for (let r = 0, o = new re(); r < i.length; r += 4) (o.fromArray(i, r), ke.colorSpaceToWorking(o, lt), o.toArray(i, r)); return { dataSize: 4, buffer: i, indices: s, mappingType: t, referenceType: n }; } parseMaterialIndices(e) { let { MappingInformationType: t, ReferenceInformationType: n } = e; if (t === "NoMappingInformation") return { dataSize: 1, buffer: [0], indices: [0], mappingType: "AllSame", referenceType: n }; let i = e.Materials.a, s = []; for (let r = 0; r < i.length; ++r) s.push(r); return { dataSize: 1, buffer: i, indices: s, mappingType: t, referenceType: n }; } parseNurbsGeometry(e) { let t = parseInt(e.Order); if (isNaN(t)) return (console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s", e.Order, e.id), new Et()); let n = t - 1, i = e.KnotVector.a, s = [], r = e.Points.a; for (let h = 0, u = r.length; h < u; h += 4) s.push(new Ye().fromArray(r, h)); let o, a; if (e.Form === "Closed") s.push(s[0]); else if (e.Form === "Periodic") { ((o = n), (a = i.length - 1 - o)); for (let h = 0; h < n; ++h) s.push(s[h]); } let c = new $c(n, i, s, o, a).getPoints(s.length * 12); return new Et().setFromPoints(c); } } class ip { parse() { let e = [], t = this.parseClips(); if (t !== void 0) for (let n in t) { let i = t[n], s = this.addClip(i); e.push(s); } return e; } parseClips() { if (Ze.Objects.AnimationCurve === void 0) return; let e = this.parseAnimationCurveNodes(); this.parseAnimationCurves(e); let t = this.parseAnimationLayers(e); return this.parseAnimStacks(t); } parseAnimationCurveNodes() { let e = Ze.Objects.AnimationCurveNode, t = new Map(); for (let n in e) { let i = e[n]; if (i.attrName.match(/S|R|T|DeformPercent/) !== null) { let s = { id: i.id, attr: i.attrName, curves: {} }; t.set(s.id, s); } } return t; } parseAnimationCurves(e) { let t = Ze.Objects.AnimationCurve; for (let n in t) { let i = { id: t[n].id, times: t[n].KeyTime.a.map(F_), values: t[n].KeyValueFloat.a }, s = Pt.get(i.id); if (s !== void 0) { let r = s.parents[0].ID, o = s.parents[0].relationship; if (o.match(/X/)) e.get(r).curves.x = i; else if (o.match(/Y/)) e.get(r).curves.y = i; else if (o.match(/Z/)) e.get(r).curves.z = i; else if (o.match(/DeformPercent/) && e.has(r)) e.get(r).curves.morph = i; } } } parseAnimationLayers(e) { let t = Ze.Objects.AnimationLayer, n = new Map(); for (let i in t) { let s = [], r = Pt.get(parseInt(i)); if (r !== void 0) (r.children.forEach(function (a, l) { if (e.has(a.ID)) { let c = e.get(a.ID); if (c.curves.x !== void 0 || c.curves.y !== void 0 || c.curves.z !== void 0) { if (s[l] === void 0) { let h = Pt.get(a.ID).parents.filter(function (u) { return u.relationship !== void 0; })[0].ID; if (h !== void 0) { let u = Ze.Objects.Model[h.toString()]; if (u === void 0) { console.warn("THREE.FBXLoader: Encountered a unused curve.", a); return; } let d = { modelName: u.attrName ? $e.sanitizeNodeName(u.attrName) : "", ID: u.id, initialPosition: [0, 0, 0], initialRotation: [0, 0, 0], initialScale: [1, 1, 1], }; if ( (sn.traverse(function (f) { if (f.ID === u.id) { if (((d.transform = f.matrix), f.userData.transformData)) d.eulerOrder = f.userData.transformData.eulerOrder; } }), !d.transform) ) d.transform = new ue(); if ("PreRotation" in u) d.preRotation = u.PreRotation.value; if ("PostRotation" in u) d.postRotation = u.PostRotation.value; s[l] = d; } } if (s[l]) s[l][c.attr] = c; } else if (c.curves.morph !== void 0) { if (s[l] === void 0) { let h = Pt.get(a.ID).parents.filter(function (p) { return p.relationship !== void 0; })[0].ID, u = Pt.get(h).parents[0].ID, d = Pt.get(u).parents[0].ID, f = Pt.get(d).parents[0].ID, m = Ze.Objects.Model[f], y = { modelName: m.attrName ? $e.sanitizeNodeName(m.attrName) : "", morphName: Ze.Objects.Deformer[h].attrName, }; s[l] = y; } s[l][c.attr] = c; } } }), n.set(parseInt(i), s)); } return n; } parseAnimStacks(e) { let t = Ze.Objects.AnimationStack, n = {}; for (let i in t) { let s = Pt.get(parseInt(i)).children; if (s.length > 1) console.warn( "THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.", ); let r = e.get(s[0].ID); n[i] = { name: t[i].attrName, layer: r }; } return n; } addClip(e) { let t = [], n = this; return ( e.layer.forEach(function (i) { t = t.concat(n.generateTracks(i)); }), new Di(e.name, -1, t) ); } generateTracks(e) { let t = [], n = new E(), i = new E(); if (e.transform) e.transform.decompose(n, new Ne(), i); if (((n = n.toArray()), (i = i.toArray()), e.T !== void 0 && Object.keys(e.T.curves).length > 0)) { let s = this.generateVectorTrack(e.modelName, e.T.curves, n, "position"); if (s !== void 0) t.push(s); } if (e.R !== void 0 && Object.keys(e.R.curves).length > 0) { let s = this.generateRotationTrack(e.modelName, e.R.curves, e.preRotation, e.postRotation, e.eulerOrder); if (s !== void 0) t.push(s); } if (e.S !== void 0 && Object.keys(e.S.curves).length > 0) { let s = this.generateVectorTrack(e.modelName, e.S.curves, i, "scale"); if (s !== void 0) t.push(s); } if (e.DeformPercent !== void 0) { let s = this.generateMorphTrack(e); if (s !== void 0) t.push(s); } return t; } generateVectorTrack(e, t, n, i) { let s = this.getTimesForAllAxes(t), r = this.getKeyframeTrackValues(s, t, n); return new Fn(e + "." + i, s, r); } generateRotationTrack(e, t, n, i, s) { let r, o; if (t.x !== void 0 && t.y !== void 0 && t.z !== void 0) { let u = this.interpolateRotations(t.x, t.y, t.z, s); ((r = u[0]), (o = u[1])); } let a = Qr(0); if (n !== void 0) ((n = n.map(bt.degToRad)), n.push(a), (n = new tt().fromArray(n)), (n = new Ne().setFromEuler(n))); if (i !== void 0) ((i = i.map(bt.degToRad)), i.push(a), (i = new tt().fromArray(i)), (i = new Ne().setFromEuler(i).invert())); let l = new Ne(), c = new tt(), h = []; if (!o || !r) return new wn(e + ".quaternion", [0], [0]); for (let u = 0; u < o.length; u += 3) { if ((c.set(o[u], o[u + 1], o[u + 2], s), l.setFromEuler(c), n !== void 0)) l.premultiply(n); if (i !== void 0) l.multiply(i); if (u > 2) { if (new Ne().fromArray(h, ((u - 3) / 3) * 4).dot(l) < 0) l.set(-l.x, -l.y, -l.z, -l.w); } l.toArray(h, (u / 3) * 4); } return new wn(e + ".quaternion", r, h); } generateMorphTrack(e) { let t = e.DeformPercent.curves.morph, n = t.values.map(function (s) { return s / 100; }), i = sn.getObjectByName(e.modelName).morphTargetDictionary[e.morphName]; return new Nn(e.modelName + ".morphTargetInfluences[" + i + "]", t.times, n); } getTimesForAllAxes(e) { let t = []; if (e.x !== void 0) t = t.concat(e.x.times); if (e.y !== void 0) t = t.concat(e.y.times); if (e.z !== void 0) t = t.concat(e.z.times); if ( ((t = t.sort(function (n, i) { return n - i; })), t.length > 1) ) { let n = 1, i = t[0]; for (let s = 1; s < t.length; s++) { let r = t[s]; if (r !== i) ((t[n] = r), (i = r), n++); } t = t.slice(0, n); } return t; } getKeyframeTrackValues(e, t, n) { let i = n, s = [], r = -1, o = -1, a = -1; return ( e.forEach(function (l) { if (t.x) r = t.x.times.indexOf(l); if (t.y) o = t.y.times.indexOf(l); if (t.z) a = t.z.times.indexOf(l); if (r !== -1) { let c = t.x.values[r]; (s.push(c), (i[0] = c)); } else s.push(i[0]); if (o !== -1) { let c = t.y.values[o]; (s.push(c), (i[1] = c)); } else s.push(i[1]); if (a !== -1) { let c = t.z.values[a]; (s.push(c), (i[2] = c)); } else s.push(i[2]); }), s ); } interpolateRotations(e, t, n, i) { let s = [], r = []; (s.push(e.times[0]), r.push(bt.degToRad(e.values[0])), r.push(bt.degToRad(t.values[0])), r.push(bt.degToRad(n.values[0]))); for (let o = 1; o < e.values.length; o++) { let a = [e.values[o - 1], t.values[o - 1], n.values[o - 1]]; if (isNaN(a[0]) || isNaN(a[1]) || isNaN(a[2])) continue; let l = a.map(bt.degToRad), c = [e.values[o], t.values[o], n.values[o]]; if (isNaN(c[0]) || isNaN(c[1]) || isNaN(c[2])) continue; let h = c.map(bt.degToRad), u = [c[0] - a[0], c[1] - a[1], c[2] - a[2]], d = [Math.abs(u[0]), Math.abs(u[1]), Math.abs(u[2])]; if (d[0] >= 180 || d[1] >= 180 || d[2] >= 180) { let m = Math.max(...d) / 180, y = new tt(...l, i), p = new tt(...h, i), g = new Ne().setFromEuler(y), _ = new Ne().setFromEuler(p); if (g.dot(_)) _.set(-_.x, -_.y, -_.z, -_.w); let x = e.times[o - 1], w = e.times[o] - x, L = new Ne(), b = new tt(); for (let R = 0; R < 1; R += 1 / m) (L.copy(g.clone().slerp(_.clone(), R)), s.push(x + R * w), b.setFromQuaternion(L, i), r.push(b.x), r.push(b.y), r.push(b.z)); } else (s.push(e.times[o]), r.push(bt.degToRad(e.values[o])), r.push(bt.degToRad(t.values[o])), r.push(bt.degToRad(n.values[o]))); } return [s, r]; } } class sp { getPrevNode() { return this.nodeStack[this.currentIndent - 2]; } getCurrentNode() { return this.nodeStack[this.currentIndent - 1]; } getCurrentProp() { return this.currentProp; } pushStack(e) { (this.nodeStack.push(e), (this.currentIndent += 1)); } popStack() { (this.nodeStack.pop(), (this.currentIndent -= 1)); } setCurrentProp(e, t) { ((this.currentProp = e), (this.currentPropName = t)); } parse(e) { ((this.currentIndent = 0), (this.allNodes = new th()), (this.nodeStack = []), (this.currentProp = []), (this.currentPropName = "")); let t = this, n = e.split(/[\r\n]+/); return ( n.forEach(function (i, s) { let r = i.match(/^[\s\t]*;/), o = i.match(/^[\s\t]*$/); if (r || o) return; let a = i.match("^\\t{" + t.currentIndent + "}(\\w+):(.*){", ""), l = i.match("^\\t{" + t.currentIndent + "}(\\w+):[\\s\\t\\r\\n](.*)"), c = i.match("^\\t{" + (t.currentIndent - 1) + "}}"); if (a) t.parseNodeBegin(i, a); else if (l) t.parseNodeProperty(i, l, n[++s]); else if (c) t.popStack(); else if (i.match(/^[^\s\t}]/)) t.parseNodePropertyContinued(i); }), this.allNodes ); } parseNodeBegin(e, t) { let n = t[1].trim().replace(/^"/, "").replace(/"$/, ""), i = t[2].split(",").map(function (a) { return a.trim().replace(/^"/, "").replace(/"$/, ""); }), s = { name: n }, r = this.parseNodeAttr(i), o = this.getCurrentNode(); if (this.currentIndent === 0) this.allNodes.add(n, s); else if (n in o) { if (n === "PoseNode") o.PoseNode.push(s); else if (o[n].id !== void 0) ((o[n] = {}), (o[n][o[n].id] = o[n])); if (r.id !== "") o[n][r.id] = s; } else if (typeof r.id === "number") ((o[n] = {}), (o[n][r.id] = s)); else if (n !== "Properties70") if (n === "PoseNode") o[n] = [s]; else o[n] = s; if (typeof r.id === "number") s.id = r.id; if (r.name !== "") s.attrName = r.name; if (r.type !== "") s.attrType = r.type; this.pushStack(s); } parseNodeAttr(e) { let t = e[0]; if (e[0] !== "") { if (((t = parseInt(e[0])), isNaN(t))) t = e[0]; } let n = "", i = ""; if (e.length > 1) ((n = e[1].replace(/^(\w+)::/, "")), (i = e[2])); return { id: t, name: n, type: i }; } parseNodeProperty(e, t, n) { let i = t[1].replace(/^"/, "").replace(/"$/, "").trim(), s = t[2].replace(/^"/, "").replace(/"$/, "").trim(); if (i === "Content" && s === ",") s = n.replace(/"/g, "").replace(/,$/, "").trim(); let r = this.getCurrentNode(); if (r.name === "Properties70") { this.parseNodeSpecialProperty(e, i, s); return; } if (i === "C") { let a = s.split(",").slice(1), l = parseInt(a[0]), c = parseInt(a[1]), h = s.split(",").slice(3); if ( ((h = h.map(function (u) { return u.trim().replace(/^"/, ""); })), (i = "connections"), (s = [l, c]), k_(s, h), r[i] === void 0) ) r[i] = []; } if (i === "Node") r.id = s; if (i in r && Array.isArray(r[i])) r[i].push(s); else if (i !== "a") r[i] = s; else r.a = s; if ((this.setCurrentProp(r, i), i === "a" && s.slice(-1) !== ",")) r.a = Qc(s); } parseNodePropertyContinued(e) { let t = this.getCurrentNode(); if (((t.a += e), e.slice(-1) !== ",")) t.a = Qc(t.a); } parseNodeSpecialProperty(e, t, n) { let i = n.split('",').map(function (c) { return c.trim().replace(/^\"/, "").replace(/\s/, "_"); }), s = i[0], r = i[1], o = i[2], a = i[3], l = i[4]; switch (r) { case "int": case "enum": case "bool": case "ULongLong": case "double": case "Number": case "FieldOfView": l = parseFloat(l); break; case "Color": case "ColorRGB": case "Vector3D": case "Lcl_Translation": case "Lcl_Rotation": case "Lcl_Scaling": l = Qc(l); break; } ((this.getPrevNode()[s] = { type: r, type2: o, flag: a, value: l }), this.setCurrentProp(this.getPrevNode(), s)); } } class rp { parse(e) { let t = new eh(e); t.skip(23); let n = t.getUint32(); if (n < 6400) throw Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + n); let i = new th(); while (!this.endOfContent(t)) { let s = this.parseNode(t, n); if (s !== null) i.add(s.name, s); } return i; } endOfContent(e) { if (e.size() % 16 === 0) return ((e.getOffset() + 160 + 16) & -16) >= e.size(); else return e.getOffset() + 160 + 16 >= e.size(); } parseNode(e, t) { let n = {}, i = t >= 7500 ? e.getUint64() : e.getUint32(), s = t >= 7500 ? e.getUint64() : e.getUint32(); t >= 7500 ? e.getUint64() : e.getUint32(); let r = e.getUint8(), o = e.getString(r); if (i === 0) return null; let a = []; for (let u = 0; u < s; u++) a.push(this.parseProperty(e)); let l = a.length > 0 ? a[0] : "", c = a.length > 1 ? a[1] : "", h = a.length > 2 ? a[2] : ""; n.singleProperty = s === 1 && e.getOffset() === i ? !0 : !1; while (i > e.getOffset()) { let u = this.parseNode(e, t); if (u !== null) this.parseSubNode(o, n, u); } if (((n.propertyList = a), typeof l === "number")) n.id = l; if (c !== "") n.attrName = c; if (h !== "") n.attrType = h; if (o !== "") n.name = o; return n; } parseSubNode(e, t, n) { if (n.singleProperty === !0) { let i = n.propertyList[0]; if (Array.isArray(i)) ((t[n.name] = n), (n.a = i)); else t[n.name] = i; } else if (e === "Connections" && n.name === "C") { let i = []; if ( (n.propertyList.forEach(function (s, r) { if (r !== 0) i.push(s); }), t.connections === void 0) ) t.connections = []; t.connections.push(i); } else if (n.name === "Properties70") Object.keys(n).forEach(function (s) { t[s] = n[s]; }); else if (e === "Properties70" && n.name === "P") { let i = n.propertyList[0], s = n.propertyList[1], r = n.propertyList[2], o = n.propertyList[3], a; if (i.indexOf("Lcl ") === 0) i = i.replace("Lcl ", "Lcl_"); if (s.indexOf("Lcl ") === 0) s = s.replace("Lcl ", "Lcl_"); if (s === "Color" || s === "ColorRGB" || s === "Vector" || s === "Vector3D" || s.indexOf("Lcl_") === 0) a = [n.propertyList[4], n.propertyList[5], n.propertyList[6]]; else a = n.propertyList[4]; t[i] = { type: s, type2: r, flag: o, value: a }; } else if (t[n.name] === void 0) if (typeof n.id === "number") ((t[n.name] = {}), (t[n.name][n.id] = n)); else t[n.name] = n; else if (n.name === "PoseNode") { if (!Array.isArray(t[n.name])) t[n.name] = [t[n.name]]; t[n.name].push(n); } else if (t[n.name][n.id] === void 0) t[n.name][n.id] = n; } parseProperty(e) { let t = e.getString(1), n; switch (t) { case "C": return e.getBoolean(); case "D": return e.getFloat64(); case "F": return e.getFloat32(); case "I": return e.getInt32(); case "L": return e.getInt64(); case "R": return ((n = e.getUint32()), e.getArrayBuffer(n)); case "S": return ((n = e.getUint32()), e.getString(n)); case "Y": return e.getInt16(); case "b": case "c": case "d": case "f": case "i": case "l": let i = e.getUint32(), s = e.getUint32(), r = e.getUint32(); if (s === 0) switch (t) { case "b": case "c": return e.getBooleanArray(i); case "d": return e.getFloat64Array(i); case "f": return e.getFloat32Array(i); case "i": return e.getInt32Array(i); case "l": return e.getInt64Array(i); } let o = Kf(new Uint8Array(e.getArrayBuffer(r))), a = new eh(o.buffer); switch (t) { case "b": case "c": return a.getBooleanArray(i); case "d": return a.getFloat64Array(i); case "f": return a.getFloat32Array(i); case "i": return a.getInt32Array(i); case "l": return a.getInt64Array(i); } break; default: throw Error("THREE.FBXLoader: Unknown property type " + t); } } } class eh { constructor(e, t) { ((this.dv = new DataView(e)), (this.offset = 0), (this.littleEndian = t !== void 0 ? t : !0), (this._textDecoder = new TextDecoder())); } getOffset() { return this.offset; } size() { return this.dv.buffer.byteLength; } skip(e) { this.offset += e; } getBoolean() { return (this.getUint8() & 1) === 1; } getBooleanArray(e) { let t = []; for (let n = 0; n < e; n++) t.push(this.getBoolean()); return t; } getUint8() { let e = this.dv.getUint8(this.offset); return ((this.offset += 1), e); } getInt16() { let e = this.dv.getInt16(this.offset, this.littleEndian); return ((this.offset += 2), e); } getInt32() { let e = this.dv.getInt32(this.offset, this.littleEndian); return ((this.offset += 4), e); } getInt32Array(e) { let t = []; for (let n = 0; n < e; n++) t.push(this.getInt32()); return t; } getUint32() { let e = this.dv.getUint32(this.offset, this.littleEndian); return ((this.offset += 4), e); } getInt64() { let e, t; if (this.littleEndian) ((e = this.getUint32()), (t = this.getUint32())); else ((t = this.getUint32()), (e = this.getUint32())); if (t & 2147483648) { if (((t = ~t & 4294967295), (e = ~e & 4294967295), e === 4294967295)) t = (t + 1) & 4294967295; return ((e = (e + 1) & 4294967295), -(t * 4294967296 + e)); } return t * 4294967296 + e; } getInt64Array(e) { let t = []; for (let n = 0; n < e; n++) t.push(this.getInt64()); return t; } getUint64() { let e, t; if (this.littleEndian) ((e = this.getUint32()), (t = this.getUint32())); else ((t = this.getUint32()), (e = this.getUint32())); return t * 4294967296 + e; } getFloat32() { let e = this.dv.getFloat32(this.offset, this.littleEndian); return ((this.offset += 4), e); } getFloat32Array(e) { let t = []; for (let n = 0; n < e; n++) t.push(this.getFloat32()); return t; } getFloat64() { let e = this.dv.getFloat64(this.offset, this.littleEndian); return ((this.offset += 8), e); } getFloat64Array(e) { let t = []; for (let n = 0; n < e; n++) t.push(this.getFloat64()); return t; } getArrayBuffer(e) { let t = this.dv.buffer.slice(this.offset, this.offset + e); return ((this.offset += e), t); } getString(e) { let t = this.offset, n = new Uint8Array(this.dv.buffer, t, e); this.skip(e); let i = n.indexOf(0); if (i >= 0) n = new Uint8Array(this.dv.buffer, t, i); return this._textDecoder.decode(n); } } class th { add(e, t) { this[e] = t; } } function U_(e) { return e.byteLength >= 21 && ap(e, 0, 21) === "Kaydara FBX Binary \x00"; } function N_(e) { let t = ["K", "a", "y", "d", "a", "r", "a", "\\", "F", "B", "X", "\\", "B", "i", "n", "a", "r", "y", "\\", "\\"], n = 0; function i(s) { let r = e[s - 1]; return ((e = e.slice(n + s)), n++, r); } for (let s = 0; s < t.length; ++s) if (i(1) === t[s]) return !1; return !0; } function ep(e) { let t = /FBXVersion: (\d+)/, n = e.match(t); if (n) return parseInt(n[1]); throw Error("THREE.FBXLoader: Cannot find the version number for the file given."); } function F_(e) { return e / 46186158000; } var O_ = []; function Sa(e, t, n, i) { let s; switch (i.mappingType) { case "ByPolygonVertex": s = e; break; case "ByPolygon": s = t; break; case "ByVertice": s = n; break; case "AllSame": s = i.indices[0]; break; default: console.warn("THREE.FBXLoader: unknown attribute mapping type " + i.mappingType); } if (i.referenceType === "IndexToDirect") s = i.indices[s]; let r = s * i.dataSize, o = r + i.dataSize; return z_(O_, i.buffer, r, o); } var Jc = new tt(), pr = new E(); function op(e) { let t = new ue(), n = new ue(), i = new ue(), s = new ue(), r = new ue(), o = new ue(), a = new ue(), l = new ue(), c = new ue(), h = new ue(), u = new ue(), d = new ue(), f = e.inheritType ? e.inheritType : 0; if (e.translation) t.setPosition(pr.fromArray(e.translation)); let m = Qr(0); if (e.preRotation) { let I = e.preRotation.map(bt.degToRad); (I.push(m), n.makeRotationFromEuler(Jc.fromArray(I))); } if (e.rotation) { let I = e.rotation.map(bt.degToRad); (I.push(e.eulerOrder || m), i.makeRotationFromEuler(Jc.fromArray(I))); } if (e.postRotation) { let I = e.postRotation.map(bt.degToRad); (I.push(m), s.makeRotationFromEuler(Jc.fromArray(I)), s.invert()); } if (e.scale) r.scale(pr.fromArray(e.scale)); if (e.scalingOffset) a.setPosition(pr.fromArray(e.scalingOffset)); if (e.scalingPivot) o.setPosition(pr.fromArray(e.scalingPivot)); if (e.rotationOffset) l.setPosition(pr.fromArray(e.rotationOffset)); if (e.rotationPivot) c.setPosition(pr.fromArray(e.rotationPivot)); if (e.parentMatrixWorld) (u.copy(e.parentMatrix), h.copy(e.parentMatrixWorld)); let y = n.clone().multiply(i).multiply(s), p = new ue(); p.extractRotation(h); let g = new ue(); g.copyPosition(h); let _ = g.clone().invert().multiply(h), x = p.clone().invert().multiply(_), w = r, L = new ue(); if (f === 0) L.copy(p).multiply(y).multiply(x).multiply(w); else if (f === 1) L.copy(p).multiply(x).multiply(y).multiply(w); else { let G = new ue().scale(new E().setFromMatrixScale(u)).clone().invert(), q = x.clone().multiply(G); L.copy(p).multiply(y).multiply(q).multiply(w); } let b = c.clone().invert(), R = o.clone().invert(), F = t .clone() .multiply(l) .multiply(c) .multiply(n) .multiply(i) .multiply(s) .multiply(b) .multiply(a) .multiply(o) .multiply(r) .multiply(R), M = new ue().copyPosition(F), T = h.clone().multiply(M); return (d.copyPosition(T), (F = d.clone().multiply(L)), F.premultiply(h.invert()), F); } function Qr(e) { e = e || 0; let t = ["ZYX", "YZX", "XZY", "ZXY", "YXZ", "XYZ"]; if (e === 6) return ( console.warn( "THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.", ), t[0] ); return t[e]; } function Qc(e) { return e.split(",").map(function (n) { return parseFloat(n); }); } function ap(e, t, n) { if (t === void 0) t = 0; if (n === void 0) n = e.byteLength; return new TextDecoder().decode(new Uint8Array(e, t, n)); } function k_(e, t) { for (let n = 0, i = e.length, s = t.length; n < s; n++, i++) e[i] = t[n]; } function z_(e, t, n, i) { for (let s = n, r = 0; s < i; s++, r++) e[r] = t[s]; return e; } class nh extends _i { constructor() { super(); let e = new Hi(); e.deleteAttribute("uv"); let t = new Mi({ side: Gt }), n = new Mi(), i = new wi(16777215, 900, 28, 2); (i.position.set(0.418, 16.199, 0.3), this.add(i)); let s = new st(e, t); (s.position.set(-0.757, 13.219, 0.717), s.scale.set(31.713, 28.305, 28.591), this.add(s)); let r = new nr(e, n, 6), o = new it(); (o.position.set(-10.906, 2.009, 1.846), o.rotation.set(0, -0.195, 0), o.scale.set(2.328, 7.905, 4.651), o.updateMatrix(), r.setMatrixAt(0, o.matrix), o.position.set(-5.607, -0.754, -0.758), o.rotation.set(0, 0.994, 0), o.scale.set(1.97, 1.534, 3.955), o.updateMatrix(), r.setMatrixAt(1, o.matrix), o.position.set(6.167, 0.857, 7.803), o.rotation.set(0, 0.561, 0), o.scale.set(3.927, 6.285, 3.687), o.updateMatrix(), r.setMatrixAt(2, o.matrix), o.position.set(-2.017, 0.018, 6.124), o.rotation.set(0, 0.333, 0), o.scale.set(2.002, 4.566, 2.064), o.updateMatrix(), r.setMatrixAt(3, o.matrix), o.position.set(2.291, -0.756, -2.621), o.rotation.set(0, -0.286, 0), o.scale.set(1.546, 1.552, 1.496), o.updateMatrix(), r.setMatrixAt(4, o.matrix), o.position.set(-2.193, -0.369, -5.547), o.rotation.set(0, 0.516, 0), o.scale.set(3.875, 3.487, 2.986), o.updateMatrix(), r.setMatrixAt(5, o.matrix), this.add(r)); let a = new st(e, mr(50)); (a.position.set(-16.116, 14.37, 8.208), a.scale.set(0.1, 2.428, 2.739), this.add(a)); let l = new st(e, mr(50)); (l.position.set(-16.109, 18.021, -8.207), l.scale.set(0.1, 2.425, 2.751), this.add(l)); let c = new st(e, mr(17)); (c.position.set(14.904, 12.198, -1.832), c.scale.set(0.15, 4.265, 6.331), this.add(c)); let h = new st(e, mr(43)); (h.position.set(-0.462, 8.89, 14.52), h.scale.set(4.38, 5.441, 0.088), this.add(h)); let u = new st(e, mr(20)); (u.position.set(3.235, 11.486, -12.541), u.scale.set(2.5, 2, 0.1), this.add(u)); let d = new st(e, mr(100)); (d.position.set(0, 20, 0), d.scale.set(1, 0.1, 1), this.add(d)); } dispose() { let e = new Set(); this.traverse((t) => { if (t.isMesh) (e.add(t.geometry), e.add(t.material)); }); for (let t of e) t.dispose(); } } function mr(e) { return new rr({ color: 0, emissive: 16777215, emissiveIntensity: e }); } var eo = function () { var e = 0, t = document.createElement("div"); ((t.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000"), t.addEventListener( "click", function (h) { (h.preventDefault(), i(++e % t.children.length)); }, !1, )); function n(h) { return (t.appendChild(h.dom), h); } function i(h) { for (var u = 0; u < t.children.length; u++) t.children[u].style.display = u === h ? "block" : "none"; e = h; } var s = (performance || Date).now(), r = s, o = 0, a = n(new eo.Panel("FPS", "#0ff", "#002")), l = n(new eo.Panel("MS", "#0f0", "#020")); if (self.performance && self.performance.memory) var c = n(new eo.Panel("MB", "#f08", "#201")); return ( i(0), { REVISION: 16, dom: t, addPanel: n, showPanel: i, begin: function () { s = (performance || Date).now(); }, end: function () { o++; var h = (performance || Date).now(); if ((l.update(h - s, 200), h >= r + 1000)) { if ((a.update((o * 1000) / (h - r), 100), (r = h), (o = 0), c)) { var u = performance.memory; c.update(u.usedJSHeapSize / 1048576, u.jsHeapSizeLimit / 1048576); } } return h; }, update: function () { s = this.end(); }, domElement: t, setMode: i, } ); }; eo.Panel = function (e, t, n) { var i = 1 / 0, s = 0, r = Math.round, o = r(window.devicePixelRatio || 1), a = 80 * o, l = 48 * o, c = 3 * o, h = 2 * o, u = 3 * o, d = 15 * o, f = 74 * o, m = 30 * o, y = document.createElement("canvas"); ((y.width = a), (y.height = l), (y.style.cssText = "width:80px;height:48px")); var p = y.getContext("2d"); return ( (p.font = "bold " + 9 * o + "px Helvetica,Arial,sans-serif"), (p.textBaseline = "top"), (p.fillStyle = n), p.fillRect(0, 0, a, l), (p.fillStyle = t), p.fillText(e, c, h), p.fillRect(u, d, f, m), (p.fillStyle = n), (p.globalAlpha = 0.9), p.fillRect(u, d, f, m), { dom: y, update: function (g, _) { ((i = Math.min(i, g)), (s = Math.max(s, g)), (p.fillStyle = n), (p.globalAlpha = 1), p.fillRect(0, 0, a, d), (p.fillStyle = t), p.fillText(r(g) + " " + e + " (" + r(i) + "-" + r(s) + ")", c, h), p.drawImage(y, u + o, d, f - o, m, u, d, f - o, m), p.fillRect(u + f - o, d, o, m), (p.fillStyle = n), (p.globalAlpha = 0.9), p.fillRect(u + f - o, d, o, r((1 - g / _) * m))); }, } ); }; var lp = eo; var D, hn, vn, Me = [0, 0, 0, 0], ze = new E(), Ma = new E(), Zt = new E(), wa = new E(), jM = new mn(), ZM = new zn(), KM = new tt(), Kt = new Ne(), cp = new Ne(), si = new ue(), ri = new ue(), $M = new E(), Ta = new E(0, 0, 1), H_ = new E(1, 0, 0), B_ = new E(0, 1, 0), G_ = new E(0, 0, 1); class ih { constructor(e = null) { ((this.opt = Object.assign( { warmupMs: 2000, sensitivityFactor: 1, movementFactor: 1, isExcludes: !0, isPivots: !0, isLimits: !0, helperBoneColor1: 16711680, helperBoneColor2: 16238028, helperLinkColor1: 16711680, helperLinkColor2: 255, helperExcludesColor: 11184895, }, e || {}, )), (this.scene = null), (this.armature = null), (this.config = []), (this.data = []), (this.dict = {}), (this.objectsUpdate = []), (this.helpers = { isActive: !1, isShowAll: !1, points: { bones: [], pivots: [], object: null }, lines: { bones: [], object: null }, excludes: { bones: [], deltaLocals: [], radii: [], objects: [] }, }), (this.running = !1), (this.timerMs = 0)); } getOptionValue(e) { return this.opt[e]; } setOptionValue(e, t) { if (((this.opt[e] = t), this.helpers.isActive)) this.showHelpers(); } getBoneNames() { return this.data.map((e) => e.name); } getValue(e, t) { if (this.scene === null) throw Error("Dynamic bones has not been setup yet."); if (!this.dict.hasOwnProperty(e)) throw Error("Dynamic bone '" + e + "' not found."); let n = this.dict[e], i; if (t === "type") i = n.type; else if (t === "stiffness") i = n.k.every((s) => s === n.k[0]) ? n.k[0] : [...n.k]; else if (t === "damping") i = n.c.every((s) => s === n.c[0]) ? n.c[0] : [...n.c]; else if (t === "external") i = n.ext < 1 ? n.ext : null; else if (t === "limits") i = n.limits?.map((s) => (s === null ? null : [...s])); else if (t === "deltaLocal") i = n.dl ? [...n.dl] : null; else if (t === "excludes") i = n.excludes ? [ ...n.excludes.map((s) => { let r = { bone: s.bone.name.slice(), radius: s.radius }; if (s.deltaLocal) r.deltaLocal = [...s.deltaLocal]; return r; }), ] : null; else if (t === "deltaWorld") i = n.dw ? [...n.dw] : null; else if (t === "pivot") i = n.pivot; else if (t === "helper") i = n.helper; else throw Error("Unsupported property '" + t + "'."); return i; } setValue(e, t, n) { if (this.scene === null) throw Error("Dynamic bones has not been setup yet."); if (!this.dict.hasOwnProperty(e)) throw Error("Dynamic bone '" + e + "' not found."); let i = this.dict[e]; if (t === "type") { if (!n) throw Error("Parameter 'type' not set."); if (typeof n !== "string") throw Error("Type must be a string."); switch (n) { case "point": ((i.isPoint = !0), (i.isX = !0), (i.isY = !0), (i.isZ = !0), (i.isT = !1)); break; case "link": ((i.isPoint = !1), (i.isX = !0), (i.isY = !1), (i.isZ = !0), (i.isT = !1)); break; case "mix1": ((i.isPoint = !1), (i.isX = !0), (i.isY = !0), (i.isZ = !0), (i.isT = !1)); break; case "mix2": ((i.isPoint = !1), (i.isX = !0), (i.isY = !1), (i.isZ = !0), (i.isT = !0)); break; case "full": ((i.isPoint = !1), (i.isX = !0), (i.isY = !0), (i.isZ = !0), (i.isT = !0)); break; default: throw Error("Unknown type'" + n + "'."); } i.type = n.slice(); } else if (t === "stiffness") { if (!n) throw Error("Parameter 'stiffness' not set."); if (!Number.isNaN(n) && n >= 0) i.k = Array(4).fill(n); else if (Array.isArray(n) && n.length === 4 && n.every((s) => s >= 0)) i.k = [...n]; else throw Error("Stiffness must be a non-negative number or an array of four non-negative numbers."); } else if (t === "damping") { if (!n) throw Error("Parameter 'damping' not set."); if (!Number.isNaN(n) && n >= 0) i.c = Array(4).fill(n); else if (Array.isArray(n) && n.length === 4 && n.every((s) => s >= 0)) i.c = [...n]; else throw Error("Damping must be a non-negative number or an array of four non-negative numbers."); } else if (t === "external") if (n === null || n === void 0) i.ext = 1; else if (!Number.isNaN(n) && n >= 0 && n <= 1) i.ext = n; else throw Error("External (if set) must be a number between [0,1]."); else if (t === "limits") if (n === null || n === void 0) i.limits = null; else { if (!Array.isArray(n) || n.length !== 4) throw Error("Limits (if set) must null, or an array of four arrays."); if ( !n.every( (s) => s === null || (Array.isArray(s) && s.length === 2 && (s[0] === null || !Number.isNaN(s[0])) && (s[1] === null || !Number.isNaN(s))), ) ) throw Error("Limit values must be null or numbers."); i.limits = [n[0] ? [...n[0]] : null, n[1] ? [...n[1]] : null, n[2] ? [...n[2]] : null, n[3] ? [...n[3]] : null]; } else if (t === "excludes") { if (n === null || n === void 0) i.excludes = null; else { if (!Array.isArray(n)) throw Error("Excludes (if set) must null, or an array."); ((i.excludes = []), n.forEach((s, r) => { if (!s.bone) throw Error("Bone not specified in #" + r + " exclude."); if (typeof s.bone !== "string" || s.bone.length === 0) throw Error("Bone name must be a non-empty string in #" + r + " exclude."); let o = this.armature.getObjectByName(s.bone); if (!o) throw Error("Bone '" + s.bone + "' not found in #" + r + " exclude."); if (Number.isNaN(s.radius) && s.radius >= 0) throw Error("Radius must be a non-negative number in #" + r + " exclude."); let a = { bone: o, radius: s.radius, radiusSq: s.radius * s.radius, deltaLocal: null }; if (s.deltaLocal) { if ( !Array.isArray(s.deltaLocal) || s.deltaLocal.length !== 3 || s.deltaLocal.some((l) => Number.isNaN(l)) ) throw Error("deltaLocal must be an array of three numbers in #" + r + " exclude."); a.deltaLocal = [...s.deltaLocal]; } i.excludes.push(a); })); } this.showHelpers(); } else if (t === "helper") { if (n === null || n === void 0) i.helper = null; else { if (n !== !1 && n !== !0) throw Error("Helper, if set, must be false or true."); i.helper = n; } this.showHelpers(); } else if (t === "pivot") if (n === null || n === void 0) i.pivot = null; else { if (n !== !1 && n !== !0) throw Error("Pivot, if set, must be false or true."); if (n === !0 && i.type === 0) throw Error("Point type bone can't be a pivot."); i.pivot = n; } else if (t === "deltaLocal") if (n === null || n === void 0) i.dl = null; else { if (!Array.isArray(n) || n.length !== 3) throw Error("deltaLocal, is set, must be an array of three numbers."); if (!n.every((s) => !Number.isNaN(s))) throw Error("deltaLocal values must be numbers."); i.dl = [...n]; } else if (t === "deltaWorld") if (n === null || n === void 0) i.dw = null; else { if (!Array.isArray(n) || n.length !== 3) throw Error("deltaWorld, is set, must be an array of three values."); if (!n.every((s) => !Number.isNaN(s))) throw Error("deltaWorld values must be numbers."); i.dw = [...n]; } else throw Error("Unsupported property " + t); } getConfig() { return this.data.map((e) => { let t = { bone: e.name.slice() }; return ( [ "type", "stiffness", "damping", "external", "deltaLocal", "deltaWorld", "limits", "excludes", "pivot", "helper", ].forEach((n) => { if (((D = this.getValue(e.name, n)), D)) t[n] = D; }), t ); }); } sortBones() { if (this.scene === null) throw Error("Dynamic bones has not been setup yet."); let e = 0, t = new WeakMap(); (this.armature.traverse((r) => { if (!t.has(r)) (t.set(r, e), e++); }), this.data.sort((r, o) => t.get(r.bone) - t.get(o.bone)), this.data.forEach((r) => { if (((D = this.dict[r.boneParent.name]), D)) { if (!D.children) D.children = []; D.children.push(r); } }), (this.objectsUpdate = [])); let n = new WeakSet(), i = (r) => (r.parent?.isBone ? [r, ...i(r.parent)] : [r]), s = (r) => { i(r).forEach((a) => { if (!n.has(a)) (this.objectsUpdate.push(a), n.add(a)); }); }; (this.data.forEach((r) => { if ((s(r.bone), r.excludes)) r.excludes.forEach((o) => { s(o.bone); }); }), this.objectsUpdate.sort((r, o) => t.get(r) - t.get(o))); } setup(e, t, n) { this.dispose(); let i = (s, r) => { if (!s) throw (this.dispose(), Error(r)); }; (i(e?.isScene, "First parameter must be Scene."), (this.scene = e), i(t?.isObject3D, "Second parameter must be the armature Object3D."), (this.armature = t), i(Array.isArray(n), "Third parameter must be an array of bone configs."), (this.config = n), this.config.forEach((s, r) => { let o = "Config item #" + r + ": "; i(s.bone, o + "Bone not specified."); let a = s.bone; i(typeof a === "string" && a.length > 0, o + "Bone name must be a non-empty string."); let l = this.armature.getObjectByName(a); (i(l, o + "Bone '" + a + "' not found."), i(l.parent?.isBone, o + "Bone must have a parent bone."), i( this.data.every((h) => h.bone !== l), o + "Bone '" + a + "' already exists.", ), l.updateMatrixWorld(!0)); let c = { name: a, bone: l, boneParent: l.parent, vBasis: l.position.clone(), vWorld: l.parent.getWorldPosition(ze).clone(), qBasis: l.parent.quaternion.clone(), l: l.position.length(), p: [0, 0, 0, 0], v: [0, 0, 0, 0], a: [0, 0, 0, 0], ev: [0, 0, 0, 0], ea: [0, 0, 0, 0], }; (c.boneParent.matrixWorld.decompose(ze, Kt, Zt), ze.copy(Ta).applyQuaternion(Kt).setY(0).normalize(), Kt.premultiply(cp.setFromUnitVectors(Ta, ze).invert()).normalize(), (c.qWorldInverseYaw = Kt.clone().normalize()), this.data.push(c), (this.dict[a] = c)); try { (this.setValue(a, "type", s.type), this.setValue(a, "stiffness", s.stiffness), this.setValue(a, "damping", s.damping), this.setValue(a, "external", s.external), this.setValue(a, "limits", s.limits), this.setValue(a, "excludes", s.excludes), this.setValue(a, "deltaLocal", s.deltaLocal), this.setValue(a, "deltaWorld", s.deltaWorld), this.setValue(a, "pivot", s.pivot), this.setValue(a, "helper", s.helper)); } catch (h) { i(!1, o + h); } }), this.sortBones(), this.start()); } update(e) { if (!this.running) return; let t, n, i, s, r; if (((this.timerMs += e), e > 1000)) this.timerMs = 0; e /= 1000; for (t = 0, i = this.objectsUpdate.length; t < i; t++) { if (((r = this.objectsUpdate[t]), r.updateMatrix(), r.parent === null)) r.matrixWorld.copy(r.matrix); else r.matrixWorld.multiplyMatrices(r.parent.matrixWorld, r.matrix); r.matrixWorldNeedsUpdate = !1; } for (t = 0, i = this.data.length; t < i; t++) { if ( ((r = this.data[t]), ze.copy(r.vWorld), si.copy(r.boneParent.matrixWorld), ri.copy(si).invert(), r.vWorld.setFromMatrixPosition(si), ze.applyMatrix4(ri), ze.length() > 0.5) ) (console.info("Info: Unrealistic jump of " + ze.length().toFixed(2) + " meters."), ze.setLength(0.5)); if ( (ze.applyQuaternion(r.bone.quaternion), (Me[0] = ze.x), (Me[1] = ze.y), (Me[2] = -ze.z), (Me[3] = ze.length() / 3), r.children) ) for (n = 0, s = r.children.length; n < s; n++) ((D = r.children[n]), (Me[0] -= (D.v[0] * e) / 3), (Me[1] -= (D.v[1] * e) / 3), (Me[2] += (D.v[2] * e) / 3), (Me[3] -= (D.v[3] * e) / 3)); if ( ((D = this.opt.sensitivityFactor), (Me[0] *= r.ext * D), (Me[1] *= r.ext * D), (Me[2] *= r.ext * D), (Me[3] *= r.ext * D), r.isX) ) ((D = Me[0] / e), (r.ea[0] = (D - r.ev[0]) / e), (r.ev[0] = D), (r.a[0] = -r.k[0] * r.p[0] - r.c[0] * r.v[0] - r.ea[0]), (r.p[0] += r.v[0] * e + (r.a[0] * e * e) / 2 + Me[0]), (D = r.v[0] + (r.a[0] * e) / 2), (D = -r.k[0] * r.p[0] - r.c[0] * D - r.ea[0]), (r.v[0] = r.v[0] + ((D + r.a[0]) * e) / 2)); if (r.isY) ((D = Me[1] / e), (r.ea[1] = (D - r.ev[1]) / e), (r.ev[1] = D), (r.a[1] = -r.k[1] * r.p[1] - r.c[1] * r.v[1] - r.ea[1]), (r.p[1] += r.v[1] * e + (r.a[1] * e * e) / 2 + Me[1]), (D = r.v[1] + (r.a[1] * e) / 2), (D = -r.k[1] * r.p[1] - r.c[1] * D - r.ea[1]), (r.v[1] = r.v[1] + ((D + r.a[1]) * e) / 2)); if (r.isZ) ((D = Me[2] / e), (r.ea[2] = (D - r.ev[2]) / e), (r.ev[2] = D), (r.a[2] = -r.k[2] * r.p[2] - r.c[2] * r.v[2] - r.ea[2]), (r.p[2] += r.v[2] * e + (r.a[2] * e * e) / 2 + Me[2]), (D = r.v[2] + (r.a[2] * e) / 2), (D = -r.k[2] * r.p[2] - r.c[2] * D - r.ea[2]), (r.v[2] = r.v[2] + ((D + r.a[2]) * e) / 2)); if (r.isT) ((D = Me[3] / e), (r.ea[3] = (D - r.ev[3]) / e), (r.ev[3] = D), (r.a[3] = -r.k[3] * r.p[3] - r.c[3] * r.v[3] - r.ea[3]), (r.p[3] += r.v[3] * e + (r.a[3] * e * e) / 2 + Me[3]), (D = r.v[3] + (r.a[3] * e) / 2), (D = -r.k[3] * r.p[3] - r.c[3] * D - r.ea[3]), (r.v[3] = r.v[3] + ((D + r.a[3]) * e) / 2)); if (this.timerMs < this.opt.warmupMs) ((r.v[0] *= 0.0001), (r.p[0] *= 0.0001), (r.v[1] *= 0.0001), (r.p[1] *= 0.0001), (r.v[2] *= 0.0001), (r.p[2] *= 0.0001), (r.v[3] *= 0.0001), (r.p[3] *= 0.0001)); if ( ((Me[0] = r.p[0]), (Me[1] = r.p[1]), (Me[2] = r.p[2]), (Me[3] = r.p[3]), (D = this.opt.movementFactor), (Me[0] *= D), (Me[1] *= D), (Me[2] *= D), (Me[3] *= D), r.dl) ) ((D = r.dl), (Me[0] += D[0]), (Me[1] += D[1]), (Me[2] += D[2])); if (r.dw) ((D = r.dw), ze.set(r.vBasis.x + Me[0], r.vBasis.y + Me[1], r.vBasis.z + Me[2]), ze.applyMatrix4(si), (ze.x += D[0]), (ze.y += D[1]), (ze.z += D[2]), ze.applyMatrix4(ri), (Me[0] += ze.x - r.vBasis.x), (Me[1] += ze.y - r.vBasis.y), (Me[2] += ze.z - r.vBasis.z)); if (r.limits && this.opt.isLimits) { if (((D = r.limits), D[0])) { if (D[0][0] !== null && Me[0] < D[0][0]) Me[0] = D[0][0]; if (D[0][1] !== null && Me[0] > D[0][1]) Me[0] = D[0][1]; } if (D[1]) { if (D[1][0] !== null && Me[1] < D[1][0]) Me[1] = D[1][0]; if (D[1][1] !== null && Me[1] > D[1][1]) Me[1] = D[1][1]; } if (D[2]) { if (D[2][0] !== null && Me[2] < D[2][0]) Me[2] = D[2][0]; if (D[2][1] !== null && Me[2] > D[2][1]) Me[2] = D[2][1]; } if (D[3]) { if (D[3][0] !== null && Me[3] < D[3][0]) Me[3] = D[3][0]; if (D[3][1] !== null && Me[3] > D[3][1]) Me[3] = D[3][1]; } } if (r.isPoint) r.bone.position.set(r.vBasis.x + Me[0], r.vBasis.y + Me[1], r.vBasis.z - Me[2]); else { if ((r.boneParent.quaternion.copy(r.qBasis), r.pivot && this.opt.isPivots)) (r.boneParent.updateWorldMatrix(!1, !1), r.boneParent.matrixWorld.decompose(ze, Kt, Zt), ze.copy(Ta).applyQuaternion(Kt).setY(0).normalize(), Kt.premultiply(cp.setFromUnitVectors(Ta, ze).invert()).normalize(), r.boneParent.quaternion.multiply(Kt.invert()), r.boneParent.quaternion.multiply(r.qWorldInverseYaw)); if (r.isZ) ((D = Math.atan(Me[0] / r.l)), Kt.setFromAxisAngle(G_, -D), r.boneParent.quaternion.multiply(Kt)); if (r.isY) ((D = r.l / 3), (D = D * Math.tanh(Me[1] / D)), r.bone.position.setLength(r.l + D)); if (r.isX) ((D = Math.atan(Me[2] / r.l)), Kt.setFromAxisAngle(H_, -D), r.boneParent.quaternion.multiply(Kt)); if (r.isT) ((D = 1.5 * Math.tanh(Me[3] * 1.5)), Kt.setFromAxisAngle(B_, -D), r.boneParent.quaternion.multiply(Kt)); if ((r.boneParent.updateWorldMatrix(!1, !0), r.excludes && this.opt.isExcludes)) for (n = 0, s = r.excludes.length; n < s; n++) { if (((D = r.excludes[n]), Zt.set(0, 0, 0), D.deltaLocal)) ((Zt.x += D.deltaLocal[0]), (Zt.y += D.deltaLocal[1]), (Zt.z += D.deltaLocal[2])); if ( (Zt.applyMatrix4(D.bone.matrixWorld), ri.copy(r.boneParent.matrixWorld).invert(), Zt.applyMatrix4(ri), ze.copy(r.bone.position), ze.distanceToSquared(Zt) >= D.radiusSq) ) continue; if (((vn = ze.length()), (hn = Zt.length()), hn > D.radius + vn)) continue; if (hn < Math.abs(D.radius - vn)) continue; if ( ((hn = (hn * hn + vn * vn - D.radiusSq) / (2 * hn)), Zt.normalize(), wa.copy(Zt).multiplyScalar(hn), (hn = Math.sqrt(vn * vn - hn * hn)), ze.subVectors(ze, wa).projectOnPlane(Zt).normalize().multiplyScalar(hn), Ma.subVectors(r.vBasis, wa).projectOnPlane(Zt).normalize(), (vn = Ma.dot(ze)), vn < 0) ) ((vn = Math.sqrt(hn * hn - vn * vn)), Ma.multiplyScalar(vn), ze.add(Ma)); (ze.add(wa).normalize(), Zt.copy(r.bone.position).normalize(), Kt.setFromUnitVectors(Zt, ze), r.boneParent.quaternion.premultiply(Kt), r.boneParent.updateWorldMatrix(!1, !0)); } } } if (this.helpers.isActive) this.updateHelpers(); } showHelpers(e) { if ( (this.hideHelpers(), (this.helpers.isShowAll = e === void 0 ? this.helpers.isShowAll : e === !0), (D = this.helpers), this.data.forEach((t) => { if (this.helpers.isShowAll || t.helper === !0) { if ((D.points.bones.push(t.bone), D.points.pivots.push(t.pivot), t.type !== 0)) D.lines.bones.push(t.bone); if (t.excludes) t.excludes.forEach((n) => { let i = !1; for (let s = 0; s < D.excludes.bones.length; s++) { if (D.excludes.bones[s] !== n.bone) continue; if (D.excludes.radii[s] !== n.radius) continue; if (D.excludes.deltaLocals[s] === null && n.deltaLocal !== null) continue; if (D.excludes.deltaLocals[s] !== null && n.deltaLocal === null) continue; if ( D.excludes.deltaLocals[s] !== null && D.excludes.deltaLocals[s].some((r, o) => r !== n.deltaLocal[o]) ) continue; i = !0; break; } if (!i) (D.excludes.bones.push(n.bone), D.excludes.radii.push(n.radius), D.excludes.deltaLocals.push(n.deltaLocal ? [...n.deltaLocal] : null), D.excludes.objects.push(null)); }); } }), (D = this.helpers.excludes), this.opt.isExcludes && D.bones.length) ) D.bones.forEach((t, n) => { let i = new gs(D.radii[n], 6, 6), s = new Wt({ depthTest: !1, depthWrite: !1, toneMapped: !1, transparent: !0, wireframe: !0, color: this.opt.helperExcludesColor, }); if (((D.objects[n] = new st(i, s)), (D.objects[n].renderOrder = 997), t.add(D.objects[n]), D.deltaLocals[n])) D.objects[n].position.set(D.deltaLocals[n][0], D.deltaLocals[n][1], D.deltaLocals[n][2]); }); if (((D = this.helpers.points), D.bones.length)) { this.helpers.isActive = !0; let t = new Et(), n = D.bones.map((a) => [0, 0, 0]).flat(); t.setAttribute("position", new at(n, 3)); let i = new re(this.opt.helperBoneColor1), s = new re(this.opt.helperBoneColor2), r = D.pivots.map((a) => (a && this.opt.isPivots ? [s.r, s.g, s.b] : [i.r, i.g, i.b])).flat(); t.setAttribute("color", new at(r, 3)); let o = new ms({ depthTest: !1, depthWrite: !1, toneMapped: !1, transparent: !0, size: 0.2, vertexColors: !0 }); ((D.object = new sr(t, o)), (D.object.renderOrder = 998), (D.object.matrix = this.armature.matrixWorld), (D.object.matrixAutoUpdate = !1), this.scene.add(D.object)); } if (((D = this.helpers.lines), D.bones.length)) { let t = new Et(), n = D.bones.map((a) => [0, 0, 0, 0, 0, 0]).flat(); t.setAttribute("position", new at(n, 3)); let i = new re(this.opt.helperLinkColor1), s = new re(this.opt.helperLinkColor2), r = D.bones.map((a) => [i.r, i.g, i.b, s.r, s.g, s.b]).flat(); t.setAttribute("color", new at(r, 3)); let o = new bi({ vertexColors: !0, depthTest: !1, depthWrite: !1, toneMapped: !1, transparent: !0 }); ((D.object = new ir(t, o)), (D.object.renderOrder = 999), (D.object.matrix = this.armature.matrixWorld), (D.object.matrixAutoUpdate = !1), this.scene.add(D.object)); } } updateHelpers() { if (((D = this.helpers.points), D.bones.length)) { ri.copy(this.armature.matrixWorld).invert(); let e = D.object.geometry.getAttribute("position"); for (let t = 0, n = D.bones.length; t < n; t++) (si.multiplyMatrices(ri, D.bones[t].matrixWorld), ze.setFromMatrixPosition(si), e.setXYZ(t, ze.x, ze.y, ze.z)); ((e.needsUpdate = !0), D.object.updateMatrixWorld()); } if (((D = this.helpers.lines), D.bones.length)) { ri.copy(this.armature.matrixWorld).invert(); let e = D.object.geometry.getAttribute("position"); for (let t = 0, n = 0, i = D.bones.length; t < i; t++, n += 2) (si.multiplyMatrices(ri, D.bones[t].matrixWorld), ze.setFromMatrixPosition(si), e.setXYZ(n, ze.x, ze.y, ze.z), si.multiplyMatrices(ri, D.bones[t].parent.matrixWorld), ze.setFromMatrixPosition(si), e.setXYZ(n + 1, ze.x, ze.y, ze.z)); ((e.needsUpdate = !0), D.object.updateMatrixWorld()); } } hideHelpers() { ([this.helpers.points, this.helpers.lines].forEach((e) => { if (((e.bones = []), e.object)) (this.scene.remove(e.object), e.object.geometry.dispose(), e.object.material.dispose(), (e.object = null)); }), (D = this.helpers.excludes), D.objects.forEach((e, t) => { if (e) (D.bones[t].remove(e), e.geometry.dispose(), e.material.dispose()); }), (D.bones = []), (D.deltaLocals = []), (D.radii = []), (D.objects = []), (this.helpers.isActive = !1)); } start() { if (this.data.length) ((this.running = !0), (this.timerMs = 0), this.showHelpers()); } stop() { ((this.running = !1), this.hideHelpers()); for (let e = 0, t = this.data.length; e < t; e++) { let n = this.data[e]; (n.bone.position.copy(n.vBasis), n.boneParent.quaternion.copy(n.qBasis)); } } dispose() { (this.stop(), (this.scene = null), (this.armature = null), (this.config = []), (this.data = []), (this.dict = {}), (this.objectsUpdate = []), (this.timerMs = 0)); } } var V_ = new URL("./playback-worklet.js", import.meta.url), Lt = new Ne(), ft = new tt(), Ti = new E(), $i = new E(), hp = new ln(), ow = new ue(), aw = new ue(), lw = new E(), cw = new E(0, 0, 1), W_ = new E(1, 0, 0), hw = new E(0, 1, 0), uw = new E(0, 0, 1); class sh { constructor(e, t = null) { if ( ((this.nodeAvatar = e), (this.opt = { jwtGet: null, ttsEndpoint: "", ttsApikey: null, ttsTrimStart: 0, ttsTrimEnd: 400, ttsLang: "fi-FI", ttsVoice: "fi-FI-Standard-A", ttsRate: 1, ttsPitch: 0, ttsVolume: 0, mixerGainSpeech: null, mixerGainBackground: null, lipsyncLang: "fi", lipsyncModules: ["fi", "en", "lt"], pcmSampleRate: 22050, modelRoot: "Armature", modelPixelRatio: 1, modelFPS: 30, modelMovementFactor: 1, cameraView: "full", dracoEnabled: !1, dracoDecoderPath: "https://www.gstatic.com/draco/v1/decoders/", cameraDistance: 0, cameraX: 0, cameraY: 0, cameraRotateX: 0, cameraRotateY: 0, cameraRotateEnable: !0, cameraPanEnable: !1, cameraZoomEnable: !1, lightAmbientColor: 16777215, lightAmbientIntensity: 2, lightDirectColor: 8947882, lightDirectIntensity: 30, lightDirectPhi: 1, lightDirectTheta: 2, lightSpotIntensity: 0, lightSpotColor: 3377407, lightSpotPhi: 0.1, lightSpotTheta: 4, lightSpotDispersion: 1, avatarMood: "neutral", avatarMute: !1, avatarIdleEyeContact: 0.2, avatarIdleHeadMove: 0.5, avatarSpeakingEyeContact: 0.5, avatarSpeakingHeadMove: 0.5, avatarIgnoreCamera: !1, listeningSilenceThresholdLevel: 40, listeningSilenceThresholdMs: 2000, listeningSilenceDurationMax: 1e4, listeningActiveThresholdLevel: 75, listeningActiveThresholdMs: 300, listeningActiveDurationMax: 240000, update: null, avatarOnly: !1, avatarOnlyScene: null, avatarOnlyCamera: null, statsNode: null, statsStyle: null, }), Object.assign(this.opt, t || {}), this.opt.statsNode) ) { if (((this.stats = new lp()), this.opt.statsStyle)) this.stats.dom.style.cssText = this.opt.statsStyle; this.opt.statsNode.appendChild(this.stats.dom); } ((this.poseTemplates = { side: { standing: !0, props: { "Hips.position": { x: 0, y: 1, z: 0 }, "Hips.rotation": { x: -0.003, y: -0.017, z: 0.1 }, "Spine.rotation": { x: -0.103, y: -0.002, z: -0.063 }, "Spine1.rotation": { x: 0.042, y: -0.02, z: -0.069 }, "Spine2.rotation": { x: 0.131, y: -0.012, z: -0.065 }, "Neck.rotation": { x: 0.027, y: 0.006, z: 0 }, "Head.rotation": { x: 0.077, y: -0.065, z: 0 }, "LeftShoulder.rotation": { x: 1.599, y: 0.084, z: -1.77 }, "LeftArm.rotation": { x: 1.364, y: 0.052, z: -0.044 }, "LeftForeArm.rotation": { x: 0.002, y: -0.007, z: 0.331 }, "LeftHand.rotation": { x: 0.104, y: -0.067, z: -0.174 }, "LeftHandThumb1.rotation": { x: 0.231, y: 0.258, z: 0.355 }, "LeftHandThumb2.rotation": { x: -0.106, y: -0.339, z: -0.454 }, "LeftHandThumb3.rotation": { x: -0.02, y: -0.142, z: -0.004 }, "LeftHandIndex1.rotation": { x: 0.148, y: 0.032, z: -0.069 }, "LeftHandIndex2.rotation": { x: 0.326, y: -0.049, z: -0.029 }, "LeftHandIndex3.rotation": { x: 0.247, y: -0.053, z: -0.073 }, "LeftHandMiddle1.rotation": { x: 0.238, y: -0.057, z: -0.089 }, "LeftHandMiddle2.rotation": { x: 0.469, y: -0.036, z: -0.081 }, "LeftHandMiddle3.rotation": { x: 0.206, y: -0.015, z: -0.017 }, "LeftHandRing1.rotation": { x: 0.187, y: -0.118, z: -0.157 }, "LeftHandRing2.rotation": { x: 0.579, y: 0.02, z: -0.097 }, "LeftHandRing3.rotation": { x: 0.272, y: 0.021, z: -0.063 }, "LeftHandPinky1.rotation": { x: 0.405, y: -0.182, z: -0.138 }, "LeftHandPinky2.rotation": { x: 0.613, y: 0.128, z: -0.144 }, "LeftHandPinky3.rotation": { x: 0.268, y: 0.094, z: -0.081 }, "RightShoulder.rotation": { x: 1.541, y: 0.192, z: 1.775 }, "RightArm.rotation": { x: 1.273, y: -0.352, z: -0.067 }, "RightForeArm.rotation": { x: -0.011, y: -0.031, z: -0.357 }, "RightHand.rotation": { x: -0.008, y: 0.312, z: -0.028 }, "RightHandThumb1.rotation": { x: 0.23, y: -0.258, z: -0.355 }, "RightHandThumb2.rotation": { x: -0.107, y: 0.339, z: 0.454 }, "RightHandThumb3.rotation": { x: -0.02, y: 0.142, z: 0.004 }, "RightHandIndex1.rotation": { x: 0.148, y: -0.031, z: 0.069 }, "RightHandIndex2.rotation": { x: 0.326, y: 0.049, z: 0.029 }, "RightHandIndex3.rotation": { x: 0.247, y: 0.053, z: 0.073 }, "RightHandMiddle1.rotation": { x: 0.237, y: 0.057, z: 0.089 }, "RightHandMiddle2.rotation": { x: 0.469, y: 0.036, z: 0.081 }, "RightHandMiddle3.rotation": { x: 0.206, y: 0.015, z: 0.017 }, "RightHandRing1.rotation": { x: 0.204, y: 0.086, z: 0.135 }, "RightHandRing2.rotation": { x: 0.579, y: -0.02, z: 0.098 }, "RightHandRing3.rotation": { x: 0.272, y: -0.021, z: 0.063 }, "RightHandPinky1.rotation": { x: 0.404, y: 0.182, z: 0.137 }, "RightHandPinky2.rotation": { x: 0.613, y: -0.128, z: 0.144 }, "RightHandPinky3.rotation": { x: 0.268, y: -0.094, z: 0.081 }, "LeftUpLeg.rotation": { x: 0.096, y: 0.209, z: 2.983 }, "LeftLeg.rotation": { x: -0.053, y: 0.042, z: -0.017 }, "LeftFoot.rotation": { x: 1.091, y: 0.15, z: 0.026 }, "LeftToeBase.rotation": { x: 0.469, y: -0.07, z: -0.015 }, "RightUpLeg.rotation": { x: -0.307, y: -0.219, z: 2.912 }, "RightLeg.rotation": { x: -0.359, y: 0.164, z: 0.015 }, "RightFoot.rotation": { x: 1.035, y: 0.11, z: 0.005 }, "RightToeBase.rotation": { x: 0.467, y: 0.07, z: 0.015 }, }, }, hip: { standing: !0, props: { "Hips.position": { x: 0, y: 1, z: 0 }, "Hips.rotation": { x: -0.036, y: 0.09, z: 0.135 }, "Spine.rotation": { x: 0.076, y: -0.035, z: 0.01 }, "Spine1.rotation": { x: -0.096, y: 0.013, z: -0.094 }, "Spine2.rotation": { x: -0.014, y: 0.002, z: -0.097 }, "Neck.rotation": { x: 0.034, y: -0.051, z: -0.075 }, "Head.rotation": { x: 0.298, y: -0.1, z: 0.154 }, "LeftShoulder.rotation": { x: 1.694, y: 0.011, z: -1.68 }, "LeftArm.rotation": { x: 1.343, y: 0.177, z: -0.153 }, "LeftForeArm.rotation": { x: -0.049, y: 0.134, z: 0.351 }, "LeftHand.rotation": { x: 0.057, y: -0.189, z: -0.026 }, "LeftHandThumb1.rotation": { x: 0.368, y: -0.066, z: 0.438 }, "LeftHandThumb2.rotation": { x: -0.156, y: 0.029, z: -0.369 }, "LeftHandThumb3.rotation": { x: 0.034, y: -0.009, z: 0.016 }, "LeftHandIndex1.rotation": { x: 0.157, y: -0.002, z: -0.171 }, "LeftHandIndex2.rotation": { x: 0.099, y: 0, z: 0 }, "LeftHandIndex3.rotation": { x: 0.1, y: 0, z: 0 }, "LeftHandMiddle1.rotation": { x: 0.222, y: -0.019, z: -0.16 }, "LeftHandMiddle2.rotation": { x: 0.142, y: 0, z: 0 }, "LeftHandMiddle3.rotation": { x: 0.141, y: 0, z: 0 }, "LeftHandRing1.rotation": { x: 0.333, y: -0.039, z: -0.174 }, "LeftHandRing2.rotation": { x: 0.214, y: 0, z: 0 }, "LeftHandRing3.rotation": { x: 0.213, y: 0, z: 0 }, "LeftHandPinky1.rotation": { x: 0.483, y: -0.069, z: -0.189 }, "LeftHandPinky2.rotation": { x: 0.312, y: 0, z: 0 }, "LeftHandPinky3.rotation": { x: 0.309, y: 0, z: 0 }, "RightShoulder.rotation": { x: 1.597, y: 0.012, z: 1.816 }, "RightArm.rotation": { x: 0.618, y: -1.274, z: -0.266 }, "RightForeArm.rotation": { x: -0.395, y: -0.097, z: -1.342 }, "RightHand.rotation": { x: -0.816, y: -0.057, z: -0.976 }, "RightHandThumb1.rotation": { x: 0.42, y: 0.23, z: -1.172 }, "RightHandThumb2.rotation": { x: -0.027, y: 0.361, z: 0.122 }, "RightHandThumb3.rotation": { x: 0.076, y: 0.125, z: -0.371 }, "RightHandIndex1.rotation": { x: -0.158, y: -0.045, z: 0.033 }, "RightHandIndex2.rotation": { x: 0.391, y: 0.051, z: 0.025 }, "RightHandIndex3.rotation": { x: 0.317, y: 0.058, z: 0.07 }, "RightHandMiddle1.rotation": { x: 0.486, y: 0.066, z: 0.014 }, "RightHandMiddle2.rotation": { x: 0.718, y: 0.055, z: 0.07 }, "RightHandMiddle3.rotation": { x: 0.453, y: 0.019, z: 0.013 }, "RightHandRing1.rotation": { x: 0.591, y: 0.241, z: 0.11 }, "RightHandRing2.rotation": { x: 1.014, y: 0.023, z: 0.097 }, "RightHandRing3.rotation": { x: 0.708, y: 0.008, z: 0.066 }, "RightHandPinky1.rotation": { x: 1.02, y: 0.305, z: 0.051 }, "RightHandPinky2.rotation": { x: 1.187, y: -0.028, z: 0.191 }, "RightHandPinky3.rotation": { x: 0.872, y: -0.031, z: 0.121 }, "LeftUpLeg.rotation": { x: -0.095, y: -0.058, z: -3.338 }, "LeftLeg.rotation": { x: -0.366, y: 0.287, z: -0.021 }, "LeftFoot.rotation": { x: 1.131, y: 0.21, z: 0.176 }, "LeftToeBase.rotation": { x: 0.739, y: -0.068, z: -0.001 }, "RightUpLeg.rotation": { x: -0.502, y: 0.362, z: 3.153 }, "RightLeg.rotation": { x: -1.002, y: 0.109, z: 0.008 }, "RightFoot.rotation": { x: 0.626, y: -0.097, z: -0.194 }, "RightToeBase.rotation": { x: 1.33, y: 0.288, z: -0.078 }, }, }, turn: { standing: !0, props: { "Hips.position": { x: 0, y: 1, z: 0 }, "Hips.rotation": { x: -0.07, y: -0.604, z: -0.004 }, "Spine.rotation": { x: -0.007, y: 0.003, z: 0.071 }, "Spine1.rotation": { x: -0.053, y: 0.024, z: -0.06 }, "Spine2.rotation": { x: 0.074, y: 0.013, z: -0.068 }, "Neck.rotation": { x: 0.03, y: 0.186, z: -0.077 }, "Head.rotation": { x: 0.045, y: 0.243, z: -0.086 }, "LeftShoulder.rotation": { x: 1.717, y: -0.085, z: -1.761 }, "LeftArm.rotation": { x: 1.314, y: 0.07, z: -0.057 }, "LeftForeArm.rotation": { x: -0.151, y: 0.714, z: 0.302 }, "LeftHand.rotation": { x: -0.069, y: 0.003, z: -0.118 }, "LeftHandThumb1.rotation": { x: 0.23, y: 0.258, z: 0.354 }, "LeftHandThumb2.rotation": { x: -0.107, y: -0.338, z: -0.455 }, "LeftHandThumb3.rotation": { x: -0.015, y: -0.142, z: 0.002 }, "LeftHandIndex1.rotation": { x: 0.145, y: 0.032, z: -0.069 }, "LeftHandIndex2.rotation": { x: 0.323, y: -0.049, z: -0.028 }, "LeftHandIndex3.rotation": { x: 0.249, y: -0.053, z: -0.074 }, "LeftHandMiddle1.rotation": { x: 0.235, y: -0.057, z: -0.088 }, "LeftHandMiddle2.rotation": { x: 0.468, y: -0.036, z: -0.081 }, "LeftHandMiddle3.rotation": { x: 0.203, y: -0.015, z: -0.017 }, "LeftHandRing1.rotation": { x: 0.185, y: -0.118, z: -0.157 }, "LeftHandRing2.rotation": { x: 0.578, y: 0.02, z: -0.097 }, "LeftHandRing3.rotation": { x: 0.27, y: 0.021, z: -0.063 }, "LeftHandPinky1.rotation": { x: 0.404, y: -0.182, z: -0.138 }, "LeftHandPinky2.rotation": { x: 0.612, y: 0.128, z: -0.144 }, "LeftHandPinky3.rotation": { x: 0.267, y: 0.094, z: -0.081 }, "RightShoulder.rotation": { x: 1.605, y: 0.17, z: 1.625 }, "RightArm.rotation": { x: 1.574, y: -0.655, z: 0.388 }, "RightForeArm.rotation": { x: -0.36, y: -0.849, z: -0.465 }, "RightHand.rotation": { x: 0.114, y: 0.416, z: -0.069 }, "RightHandThumb1.rotation": { x: 0.486, y: 0.009, z: -0.492 }, "RightHandThumb2.rotation": { x: -0.073, y: -0.01, z: 0.284 }, "RightHandThumb3.rotation": { x: -0.054, y: -0.006, z: 0.209 }, "RightHandIndex1.rotation": { x: 0.245, y: -0.014, z: 0.052 }, "RightHandIndex2.rotation": { x: 0.155, y: 0, z: 0 }, "RightHandIndex3.rotation": { x: 0.153, y: 0, z: 0 }, "RightHandMiddle1.rotation": { x: 0.238, y: 0.004, z: 0.028 }, "RightHandMiddle2.rotation": { x: 0.15, y: 0, z: 0 }, "RightHandMiddle3.rotation": { x: 0.149, y: 0, z: 0 }, "RightHandRing1.rotation": { x: 0.267, y: 0.012, z: 0.007 }, "RightHandRing2.rotation": { x: 0.169, y: 0, z: 0 }, "RightHandRing3.rotation": { x: 0.167, y: 0, z: 0 }, "RightHandPinky1.rotation": { x: 0.304, y: 0.018, z: -0.021 }, "RightHandPinky2.rotation": { x: 0.192, y: 0, z: 0 }, "RightHandPinky3.rotation": { x: 0.19, y: 0, z: 0 }, "LeftUpLeg.rotation": { x: -0.001, y: -0.058, z: -3.238 }, "LeftLeg.rotation": { x: -0.29, y: 0.058, z: -0.021 }, "LeftFoot.rotation": { x: 1.288, y: 0.168, z: 0.183 }, "LeftToeBase.rotation": { x: 0.363, y: -0.09, z: -0.01 }, "RightUpLeg.rotation": { x: -0.1, y: 0.36, z: 3.062 }, "RightLeg.rotation": { x: -0.67, y: -0.304, z: 0.043 }, "RightFoot.rotation": { x: 1.195, y: -0.159, z: -0.294 }, "RightToeBase.rotation": { x: 0.737, y: 0.164, z: -0.002 }, }, }, bend: { bend: !0, standing: !0, props: { "Hips.position": { x: -0.007, y: 0.943, z: -0.001 }, "Hips.rotation": { x: 1.488, y: -0.633, z: 1.435 }, "Spine.rotation": { x: -0.126, y: 0.007, z: -0.057 }, "Spine1.rotation": { x: -0.134, y: 0.009, z: 0.01 }, "Spine2.rotation": { x: -0.019, y: 0, z: -0.002 }, "Neck.rotation": { x: -0.159, y: 0.572, z: -0.108 }, "Head.rotation": { x: -0.064, y: 0.716, z: -0.257 }, "RightShoulder.rotation": { x: 1.625, y: -0.043, z: 1.382 }, "RightArm.rotation": { x: 0.746, y: -0.96, z: -1.009 }, "RightForeArm.rotation": { x: -0.199, y: -0.528, z: -0.38 }, "RightHand.rotation": { x: -0.261, y: -0.043, z: -0.027 }, "RightHandThumb1.rotation": { x: 0.172, y: -0.138, z: -0.445 }, "RightHandThumb2.rotation": { x: -0.158, y: 0.327, z: 0.545 }, "RightHandThumb3.rotation": { x: -0.062, y: 0.138, z: 0.152 }, "RightHandIndex1.rotation": { x: 0.328, y: -0.005, z: 0.132 }, "RightHandIndex2.rotation": { x: 0.303, y: 0.049, z: 0.028 }, "RightHandIndex3.rotation": { x: 0.241, y: 0.046, z: 0.077 }, "RightHandMiddle1.rotation": { x: 0.309, y: 0.074, z: 0.089 }, "RightHandMiddle2.rotation": { x: 0.392, y: 0.036, z: 0.081 }, "RightHandMiddle3.rotation": { x: 0.199, y: 0.014, z: 0.019 }, "RightHandRing1.rotation": { x: 0.239, y: 0.143, z: 0.091 }, "RightHandRing2.rotation": { x: 0.275, y: -0.02, z: 0.097 }, "RightHandRing3.rotation": { x: 0.248, y: -0.023, z: 0.061 }, "RightHandPinky1.rotation": { x: 0.211, y: 0.154, z: 0.029 }, "RightHandPinky2.rotation": { x: 0.348, y: -0.128, z: 0.144 }, "RightHandPinky3.rotation": { x: 0.21, y: -0.091, z: 0.065 }, "LeftShoulder.rotation": { x: 1.626, y: -0.027, z: -1.367 }, "LeftArm.rotation": { x: 1.048, y: 0.737, z: 0.712 }, "LeftForeArm.rotation": { x: -0.508, y: 0.879, z: 0.625 }, "LeftHand.rotation": { x: 0.06, y: -0.243, z: -0.079 }, "LeftHandThumb1.rotation": { x: 0.187, y: -0.072, z: 0.346 }, "LeftHandThumb2.rotation": { x: -0.066, y: 0.008, z: -0.256 }, "LeftHandThumb3.rotation": { x: -0.085, y: 0.014, z: -0.334 }, "LeftHandIndex1.rotation": { x: -0.1, y: 0.016, z: -0.058 }, "LeftHandIndex2.rotation": { x: 0.334, y: 0, z: 0 }, "LeftHandIndex3.rotation": { x: 0.281, y: 0, z: 0 }, "LeftHandMiddle1.rotation": { x: -0.056, y: 0, z: 0 }, "LeftHandMiddle2.rotation": { x: 0.258, y: 0, z: 0 }, "LeftHandMiddle3.rotation": { x: 0.26, y: 0, z: 0 }, "LeftHandRing1.rotation": { x: -0.067, y: -0.002, z: 0.008 }, "LeftHandRing2.rotation": { x: 0.259, y: 0, z: 0 }, "LeftHandRing3.rotation": { x: 0.276, y: 0, z: 0 }, "LeftHandPinky1.rotation": { x: -0.128, y: -0.007, z: 0.042 }, "LeftHandPinky2.rotation": { x: 0.227, y: 0, z: 0 }, "LeftHandPinky3.rotation": { x: 0.145, y: 0, z: 0 }, "RightUpLeg.rotation": { x: -1.507, y: 0.2, z: -3.043 }, "RightLeg.rotation": { x: -0.689, y: -0.124, z: 0.017 }, "RightFoot.rotation": { x: 0.909, y: 0.008, z: -0.093 }, "RightToeBase.rotation": { x: 0.842, y: 0.075, z: -0.008 }, "LeftUpLeg.rotation": { x: -1.449, y: -0.2, z: 3.018 }, "LeftLeg.rotation": { x: -0.74, y: -0.115, z: -0.008 }, "LeftFoot.rotation": { x: 1.048, y: -0.058, z: 0.117 }, "LeftToeBase.rotation": { x: 0.807, y: -0.067, z: 0.003 }, }, }, back: { standing: !0, props: { "Hips.position": { x: 0, y: 1, z: 0 }, "Hips.rotation": { x: -0.732, y: -1.463, z: -0.637 }, "Spine.rotation": { x: -0.171, y: 0.106, z: 0.157 }, "Spine1.rotation": { x: -0.044, y: 0.138, z: -0.059 }, "Spine2.rotation": { x: 0.082, y: 0.133, z: -0.074 }, "Neck.rotation": { x: 0.39, y: 0.591, z: -0.248 }, "Head.rotation": { x: -0.001, y: 0.596, z: -0.057 }, "LeftShoulder.rotation": { x: 1.676, y: 0.007, z: -1.892 }, "LeftArm.rotation": { x: -5.566, y: 1.188, z: -0.173 }, "LeftForeArm.rotation": { x: -0.673, y: -0.105, z: 1.702 }, "LeftHand.rotation": { x: -0.469, y: -0.739, z: 0.003 }, "LeftHandThumb1.rotation": { x: 0.876, y: 0.274, z: 0.793 }, "LeftHandThumb2.rotation": { x: 0.161, y: -0.23, z: -0.172 }, "LeftHandThumb3.rotation": { x: 0.078, y: 0.027, z: 0.156 }, "LeftHandIndex1.rotation": { x: -0.085, y: -0.002, z: 0.009 }, "LeftHandIndex2.rotation": { x: 0.176, y: 0, z: -0.002 }, "LeftHandIndex3.rotation": { x: -0.036, y: 0.001, z: -0.035 }, "LeftHandMiddle1.rotation": { x: 0.015, y: 0.144, z: -0.076 }, "LeftHandMiddle2.rotation": { x: 0.378, y: -0.007, z: -0.077 }, "LeftHandMiddle3.rotation": { x: -0.141, y: -0.001, z: 0.031 }, "LeftHandRing1.rotation": { x: 0.039, y: 0.02, z: -0.2 }, "LeftHandRing2.rotation": { x: 0.25, y: -0.002, z: -0.073 }, "LeftHandRing3.rotation": { x: 0.236, y: 0.006, z: -0.075 }, "LeftHandPinky1.rotation": { x: 0.172, y: -0.033, z: -0.275 }, "LeftHandPinky2.rotation": { x: 0.216, y: 0.043, z: -0.054 }, "LeftHandPinky3.rotation": { x: 0.325, y: 0.078, z: -0.13 }, "RightShoulder.rotation": { x: 2.015, y: -0.168, z: 1.706 }, "RightArm.rotation": { x: 0.203, y: -1.258, z: -0.782 }, "RightForeArm.rotation": { x: -0.658, y: -0.133, z: -1.401 }, "RightHand.rotation": { x: -1.504, y: 0.375, z: -0.005 }, "RightHandThumb1.rotation": { x: 0.413, y: -0.158, z: -1.121 }, "RightHandThumb2.rotation": { x: -0.142, y: -0.008, z: 0.209 }, "RightHandThumb3.rotation": { x: -0.091, y: 0.021, z: 0.142 }, "RightHandIndex1.rotation": { x: -0.167, y: 0.014, z: -0.072 }, "RightHandIndex2.rotation": { x: 0.474, y: 0.009, z: 0.051 }, "RightHandIndex3.rotation": { x: 0.115, y: 0.006, z: 0.047 }, "RightHandMiddle1.rotation": { x: 0.385, y: 0.019, z: 0.144 }, "RightHandMiddle2.rotation": { x: 0.559, y: 0.035, z: 0.101 }, "RightHandMiddle3.rotation": { x: 0.229, y: 0, z: 0.027 }, "RightHandRing1.rotation": { x: 0.48, y: 0.026, z: 0.23 }, "RightHandRing2.rotation": { x: 0.772, y: 0.038, z: 0.109 }, "RightHandRing3.rotation": { x: 0.622, y: 0.039, z: 0.106 }, "RightHandPinky1.rotation": { x: 0.767, y: 0.288, z: 0.353 }, "RightHandPinky2.rotation": { x: 0.886, y: 0.049, z: 0.122 }, "RightHandPinky3.rotation": { x: 0.662, y: 0.044, z: 0.113 }, "LeftUpLeg.rotation": { x: -0.206, y: -0.268, z: -3.343 }, "LeftLeg.rotation": { x: -0.333, y: 0.757, z: -0.043 }, "LeftFoot.rotation": { x: 1.049, y: 0.167, z: 0.287 }, "LeftToeBase.rotation": { x: 0.672, y: -0.069, z: -0.004 }, "RightUpLeg.rotation": { x: 0.055, y: -0.226, z: 3.037 }, "RightLeg.rotation": { x: -0.559, y: 0.39, z: -0.001 }, "RightFoot.rotation": { x: 1.2, y: 0.133, z: 0.085 }, "RightToeBase.rotation": { x: 0.92, y: 0.093, z: -0.013 }, }, }, straight: { standing: !0, props: { "Hips.position": { x: 0, y: 0.989, z: 0.001 }, "Hips.rotation": { x: 0.047, y: 0.007, z: -0.007 }, "Spine.rotation": { x: -0.143, y: -0.007, z: 0.005 }, "Spine1.rotation": { x: -0.043, y: -0.014, z: 0.012 }, "Spine2.rotation": { x: 0.072, y: -0.013, z: 0.013 }, "Neck.rotation": { x: 0.048, y: -0.003, z: 0.012 }, "Head.rotation": { x: 0.05, y: -0.02, z: -0.017 }, "LeftShoulder.rotation": { x: 1.62, y: -0.166, z: -1.605 }, "LeftArm.rotation": { x: 1.275, y: 0.544, z: -0.092 }, "LeftForeArm.rotation": { x: 0, y: 0, z: 0.302 }, "LeftHand.rotation": { x: -0.225, y: -0.154, z: 0.11 }, "LeftHandThumb1.rotation": { x: 0.435, y: -0.044, z: 0.457 }, "LeftHandThumb2.rotation": { x: -0.028, y: 0.002, z: -0.246 }, "LeftHandThumb3.rotation": { x: -0.236, y: -0.025, z: 0.113 }, "LeftHandIndex1.rotation": { x: 0.218, y: 0.008, z: -0.081 }, "LeftHandIndex2.rotation": { x: 0.165, y: -0.001, z: -0.017 }, "LeftHandIndex3.rotation": { x: 0.165, y: -0.001, z: -0.017 }, "LeftHandMiddle1.rotation": { x: 0.235, y: -0.011, z: -0.065 }, "LeftHandMiddle2.rotation": { x: 0.182, y: -0.002, z: -0.019 }, "LeftHandMiddle3.rotation": { x: 0.182, y: -0.002, z: -0.019 }, "LeftHandRing1.rotation": { x: 0.316, y: -0.017, z: 0.008 }, "LeftHandRing2.rotation": { x: 0.253, y: -0.003, z: -0.026 }, "LeftHandRing3.rotation": { x: 0.255, y: -0.003, z: -0.026 }, "LeftHandPinky1.rotation": { x: 0.336, y: -0.062, z: 0.088 }, "LeftHandPinky2.rotation": { x: 0.276, y: -0.004, z: -0.028 }, "LeftHandPinky3.rotation": { x: 0.276, y: -0.004, z: -0.028 }, "RightShoulder.rotation": { x: 1.615, y: 0.064, z: 1.53 }, "RightArm.rotation": { x: 1.313, y: -0.424, z: 0.131 }, "RightForeArm.rotation": { x: 0, y: 0, z: -0.317 }, "RightHand.rotation": { x: -0.158, y: -0.639, z: -0.196 }, "RightHandThumb1.rotation": { x: 0.44, y: 0.048, z: -0.549 }, "RightHandThumb2.rotation": { x: -0.056, y: -0.008, z: 0.274 }, "RightHandThumb3.rotation": { x: -0.258, y: 0.031, z: -0.095 }, "RightHandIndex1.rotation": { x: 0.169, y: -0.011, z: 0.105 }, "RightHandIndex2.rotation": { x: 0.134, y: 0.001, z: 0.011 }, "RightHandIndex3.rotation": { x: 0.134, y: 0.001, z: 0.011 }, "RightHandMiddle1.rotation": { x: 0.288, y: 0.014, z: 0.092 }, "RightHandMiddle2.rotation": { x: 0.248, y: 0.003, z: 0.02 }, "RightHandMiddle3.rotation": { x: 0.249, y: 0.003, z: 0.02 }, "RightHandRing1.rotation": { x: 0.369, y: 0.019, z: 0.006 }, "RightHandRing2.rotation": { x: 0.321, y: 0.004, z: 0.026 }, "RightHandRing3.rotation": { x: 0.323, y: 0.004, z: 0.026 }, "RightHandPinky1.rotation": { x: 0.468, y: 0.085, z: -0.03 }, "RightHandPinky2.rotation": { x: 0.427, y: 0.007, z: 0.034 }, "RightHandPinky3.rotation": { x: 0.142, y: 0.001, z: 0.012 }, "LeftUpLeg.rotation": { x: -0.077, y: -0.058, z: 3.126 }, "LeftLeg.rotation": { x: -0.252, y: 0.001, z: -0.018 }, "LeftFoot.rotation": { x: 1.315, y: -0.064, z: 0.315 }, "LeftToeBase.rotation": { x: 0.577, y: -0.07, z: -0.009 }, "RightUpLeg.rotation": { x: -0.083, y: -0.032, z: 3.124 }, "RightLeg.rotation": { x: -0.272, y: -0.003, z: 0.021 }, "RightFoot.rotation": { x: 1.342, y: 0.076, z: -0.222 }, "RightToeBase.rotation": { x: 0.44, y: 0.069, z: 0.016 }, }, }, wide: { standing: !0, props: { "Hips.position": { x: 0, y: 1.017, z: 0.016 }, "Hips.rotation": { x: 0.064, y: -0.048, z: 0.059 }, "Spine.rotation": { x: -0.123, y: 0, z: -0.018 }, "Spine1.rotation": { x: 0.014, y: 0.003, z: -0.006 }, "Spine2.rotation": { x: 0.04, y: 0.003, z: -0.007 }, "Neck.rotation": { x: 0.101, y: 0.007, z: -0.035 }, "Head.rotation": { x: -0.091, y: -0.049, z: 0.105 }, "RightShoulder.rotation": { x: 1.831, y: 0.017, z: 1.731 }, "RightArm.rotation": { x: -1.673, y: -1.102, z: -3.132 }, "RightForeArm.rotation": { x: 0.265, y: 0.23, z: -0.824 }, "RightHand.rotation": { x: -0.52, y: 0.345, z: -0.061 }, "RightHandThumb1.rotation": { x: 0.291, y: 0.056, z: -0.428 }, "RightHandThumb2.rotation": { x: 0.025, y: 0.005, z: 0.166 }, "RightHandThumb3.rotation": { x: -0.089, y: 0.009, z: 0.068 }, "RightHandIndex1.rotation": { x: 0.392, y: -0.015, z: 0.11 }, "RightHandIndex2.rotation": { x: 0.391, y: 0.001, z: 0.004 }, "RightHandIndex3.rotation": { x: 0.326, y: 0, z: 0.003 }, "RightHandMiddle1.rotation": { x: 0.285, y: 0.068, z: 0.081 }, "RightHandMiddle2.rotation": { x: 0.519, y: 0.004, z: 0.011 }, "RightHandMiddle3.rotation": { x: 0.252, y: 0, z: 0.001 }, "RightHandRing1.rotation": { x: 0.207, y: 0.133, z: 0.146 }, "RightHandRing2.rotation": { x: 0.597, y: 0.004, z: 0.004 }, "RightHandRing3.rotation": { x: 0.292, y: 0.002, z: 0.012 }, "RightHandPinky1.rotation": { x: 0.338, y: 0.182, z: 0.136 }, "RightHandPinky2.rotation": { x: 0.533, y: 0.002, z: 0.004 }, "RightHandPinky3.rotation": { x: 0.194, y: 0, z: 0.002 }, "LeftShoulder.rotation": { x: 1.83, y: -0.063, z: -1.808 }, "LeftArm.rotation": { x: -1.907, y: 1.228, z: -2.959 }, "LeftForeArm.rotation": { x: -0.159, y: 0.268, z: 0.572 }, "LeftHand.rotation": { x: 0.069, y: -0.498, z: -0.025 }, "LeftHandThumb1.rotation": { x: 0.738, y: 0.123, z: 0.178 }, "LeftHandThumb2.rotation": { x: -0.26, y: 0.028, z: -0.477 }, "LeftHandThumb3.rotation": { x: -0.448, y: 0.093, z: -0.661 }, "LeftHandIndex1.rotation": { x: 1.064, y: 0.005, z: -0.13 }, "LeftHandIndex2.rotation": { x: 1.55, y: -0.143, z: -0.136 }, "LeftHandIndex3.rotation": { x: 0.722, y: -0.076, z: -0.127 }, "LeftHandMiddle1.rotation": { x: 1.095, y: -0.091, z: 0.006 }, "LeftHandMiddle2.rotation": { x: 1.493, y: -0.174, z: -0.151 }, "LeftHandMiddle3.rotation": { x: 0.651, y: -0.031, z: -0.087 }, "LeftHandRing1.rotation": { x: 1.083, y: -0.224, z: 0.072 }, "LeftHandRing2.rotation": { x: 1.145, y: -0.107, z: -0.195 }, "LeftHandRing3.rotation": { x: 1.208, y: -0.134, z: -0.158 }, "LeftHandPinky1.rotation": { x: 0.964, y: -0.383, z: 0.128 }, "LeftHandPinky2.rotation": { x: 1.457, y: -0.146, z: -0.159 }, "LeftHandPinky3.rotation": { x: 1.019, y: -0.102, z: -0.141 }, "RightUpLeg.rotation": { x: -0.221, y: -0.233, z: 2.87 }, "RightLeg.rotation": { x: -0.339, y: -0.043, z: -0.041 }, "RightFoot.rotation": { x: 1.081, y: 0.177, z: 0.114 }, "RightToeBase.rotation": { x: 0.775, y: 0, z: 0 }, "LeftUpLeg.rotation": { x: -0.185, y: 0.184, z: 3.131 }, "LeftLeg.rotation": { x: -0.408, y: 0.129, z: 0.02 }, "LeftFoot.rotation": { x: 1.167, y: -0.002, z: -0.007 }, "LeftToeBase.rotation": { x: 0.723, y: 0, z: 0 }, }, }, oneknee: { kneeling: !0, props: { "Hips.position": { x: -0.005, y: 0.415, z: -0.017 }, "Hips.rotation": { x: -0.25, y: 0.04, z: -0.238 }, "Spine.rotation": { x: 0.037, y: 0.043, z: 0.047 }, "Spine1.rotation": { x: 0.317, y: 0.103, z: 0.066 }, "Spine2.rotation": { x: 0.433, y: 0.109, z: 0.054 }, "Neck.rotation": { x: -0.156, y: -0.092, z: 0.059 }, "Head.rotation": { x: -0.398, y: -0.032, z: 0.018 }, "RightShoulder.rotation": { x: 1.546, y: 0.119, z: 1.528 }, "RightArm.rotation": { x: 0.896, y: -0.247, z: -0.512 }, "RightForeArm.rotation": { x: 0.007, y: 0, z: -1.622 }, "RightHand.rotation": { x: 1.139, y: -0.853, z: 0.874 }, "RightHandThumb1.rotation": { x: 0.176, y: 0.107, z: -0.311 }, "RightHandThumb2.rotation": { x: -0.047, y: -0.003, z: 0.12 }, "RightHandThumb3.rotation": { x: 0, y: 0, z: 0 }, "RightHandIndex1.rotation": { x: 0.186, y: 0.005, z: 0.125 }, "RightHandIndex2.rotation": { x: 0.454, y: 0.005, z: 0.015 }, "RightHandIndex3.rotation": { x: 0, y: 0, z: 0 }, "RightHandMiddle1.rotation": { x: 0.444, y: 0.035, z: 0.127 }, "RightHandMiddle2.rotation": { x: 0.403, y: -0.006, z: -0.04 }, "RightHandMiddle3.rotation": { x: 0, y: 0, z: 0 }, "RightHandRing1.rotation": { x: 0.543, y: 0.074, z: 0.121 }, "RightHandRing2.rotation": { x: 0.48, y: -0.018, z: -0.063 }, "RightHandRing3.rotation": { x: 0, y: 0, z: 0 }, "RightHandPinky1.rotation": { x: 0.464, y: 0.086, z: 0.113 }, "RightHandPinky2.rotation": { x: 0.667, y: -0.06, z: -0.128 }, "RightHandPinky3.rotation": { x: 0, y: 0, z: 0 }, "LeftShoulder.rotation": { x: 1.545, y: -0.116, z: -1.529 }, "LeftArm.rotation": { x: 0.799, y: 0.631, z: 0.556 }, "LeftForeArm.rotation": { x: -0.002, y: 0.007, z: 0.926 }, "LeftHand.rotation": { x: -0.508, y: 0.439, z: 0.502 }, "LeftHandThumb1.rotation": { x: 0.651, y: -0.035, z: 0.308 }, "LeftHandThumb2.rotation": { x: -0.053, y: 0.008, z: -0.11 }, "LeftHandThumb3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandIndex1.rotation": { x: 0.662, y: -0.053, z: -0.116 }, "LeftHandIndex2.rotation": { x: 0.309, y: -0.004, z: -0.02 }, "LeftHandIndex3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandMiddle1.rotation": { x: 0.501, y: -0.062, z: -0.12 }, "LeftHandMiddle2.rotation": { x: 0.144, y: -0.002, z: 0.016 }, "LeftHandMiddle3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandRing1.rotation": { x: 0.397, y: -0.029, z: -0.143 }, "LeftHandRing2.rotation": { x: 0.328, y: 0.01, z: 0.059 }, "LeftHandRing3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandPinky1.rotation": { x: 0.194, y: 0.008, z: -0.164 }, "LeftHandPinky2.rotation": { x: 0.38, y: 0.031, z: 0.128 }, "LeftHandPinky3.rotation": { x: 0, y: 0, z: 0 }, "RightUpLeg.rotation": { x: -1.594, y: -0.251, z: 2.792 }, "RightLeg.rotation": { x: -2.301, y: -0.073, z: 0.055 }, "RightFoot.rotation": { x: 1.553, y: -0.207, z: -0.094 }, "RightToeBase.rotation": { x: 0.459, y: 0.069, z: 0.016 }, "LeftUpLeg.rotation": { x: -0.788, y: -0.236, z: -2.881 }, "LeftLeg.rotation": { x: -2.703, y: 0.012, z: -0.047 }, "LeftFoot.rotation": { x: 2.191, y: -0.102, z: 0.019 }, "LeftToeBase.rotation": { x: 1.215, y: -0.027, z: 0.01 }, }, }, kneel: { kneeling: !0, lying: !0, props: { "Hips.position": { x: 0, y: 0.532, z: -0.002 }, "Hips.rotation": { x: 0.018, y: -0.008, z: -0.017 }, "Spine.rotation": { x: -0.139, y: -0.01, z: 0.002 }, "Spine1.rotation": { x: 0.002, y: -0.002, z: 0.001 }, "Spine2.rotation": { x: 0.028, y: -0.002, z: 0.001 }, "Neck.rotation": { x: -0.007, y: 0, z: -0.002 }, "Head.rotation": { x: -0.02, y: -0.008, z: -0.004 }, "LeftShoulder.rotation": { x: 1.77, y: -0.428, z: -1.588 }, "LeftArm.rotation": { x: 0.911, y: 0.343, z: 0.083 }, "LeftForeArm.rotation": { x: 0, y: 0, z: 0.347 }, "LeftHand.rotation": { x: 0.033, y: -0.052, z: -0.105 }, "LeftHandThumb1.rotation": { x: 0.508, y: -0.22, z: 0.708 }, "LeftHandThumb2.rotation": { x: -0.323, y: -0.139, z: -0.56 }, "LeftHandThumb3.rotation": { x: -0.328, y: 0.16, z: -0.301 }, "LeftHandIndex1.rotation": { x: 0.178, y: 0.248, z: 0.045 }, "LeftHandIndex2.rotation": { x: 0.236, y: -0.002, z: -0.019 }, "LeftHandIndex3.rotation": { x: -0.062, y: 0, z: 0.005 }, "LeftHandMiddle1.rotation": { x: 0.123, y: -0.005, z: -0.019 }, "LeftHandMiddle2.rotation": { x: 0.589, y: -0.014, z: -0.045 }, "LeftHandMiddle3.rotation": { x: 0.231, y: -0.002, z: -0.019 }, "LeftHandRing1.rotation": { x: 0.196, y: -0.008, z: -0.091 }, "LeftHandRing2.rotation": { x: 0.483, y: -0.009, z: -0.038 }, "LeftHandRing3.rotation": { x: 0.367, y: -0.005, z: -0.029 }, "LeftHandPinky1.rotation": { x: 0.191, y: -0.269, z: -0.246 }, "LeftHandPinky2.rotation": { x: 0.37, y: -0.006, z: -0.029 }, "LeftHandPinky3.rotation": { x: 0.368, y: -0.005, z: -0.029 }, "RightShoulder.rotation": { x: 1.73, y: 0.434, z: 1.715 }, "RightArm.rotation": { x: 0.841, y: -0.508, z: -0.155 }, "RightForeArm.rotation": { x: 0, y: 0, z: -0.355 }, "RightHand.rotation": { x: 0.091, y: 0.137, z: 0.197 }, "RightHandThumb1.rotation": { x: 0.33, y: 0.051, z: -0.753 }, "RightHandThumb2.rotation": { x: -0.113, y: 0.075, z: 0.612 }, "RightHandThumb3.rotation": { x: -0.271, y: -0.166, z: 0.164 }, "RightHandIndex1.rotation": { x: 0.073, y: 0.001, z: -0.093 }, "RightHandIndex2.rotation": { x: 0.338, y: 0.006, z: 0.034 }, "RightHandIndex3.rotation": { x: 0.131, y: 0.001, z: 0.013 }, "RightHandMiddle1.rotation": { x: 0.13, y: 0.005, z: -0.017 }, "RightHandMiddle2.rotation": { x: 0.602, y: 0.018, z: 0.058 }, "RightHandMiddle3.rotation": { x: -0.031, y: 0, z: -0.003 }, "RightHandRing1.rotation": { x: 0.351, y: 0.019, z: 0.045 }, "RightHandRing2.rotation": { x: 0.19, y: 0.002, z: 0.019 }, "RightHandRing3.rotation": { x: 0.21, y: 0.002, z: 0.021 }, "RightHandPinky1.rotation": { x: 0.256, y: 0.17, z: 0.118 }, "RightHandPinky2.rotation": { x: 0.451, y: 0.01, z: 0.045 }, "RightHandPinky3.rotation": { x: 0.346, y: 0.006, z: 0.035 }, "LeftUpLeg.rotation": { x: -0.06, y: 0.1, z: -2.918 }, "LeftLeg.rotation": { x: -1.933, y: -0.01, z: 0.011 }, "LeftFoot.rotation": { x: 0.774, y: -0.162, z: -0.144 }, "LeftToeBase.rotation": { x: 1.188, y: 0, z: 0 }, "RightUpLeg.rotation": { x: -0.099, y: -0.057, z: 2.922 }, "RightLeg.rotation": { x: -1.93, y: 0.172, z: -0.02 }, "RightFoot.rotation": { x: 0.644, y: 0.251, z: 0.212 }, "RightToeBase.rotation": { x: 0.638, y: -0.034, z: -0.001 }, }, }, sitting: { sitting: !0, lying: !0, props: { "Hips.position": { x: 0, y: 0.117, z: 0.005 }, "Hips.rotation": { x: -0.411, y: -0.049, z: 0.056 }, "Spine.rotation": { x: 0.45, y: -0.039, z: -0.116 }, "Spine1.rotation": { x: 0.092, y: -0.076, z: 0.08 }, "Spine2.rotation": { x: 0.073, y: 0.035, z: 0.066 }, "Neck.rotation": { x: 0.051, y: 0.053, z: -0.079 }, "Head.rotation": { x: -0.169, y: 0.009, z: 0.034 }, "LeftShoulder.rotation": { x: 1.756, y: -0.037, z: -1.301 }, "LeftArm.rotation": { x: -0.098, y: 0.016, z: 1.006 }, "LeftForeArm.rotation": { x: -0.089, y: 0.08, z: 0.837 }, "LeftHand.rotation": { x: 0.262, y: -0.399, z: 0.3 }, "LeftHandThumb1.rotation": { x: 0.149, y: -0.043, z: 0.452 }, "LeftHandThumb2.rotation": { x: 0.032, y: 0.006, z: -0.162 }, "LeftHandThumb3.rotation": { x: -0.086, y: -0.005, z: -0.069 }, "LeftHandIndex1.rotation": { x: 0.145, y: 0.032, z: -0.069 }, "LeftHandIndex2.rotation": { x: 0.325, y: -0.001, z: -0.004 }, "LeftHandIndex3.rotation": { x: 0.253, y: 0, z: -0.003 }, "LeftHandMiddle1.rotation": { x: 0.186, y: -0.051, z: -0.091 }, "LeftHandMiddle2.rotation": { x: 0.42, y: -0.003, z: -0.011 }, "LeftHandMiddle3.rotation": { x: 0.153, y: 0.001, z: -0.001 }, "LeftHandRing1.rotation": { x: 0.087, y: -0.19, z: -0.078 }, "LeftHandRing2.rotation": { x: 0.488, y: -0.004, z: -0.005 }, "LeftHandRing3.rotation": { x: 0.183, y: -0.001, z: -0.012 }, "LeftHandPinky1.rotation": { x: 0.205, y: -0.262, z: 0.051 }, "LeftHandPinky2.rotation": { x: 0.407, y: -0.002, z: -0.004 }, "LeftHandPinky3.rotation": { x: 0.068, y: 0, z: -0.002 }, "RightShoulder.rotation": { x: 1.619, y: -0.139, z: 1.179 }, "RightArm.rotation": { x: 0.17, y: -0.037, z: -1.07 }, "RightForeArm.rotation": { x: -0.044, y: -0.056, z: -0.665 }, "RightHand.rotation": { x: 0.278, y: 0.454, z: -0.253 }, "RightHandThumb1.rotation": { x: 0.173, y: 0.089, z: -0.584 }, "RightHandThumb2.rotation": { x: -0.003, y: -0.004, z: 0.299 }, "RightHandThumb3.rotation": { x: -0.133, y: -0.002, z: 0.235 }, "RightHandIndex1.rotation": { x: 0.393, y: -0.023, z: 0.108 }, "RightHandIndex2.rotation": { x: 0.391, y: 0.001, z: 0.004 }, "RightHandIndex3.rotation": { x: 0.326, y: 0, z: 0.003 }, "RightHandMiddle1.rotation": { x: 0.285, y: 0.062, z: 0.086 }, "RightHandMiddle2.rotation": { x: 0.519, y: 0.003, z: 0.011 }, "RightHandMiddle3.rotation": { x: 0.252, y: -0.001, z: 0.001 }, "RightHandRing1.rotation": { x: 0.207, y: 0.122, z: 0.155 }, "RightHandRing2.rotation": { x: 0.597, y: 0.004, z: 0.005 }, "RightHandRing3.rotation": { x: 0.292, y: 0.001, z: 0.012 }, "RightHandPinky1.rotation": { x: 0.338, y: 0.171, z: 0.149 }, "RightHandPinky2.rotation": { x: 0.533, y: 0.002, z: 0.004 }, "RightHandPinky3.rotation": { x: 0.194, y: 0, z: 0.002 }, "LeftUpLeg.rotation": { x: -1.957, y: 0.083, z: -2.886 }, "LeftLeg.rotation": { x: -1.46, y: 0.123, z: 0.005 }, "LeftFoot.rotation": { x: -0.013, y: 0.016, z: 0.09 }, "LeftToeBase.rotation": { x: 0.744, y: 0, z: 0 }, "RightUpLeg.rotation": { x: -1.994, y: 0.125, z: 2.905 }, "RightLeg.rotation": { x: -1.5, y: -0.202, z: -0.006 }, "RightFoot.rotation": { x: -0.012, y: -0.065, z: 0.081 }, "RightToeBase.rotation": { x: 0.758, y: 0, z: 0 }, }, }, }), (this.gestureTemplates = { handup: { "LeftShoulder.rotation": { x: [1.5, 2, 1, 2], y: [0.2, 0.4, 1, 2], z: [-1.5, -1.3, 1, 2] }, "LeftArm.rotation": { x: [1.5, 1.7, 1, 2], y: [-0.6, -0.4, 1, 2], z: [1, 1.2, 1, 2] }, "LeftForeArm.rotation": { x: -0.815, y: [-0.4, 0, 1, 2], z: 1.575 }, "LeftHand.rotation": { x: -0.529, y: -0.2, z: 0.022 }, "LeftHandThumb1.rotation": { x: 0.745, y: -0.526, z: 0.604 }, "LeftHandThumb2.rotation": { x: -0.107, y: -0.01, z: -0.142 }, "LeftHandThumb3.rotation": { x: 0, y: 0.001, z: 0 }, "LeftHandIndex1.rotation": { x: -0.126, y: -0.035, z: -0.087 }, "LeftHandIndex2.rotation": { x: 0.255, y: 0.007, z: -0.085 }, "LeftHandIndex3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandMiddle1.rotation": { x: -0.019, y: -0.128, z: -0.082 }, "LeftHandMiddle2.rotation": { x: 0.233, y: 0.019, z: -0.074 }, "LeftHandMiddle3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandRing1.rotation": { x: 0.005, y: -0.241, z: -0.122 }, "LeftHandRing2.rotation": { x: 0.261, y: 0.021, z: -0.076 }, "LeftHandRing3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandPinky1.rotation": { x: 0.059, y: -0.336, z: -0.2 }, "LeftHandPinky2.rotation": { x: 0.153, y: 0.019, z: 0.001 }, "LeftHandPinky3.rotation": { x: 0, y: 0, z: 0 }, }, index: { "LeftShoulder.rotation": { x: [1.5, 2, 1, 2], y: [0.2, 0.4, 1, 2], z: [-1.5, -1.3, 1, 2] }, "LeftArm.rotation": { x: [1.5, 1.7, 1, 2], y: [-0.6, -0.4, 1, 2], z: [1, 1.2, 1, 2] }, "LeftForeArm.rotation": { x: -0.815, y: [-0.4, 0, 1, 2], z: 1.575 }, "LeftHand.rotation": { x: -0.276, y: -0.506, z: -0.208 }, "LeftHandThumb1.rotation": { x: 0.579, y: 0.228, z: 0.363 }, "LeftHandThumb2.rotation": { x: -0.027, y: -0.04, z: -0.662 }, "LeftHandThumb3.rotation": { x: 0, y: 0.001, z: 0 }, "LeftHandIndex1.rotation": { x: 0, y: -0.105, z: 0.225 }, "LeftHandIndex2.rotation": { x: 0.256, y: -0.103, z: -0.213 }, "LeftHandIndex3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandMiddle1.rotation": { x: 1.453, y: 0.07, z: 0.021 }, "LeftHandMiddle2.rotation": { x: 1.599, y: 0.062, z: 0.07 }, "LeftHandMiddle3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandRing1.rotation": { x: 1.528, y: -0.073, z: 0.052 }, "LeftHandRing2.rotation": { x: 1.386, y: 0.044, z: 0.053 }, "LeftHandRing3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandPinky1.rotation": { x: 1.65, y: -0.204, z: 0.031 }, "LeftHandPinky2.rotation": { x: 1.302, y: 0.071, z: 0.085 }, "LeftHandPinky3.rotation": { x: 0, y: 0, z: 0 }, }, ok: { "LeftShoulder.rotation": { x: [1.5, 2, 1, 2], y: [0.2, 0.4, 1, 2], z: [-1.5, -1.3, 1, 2] }, "LeftArm.rotation": { x: [1.5, 1.7, 1, 1], y: [-0.6, -0.4, 1, 2], z: [1, 1.2, 1, 2] }, "LeftForeArm.rotation": { x: -0.415, y: [-0.4, 0, 1, 2], z: 1.575 }, "LeftHand.rotation": { x: -0.476, y: -0.506, z: -0.208 }, "LeftHandThumb1.rotation": { x: 0.703, y: 0.445, z: 0.899 }, "LeftHandThumb2.rotation": { x: -0.312, y: -0.04, z: -0.938 }, "LeftHandThumb3.rotation": { x: -0.37, y: 0.024, z: -0.393 }, "LeftHandIndex1.rotation": { x: 0.8, y: -0.086, z: -0.091 }, "LeftHandIndex2.rotation": { x: 1.123, y: -0.046, z: -0.074 }, "LeftHandIndex3.rotation": { x: 0.562, y: -0.013, z: -0.043 }, "LeftHandMiddle1.rotation": { x: -0.019, y: -0.128, z: -0.082 }, "LeftHandMiddle2.rotation": { x: 0.233, y: 0.019, z: -0.074 }, "LeftHandMiddle3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandRing1.rotation": { x: 0.005, y: -0.241, z: -0.122 }, "LeftHandRing2.rotation": { x: 0.261, y: 0.021, z: -0.076 }, "LeftHandRing3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandPinky1.rotation": { x: 0.059, y: -0.336, z: -0.2 }, "LeftHandPinky2.rotation": { x: 0.153, y: 0.019, z: 0.001 }, "LeftHandPinky3.rotation": { x: 0, y: 0, z: 0 }, }, thumbup: { "LeftShoulder.rotation": { x: [1.5, 2, 1, 2], y: [0.2, 0.4, 1, 2], z: [-1.5, -1.3, 1, 2] }, "LeftArm.rotation": { x: [1.5, 1.7, 1, 2], y: [-0.6, -0.4, 1, 2], z: [1, 1.2, 1, 2] }, "LeftForeArm.rotation": { x: -0.415, y: 0.206, z: 1.575 }, "LeftHand.rotation": { x: -0.276, y: -0.506, z: -0.208 }, "LeftHandThumb1.rotation": { x: 0.208, y: -0.189, z: 0.685 }, "LeftHandThumb2.rotation": { x: 0.129, y: -0.285, z: -0.163 }, "LeftHandThumb3.rotation": { x: -0.047, y: 0.068, z: 0.401 }, "LeftHandIndex1.rotation": { x: 1.412, y: -0.102, z: -0.152 }, "LeftHandIndex2.rotation": { x: 1.903, y: -0.16, z: -0.114 }, "LeftHandIndex3.rotation": { x: 0.535, y: -0.017, z: -0.062 }, "LeftHandMiddle1.rotation": { x: 1.424, y: -0.103, z: -0.12 }, "LeftHandMiddle2.rotation": { x: 1.919, y: -0.162, z: -0.114 }, "LeftHandMiddle3.rotation": { x: 0.44, y: -0.012, z: -0.051 }, "LeftHandRing1.rotation": { x: 1.619, y: -0.127, z: -0.053 }, "LeftHandRing2.rotation": { x: 1.898, y: -0.16, z: -0.115 }, "LeftHandRing3.rotation": { x: 0.262, y: -0.004, z: -0.031 }, "LeftHandPinky1.rotation": { x: 1.661, y: -0.131, z: -0.016 }, "LeftHandPinky2.rotation": { x: 1.715, y: -0.067, z: -0.13 }, "LeftHandPinky3.rotation": { x: 0.627, y: -0.023, z: -0.071 }, }, thumbdown: { "LeftShoulder.rotation": { x: [1.5, 2, 1, 2], y: [0.2, 0.4, 1, 2], z: [-1.5, -1.3, 1, 2] }, "LeftArm.rotation": { x: [1.5, 1.7, 1, 2], y: [-0.6, -0.4, 1, 2], z: [1, 1.2, 1, 2] }, "LeftForeArm.rotation": { x: -2.015, y: 0.406, z: 1.575 }, "LeftHand.rotation": { x: -0.176, y: -0.206, z: -0.208 }, "LeftHandThumb1.rotation": { x: 0.208, y: -0.189, z: 0.685 }, "LeftHandThumb2.rotation": { x: 0.129, y: -0.285, z: -0.163 }, "LeftHandThumb3.rotation": { x: -0.047, y: 0.068, z: 0.401 }, "LeftHandIndex1.rotation": { x: 1.412, y: -0.102, z: -0.152 }, "LeftHandIndex2.rotation": { x: 1.903, y: -0.16, z: -0.114 }, "LeftHandIndex3.rotation": { x: 0.535, y: -0.017, z: -0.062 }, "LeftHandMiddle1.rotation": { x: 1.424, y: -0.103, z: -0.12 }, "LeftHandMiddle2.rotation": { x: 1.919, y: -0.162, z: -0.114 }, "LeftHandMiddle3.rotation": { x: 0.44, y: -0.012, z: -0.051 }, "LeftHandRing1.rotation": { x: 1.619, y: -0.127, z: -0.053 }, "LeftHandRing2.rotation": { x: 1.898, y: -0.16, z: -0.115 }, "LeftHandRing3.rotation": { x: 0.262, y: -0.004, z: -0.031 }, "LeftHandPinky1.rotation": { x: 1.661, y: -0.131, z: -0.016 }, "LeftHandPinky2.rotation": { x: 1.715, y: -0.067, z: -0.13 }, "LeftHandPinky3.rotation": { x: 0.627, y: -0.023, z: -0.071 }, }, side: { "LeftShoulder.rotation": { x: 1.755, y: -0.035, z: -1.63 }, "LeftArm.rotation": { x: 1.263, y: -0.955, z: 1.024 }, "LeftForeArm.rotation": { x: 0, y: 0, z: 0.8 }, "LeftHand.rotation": { x: -0.36, y: -1.353, z: -0.184 }, "LeftHandThumb1.rotation": { x: 0.137, y: -0.049, z: 0.863 }, "LeftHandThumb2.rotation": { x: -0.293, y: 0.153, z: -0.193 }, "LeftHandThumb3.rotation": { x: -0.271, y: -0.17, z: 0.18 }, "LeftHandIndex1.rotation": { x: -0.018, y: 0.007, z: 0.28 }, "LeftHandIndex2.rotation": { x: 0.247, y: -0.003, z: -0.025 }, "LeftHandIndex3.rotation": { x: 0.13, y: -0.001, z: -0.013 }, "LeftHandMiddle1.rotation": { x: 0.333, y: -0.015, z: 0.182 }, "LeftHandMiddle2.rotation": { x: 0.313, y: -0.005, z: -0.032 }, "LeftHandMiddle3.rotation": { x: 0.294, y: -0.004, z: -0.03 }, "LeftHandRing1.rotation": { x: 0.456, y: -0.028, z: -0.092 }, "LeftHandRing2.rotation": { x: 0.53, y: -0.014, z: -0.052 }, "LeftHandRing3.rotation": { x: 0.478, y: -0.012, z: -0.047 }, "LeftHandPinky1.rotation": { x: 0.647, y: -0.049, z: -0.184 }, "LeftHandPinky2.rotation": { x: 0.29, y: -0.004, z: -0.029 }, "LeftHandPinky3.rotation": { x: 0.501, y: -0.013, z: -0.049 }, }, shrug: { "Neck.rotation": { x: [-0.3, 0.3, 1, 2], y: [-0.3, 0.3, 1, 2], z: [-0.1, 0.1] }, "Head.rotation": { x: [-0.3, 0.3], y: [-0.3, 0.3], z: [-0.1, 0.1] }, "RightShoulder.rotation": { x: 1.732, y: -0.058, z: 1.407 }, "RightArm.rotation": { x: 1.305, y: 0.46, z: 0.118 }, "RightForeArm.rotation": { x: [0, 2], y: [-1, 0.2], z: -1.637 }, "RightHand.rotation": { x: -0.048, y: 0.165, z: -0.39 }, "RightHandThumb1.rotation": { x: 1.467, y: 0.599, z: -1.315 }, "RightHandThumb2.rotation": { x: -0.255, y: -0.123, z: 0.119 }, "RightHandThumb3.rotation": { x: 0, y: -0.002, z: 0 }, "RightHandIndex1.rotation": { x: -0.293, y: -0.066, z: -0.112 }, "RightHandIndex2.rotation": { x: 0.181, y: 0.007, z: 0.069 }, "RightHandIndex3.rotation": { x: 0, y: 0, z: 0 }, "RightHandMiddle1.rotation": { x: -0.063, y: -0.041, z: 0.032 }, "RightHandMiddle2.rotation": { x: 0.149, y: 0.005, z: 0.05 }, "RightHandMiddle3.rotation": { x: 0, y: 0, z: 0 }, "RightHandRing1.rotation": { x: 0.152, y: -0.03, z: 0.132 }, "RightHandRing2.rotation": { x: 0.194, y: 0.007, z: 0.058 }, "RightHandRing3.rotation": { x: 0, y: 0, z: 0 }, "RightHandPinky1.rotation": { x: 0.306, y: -0.015, z: 0.257 }, "RightHandPinky2.rotation": { x: 0.15, y: -0.003, z: -0.003 }, "RightHandPinky3.rotation": { x: 0, y: 0, z: 0 }, "LeftShoulder.rotation": { x: 1.713, y: 0.141, z: -1.433 }, "LeftArm.rotation": { x: 1.136, y: -0.422, z: -0.416 }, "LeftForeArm.rotation": { x: 1.42, y: 0.123, z: 1.506 }, "LeftHand.rotation": { x: 0.073, y: -0.138, z: 0.064 }, "LeftHandThumb1.rotation": { x: 1.467, y: -0.599, z: 1.314 }, "LeftHandThumb2.rotation": { x: -0.255, y: 0.123, z: -0.119 }, "LeftHandThumb3.rotation": { x: 0, y: 0.001, z: 0 }, "LeftHandIndex1.rotation": { x: -0.293, y: 0.066, z: 0.112 }, "LeftHandIndex2.rotation": { x: 0.181, y: -0.007, z: -0.069 }, "LeftHandIndex3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandMiddle1.rotation": { x: -0.062, y: 0.041, z: -0.032 }, "LeftHandMiddle2.rotation": { x: 0.149, y: -0.005, z: -0.05 }, "LeftHandMiddle3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandRing1.rotation": { x: 0.152, y: 0.03, z: -0.132 }, "LeftHandRing2.rotation": { x: 0.194, y: -0.007, z: -0.058 }, "LeftHandRing3.rotation": { x: 0, y: 0, z: 0 }, "LeftHandPinky1.rotation": { x: 0.306, y: 0.015, z: -0.257 }, "LeftHandPinky2.rotation": { x: 0.15, y: 0.003, z: 0.003 }, "LeftHandPinky3.rotation": { x: 0, y: 0, z: 0 }, }, namaste: { "RightShoulder.rotation": { x: 1.758, y: 0.099, z: 1.604 }, "RightArm.rotation": { x: 0.862, y: -0.292, z: -0.932 }, "RightForeArm.rotation": { x: 0.083, y: 0.066, z: -1.791 }, "RightHand.rotation": { x: -0.52, y: -0.001, z: -0.176 }, "RightHandThumb1.rotation": { x: 0.227, y: 0.418, z: -0.776 }, "RightHandThumb2.rotation": { x: -0.011, y: -0.003, z: 0.171 }, "RightHandThumb3.rotation": { x: -0.041, y: -0.001, z: -0.013 }, "RightHandIndex1.rotation": { x: -0.236, y: 0.003, z: -0.028 }, "RightHandIndex2.rotation": { x: 0.004, y: 0, z: 0.001 }, "RightHandIndex3.rotation": { x: 0.002, y: 0, z: 0 }, "RightHandMiddle1.rotation": { x: -0.236, y: 0.003, z: -0.028 }, "RightHandMiddle2.rotation": { x: 0.004, y: 0, z: 0.001 }, "RightHandMiddle3.rotation": { x: 0.002, y: 0, z: 0 }, "RightHandRing1.rotation": { x: -0.236, y: 0.003, z: -0.028 }, "RightHandRing2.rotation": { x: 0.004, y: 0, z: 0.001 }, "RightHandRing3.rotation": { x: 0.002, y: 0, z: 0 }, "RightHandPinky1.rotation": { x: -0.236, y: 0.003, z: -0.028 }, "RightHandPinky2.rotation": { x: 0.004, y: 0, z: 0.001 }, "RightHandPinky3.rotation": { x: 0.002, y: 0, z: 0 }, "LeftShoulder.rotation": { x: 1.711, y: -0.002, z: -1.625 }, "LeftArm.rotation": { x: 0.683, y: 0.334, z: 0.977 }, "LeftForeArm.rotation": { x: 0.086, y: -0.066, z: 1.843 }, "LeftHand.rotation": { x: -0.595, y: -0.229, z: 0.096 }, "LeftHandThumb1.rotation": { x: 0.404, y: -0.05, z: 0.537 }, "LeftHandThumb2.rotation": { x: -0.02, y: 0.004, z: -0.154 }, "LeftHandThumb3.rotation": { x: -0.049, y: 0.002, z: -0.019 }, "LeftHandIndex1.rotation": { x: -0.113, y: -0.001, z: 0.014 }, "LeftHandIndex2.rotation": { x: 0.003, y: 0, z: 0 }, "LeftHandIndex3.rotation": { x: 0.002, y: 0, z: 0 }, "LeftHandMiddle1.rotation": { x: -0.113, y: -0.001, z: 0.014 }, "LeftHandMiddle2.rotation": { x: 0.004, y: 0, z: 0 }, "LeftHandMiddle3.rotation": { x: 0.002, y: 0, z: 0 }, "LeftHandRing1.rotation": { x: -0.113, y: -0.001, z: 0.014 }, "LeftHandRing2.rotation": { x: 0.003, y: 0, z: 0 }, "LeftHandRing3.rotation": { x: 0.002, y: 0, z: 0 }, "LeftHandPinky1.rotation": { x: -0.122, y: -0.001, z: -0.057 }, "LeftHandPinky2.rotation": { x: 0.012, y: 0.001, z: 0.07 }, "LeftHandPinky3.rotation": { x: 0.002, y: 0, z: 0 }, }, }), (this.poseDelta = { props: { "Hips.quaternion": { x: 0, y: 0, z: 0 }, "Spine.quaternion": { x: 0, y: 0, z: 0 }, "Spine1.quaternion": { x: 0, y: 0, z: 0 }, "Neck.quaternion": { x: 0, y: 0, z: 0 }, "Head.quaternion": { x: 0, y: 0, z: 0 }, "Spine1.scale": { x: 0, y: 0, z: 0 }, "Neck.scale": { x: 0, y: 0, z: 0 }, "LeftArm.scale": { x: 0, y: 0, z: 0 }, "RightArm.scale": { x: 0, y: 0, z: 0 }, }, }), ["Left", "Right"].forEach((o) => { (["Leg", "UpLeg", "Arm", "ForeArm", "Hand"].forEach((a) => { this.poseDelta.props[o + a + ".quaternion"] = { x: 0, y: 0, z: 0 }; }), ["HandThumb", "HandIndex", "HandMiddle", "HandRing", "HandPinky"].forEach((a) => { ((this.poseDelta.props[o + a + "1.quaternion"] = { x: 0, y: 0, z: 0 }), (this.poseDelta.props[o + a + "2.quaternion"] = { x: 0, y: 0, z: 0 }), (this.poseDelta.props[o + a + "3.quaternion"] = { x: 0, y: 0, z: 0 })); })); })); let n = new Set(); if ( (Object.values(this.poseTemplates).forEach((o) => { Object.keys(this.propsToThreeObjects(o.props)).forEach((a) => n.add(a)); }), Object.keys(this.poseDelta.props).forEach((o) => { n.add(o); }), (this.posePropNames = [...n]), (this.poseName = "side"), (this.poseWeightOnLeft = !0), (this.gesture = null), (this.poseCurrentTemplate = this.poseTemplates[this.poseName]), (this.poseStraight = this.propsToThreeObjects(this.poseTemplates.straight.props)), (this.poseBase = this.poseFactory(this.poseCurrentTemplate)), (this.poseTarget = this.poseFactory(this.poseCurrentTemplate)), (this.poseAvatar = null), (this.avatarHeight = 1.7), (this.animTemplateEyes = { name: "eyes", idle: { alt: [ { p: () => this.avatar?.hasOwnProperty("avatarIdleEyeContact") ? this.avatar.avatarIdleEyeContact : this.opt.avatarIdleEyeContact, delay: [200, 5000], dt: [200, [2000, 5000], [3000, 1e4, 1, 2]], vs: { headMove: [ this.avatar?.hasOwnProperty("avatarIdleHeadMove") ? this.avatar.avatarIdleHeadMove : this.opt.avatarIdleHeadMove, ], eyesRotateY: [[-0.6, 0.6]], eyesRotateX: [[-0.2, 0.6]], eyeContact: [null, 1], }, }, { delay: [200, 5000], dt: [200, [2000, 5000, 1, 2]], vs: { headMove: [ this.avatar?.hasOwnProperty("avatarIdleHeadMove") ? this.avatar.avatarIdleHeadMove : this.opt.avatarIdleHeadMove, ], eyesRotateY: [[-0.6, 0.6]], eyesRotateX: [[-0.2, 0.6]], }, }, ], }, speaking: { alt: [ { p: () => this.avatar?.hasOwnProperty("avatarSpeakingEyeContact") ? this.avatar.avatarSpeakingEyeContact : this.opt.avatarSpeakingEyeContact, delay: [200, 5000], dt: [0, [3000, 1e4, 1, 2], [2000, 5000]], vs: { eyeContact: [1, null], headMove: [ null, this.avatar?.hasOwnProperty("avatarSpeakingHeadMove") ? this.avatar.avatarSpeakingHeadMove : this.opt.avatarSpeakingHeadMove, null, ], eyesRotateY: [null, [-0.6, 0.6]], eyesRotateX: [null, [-0.2, 0.6]], }, }, { delay: [200, 5000], dt: [200, [2000, 5000, 1, 2]], vs: { headMove: [ this.avatar?.hasOwnProperty("avatarSpeakingHeadMove") ? this.avatar.avatarSpeakingHeadMove : this.opt.avatarSpeakingHeadMove, null, ], eyesRotateY: [[-0.6, 0.6]], eyesRotateX: [[-0.2, 0.6]], }, }, ], }, }), (this.animTemplateBlink = { name: "blink", alt: [ { p: 0.85, delay: [1000, 8000, 1, 2], dt: [50, [100, 300], 100], vs: { eyeBlinkLeft: [1, 1, 0], eyeBlinkRight: [1, 1, 0] }, }, { delay: [1000, 4000, 1, 2], dt: [50, [100, 200], 100, [10, 400, 0], 50, [100, 200], 100], vs: { eyeBlinkLeft: [1, 1, 0, 0, 1, 1, 0], eyeBlinkRight: [1, 1, 0, 0, 1, 1, 0] }, }, ], }), (this.animMoods = { neutral: { baseline: { eyesLookDown: 0.1 }, speech: { deltaRate: 0, deltaPitch: 0, deltaVolume: 0 }, anims: [ { name: "breathing", delay: 1500, dt: [1200, 500, 1000], vs: { chestInhale: [0.5, 0.5, 0] } }, { name: "pose", alt: [ { p: 0.5, delay: [5000, 30000], vs: { pose: ["side"] } }, { p: 0.3, delay: [5000, 30000], vs: { pose: ["hip"] }, M: { delay: [5000, 30000], vs: { pose: ["wide"] } }, }, { delay: [5000, 30000], vs: { pose: ["straight"] } }, ], }, { name: "head", idle: { delay: [0, 1000], dt: [[200, 5000]], vs: { bodyRotateX: [[-0.04, 0.1]], bodyRotateY: [[-0.3, 0.3]], bodyRotateZ: [[-0.08, 0.08]] }, }, speaking: { dt: [[0, 1000, 0]], vs: { bodyRotateX: [[-0.05, 0.15, 1, 2]], bodyRotateY: [[-0.1, 0.1]], bodyRotateZ: [[-0.1, 0.1]] }, }, }, this.animTemplateEyes, this.animTemplateBlink, { name: "mouth", delay: [1000, 5000], dt: [ [100, 500], [100, 5000, 2], ], vs: { mouthRollLower: [[0, 0.3, 2]], mouthRollUpper: [[0, 0.3, 2]], mouthStretchLeft: [[0, 0.3]], mouthStretchRight: [[0, 0.3]], mouthPucker: [[0, 0.3]], }, }, { name: "misc", delay: [100, 5000], dt: [ [100, 500], [1000, 5000, 2], ], vs: { eyeSquintLeft: [[0, 0.3, 2]], eyeSquintRight: [[0, 0.3, 2]], browInnerUp: [[0, 0.3, 2]], browOuterUpLeft: [[0, 0.3, 2]], browOuterUpRight: [[0, 0.3, 2]], }, }, ], }, happy: { baseline: { mouthSmile: 0.2, eyesLookDown: 0.1 }, speech: { deltaRate: 0, deltaPitch: 0.1, deltaVolume: 0 }, anims: [ { name: "breathing", delay: 1500, dt: [1200, 500, 1000], vs: { chestInhale: [0.5, 0.5, 0] } }, { name: "pose", idle: { alt: [ { p: 0.6, delay: [5000, 30000], vs: { pose: ["side"] } }, { p: 0.2, delay: [5000, 30000], vs: { pose: ["hip"] }, M: { delay: [5000, 30000], vs: { pose: ["side"] } }, }, { p: 0.1, delay: [5000, 30000], vs: { pose: ["straight"] } }, { delay: [5000, 1e4], vs: { pose: ["wide"] } }, { delay: [1000, 3000], vs: { pose: ["turn"] } }, ], }, speaking: { alt: [ { p: 0.4, delay: [5000, 30000], vs: { pose: ["side"] } }, { p: 0.4, delay: [5000, 30000], vs: { pose: ["straight"] } }, { delay: [5000, 20000], vs: { pose: ["hip"] }, M: { delay: [5000, 30000], vs: { pose: ["wide"] } } }, ], }, }, { name: "head", idle: { dt: [[1000, 5000]], vs: { bodyRotateX: [[-0.04, 0.1]], bodyRotateY: [[-0.3, 0.3]], bodyRotateZ: [[-0.08, 0.08]] }, }, speaking: { dt: [[0, 1000, 0]], vs: { bodyRotateX: [[-0.05, 0.15, 1, 2]], bodyRotateY: [[-0.1, 0.1]], bodyRotateZ: [[-0.1, 0.1]] }, }, }, this.animTemplateEyes, this.animTemplateBlink, { name: "mouth", delay: [1000, 5000], dt: [ [100, 500], [100, 5000, 2], ], vs: { mouthLeft: [[0, 0.3, 2]], mouthSmile: [[0, 0.2, 3]], mouthRollLower: [[0, 0.3, 2]], mouthRollUpper: [[0, 0.3, 2]], mouthStretchLeft: [[0, 0.3]], mouthStretchRight: [[0, 0.3]], mouthPucker: [[0, 0.3]], }, }, { name: "misc", delay: [100, 5000], dt: [ [100, 500], [1000, 5000, 2], ], vs: { eyeSquintLeft: [[0, 0.3, 2]], eyeSquintRight: [[0, 0.3, 2]], browInnerUp: [[0, 0.3, 2]], browOuterUpLeft: [[0, 0.3, 2]], browOuterUpRight: [[0, 0.3, 2]], }, }, ], }, angry: { baseline: { eyesLookDown: 0.1, browDownLeft: 0.6, browDownRight: 0.6, jawForward: 0.3, mouthFrownLeft: 0.7, mouthFrownRight: 0.7, mouthRollLower: 0.2, mouthShrugLower: 0.3, handFistLeft: 1, handFistRight: 1, }, speech: { deltaRate: -0.2, deltaPitch: 0.2, deltaVolume: 0 }, anims: [ { name: "breathing", delay: 500, dt: [1000, 500, 1000], vs: { chestInhale: [0.7, 0.7, 0] } }, { name: "pose", alt: [ { p: 0.4, delay: [5000, 30000], vs: { pose: ["side"] } }, { p: 0.4, delay: [5000, 30000], vs: { pose: ["straight"] } }, { p: 0.2, delay: [5000, 30000], vs: { pose: ["hip"] }, M: { delay: [5000, 30000], vs: { pose: ["wide"] } }, }, ], }, { name: "head", idle: { delay: [100, 500], dt: [[200, 5000]], vs: { bodyRotateX: [[-0.04, 0.1]], bodyRotateY: [[-0.2, 0.2]], bodyRotateZ: [[-0.08, 0.08]] }, }, speaking: { dt: [[0, 1000, 0]], vs: { bodyRotateX: [[-0.05, 0.15, 1, 2]], bodyRotateY: [[-0.1, 0.1]], bodyRotateZ: [[-0.1, 0.1]] }, }, }, this.animTemplateEyes, this.animTemplateBlink, { name: "mouth", delay: [1000, 5000], dt: [ [100, 500], [100, 5000, 2], ], vs: { mouthRollLower: [[0, 0.3, 2]], mouthRollUpper: [[0, 0.3, 2]], mouthStretchLeft: [[0, 0.3]], mouthStretchRight: [[0, 0.3]], mouthPucker: [[0, 0.3]], }, }, { name: "misc", delay: [100, 5000], dt: [ [100, 500], [1000, 5000, 2], ], vs: { eyeSquintLeft: [[0, 0.3, 2]], eyeSquintRight: [[0, 0.3, 2]], browInnerUp: [[0, 0.3, 2]], browOuterUpLeft: [[0, 0.3, 2]], browOuterUpRight: [[0, 0.3, 2]], }, }, ], }, sad: { baseline: { eyesLookDown: 0.2, browDownRight: 0.1, browInnerUp: 0.6, browOuterUpRight: 0.2, eyeSquintLeft: 0.7, eyeSquintRight: 0.7, mouthFrownLeft: 0.8, mouthFrownRight: 0.8, mouthLeft: 0.2, mouthPucker: 0.5, mouthRollLower: 0.2, mouthRollUpper: 0.2, mouthShrugLower: 0.2, mouthShrugUpper: 0.2, mouthStretchLeft: 0.4, }, speech: { deltaRate: -0.2, deltaPitch: -0.2, deltaVolume: 0 }, anims: [ { name: "breathing", delay: 1500, dt: [1000, 500, 1000], vs: { chestInhale: [0.3, 0.3, 0] } }, { name: "pose", alt: [ { p: 0.4, delay: [5000, 30000], vs: { pose: ["side"] } }, { p: 0.4, delay: [5000, 30000], vs: { pose: ["straight"] } }, { delay: [5000, 20000], vs: { pose: ["side"] }, full: { delay: [5000, 20000], vs: { pose: ["oneknee"] } }, }, ], }, { name: "head", idle: { delay: [100, 500], dt: [[200, 5000]], vs: { bodyRotateX: [[-0.04, 0.1]], bodyRotateY: [[-0.2, 0.2]], bodyRotateZ: [[-0.08, 0.08]] }, }, speaking: { dt: [[0, 1000, 0]], vs: { bodyRotateX: [[-0.05, 0.15, 1, 2]], bodyRotateY: [[-0.1, 0.1]], bodyRotateZ: [[-0.1, 0.1]] }, }, }, this.animTemplateEyes, this.animTemplateBlink, { name: "mouth", delay: [1000, 5000], dt: [ [100, 500], [100, 5000, 2], ], vs: { mouthRollLower: [[0, 0.3, 2]], mouthRollUpper: [[0, 0.3, 2]], mouthStretchLeft: [[0, 0.3]], mouthStretchRight: [[0, 0.3]], mouthPucker: [[0, 0.3]], }, }, { name: "misc", delay: [100, 5000], dt: [ [100, 500], [1000, 5000, 2], ], vs: { eyeSquintLeft: [[0, 0.3, 2]], eyeSquintRight: [[0, 0.3, 2]], browInnerUp: [[0, 0.3, 2]], browOuterUpLeft: [[0, 0.3, 2]], browOuterUpRight: [[0, 0.3, 2]], }, }, ], }, fear: { baseline: { browInnerUp: 0.7, eyeSquintLeft: 0.5, eyeSquintRight: 0.5, eyeWideLeft: 0.6, eyeWideRight: 0.6, mouthClose: 0.1, mouthFunnel: 0.3, mouthShrugLower: 0.5, mouthShrugUpper: 0.5, }, speech: { deltaRate: -0.2, deltaPitch: 0, deltaVolume: 0 }, anims: [ { name: "breathing", delay: 500, dt: [1000, 500, 1000], vs: { chestInhale: [0.7, 0.7, 0] } }, { name: "pose", alt: [ { p: 0.8, delay: [5000, 30000], vs: { pose: ["side"] } }, { delay: [5000, 30000], vs: { pose: ["straight"] } }, { delay: [5000, 20000], vs: { pose: ["wide"] } }, { delay: [5000, 20000], vs: { pose: ["side"] }, full: { delay: [5000, 20000], vs: { pose: ["oneknee"] } }, }, ], }, { name: "head", idle: { delay: [100, 500], dt: [[200, 3000]], vs: { bodyRotateX: [[-0.06, 0.12]], bodyRotateY: [[-0.7, 0.7]], bodyRotateZ: [[-0.1, 0.1]] }, }, speaking: { dt: [[0, 1000, 0]], vs: { bodyRotateX: [[-0.05, 0.15, 1, 2]], bodyRotateY: [[-0.1, 0.1]], bodyRotateZ: [[-0.1, 0.1]] }, }, }, this.animTemplateEyes, this.animTemplateBlink, { name: "mouth", delay: [1000, 5000], dt: [ [100, 500], [100, 5000, 2], ], vs: { mouthRollLower: [[0, 0.3, 2]], mouthRollUpper: [[0, 0.3, 2]], mouthStretchLeft: [[0, 0.3]], mouthStretchRight: [[0, 0.3]], mouthPucker: [[0, 0.3]], }, }, { name: "misc", delay: [100, 5000], dt: [ [100, 500], [1000, 5000, 2], ], vs: { eyeSquintLeft: [[0, 0.3, 2]], eyeSquintRight: [[0, 0.3, 2]], browInnerUp: [[0, 0.3, 2]], browOuterUpLeft: [[0, 0.3, 2]], browOuterUpRight: [[0, 0.3, 2]], }, }, ], }, disgust: { baseline: { browDownLeft: 0.7, browDownRight: 0.1, browInnerUp: 0.3, eyeSquintLeft: 1, eyeSquintRight: 1, eyeWideLeft: 0.5, eyeWideRight: 0.5, eyesRotateX: 0.05, mouthLeft: 0.4, mouthPressLeft: 0.3, mouthRollLower: 0.3, mouthShrugLower: 0.3, mouthShrugUpper: 0.8, mouthUpperUpLeft: 0.3, noseSneerLeft: 1, noseSneerRight: 0.7, }, speech: { deltaRate: -0.2, deltaPitch: 0, deltaVolume: 0 }, anims: [ { name: "breathing", delay: 1500, dt: [1000, 500, 1000], vs: { chestInhale: [0.5, 0.5, 0] } }, { name: "pose", alt: [{ delay: [5000, 20000], vs: { pose: ["side"] } }] }, { name: "head", idle: { delay: [100, 500], dt: [[200, 5000]], vs: { bodyRotateX: [[-0.04, 0.1]], bodyRotateY: [[-0.2, 0.2]], bodyRotateZ: [[-0.08, 0.08]] }, }, speaking: { dt: [[0, 1000, 0]], vs: { bodyRotateX: [[-0.05, 0.15, 1, 2]], bodyRotateY: [[-0.1, 0.1]], bodyRotateZ: [[-0.1, 0.1]] }, }, }, this.animTemplateEyes, this.animTemplateBlink, { name: "mouth", delay: [1000, 5000], dt: [ [100, 500], [100, 5000, 2], ], vs: { mouthRollLower: [[0, 0.3, 2]], mouthRollUpper: [[0, 0.3, 2]], mouthStretchLeft: [[0, 0.3]], mouthStretchRight: [[0, 0.3]], mouthPucker: [[0, 0.3]], }, }, { name: "misc", delay: [100, 5000], dt: [ [100, 500], [1000, 5000, 2], ], vs: { eyeSquintLeft: [[0, 0.3, 2]], eyeSquintRight: [[0, 0.3, 2]], browInnerUp: [[0, 0.3, 2]], browOuterUpLeft: [[0, 0.3, 2]], browOuterUpRight: [[0, 0.3, 2]], }, }, ], }, love: { baseline: { browInnerUp: 0.4, browOuterUpLeft: 0.2, browOuterUpRight: 0.2, mouthSmile: 0.2, eyeBlinkLeft: 0.6, eyeBlinkRight: 0.6, eyeWideLeft: 0.7, eyeWideRight: 0.7, bodyRotateX: 0.1, mouthDimpleLeft: 0.1, mouthDimpleRight: 0.1, mouthPressLeft: 0.2, mouthShrugUpper: 0.2, mouthUpperUpLeft: 0.1, mouthUpperUpRight: 0.1, }, speech: { deltaRate: -0.1, deltaPitch: -0.7, deltaVolume: 0 }, anims: [ { name: "breathing", delay: 1500, dt: [1500, 500, 1500], vs: { chestInhale: [0.8, 0.8, 0] } }, { name: "pose", alt: [ { p: 0.4, delay: [5000, 30000], vs: { pose: ["side"] } }, { p: 0.2, delay: [5000, 30000], vs: { pose: ["straight"] } }, { p: 0.2, delay: [5000, 30000], vs: { pose: ["hip"] }, M: { delay: [5000, 30000], vs: { pose: ["side"] } }, }, { delay: [5000, 1e4], vs: { pose: ["side"] }, full: { delay: [5000, 1e4], vs: { pose: ["kneel"] } } }, { delay: [1000, 3000], vs: { pose: ["turn"] }, M: { delay: [1000, 3000], vs: { pose: ["wide"] } } }, { delay: [1000, 3000], vs: { pose: ["back"] }, M: { delay: [1000, 3000], vs: { pose: ["wide"] } } }, { delay: [5000, 20000], vs: { pose: ["side"] }, M: { delay: [5000, 20000], vs: { pose: ["side"] } }, full: { delay: [5000, 20000], vs: { pose: ["bend"] } }, }, { delay: [1000, 3000], vs: { pose: ["side"] }, full: { delay: [5000, 1e4], vs: { pose: ["oneknee"] } }, }, ], }, { name: "head", idle: { dt: [[1000, 5000]], vs: { bodyRotateX: [[-0.04, 0.1]], bodyRotateY: [[-0.3, 0.3]], bodyRotateZ: [[-0.08, 0.08]] }, }, speaking: { dt: [[0, 1000, 0]], vs: { bodyRotateX: [[-0.05, 0.15, 1, 2]], bodyRotateY: [[-0.1, 0.1]], bodyRotateZ: [[-0.1, 0.1]] }, }, }, this.animTemplateEyes, this.deepCopy(this.animTemplateBlink, (o) => { o.alt[0].delay[0] = o.alt[1].delay[0] = 2000; }), { name: "mouth", delay: [1000, 5000], dt: [ [100, 500], [100, 5000, 2], ], vs: { mouthLeft: [[0, 0.3, 2]], mouthRollLower: [[0, 0.3, 2]], mouthRollUpper: [[0, 0.3, 2]], mouthStretchLeft: [[0, 0.3]], mouthStretchRight: [[0, 0.3]], mouthPucker: [[0, 0.3]], }, }, { name: "misc", delay: [100, 5000], dt: [ [500, 1000], [1000, 5000, 2], ], vs: { eyeSquintLeft: [[0, 0.3, 2]], eyeSquintRight: [[0, 0.3, 2]], browInnerUp: [[0.3, 0.6, 2]], browOuterUpLeft: [[0.1, 0.3, 2]], browOuterUpRight: [[0.1, 0.3, 2]], }, }, ], }, sleep: { baseline: { eyeBlinkLeft: 1, eyeBlinkRight: 1, eyesClosed: 0.6 }, speech: { deltaRate: 0, deltaPitch: -0.2, deltaVolume: 0 }, anims: [ { name: "breathing", delay: 1500, dt: [1000, 500, 1000], vs: { chestInhale: [0.6, 0.6, 0] } }, { name: "pose", alt: [{ delay: [5000, 20000], vs: { pose: ["side"] } }] }, { name: "head", delay: [1000, 5000], dt: [[2000, 1e4]], vs: { bodyRotateX: [[0, 0.4]], bodyRotateY: [[-0.1, 0.1]], bodyRotateZ: [[-0.04, 0.04]] }, }, { name: "eyes", delay: 10010, dt: [], vs: {} }, { name: "blink", delay: 10020, dt: [], vs: {} }, { name: "mouth", delay: 10030, dt: [], vs: {} }, { name: "misc", delay: 10040, dt: [], vs: {} }, ], }, }), (this.moodName = this.opt.avatarMood || "neutral"), (this.mood = this.animMoods[this.moodName]), !this.mood) ) ((this.moodName = "neutral"), (this.mood = this.animMoods.neutral)); ((this.animEmojis = { "\uD83D\uDE10": { dt: [300, 2000], rescale: [0, 1], vs: { pose: ["straight"], browInnerUp: [0.4], eyeWideLeft: [0.7], eyeWideRight: [0.7], mouthPressLeft: [0.6], mouthPressRight: [0.6], mouthRollLower: [0.3], mouthStretchLeft: [1], mouthStretchRight: [1], }, }, "\uD83D\uDE36": { link: "\uD83D\uDE10" }, "\uD83D\uDE0F": { dt: [300, 2000], rescale: [0, 1], vs: { eyeContact: [0], browDownRight: [0.1], browInnerUp: [0.7], browOuterUpRight: [0.2], eyeLookInRight: [0.7], eyeLookOutLeft: [0.7], eyeSquintLeft: [1], eyeSquintRight: [0.8], eyesRotateY: [0.7], mouthLeft: [0.4], mouthPucker: [0.4], mouthShrugLower: [0.3], mouthShrugUpper: [0.2], mouthSmile: [0.2], mouthSmileLeft: [0.4], mouthSmileRight: [0.2], mouthStretchLeft: [0.5], mouthUpperUpLeft: [0.6], noseSneerLeft: [0.7], }, }, "\uD83D\uDE42": { dt: [300, 2000], rescale: [0, 1], vs: { mouthSmile: [0.5] } }, "\uD83D\uDE43": { link: "\uD83D\uDE42" }, "\uD83D\uDE0A": { dt: [300, 2000], rescale: [0, 1], vs: { browInnerUp: [0.6], eyeSquintLeft: [1], eyeSquintRight: [1], mouthSmile: [0.7], noseSneerLeft: [0.7], noseSneerRight: [0.7], }, }, "\uD83D\uDE07": { link: "\uD83D\uDE0A" }, "\uD83D\uDE00": { dt: [300, 2000], rescale: [0, 1], vs: { browInnerUp: [0.6], jawOpen: [0.1], mouthDimpleLeft: [0.2], mouthDimpleRight: [0.2], mouthOpen: [0.3], mouthPressLeft: [0.3], mouthPressRight: [0.3], mouthRollLower: [0.4], mouthShrugUpper: [0.4], mouthSmile: [0.7], mouthUpperUpLeft: [0.3], mouthUpperUpRight: [0.3], noseSneerLeft: [0.4], noseSneerRight: [0.4], }, }, "\uD83D\uDE03": { dt: [300, 2000], rescale: [0, 1], vs: { browInnerUp: [0.6], eyeWideLeft: [0.7], eyeWideRight: [0.7], jawOpen: [0.1], mouthDimpleLeft: [0.2], mouthDimpleRight: [0.2], mouthOpen: [0.3], mouthPressLeft: [0.3], mouthPressRight: [0.3], mouthRollLower: [0.4], mouthShrugUpper: [0.4], mouthSmile: [0.7], mouthUpperUpLeft: [0.3], mouthUpperUpRight: [0.3], noseSneerLeft: [0.4], noseSneerRight: [0.4], }, }, "\uD83D\uDE04": { dt: [300, 2000], rescale: [0, 1], vs: { browInnerUp: [0.3], eyeSquintLeft: [1], eyeSquintRight: [1], jawOpen: [0.2], mouthDimpleLeft: [0.2], mouthDimpleRight: [0.2], mouthOpen: [0.3], mouthPressLeft: [0.3], mouthPressRight: [0.3], mouthRollLower: [0.4], mouthShrugUpper: [0.4], mouthSmile: [0.7], mouthUpperUpLeft: [0.3], mouthUpperUpRight: [0.3], noseSneerLeft: [0.4], noseSneerRight: [0.4], }, }, "\uD83D\uDE01": { dt: [300, 2000], rescale: [0, 1], vs: { browInnerUp: [0.3], eyeSquintLeft: [1], eyeSquintRight: [1], jawOpen: [0.3], mouthDimpleLeft: [0.2], mouthDimpleRight: [0.2], mouthPressLeft: [0.5], mouthPressRight: [0.5], mouthShrugUpper: [0.4], mouthSmile: [0.7], mouthUpperUpLeft: [0.3], mouthUpperUpRight: [0.3], noseSneerLeft: [0.4], noseSneerRight: [0.4], }, }, "\uD83D\uDE06": { dt: [300, 2000], rescale: [0, 1], vs: { browInnerUp: [0.3], eyeSquintLeft: [1], eyeSquintRight: [1], eyesClosed: [0.6], jawOpen: [0.3], mouthDimpleLeft: [0.2], mouthDimpleRight: [0.2], mouthPressLeft: [0.5], mouthPressRight: [0.5], mouthShrugUpper: [0.4], mouthSmile: [0.7], mouthUpperUpLeft: [0.3], mouthUpperUpRight: [0.3], noseSneerLeft: [0.4], noseSneerRight: [0.4], }, }, "\uD83D\uDE1D": { dt: [300, 100, 1500, 500, 500], rescale: [0, 0, 1, 0, 0], vs: { browInnerUp: [0.8], eyesClosed: [1], jawOpen: [0.7], mouthFunnel: [0.5], mouthSmile: [1], tongueOut: [0, 1, 1, 0], }, }, "\uD83D\uDE0B": { link: "\uD83D\uDE1D" }, "\uD83D\uDE1B": { link: "\uD83D\uDE1D" }, "\uD83D\uDE1B": { link: "\uD83D\uDE1D" }, "\uD83D\uDE1C": { link: "\uD83D\uDE1D" }, "\uD83E\uDD2A": { link: "\uD83D\uDE1D" }, "\uD83D\uDE02": { dt: [300, 2000], rescale: [0, 1], vs: { browInnerUp: [0.3], eyeSquintLeft: [1], eyeSquintRight: [1], eyesClosed: [0.6], jawOpen: [0.3], mouthDimpleLeft: [0.2], mouthDimpleRight: [0.2], mouthPressLeft: [0.5], mouthPressRight: [0.5], mouthShrugUpper: [0.4], mouthSmile: [0.7], mouthUpperUpLeft: [0.3], mouthUpperUpRight: [0.3], noseSneerLeft: [0.4], noseSneerRight: [0.4], }, }, "\uD83E\uDD23": { link: "\uD83D\uDE02" }, "\uD83D\uDE05": { link: "\uD83D\uDE02" }, "\uD83D\uDE09": { dt: [500, 200, 500, 500], rescale: [0, 0, 0, 1], vs: { mouthSmile: [0.5], mouthOpen: [0.2], mouthSmileLeft: [0, 0.5, 0], eyeBlinkLeft: [0, 0.7, 0], eyeBlinkRight: [0, 0, 0], bodyRotateX: [0.05, 0.05, 0.05, 0], bodyRotateZ: [-0.05, -0.05, -0.05, 0], browDownLeft: [0, 0.7, 0], cheekSquintLeft: [0, 0.7, 0], eyeSquintLeft: [0, 1, 0], eyesClosed: [0], }, }, "\uD83D\uDE2D": { dt: [1000, 1000], rescale: [0, 1], vs: { browInnerUp: [1], eyeSquintLeft: [1], eyeSquintRight: [1], eyesClosed: [0.1], jawOpen: [0], mouthFrownLeft: [1], mouthFrownRight: [1], mouthOpen: [0.5], mouthPucker: [0.5], mouthUpperUpLeft: [0.6], mouthUpperUpRight: [0.6], }, }, "\uD83E\uDD7A": { dt: [1000, 1000], rescale: [0, 1], vs: { browDownLeft: [0.2], browDownRight: [0.2], browInnerUp: [1], eyeWideLeft: [0.9], eyeWideRight: [0.9], eyesClosed: [0.1], mouthClose: [0.2], mouthFrownLeft: [1], mouthFrownRight: [1], mouthPressLeft: [0.4], mouthPressRight: [0.4], mouthPucker: [1], mouthRollLower: [0.6], mouthRollUpper: [0.2], mouthUpperUpLeft: [0.8], mouthUpperUpRight: [0.8], }, }, "\uD83D\uDE1E": { dt: [1000, 1000], rescale: [0, 1], vs: { browInnerUp: [0.7], eyeSquintLeft: [1], eyeSquintRight: [1], eyesClosed: [0.5], bodyRotateX: [0.3], mouthClose: [0.2], mouthFrownLeft: [1], mouthFrownRight: [1], mouthPucker: [1], mouthRollLower: [1], mouthShrugLower: [0.2], mouthUpperUpLeft: [0.8], mouthUpperUpRight: [0.8], }, }, "\uD83D\uDE14": { dt: [1000, 1000], rescale: [0, 1], vs: { browInnerUp: [1], eyeSquintLeft: [1], eyeSquintRight: [1], eyesClosed: [0.5], bodyRotateX: [0.3], mouthClose: [0.2], mouthFrownLeft: [1], mouthFrownRight: [1], mouthPressLeft: [0.4], mouthPressRight: [0.4], mouthPucker: [1], mouthRollLower: [0.6], mouthRollUpper: [0.2], mouthUpperUpLeft: [0.8], mouthUpperUpRight: [0.8], }, }, "\uD83D\uDE33": { dt: [1000, 1000], rescale: [0, 1], vs: { browInnerUp: [1], eyeWideLeft: [0.5], eyeWideRight: [0.5], eyesRotateY: [0.05], eyesRotateX: [0.05], mouthClose: [0.2], mouthFunnel: [0.5], mouthPucker: [0.4], mouthRollLower: [0.4], mouthRollUpper: [0.4], }, }, "☹️": { dt: [500, 1500], rescale: [0, 1], vs: { mouthFrownLeft: [1], mouthFrownRight: [1], mouthPucker: [0.1], mouthRollLower: [0.8] }, }, "\uD83D\uDE1A": { dt: [500, 1000, 1000], rescale: [0, 1, 0], vs: { browInnerUp: [0.6], eyeBlinkLeft: [1], eyeBlinkRight: [1], eyeSquintLeft: [1], eyeSquintRight: [1], mouthPucker: [0, 0.5], noseSneerLeft: [0, 0.7], noseSneerRight: [0, 0.7], viseme_U: [0, 1], }, }, "\uD83D\uDE18": { dt: [500, 500, 200, 500], rescale: [0, 0, 0, 1], vs: { browInnerUp: [0.6], eyeBlinkLeft: [0, 0, 1, 0], eyeBlinkRight: [0], eyesRotateY: [0], bodyRotateY: [0], bodyRotateX: [0, 0.05, 0.05, 0], bodyRotateZ: [0, -0.05, -0.05, 0], eyeSquintLeft: [1], eyeSquintRight: [1], mouthPucker: [0, 0.5, 0], noseSneerLeft: [0, 0.7], noseSneerRight: [0.7], viseme_U: [0, 1], }, }, "\uD83E\uDD70": { dt: [1000, 1000], rescale: [0, 1], vs: { browInnerUp: [0.6], eyeSquintLeft: [1], eyeSquintRight: [1], mouthSmile: [0.7], noseSneerLeft: [0.7], noseSneerRight: [0.7], }, }, "\uD83D\uDE0D": { dt: [1000, 1000], rescale: [0, 1], vs: { browInnerUp: [0.6], jawOpen: [0.1], mouthDimpleLeft: [0.2], mouthDimpleRight: [0.2], mouthOpen: [0.3], mouthPressLeft: [0.3], mouthPressRight: [0.3], mouthRollLower: [0.4], mouthShrugUpper: [0.4], mouthSmile: [0.7], mouthUpperUpLeft: [0.3], mouthUpperUpRight: [0.3], noseSneerLeft: [0.4], noseSneerRight: [0.4], }, }, "\uD83E\uDD29": { link: "\uD83D\uDE0D" }, "\uD83D\uDE21": { dt: [1000, 1500], rescale: [0, 1], vs: { browDownLeft: [1], browDownRight: [1], eyesLookUp: [0.2], jawForward: [0.3], mouthFrownLeft: [1], mouthFrownRight: [1], bodyRotateX: [0.15], }, }, "\uD83D\uDE20": { dt: [1000, 1500], rescale: [0, 1], vs: { browDownLeft: [1], browDownRight: [1], eyesLookUp: [0.2], jawForward: [0.3], mouthFrownLeft: [1], mouthFrownRight: [1], bodyRotateX: [0.15], }, }, "\uD83E\uDD2C": { link: "\uD83D\uDE20" }, "\uD83D\uDE12": { dt: [1000, 1000], rescale: [0, 1], vs: { eyeContact: [0], browDownRight: [0.1], browInnerUp: [0.7], browOuterUpRight: [0.2], eyeLookInRight: [0.7], eyeLookOutLeft: [0.7], eyeSquintLeft: [1], eyeSquintRight: [0.8], eyesRotateY: [0.7], mouthFrownLeft: [1], mouthFrownRight: [1], mouthLeft: [0.2], mouthPucker: [0.5], mouthRollLower: [0.2], mouthRollUpper: [0.2], mouthShrugLower: [0.2], mouthShrugUpper: [0.2], mouthStretchLeft: [0.5], }, }, "\uD83D\uDE31": { dt: [500, 1500], rescale: [0, 1], vs: { browInnerUp: [0.8], eyeWideLeft: [0.5], eyeWideRight: [0.5], jawOpen: [0.7], mouthFunnel: [0.5] }, }, "\uD83D\uDE2C": { dt: [500, 1500], rescale: [0, 1], vs: { browDownLeft: [1], browDownRight: [1], browInnerUp: [1], mouthDimpleLeft: [0.5], mouthDimpleRight: [0.5], mouthLowerDownLeft: [1], mouthLowerDownRight: [1], mouthPressLeft: [0.4], mouthPressRight: [0.4], mouthPucker: [0.5], mouthSmile: [0.1], mouthSmileLeft: [0.2], mouthSmileRight: [0.2], mouthStretchLeft: [1], mouthStretchRight: [1], mouthUpperUpLeft: [1], mouthUpperUpRight: [1], }, }, "\uD83D\uDE44": { dt: [500, 1500], rescale: [0, 1], vs: { browInnerUp: [0.8], eyeWideLeft: [1], eyeWideRight: [1], eyesRotateX: [-0.8], bodyRotateX: [0.15], mouthPucker: [0.5], mouthRollLower: [0.6], mouthRollUpper: [0.5], mouthShrugLower: [0], mouthSmile: [0], }, }, "\uD83E\uDD14": { dt: [500, 1500], rescale: [0, 1], vs: { browDownLeft: [1], browOuterUpRight: [1], eyeSquintLeft: [0.6], mouthFrownLeft: [0.7], mouthFrownRight: [0.7], mouthLowerDownLeft: [0.3], mouthPressRight: [0.4], mouthPucker: [0.1], mouthRight: [0.5], mouthRollLower: [0.5], mouthRollUpper: [0.2], handRight: [{ x: 0.1, y: 0.1, z: 0.1, d: 1000 }, { d: 1000 }], handFistRight: [0.1], }, }, "\uD83D\uDC40": { dt: [500, 1500], rescale: [0, 1], vs: { eyesRotateY: [-0.8] } }, "\uD83D\uDE34": { dt: [5000, 5000], rescale: [0, 1], vs: { eyeBlinkLeft: [1], eyeBlinkRight: [1], bodyRotateX: [0.2], bodyRotateZ: [0.1] }, }, "✋": { dt: [300, 2000], rescale: [0, 1], vs: { mouthSmile: [0.5], gesture: [["handup", 2, !0], null] } }, "\uD83E\uDD1A": { dt: [300, 2000], rescale: [0, 1], vs: { mouthSmile: [0.5], gesture: [["handup", 2], null] } }, "\uD83D\uDC4B": { link: "✋" }, "\uD83D\uDC4D": { dt: [300, 2000], rescale: [0, 1], vs: { mouthSmile: [0.5], gesture: [["thumbup", 2], null] } }, "\uD83D\uDC4E": { dt: [300, 2000], rescale: [0, 1], vs: { browDownLeft: [1], browDownRight: [1], eyesLookUp: [0.2], jawForward: [0.3], mouthFrownLeft: [1], mouthFrownRight: [1], bodyRotateX: [0.15], gesture: [["thumbdown", 2], null], }, }, "\uD83D\uDC4C": { dt: [300, 2000], rescale: [0, 1], vs: { mouthSmile: [0.5], gesture: [["ok", 2], null] } }, "\uD83E\uDD37‍♂️": { dt: [1000, 1500], rescale: [0, 1], vs: { gesture: [["shrug", 2], null] } }, "\uD83E\uDD37‍♀️": { link: "\uD83E\uDD37‍♂️" }, "\uD83E\uDD37": { link: "\uD83E\uDD37‍♂️" }, "\uD83D\uDE4F": { dt: [1500, 300, 1000], rescale: [0, 1, 0], vs: { eyeBlinkLeft: [0, 1], eyeBlinkRight: [0, 1], bodyRotateX: [0], bodyRotateZ: [0.1], gesture: [["namaste", 2], null], }, }, yes: { dt: [ [200, 500], [200, 500], [200, 500], [200, 500], ], vs: { headMove: [0], headRotateX: [[0.1, 0.2], 0.1, [0.1, 0.2], 0], headRotateZ: [[-0.2, 0.2]] }, }, no: { dt: [ [200, 500], [200, 500], [200, 500], [200, 500], [200, 500], ], vs: { headMove: [0], headRotateY: [[-0.1, -0.05], [0.05, 0.1], [-0.1, -0.05], [0.05, 0.1], 0], headRotateZ: [[-0.2, 0.2]], }, }, }), (this.mtAvatar = {}), (this.mtCustoms = [ "handFistLeft", "handFistRight", "bodyRotateX", "bodyRotateY", "bodyRotateZ", "headRotateX", "headRotateY", "headRotateZ", "chestInhale", ]), (this.mtEasingDefault = this.sigmoidFactory(5)), (this.mtAccDefault = 0.01), (this.mtAccExceptions = { eyeBlinkLeft: 0.1, eyeBlinkRight: 0.1, eyeLookOutLeft: 0.1, eyeLookInLeft: 0.1, eyeLookOutRight: 0.1, eyeLookInRight: 0.1, }), (this.mtMaxVDefault = 5), (this.mtMaxVExceptions = { bodyRotateX: 1, bodyRotateY: 1, bodyRotateZ: 1 }), (this.mtBaselineDefault = 0), (this.mtBaselineExceptions = { bodyRotateX: null, bodyRotateY: null, bodyRotateZ: null, eyeLookOutLeft: null, eyeLookInLeft: null, eyeLookOutRight: null, eyeLookInRight: null, eyesLookDown: null, eyesLookUp: null, }), (this.mtMinDefault = 0), (this.mtMinExceptions = { bodyRotateX: -1, bodyRotateY: -1, bodyRotateZ: -1, headRotateX: -1, headRotateY: -1, headRotateZ: -1, }), (this.mtMaxDefault = 1), (this.mtMaxExceptions = {}), (this.mtLimits = { eyeBlinkLeft: (o) => Math.max(o, (this.mtAvatar.eyesLookDown.value + this.mtAvatar.browDownLeft.value) / 2), eyeBlinkRight: (o) => Math.max(o, (this.mtAvatar.eyesLookDown.value + this.mtAvatar.browDownRight.value) / 2), }), (this.mtOnchange = { eyesLookDown: () => { ((this.mtAvatar.eyeBlinkLeft.needsUpdate = !0), (this.mtAvatar.eyeBlinkRight.needsUpdate = !0)); }, browDownLeft: () => { this.mtAvatar.eyeBlinkLeft.needsUpdate = !0; }, browDownRight: () => { this.mtAvatar.eyeBlinkRight.needsUpdate = !0; }, }), (this.mtRandomized = [ "mouthDimpleLeft", "mouthDimpleRight", "mouthLeft", "mouthPressLeft", "mouthPressRight", "mouthStretchLeft", "mouthStretchRight", "mouthShrugLower", "mouthShrugUpper", "noseSneerLeft", "noseSneerRight", "mouthRollLower", "mouthRollUpper", "browDownLeft", "browDownRight", "browOuterUpLeft", "browOuterUpRight", "cheekPuff", "cheekSquintLeft", "cheekSquintRight", ]), (this.mtExtras = [ { key: "mouthOpen", mix: { jawOpen: 0.5 } }, { key: "mouthSmile", mix: { mouthSmileLeft: 0.8, mouthSmileRight: 0.8 } }, { key: "eyesClosed", mix: { eyeBlinkLeft: 1, eyeBlinkRight: 1 } }, { key: "eyesLookUp", mix: { eyeLookUpLeft: 1, eyeLookUpRight: 1 } }, { key: "eyesLookDown", mix: { eyeLookDownLeft: 1, eyeLookDownRight: 1 } }, ]), (this.animQueue = []), (this.animClips = []), (this.animPoses = []), (this.animate = this.animate.bind(this)), (this._raf = null), (this.animFrameDur = 1000 / this.opt.modelFPS), (this.animClock = 0), (this.animSlowdownRate = 1), (this.animTimeLast = 0), (this.easing = this.sigmoidFactory(5)), (this.lipsync = {}), this.opt.lipsyncModules.forEach((o) => this.lipsyncGetProcessor(o)), (this.visemeNames = ["aa", "E", "I", "O", "U", "PP", "SS", "TH", "DD", "FF", "kk", "nn", "RR", "CH", "sil"]), (this.segmenter = new Intl.Segmenter("en", { granularity: "grapheme" })), this.initAudioGraph(), (this.audioPlaylist = []), (this.volumeFrequencyData = new Uint8Array(16)), (this.volumeMax = 0), (this.volumeHeadBase = 0), (this.volumeHeadTarget = 0), (this.volumeHeadCurrent = 0), (this.volumeHeadVelocity = 0.15), (this.volumeHeadEasing = this.sigmoidFactory(3)), (this.isListening = !1), (this.listeningAnalyzer = null), (this.listeningActive = !1), (this.listeningVolume = 0), (this.listeningSilenceThresholdLevel = this.opt.listeningSilenceThresholdLevel), (this.listeningSilenceThresholdMs = this.opt.listeningSilenceThresholdMs), (this.listeningSilenceDurationMax = this.opt.listeningSilenceDurationMax), (this.listeningActiveThresholdLevel = this.opt.listeningActiveThresholdLevel), (this.listeningActiveThresholdMs = this.opt.listeningActiveThresholdMs), (this.listeningActiveDurationMax = this.opt.listeningActiveDurationMax), (this.listeningTimer = 0), (this.listeningTimerTotal = 0), (this.dracoEnabled = this.opt.dracoEnabled), (this.dracoDecoderPath = this.opt.dracoDecoderPath)); let i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; this.b64Lookup = typeof Uint8Array > "u" ? [] : new Uint8Array(256); for (let o = 0; o < i.length; o++) this.b64Lookup[i.charCodeAt(o)] = o; if ( ((this.stateName = "idle"), (this.speechQueue = []), (this.isSpeaking = !1), (this.isListening = !1), this.opt.ttsEndpoint) ) { let o = new Audio(); if (o.canPlayType("audio/ogg")) this.ttsAudioEncoding = "OGG-OPUS"; else if (o.canPlayType("audio/mp3")) this.ttsAudioEncoding = "MP3"; else throw Error("There was no support for either OGG or MP3 audio."); } if (((this.isAvatarOnly = this.opt.avatarOnly), this.isAvatarOnly)) ((this.scene = this.opt.avatarOnlyScene), (this.camera = this.opt.avatarOnlyCamera)); else { ((this.renderer = new Dc({ antialias: !0, alpha: !0 })), this.renderer.setPixelRatio(this.opt.modelPixelRatio * window.devicePixelRatio), this.renderer.setSize(this.nodeAvatar.clientWidth, this.nodeAvatar.clientHeight), (this.renderer.outputColorSpace = lt), (this.renderer.toneMapping = Ys), (this.renderer.shadowMap.enabled = !1), this.nodeAvatar.appendChild(this.renderer.domElement), (this.camera = new It(10, this.nodeAvatar.clientWidth / this.nodeAvatar.clientHeight, 0.1, 2000)), (this.scene = new _i()), (this.lightAmbient = new lr(new re(this.opt.lightAmbientColor), this.opt.lightAmbientIntensity)), (this.lightDirect = new Qn(new re(this.opt.lightDirectColor), this.opt.lightDirectIntensity)), (this.lightSpot = new Yi( new re(this.opt.lightSpotColor), this.opt.lightSpotIntensity, 0, this.opt.lightSpotDispersion, )), this.setLighting(this.opt)); let o = new Zi(this.renderer); (o.compileEquirectangularShader(), (this.scene.environment = o.fromScene(new nh()).texture), (this.resizeobserver = new ResizeObserver(this.onResize.bind(this))), this.resizeobserver.observe(this.nodeAvatar), (this.controls = new Oc(this.camera, this.renderer.domElement)), (this.controls.enableZoom = this.opt.cameraZoomEnable), (this.controls.enableRotate = this.opt.cameraRotateEnable), (this.controls.enablePan = this.opt.cameraPanEnable), (this.controls.minDistance = 2), (this.controls.maxDistance = 2000), (this.controls.autoRotateSpeed = 0), (this.controls.autoRotate = !1), this.controls.update(), (this.cameraClock = null)); } this.ikMesh = new Bi(); let s = { LeftShoulder: null, LeftArm: "LeftShoulder", LeftForeArm: "LeftArm", LeftHand: "LeftForeArm", LeftHandMiddle1: "LeftHand", RightShoulder: null, RightArm: "RightShoulder", RightForeArm: "RightArm", RightHand: "RightForeArm", RightHandMiddle1: "RightHand", }, r = []; (Object.entries(s).forEach((o, a) => { let l = new Kn(); if (((l.name = o[0]), o[1])) this.ikMesh.getObjectByName(o[1]).add(l); else this.ikMesh.add(l); r.push(l); }), this.ikMesh.bind(new Si(r)), (this.dynamicbones = new ih()), (this.isStreaming = !1), (this.streamWorkletNode = null), (this.streamAudioStartTime = null), (this.streamWaitForAudioChunks = !0), (this.streamLipsyncLang = null), (this.streamLipsyncType = "visemes"), (this.streamLipsyncQueue = [])); } initAudioGraph(e = null) { if (this.audioCtx && this.audioCtx.state !== "closed") this.audioCtx.close(); if (e) this.audioCtx = new AudioContext({ sampleRate: e }); else this.audioCtx = new AudioContext(); if ( ((this.audioSpeechSource = this.audioCtx.createBufferSource()), (this.audioBackgroundSource = this.audioCtx.createBufferSource()), (this.audioBackgroundGainNode = this.audioCtx.createGain()), (this.audioSpeechGainNode = this.audioCtx.createGain()), (this.audioStreamGainNode = this.audioCtx.createGain()), (this.audioAnalyzerNode = this.audioCtx.createAnalyser()), (this.audioAnalyzerNode.fftSize = 256), (this.audioAnalyzerNode.smoothingTimeConstant = 0.1), (this.audioAnalyzerNode.minDecibels = -70), (this.audioAnalyzerNode.maxDecibels = -10), (this.audioReverbNode = this.audioCtx.createConvolver()), this.audioBackgroundGainNode.connect(this.audioReverbNode), this.audioAnalyzerNode.connect(this.audioSpeechGainNode), this.audioSpeechGainNode.connect(this.audioReverbNode), this.audioStreamGainNode.connect(this.audioReverbNode), this.audioReverbNode.connect(this.audioCtx.destination), this.setReverb(this.currentReverb || null), this.setMixerGain(this.opt.mixerGainSpeech, this.opt.mixerGainBackground), (this.workletLoaded = !1), this.streamWorkletNode) ) { try { (this.streamWorkletNode.port.postMessage({ type: "stop" }), this.streamWorkletNode.disconnect(), (this.isStreaming = !1)); } catch (t) { console.error("Error disconnecting streamWorkletNode:", t); } this.streamWorkletNode = null; } } valueFn(e) { return typeof e === "function" ? e() : e; } deepCopy(e, t = null) { let n = JSON.parse(JSON.stringify(e)); if (t && typeof t === "function") t(n); return n; } b64ToArrayBuffer(e) { let t = (3 * e.length) / 4; if (e[e.length - 1] === "=") { if ((t--, e[e.length - 2] === "=")) t--; } let n = new ArrayBuffer(t), i = new Uint8Array(n), s, r = 0, o, a, l, c; for (s = 0; s < e.length; s += 4) ((o = this.b64Lookup[e.charCodeAt(s)]), (a = this.b64Lookup[e.charCodeAt(s + 1)]), (l = this.b64Lookup[e.charCodeAt(s + 2)]), (c = this.b64Lookup[e.charCodeAt(s + 3)]), (i[r++] = (o << 2) | (a >> 4)), (i[r++] = ((a & 15) << 4) | (l >> 2)), (i[r++] = ((l & 3) << 6) | (c & 63))); return n; } concatArrayBuffers(e) { if (e.length === 1) return e[0]; let t = 0; for (let r = 0; r < e.length; r++) t += e[r].byteLength; let n = new ArrayBuffer(t), i = new Uint8Array(n), s = 0; for (let r = 0; r < e.length; r++) (i.set(new Uint8Array(e[r]), s), (s += e[r].byteLength)); return n; } pcmToAudioBuffer(e) { let t = new Int16Array(e), n = new Float32Array(t.length); for (let s = 0; s < t.length; s++) n[s] = t[s] >= 32768 ? -(65536 - t[s]) / 32768 : t[s] / 32767; let i = this.audioCtx.createBuffer(1, n.length, this.opt.pcmSampleRate); return (i.copyToChannel(n, 0, 0), i); } propsToThreeObjects(e) { let t = {}; for (let [n, i] of Object.entries(e)) { let s = n.split("."), r = Array.isArray(i.x) ? this.gaussianRandom(...i.x) : i.x, o = Array.isArray(i.y) ? this.gaussianRandom(...i.y) : i.y, a = Array.isArray(i.z) ? this.gaussianRandom(...i.z) : i.z; if (s[1] === "position" || s[1] === "scale") t[n] = new E(r, o, a); else if (s[1] === "rotation") ((n = s[0] + ".quaternion"), (t[n] = new Ne().setFromEuler(new tt(r, o, a, "XYZ")).normalize())); else if (s[1] === "quaternion") t[n] = new Ne(r, o, a, i.w).normalize(); } return t; } clearThree(e) { while (e.children.length) (this.clearThree(e.children[0]), e.remove(e.children[0])); if (e.geometry) e.geometry.dispose(); if (e.material) if (Array.isArray(e.material)) e.material.forEach((t) => { if (t.map) t.map.dispose(); t.dispose(); }); else { if (e.material.map) e.material.map.dispose(); e.material.dispose(); } } addMixedMorphTarget(e, t, n, i = !1) { e.forEach((s) => { if (!i && s.morphTargetDictionary.hasOwnProperty(t)) return; let r = s.geometry, o = null, a = null; for (let [l, c] of Object.entries(n)) if (s.morphTargetDictionary.hasOwnProperty(l)) { let h = s.morphTargetDictionary[l], u = r.morphAttributes.position[h], d = r.morphAttributes.normal?.[h]; if (!o) { if (((o = new at(u.count * 3, 3)), d)) a = new at(u.count * 3, 3); } for (let f = 0; f < u.count; f++) { let m = o.getX(f) + u.getX(f) * c, y = o.getY(f) + u.getY(f) * c, p = o.getZ(f) + u.getZ(f) * c; o.setXYZ(f, m, y, p); } if (d) for (let f = 0; f < u.count; f++) { let m = a.getX(f) + d.getX(f) * c, y = a.getY(f) + d.getY(f) * c, p = a.getZ(f) + d.getZ(f) * c; a.setXYZ(f, m, y, p); } } if (o) { if ((r.morphAttributes.position.push(o), a)) r.morphAttributes.normal.push(a); let l = r.morphAttributes.position.length - 1; ((s.morphTargetInfluences[l] = 0), (s.morphTargetDictionary[t] = l)); } }); } async showAvatar(e, t = null) { if (!e || !e.hasOwnProperty("url")) throw Error("Invalid parameter. The avatar must have at least 'url' specified."); let n = new Wc(); if (this.dracoEnabled) { let l = new Yc(); (l.setDecoderPath(this.dracoDecoderPath), n.setDRACOLoader(l)); } let i = await n.loadAsync(e.url, t), s = [this.opt.modelRoot]; if ( (this.posePropNames.forEach((l) => s.push(l.split(".")[0])), s.forEach((l) => { if (!i.scene.getObjectByName(l)) throw Error("Avatar object " + l + " not found"); }), this.stop(), (this.avatar = e), this.dynamicbones.dispose(), this.mixer) ) (this.mixer.removeEventListener("finished", this._mixerHandler), this.mixer.stopAllAction(), this.mixer.uncacheRoot(this.armature), (this.mixer = null), (this._mixerHandler = null)); if (this.isAvatarOnly) { if (this.armature) this.clearThree(this.armature); } else if (this.armature) this.clearThree(this.scene); if ( ((this.armature = i.scene.getObjectByName(this.opt.modelRoot)), this.armature.scale.setScalar(1), (this.animations = i.animations), (this.userData = i.userData), (this.morphs = []), this.armature.traverse((l) => { if (l.morphTargetInfluences && l.morphTargetInfluences.length && l.morphTargetDictionary) this.morphs.push(l); l.frustumCulled = !1; }), this.morphs.length === 0) ) throw Error("Blend shapes not found"); let r = new Set(this.mtCustoms); (this.morphs.forEach((l) => { Object.keys(l.morphTargetDictionary).forEach((c) => r.add(c)); }), this.mtExtras.forEach((l) => { if (!r.has(l.key)) (this.addMixedMorphTarget(this.morphs, l.key, l.mix), r.add(l.key)); })); let o = {}; if ( (r.forEach((l) => { ((o[l] = { fixed: null, realtime: null, system: null, systemd: null, newvalue: null, ref: null, min: this.mtMinExceptions.hasOwnProperty(l) ? this.mtMinExceptions[l] : this.mtMinDefault, max: this.mtMaxExceptions.hasOwnProperty(l) ? this.mtMaxExceptions[l] : this.mtMaxDefault, easing: this.mtEasingDefault, base: null, v: 0, needsUpdate: !0, acc: (this.mtAccExceptions.hasOwnProperty(l) ? this.mtAccExceptions[l] : this.mtAccDefault) / 1000, maxv: (this.mtMaxVExceptions.hasOwnProperty(l) ? this.mtMaxVExceptions[l] : this.mtMaxVDefault) / 1000, limit: this.mtLimits.hasOwnProperty(l) ? this.mtLimits[l] : null, onchange: this.mtOnchange.hasOwnProperty(l) ? this.mtOnchange[l] : null, baseline: this.avatar.baseline?.hasOwnProperty(l) ? this.avatar.baseline[l] : this.mtBaselineExceptions.hasOwnProperty(l) ? this.mtBaselineExceptions[l] : this.mtBaselineDefault, ms: [], is: [], }), (o[l].value = o[l].baseline), (o[l].applied = o[l].baseline)); let c = this.mtAvatar[l]; if (c) ["fixed", "system", "systemd", "realtime", "base", "v", "value", "applied"].forEach((h) => { o[l][h] = c[h]; }); this.morphs.forEach((h) => { let u = h.morphTargetDictionary[l]; if (u !== void 0) (o[l].ms.push(h.morphTargetInfluences), o[l].is.push(u), (h.morphTargetInfluences[u] = o[l].applied)); }); }), (this.mtAvatar = o), (this.poseAvatar = { props: {} }), this.posePropNames.forEach((l) => { let c = l.split("."), h = this.armature.getObjectByName(c[0]); if (((this.poseAvatar.props[l] = h[c[1]]), this.poseBase.props.hasOwnProperty(l))) this.poseAvatar.props[l].copy(this.poseBase.props[l]); else this.poseBase.props[l] = this.poseAvatar.props[l].clone(); if (this.poseDelta.props.hasOwnProperty(l) && !this.poseTarget.props.hasOwnProperty(l)) this.poseTarget.props[l] = this.poseAvatar.props[l].clone(); ((this.poseTarget.props[l].t = this.animClock), (this.poseTarget.props[l].d = 2000)); }), this.ikMesh.traverse((l) => { if (l.isBone) l.position.copy(this.armature.getObjectByName(l.name).position); }), this.isAvatarOnly) ) { if (this.scene) this.scene.add(this.armature); } else (this.scene.add(i.scene), this.scene.add(this.lightAmbient), this.scene.add(this.lightDirect), this.scene.add(this.lightSpot), (this.lightSpot.target = this.armature.getObjectByName("Head"))); if (e.hasOwnProperty("modelDynamicBones")) try { this.dynamicbones.setup(this.scene, this.armature, e.modelDynamicBones); } catch (l) { console.error("Dynamic bones setup failed: " + l); } ((this.objectLeftToeBase = this.armature.getObjectByName("LeftToeBase")), (this.objectRightToeBase = this.armature.getObjectByName("RightToeBase")), (this.objectLeftEye = this.armature.getObjectByName("LeftEye")), (this.objectRightEye = this.armature.getObjectByName("RightEye")), (this.objectLeftArm = this.armature.getObjectByName("LeftArm")), (this.objectRightArm = this.armature.getObjectByName("RightArm")), (this.objectHips = this.armature.getObjectByName("Hips")), (this.objectHead = this.armature.getObjectByName("Head")), (this.objectNeck = this.armature.getObjectByName("Neck"))); let a = new E(); if ((this.objectLeftEye.getWorldPosition(a), (this.avatarHeight = a.y + 0.2), !this.viewName)) this.setView(this.opt.cameraView); (this.setMood(this.avatar.avatarMood || this.moodName || this.opt.avatarMood), this.start()); } getViewNames() { return ["full", "mid", "upper", "head"]; } getView() { return this.viewName; } setView(e, t = null) { if (((e = e || this.viewName), e !== "full" && e !== "upper" && e !== "head" && e !== "mid")) return; if (!this.armature) { this.opt.cameraView = e; return; } if (((this.viewName = e || this.viewName), (t = t || {}), this.isAvatarOnly)) return; let n = t.hasOwnProperty("cameraX") ? t.cameraX : this.opt.cameraX, i = t.hasOwnProperty("cameraY") ? t.cameraY : this.opt.cameraY, s = t.hasOwnProperty("cameraDistance") ? t.cameraDistance : this.opt.cameraDistance, r = t.hasOwnProperty("cameraRotateX") ? t.cameraRotateX : this.opt.cameraRotateX, o = t.hasOwnProperty("cameraRotateY") ? t.cameraRotateY : this.opt.cameraRotateY, a = this.camera.fov * (Math.PI / 180), l = -n * Math.tan(a / 2), c = (1 - i) * Math.tan(a / 2), h = s; switch (this.viewName) { case "head": ((h += 2), (c = c * h + (4 * this.avatarHeight) / 5)); break; case "upper": ((h += 4.5), (c = c * h + (2 * this.avatarHeight) / 3)); break; case "mid": ((h += 8), (c = c * h + this.avatarHeight / 3)); break; default: ((h += 12), (c = c * h)); } if ( ((l = l * h), (this.controlsEnd = new E(l, c, 0)), (this.cameraEnd = new E(l, c, h).applyEuler(new tt(r, o, 0))), this.cameraClock === null) ) (this.controls.target.copy(this.controlsEnd), this.camera.position.copy(this.cameraEnd)); ((this.controlsStart = this.controls.target.clone()), (this.cameraStart = this.camera.position.clone()), (this.cameraClock = 0)); } setLighting(e) { if (this.isAvatarOnly) return; if (((e = e || {}), e.hasOwnProperty("lightAmbientColor"))) this.lightAmbient.color.set(new re(e.lightAmbientColor)); if (e.hasOwnProperty("lightAmbientIntensity")) ((this.lightAmbient.intensity = e.lightAmbientIntensity), (this.lightAmbient.visible = e.lightAmbientIntensity !== 0)); if (e.hasOwnProperty("lightDirectColor")) this.lightDirect.color.set(new re(e.lightDirectColor)); if (e.hasOwnProperty("lightDirectIntensity")) ((this.lightDirect.intensity = e.lightDirectIntensity), (this.lightDirect.visible = e.lightDirectIntensity !== 0)); if (e.hasOwnProperty("lightDirectPhi") && e.hasOwnProperty("lightDirectTheta")) this.lightDirect.position.setFromSphericalCoords(2, e.lightDirectPhi, e.lightDirectTheta); if (e.hasOwnProperty("lightSpotColor")) this.lightSpot.color.set(new re(e.lightSpotColor)); if (e.hasOwnProperty("lightSpotIntensity")) ((this.lightSpot.intensity = e.lightSpotIntensity), (this.lightSpot.visible = e.lightSpotIntensity !== 0)); if (e.hasOwnProperty("lightSpotPhi") && e.hasOwnProperty("lightSpotTheta")) (this.lightSpot.position.setFromSphericalCoords(2, e.lightSpotPhi, e.lightSpotTheta), this.lightSpot.position.add(new E(0, 1.5, 0))); if (e.hasOwnProperty("lightSpotDispersion")) this.lightSpot.angle = e.lightSpotDispersion; } render() { if (this.isRunning && !this.isAvatarOnly) this.renderer.render(this.scene, this.camera); } onResize() { if (!this.isAvatarOnly) ((this.camera.aspect = this.nodeAvatar.clientWidth / this.nodeAvatar.clientHeight), this.camera.updateProjectionMatrix(), this.renderer.setSize(this.nodeAvatar.clientWidth, this.nodeAvatar.clientHeight), this.controls.update(), this.render()); } updatePoseBase(e) { for (let [t, n] of Object.entries(this.poseTarget.props)) { let i = this.poseAvatar.props[t]; if (i) { let s = (e - n.t) / n.d; if (s > 1 || !this.poseBase.props.hasOwnProperty(t)) i.copy(n); else if (i.isQuaternion) i.copy(this.poseBase.props[t].slerp(n, this.easing(s))); else if (i.isVector3) i.copy(this.poseBase.props[t].lerp(n, this.easing(s))); } } } updatePoseDelta() { for (let [e, t] of Object.entries(this.poseDelta.props)) { if (t.x === 0 && t.y === 0 && t.z === 0) continue; ft.set(t.x, t.y, t.z); let n = this.poseAvatar.props[e]; if (n.isQuaternion) (Lt.setFromEuler(ft), n.multiply(Lt)); else if (n.isVector3) n.add(ft); } } updateMorphTargets(e) { for (let [t, n] of Object.entries(this.mtAvatar)) { if (!n.needsUpdate) continue; let i = null, s = null; if (n.fixed !== null) { if ( ((i = n.fixed), (n.system = null), (n.systemd = null), (n.newvalue = null), n.ref && n.ref.hasOwnProperty(t)) ) delete n.ref[t]; if (((n.ref = null), (n.base = null), n.value === i)) { n.needsUpdate = !1; continue; } } else if (n.realtime !== null) ((n.ref = null), (n.base = null), (s = n.realtime)); else if (n.system !== null) { if (((i = n.system), (n.newvalue = null), n.ref && n.ref.hasOwnProperty(t))) delete n.ref[t]; if (((n.ref = null), (n.base = null), n.systemd !== null)) if (n.systemd === 0) ((i = null), (n.system = null), (n.systemd = null)); else { if (((n.systemd -= e), n.systemd < 0)) n.systemd = 0; if (n.value === i) i = null; } else if (n.value === i) ((i = null), (n.system = null)); } else if (n.newvalue !== null) ((n.ref = null), (n.base = null), (s = n.newvalue), (n.newvalue = null)); else if (n.base !== null) { if (((i = n.base), (n.ref = null), n.value === i)) ((i = null), (n.base = null), (n.needsUpdate = !1)); } else if (((n.ref = null), n.baseline !== null && n.value !== n.baseline)) ((i = n.baseline), (n.base = n.baseline)); else n.needsUpdate = !1; if (i !== null) { let r = i - n.value; if (r >= 0) if (r < 0.005) ((s = i), (n.v = 0)); else { if (n.v < n.maxv) n.v += n.acc * e; if (n.v >= 0) s = n.value + r * (1 - Math.exp(-n.v * e)); else s = n.value + n.v * e * (1 - Math.exp(n.v * e)); } else if (r > -0.005) ((s = i), (n.v = 0)); else { if (n.v > -n.maxv) n.v -= n.acc * e; if (n.v >= 0) s = n.value + n.v * e * (1 - Math.exp(-n.v * e)); else s = n.value + r * (1 - Math.exp(n.v * e)); } } if (n.limit !== null) { if (s !== null && s !== n.value) { if (((n.value = s), n.onchange !== null)) n.onchange(s); } if (((s = n.limit(n.value)), s === n.applied)) continue; } else { if (s === null || s === n.value) continue; if (((n.value = s), n.onchange !== null)) n.onchange(s); } if (((n.applied = s), n.applied < n.min)) n.applied = n.min; if (n.applied > n.max) n.applied = n.max; switch (t) { case "headRotateX": this.poseDelta.props["Head.quaternion"].x = n.applied + this.mtAvatar.bodyRotateX.applied; break; case "headRotateY": this.poseDelta.props["Head.quaternion"].y = n.applied + this.mtAvatar.bodyRotateY.applied; break; case "headRotateZ": this.poseDelta.props["Head.quaternion"].z = n.applied + this.mtAvatar.bodyRotateZ.applied; break; case "bodyRotateX": ((this.poseDelta.props["Head.quaternion"].x = n.applied + this.mtAvatar.headRotateX.applied), (this.poseDelta.props["Spine1.quaternion"].x = n.applied / 2), (this.poseDelta.props["Spine.quaternion"].x = n.applied / 8), (this.poseDelta.props["Hips.quaternion"].x = n.applied / 24)); break; case "bodyRotateY": ((this.poseDelta.props["Head.quaternion"].y = n.applied + this.mtAvatar.headRotateY.applied), (this.poseDelta.props["Spine1.quaternion"].y = n.applied / 2), (this.poseDelta.props["Spine.quaternion"].y = n.applied / 2), (this.poseDelta.props["Hips.quaternion"].y = n.applied / 4), (this.poseDelta.props["LeftUpLeg.quaternion"].y = n.applied / 2), (this.poseDelta.props["RightUpLeg.quaternion"].y = n.applied / 2), (this.poseDelta.props["LeftLeg.quaternion"].y = n.applied / 4), (this.poseDelta.props["RightLeg.quaternion"].y = n.applied / 4)); break; case "bodyRotateZ": ((this.poseDelta.props["Head.quaternion"].z = n.applied + this.mtAvatar.headRotateZ.applied), (this.poseDelta.props["Spine1.quaternion"].z = n.applied / 12), (this.poseDelta.props["Spine.quaternion"].z = n.applied / 12), (this.poseDelta.props["Hips.quaternion"].z = n.applied / 24)); break; case "handFistLeft": case "handFistRight": let r = t.substring(8); ["HandThumb", "HandIndex", "HandMiddle", "HandRing", "HandPinky"].forEach((c, h) => { if (h === 0) ((this.poseDelta.props[r + c + "1.quaternion"].x = 0), (this.poseDelta.props[r + c + "2.quaternion"].z = (r === "Left" ? -1 : 1) * n.applied), (this.poseDelta.props[r + c + "3.quaternion"].z = (r === "Left" ? -1 : 1) * n.applied)); else ((this.poseDelta.props[r + c + "1.quaternion"].x = n.applied), (this.poseDelta.props[r + c + "2.quaternion"].x = 1.5 * n.applied), (this.poseDelta.props[r + c + "3.quaternion"].x = 1.5 * n.applied)); }); break; case "chestInhale": let o = n.applied / 20, a = { x: o, y: o / 2, z: 3 * o }, l = { x: 1 / (1 + o) - 1, y: 1 / (1 + o / 2) - 1, z: 1 / (1 + 3 * o) - 1 }; ((this.poseDelta.props["Spine1.scale"] = a), (this.poseDelta.props["Neck.scale"] = l), (this.poseDelta.props["LeftArm.scale"] = l), (this.poseDelta.props["RightArm.scale"] = l)); break; default: for (let c = 0, h = n.ms.length; c < h; c++) n.ms[c][n.is[c]] = n.applied; } } } getPoseString(e, t = 1000) { let n = "{"; return ( Object.entries(e).forEach((i, s) => { let r = i[0].split("."); if (r[1] === "position" || r[1] === "rotation" || r[1] === "quaternion") { let o = r[1] === "quaternion" ? r[0] + ".rotation" : i[0], a = i[1].isQuaternion ? new tt().setFromQuaternion(i[1]) : i[1]; ((n += (s ? ", " : "") + "'" + o + "':{"), (n += "x:" + Math.round(a.x * t) / t), (n += ", y:" + Math.round(a.y * t) / t), (n += ", z:" + Math.round(a.z * t) / t), (n += "}")); } }), (n += "}"), n ); } getPoseTemplateProp(e) { let t = e.split("."), n = t[0] + "." + (t[1] === "rotation" ? "quaternion" : t[1]); if (this.gesture && this.gesture.hasOwnProperty(n)) return this.gesture[n].clone(); else { let i = t[0] + "." + (t[1] === "quaternion" ? "rotation" : t[1]); if (!this.poseWeightOnLeft) { if (i.startsWith("Left")) ((i = "Right" + i.substring(4)), (n = "Right" + n.substring(4))); else if (i.startsWith("Right")) ((i = "Left" + i.substring(5)), (n = "Left" + n.substring(5))); } let s; if (this.poseTarget.template.props.hasOwnProperty(n)) { let r = {}; ((r[n] = this.poseTarget.template.props[n]), (s = this.propsToThreeObjects(r)[n])); } else if (this.poseTarget.template.props.hasOwnProperty(i)) { let r = {}; ((r[i] = this.poseTarget.template.props[i]), (s = this.propsToThreeObjects(r)[n])); } if (s && !this.poseWeightOnLeft && s.isQuaternion) ((s.x *= -1), (s.w *= -1)); return s; } } mirrorPose(e) { let t = {}; for (let [n, i] of Object.entries(e)) { if (i.isQuaternion) { if (n.startsWith("Left")) n = "Right" + n.substring(4); else if (n.startsWith("Right")) n = "Left" + n.substring(5); ((i.x *= -1), (i.w *= -1)); } ((t[n] = i.clone()), (t[n].t = i.t), (t[n].d = i.d)); } return t; } poseFactory(e, t = 2000) { let n = { template: e, props: this.propsToThreeObjects(e.props) }; for (let [i, s] of Object.entries(n.props)) { if ( this.opt.modelMovementFactor < 1 && e.standing && (i === "Hips.quaternion" || i === "Spine.quaternion" || i === "Spine1.quaternion" || i === "Spine2.quaternion" || i === "Neck.quaternion" || i === "LeftUpLeg.quaternion" || i === "LeftLeg.quaternion" || i === "RightUpLeg.quaternion" || i === "RightLeg.quaternion") ) { let r = this.poseStraight[i], o = s.angleTo(r); s.rotateTowards(r, (1 - this.opt.modelMovementFactor) * o); } ((s.t = this.animClock), (s.d = t)); } return n; } setPoseFromTemplate(e, t = 2000) { let n = e && this.poseTarget && this.poseTarget.template && ((this.poseTarget.template.standing && e.lying) || (this.poseTarget.template.lying && e.standing)), i = e && e === this.poseCurrentTemplate, s = this.poseWeightOnLeft, r = n ? 1000 : t; if (n) ((this.poseCurrentTemplate = this.poseTemplates.oneknee), setTimeout(() => { this.setPoseFromTemplate(e, t); }, r)); else this.poseCurrentTemplate = e || this.poseCurrentTemplate; if ( ((this.poseTarget = this.poseFactory(this.poseCurrentTemplate, r)), (this.poseWeightOnLeft = !0), (!i && !s) || (i && s)) ) ((this.poseTarget.props = this.mirrorPose(this.poseTarget.props)), (this.poseWeightOnLeft = !this.poseWeightOnLeft)); if (this.gesture) { for (let [o, a] of Object.entries(this.gesture)) if (this.poseTarget.props.hasOwnProperty(o)) (this.poseTarget.props[o].copy(a), (this.poseTarget.props[o].t = a.t), (this.poseTarget.props[o].d = a.d)); } Object.keys(this.poseDelta.props).forEach((o) => { if (!this.poseTarget.props.hasOwnProperty(o)) ((this.poseTarget.props[o] = this.poseBase.props[o].clone()), (this.poseTarget.props[o].t = this.animClock), (this.poseTarget.props[o].d = r)); }); } getValue(e) { return this.mtAvatar[e]?.value; } setValue(e, t, n = null) { if (this.mtAvatar.hasOwnProperty(e)) Object.assign(this.mtAvatar[e], { system: t, systemd: n, needsUpdate: !0 }); } getMoodNames() { return Object.keys(this.animMoods); } getMood() { return this.opt.avatarMood; } setMood(e) { if (((e = (e || "").trim().toLowerCase()), !this.animMoods.hasOwnProperty(e))) throw Error("Unknown mood."); ((this.moodName = e), (this.mood = this.animMoods[this.moodName])); for (let t of Object.keys(this.mtAvatar)) { let n = this.mtBaselineExceptions.hasOwnProperty(t) ? this.mtBaselineExceptions[t] : this.mtBaselineDefault; if (this.mood.baseline.hasOwnProperty(t)) n = this.mood.baseline[t]; else if (this.avatar.baseline?.hasOwnProperty(t)) n = this.avatar.baseline[t]; this.setBaselineValue(t, n); } this.mood.anims.forEach((t) => { let n = this.animQueue.findIndex((i) => i.template.name === t.name); if (n !== -1) this.animQueue.splice(n, 1); this.animQueue.push(this.animFactory(t, -1)); }); } getMorphTargetNames() { return ["eyesRotateX", "eyesRotateY", ...Object.keys(this.mtAvatar)].sort(); } getBaselineValue(e) { if (e === "eyesRotateY") { let t = this.getBaselineValue("eyeLookOutLeft"); if (t === void 0) return; let n = this.getBaselineValue("eyeLookInLeft"); if (n === void 0) return; if (this.getBaselineValue("eyeLookOutRight") === void 0) return; if (this.getBaselineValue("eyeLookInRight") === void 0) return; return t - n; } else if (e === "eyesRotateX") { let t = this.getBaselineValue("eyesLookDown"); if (t === void 0) return; let n = this.getBaselineValue("eyesLookUp"); if (n === void 0) return; return t - n; } else return this.mtAvatar[e]?.baseline; } setBaselineValue(e, t) { if (e === "eyesRotateY") (this.setBaselineValue("eyeLookOutLeft", t === null ? null : t > 0 ? t : 0), this.setBaselineValue("eyeLookInLeft", t === null ? null : t > 0 ? 0 : -t), this.setBaselineValue("eyeLookOutRight", t === null ? null : t > 0 ? 0 : -t), this.setBaselineValue("eyeLookInRight", t === null ? null : t > 0 ? t : 0)); else if (e === "eyesRotateX") (this.setBaselineValue("eyesLookDown", t === null ? null : t > 0 ? t : 0), this.setBaselineValue("eyesLookUp", t === null ? null : t > 0 ? 0 : -t)); else if (this.mtAvatar.hasOwnProperty(e)) Object.assign(this.mtAvatar[e], { base: null, baseline: t, needsUpdate: !0 }); } getFixedValue(e) { if (e === "eyesRotateY") { let t = this.getFixedValue("eyeLookOutLeft"); if (t === null) return null; let n = this.getFixedValue("eyeLookInLeft"); if (n === null) return null; if (this.getFixedValue("eyeLookOutRight") === null) return null; if (this.getFixedValue("eyeLookInRight") === null) return null; return t - n; } else if (e === "eyesRotateX") { let t = this.getFixedValue("eyesLookDown"); if (t === null) return null; let n = this.getFixedValue("eyesLookUp"); if (n === null) return null; return t - n; } else return this.mtAvatar[e]?.fixed; } setFixedValue(e, t, n = null) { if (e === "eyesRotateY") (this.setFixedValue("eyeLookOutLeft", t === null ? null : t > 0 ? t : 0, n), this.setFixedValue("eyeLookInLeft", t === null ? null : t > 0 ? 0 : -t, n), this.setFixedValue("eyeLookOutRight", t === null ? null : t > 0 ? 0 : -t, n), this.setFixedValue("eyeLookInRight", t === null ? null : t > 0 ? t : 0, n)); else if (e === "eyesRotateX") (this.setFixedValue("eyesLookDown", t === null ? null : t > 0 ? t : 0, n), this.setFixedValue("eyesLookUp", t === null ? null : t > 0 ? 0 : -t, n)); else if (this.mtAvatar.hasOwnProperty(e)) Object.assign(this.mtAvatar[e], { fixed: t, needsUpdate: !0 }); } animFactory(e, t = !1, n = 1, i = 1, s = !1) { let r = { template: e, ts: [0], vs: {} }, o = e; while (!0) if (o.hasOwnProperty(this.stateName)) o = o[this.stateName]; else if (o.hasOwnProperty(this.moodName)) o = o[this.moodName]; else if (o.hasOwnProperty(this.poseName)) o = o[this.poseName]; else if (o.hasOwnProperty(this.viewName)) o = o[this.viewName]; else if (this.avatar.body && o.hasOwnProperty(this.avatar.body)) o = o[this.avatar.body]; else if (o.hasOwnProperty("alt")) { let l = o.alt[0]; if (o.alt.length > 1) { let c = Math.random(), h = 0; for (let u = 0; u < o.alt.length; u++) { let d = this.valueFn(o.alt[u].p); if (((h += d === void 0 ? (1 - h) / (o.alt.length - 1 - u) : d), c < h)) { l = o.alt[u]; break; } } } o = l; } else break; let a = this.valueFn(o.delay) || 0; if (Array.isArray(a)) a = this.gaussianRandom(...a); if (o.hasOwnProperty("dt")) o.dt.forEach((l, c) => { let h = this.valueFn(l); if (Array.isArray(h)) h = this.gaussianRandom(...h); r.ts[c + 1] = r.ts[c] + h; }); else { let l = Object.values(o.vs).reduce((c, h) => (h.length > c ? h.length : c), 0); r.ts = Array(l + 1).fill(0); } if (s) r.ts = r.ts.map((l) => a + l * n); else r.ts = r.ts.map((l) => this.animClock + a + l * n); for (let [l, c] of Object.entries(o.vs)) { let h = this.getBaselineValue(l), u = c.map((d) => { if (((d = this.valueFn(d)), d === null)) return null; else if (typeof d === "function") return d; else if (typeof d === "string" || d instanceof String) return d.slice(); else if (Array.isArray(d)) if (l === "gesture") return d.slice(); else return (h === void 0 ? 0 : h) + i * this.gaussianRandom(...d); else if (typeof d == "boolean") return d; else if (d instanceof Object && d.constructor === Object) return Object.assign({}, d); else return (h === void 0 ? 0 : h) + i * d; }); if (l === "eyesRotateY") ((r.vs.eyeLookOutLeft = [null, ...u.map((d) => (d > 0 ? d : 0))]), (r.vs.eyeLookInLeft = [null, ...u.map((d) => (d > 0 ? 0 : -d))]), (r.vs.eyeLookOutRight = [null, ...u.map((d) => (d > 0 ? 0 : -d))]), (r.vs.eyeLookInRight = [null, ...u.map((d) => (d > 0 ? d : 0))])); else if (l === "eyesRotateX") ((r.vs.eyesLookDown = [null, ...u.map((d) => (d > 0 ? d : 0))]), (r.vs.eyesLookUp = [null, ...u.map((d) => (d > 0 ? 0 : -d))])); else r.vs[l] = [null, ...u]; } for (let l of Object.keys(r.vs)) while (r.vs[l].length <= r.ts.length) r.vs[l].push(r.vs[l][r.vs[l].length - 1]); if (e.hasOwnProperty("mood")) r.mood = this.valueFn(e.mood).slice(); if (t) r.loop = t; return r; } valueAnimationSeq(e, t, n, i, s, r = null) { if (((e = this.valueFn(e)), (t = this.valueFn(t)), s < n)) s = n; if (s > i) s = i; let o = (t - e) / (i - n); if (r) o *= r((s - n) / (i - n)); return o * s + (e - o * n); } gaussianRandom(e, t, n = 1, i = 5) { let s = 0; for (let r = 0; r < i; r++) s += Math.random(); return e + Math.pow(s / i, n) * (t - e); } sigmoidFactory(e) { function t(i) { return 1 / (1 + Math.exp(-e * i)) - 0.5; } var n = 0.5 / t(1); return function (i) { return n * t(2 * Math.max(Math.min(i, 1), 0) - 1) + 0.5; }; } convertRange(e, t, n) { return ((e - t[0]) * (n[1] - n[0])) / (t[1] - t[0]) + n[0]; } animate(e) { if (!this.isRunning) return; let t; if (this.isAvatarOnly) t = e; else { if (((this._raf = requestAnimationFrame(this.animate)), (t = e - this.animTimeLast), t < this.animFrameDur)) return; this.animTimeLast = e; } ((t = t / this.animSlowdownRate), (this.animClock += t)); let n, i, s, r, o = 0; if (this.stats) this.stats.begin(); if (this.isListening) { this.listeningAnalyzer.getByteFrequencyData(this.volumeFrequencyData); for (n = 2, s = 10; n < s; n++) if (this.volumeFrequencyData[n] > o) o = this.volumeFrequencyData[n]; if (((this.listeningVolume = (this.listeningVolume + o) / 2), this.listeningActive)) { if (((this.listeningTimerTotal += t), this.listeningVolume < this.listeningSilenceThresholdLevel)) { if (((this.listeningTimer += t), this.listeningTimer > this.listeningSilenceThresholdMs)) { if (this.listeningOnchange) this.listeningOnchange("stop", this.listeningTimer); ((this.listeningActive = !1), (this.listeningTimer = 0), (this.listeningTimerTotal = 0)); } } else this.listeningTimer *= 0.5; if (this.listeningTimerTotal > this.listeningActiveDurationMax) { if (this.listeningOnchange) this.listeningOnchange("maxactive"); this.listeningTimerTotal = 0; } } else { if (((this.listeningTimerTotal += t), this.listeningVolume > this.listeningActiveThresholdLevel)) { if (((this.listeningTimer += t), this.listeningTimer > this.listeningActiveThresholdMs)) { if (this.listeningOnchange) this.listeningOnchange("start"); ((this.listeningActive = !0), (this.listeningTimer = 0), (this.listeningTimerTotal = 0)); } } else this.listeningTimer *= 0.5; if (this.listeningTimerTotal > this.listeningSilenceDurationMax) { if (this.listeningOnchange) this.listeningOnchange("maxsilence"); this.listeningTimerTotal = 0; } } } if (this.isSpeaking) { ((o = 0), this.audioAnalyzerNode.getByteFrequencyData(this.volumeFrequencyData)); for (n = 2, s = 10; n < s; n++) if (this.volumeFrequencyData[n] > o) o = this.volumeFrequencyData[n]; } let a = null, l = null, c = []; for (n = 0, s = this.animQueue.length; n < s; n++) { let h = this.animQueue[n]; if (this.animClock < h.ts[0]) continue; for (i = h.ndx || 0, r = h.ts.length; i < r; i++) { if (this.animClock < h.ts[i]) break; for (let [u, d] of Object.entries(h.vs)) if (this.mtAvatar.hasOwnProperty(u)) { if (d[i + 1] === null) continue; let f = this.mtAvatar[u]; if (d[i] === null) d[i] = f.value; if (i === r - 1) f.newvalue = d[i]; else { f.newvalue = d[i + 1]; let m = h.ts[i + 1] - h.ts[i], y = 1; if (m > 0.0001) y = (this.animClock - h.ts[i]) / m; if (y < 1) { if (f.easing) y = f.easing(y); f.newvalue = (1 - y) * d[i] + y * f.newvalue; } if (f.ref && f.ref !== h.vs && f.ref.hasOwnProperty(u)) delete f.ref[u]; f.ref = h.vs; } if (o) switch (u) { case "viseme_aa": case "viseme_E": case "viseme_I": case "viseme_O": case "viseme_U": f.newvalue *= 1 + o / 255 - 0.5; } f.needsUpdate = !0; } else if (u === "eyeContact" && d[i] !== null && a !== !1) a = Boolean(d[i]); else if (u === "headMove" && d[i] !== null && l !== !1) if (d[i] === 0) l = !1; else { if (Math.random() < d[i]) l = !0; d[i] = null; } else if (d[i] !== null) (c.push({ mt: u, val: d[i] }), (d[i] = null)); } if (i === r) { if (h.hasOwnProperty("mood")) this.setMood(h.mood); if (h.loop) ((r = this.isSpeaking && (h.template.name === "head" || h.template.name === "eyes") ? 4 : 1), (this.animQueue[n] = this.animFactory(h.template, h.loop > 0 ? h.loop - 1 : h.loop, 1, 1 / r))); else (this.animQueue.splice(n--, 1), s--); } else h.ndx = i - 1; } for (let h = 0, u = c.length; h < u; h++) switch (((i = c[h].val), c[h].mt)) { case "speak": this.speakText(i); break; case "subtitles": if (this.onSubtitles && typeof this.onSubtitles === "function") this.onSubtitles(i); break; case "pose": ((this.poseName = i), this.setPoseFromTemplate(this.poseTemplates[this.poseName])); break; case "gesture": this.playGesture(...i); break; case "function": if (i && typeof i === "function") i(); break; case "moveto": Object.entries(i.props).forEach((d) => { if (d[1]) this.poseTarget.props[d[0]].copy(d[1]); else this.poseTarget.props[d[0]].copy(this.getPoseTemplateProp(d[0])); ((this.poseTarget.props[d[0]].t = this.animClock), (this.poseTarget.props[d[0]].d = d[1] && d[1].d ? d[1].d : d.duration || 2000)); }); break; case "handLeft": this.ikSolve( { iterations: 20, root: "LeftShoulder", effector: "LeftHandMiddle1", links: [ { link: "LeftHand", minx: -0.5, maxx: 0.5, miny: -1, maxy: 1, minz: -0.5, maxz: 0.5 }, { link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 }, { link: "LeftArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }, ], }, i.x ? new E(i.x, i.y, i.z) : null, !0, i.d, ); break; case "handRight": this.ikSolve( { iterations: 20, root: "RightShoulder", effector: "RightHandMiddle1", links: [ { link: "RightHand", minx: -0.5, maxx: 0.5, miny: -1, maxy: 1, minz: -0.5, maxz: 0.5, maxAngle: 0.1 }, { link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5, maxAngle: 0.2, }, { link: "RightArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }, ], }, i.x ? new E(i.x, i.y, i.z) : null, !0, i.d, ); break; } if (a || l) if ( (ft.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), (ft.x = Math.max(-0.9, Math.min(0.9, 2 * ft.x - 0.5))), (ft.y = Math.max(-0.9, Math.min(0.9, -2.5 * ft.y))), a) ) { if ( (Object.assign(this.mtAvatar.eyesLookDown, { system: ft.x < 0 ? -ft.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: ft.x < 0 ? 0 : ft.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: ft.y < 0 ? -ft.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: ft.y < 0 ? 0 : ft.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: ft.y < 0 ? 0 : ft.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: ft.y < 0 ? -ft.y : 0, needsUpdate: !0 }), l) ) ((n = -this.mtAvatar.bodyRotateY.value), (i = this.gaussianRandom(-0.2, 0.2)), this.animQueue.push( this.animFactory({ name: "headmove", dt: [ [1000, 2000], [1000, 2000, 1, 2], [1000, 2000], [1000, 2000, 1, 2], ], vs: { headRotateY: [n, n, 0], headRotateX: [i, i, 0], headRotateZ: [-n / 4, -n / 4, 0] }, }), )); } else ((n = this.mtAvatar.eyeLookInLeft.value - this.mtAvatar.eyeLookOutLeft.value), (i = this.gaussianRandom(-0.2, 0.2)), this.animQueue.push( this.animFactory({ name: "headmove", dt: [ [1000, 2000], [1000, 2000, 1, 2], [1000, 2000], [1000, 2000, 1, 2], ], vs: { headRotateY: [null, n, n, 0], headRotateX: [null, i, i, 0], headRotateZ: [null, -n / 4, -n / 4, 0], eyeLookInLeft: [null, 0], eyeLookOutLeft: [null, 0], eyeLookInRight: [null, 0], eyeLookOutRight: [null, 0], eyeContact: [0], }, }), )); if (t > 2 * this.animFrameDur) t = 2 * this.animFrameDur; if (this.viewName !== "full" || this.isAvatarOnly) { if ( ((n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)]), (i = this.mtAvatar[n]), !i.needsUpdate) ) Object.assign(i, { base: (this.mood.baseline[n] || 0) + ((1 + o / 255) * Math.random()) / 5, needsUpdate: !0 }); } if ((this.updatePoseBase(this.animClock), this.mixer)) this.mixer.update((t / 1000) * this.mixer.timeScale); if ((this.updatePoseDelta(), (this.isSpeaking || this.isListening) && a)) if (o > this.volumeMax) { if (((this.volumeHeadBase = 0.05), Math.random() > 0.6)) this.volumeHeadTarget = -0.05 - Math.random() / 15; this.volumeMax = o; } else ((this.volumeMax *= 0.92), (this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget))); else ((this.volumeHeadTarget = 0), (this.volumeMax = 0)); if (((n = this.volumeHeadTarget - this.volumeHeadCurrent), (i = Math.abs(n)), i > 0.0001)) ((r = i * (this.volumeHeadEasing(Math.min(1, (this.volumeHeadVelocity * t) / 1000 / i) / 2 + 0.5) - 0.5)), (this.volumeHeadCurrent += Math.sign(n) * Math.min(i, r))); if (Math.abs(this.volumeHeadCurrent) > 0.0001) (Lt.setFromAxisAngle(W_, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(Lt)); if ( (hp.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(Ti), Ti.sub(this.armature.position), this.objectRightToeBase.getWorldPosition($i), $i.sub(this.armature.position), (this.objectHips.position.y -= hp.min.y / 2), (this.objectHips.position.x -= (Ti.x + $i.x) / 4), (this.objectHips.position.z -= (Ti.z + $i.z) / 2), this.dynamicbones.update(t), this.opt.update) ) this.opt.update(t); if ((this.updateMorphTargets(t), this.isAvatarOnly)) { if (this.stats) this.stats.end(); } else { if (this.cameraClock !== null && this.cameraClock < 1000) { if (((this.cameraClock += t), this.cameraClock > 1000)) this.cameraClock = 1000; let h = new ji().setFromVector3(this.cameraStart), u = new ji().setFromVector3(this.cameraEnd); if ( ((h.phi += this.easing(this.cameraClock / 1000) * (u.phi - h.phi)), (h.theta += this.easing(this.cameraClock / 1000) * (u.theta - h.theta)), (h.radius += this.easing(this.cameraClock / 1000) * (u.radius - h.radius)), h.makeSafe(), this.camera.position.setFromSpherical(h), this.controlsStart.x !== this.controlsEnd.x) ) this.controls.target.copy(this.controlsStart.lerp(this.controlsEnd, this.easing(this.cameraClock / 1000))); else (h.setFromVector3(this.controlsStart), u.setFromVector3(this.controlsEnd), (h.phi += this.easing(this.cameraClock / 1000) * (u.phi - h.phi)), (h.theta += this.easing(this.cameraClock / 1000) * (u.theta - h.theta)), (h.radius += this.easing(this.cameraClock / 1000) * (u.radius - h.radius)), h.makeSafe(), this.controls.target.setFromSpherical(h)); this.controls.update(); } if (this.controls.autoRotate) this.controls.update(); if (this.stats) this.stats.end(); this.render(); } } resetLips() { this.visemeNames.forEach((e) => { this.morphs.forEach((t) => { let n = t.morphTargetDictionary["viseme_" + e]; if (n !== void 0) t.morphTargetInfluences[n] = 0; }); }); } lipsyncGetProcessor(e, t = "./") { if (!this.lipsync.hasOwnProperty(e)) { let n = t + "lipsync-" + e.toLowerCase() + ".mjs", i = "Lipsync" + e.charAt(0).toUpperCase() + e.slice(1); import(n).then((s) => { this.lipsync[e] = new s[i](); }); } } lipsyncPreProcessText(e, t) { return (this.lipsync[t] || Object.values(this.lipsync)[0]).preProcessText(e); } lipsyncWordsToVisemes(e, t) { return (this.lipsync[t] || Object.values(this.lipsync)[0]).wordsToVisemes(e); } speakText(e, t = null, n = null, i = null) { t = t || {}; let s = /[!\.\?\n\p{Extended_Pictographic}]/gu, r = /[ ]/gu, o = /[\p{L}\p{N},\.\p{Quotation_Mark}!€\$\+\p{Dash_Punctuation}%&\?]/gu, a = /[\p{Extended_Pictographic}]/gu, l = t.lipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, c = "", h = "", u = 0, d = [], f = [], m = Array.from(this.segmenter.segment(e), (y) => y.segment); for (let y = 0; y < m.length; y++) { let p = y === m.length - 1, g = m[y].match(o), _ = m[y].match(s), x = m[y].match(a), w = m[y].match(r); if (_ && !p && !x && m[y + 1].match(s)) _ = !1; if (n) c += m[y]; if (g) { if (!i || i.every((L) => y < L[0] || y > L[1])) h += m[y]; } if (w || _ || p) { if (h.length) { if (((h = this.lipsyncPreProcessText(h, l)), h.length)) d.push({ mark: u, word: h }); } if (c.length) (f.push({ mark: u, template: { name: "subtitles" }, ts: [0], vs: { subtitles: [c] } }), (c = "")); if (h.length) { let L = this.lipsyncWordsToVisemes(h, l); if (L && L.visemes && L.visemes.length) { let b = L.times[L.visemes.length - 1] + L.durations[L.visemes.length - 1]; for (let R = 0; R < L.visemes.length; R++) { let F = f.push({ mark: u, template: { name: "viseme" }, ts: [(L.times[R] - 0.6) / b, (L.times[R] + 0.5) / b, (L.times[R] + L.durations[R] + 0.5) / b], vs: { ["viseme_" + L.visemes[R]]: [null, L.visemes[R] === "PP" || L.visemes[R] === "FF" ? 0.9 : 0.6, 0], }, }); } } ((h = ""), u++); } } if (_ || p) { if (d.length || (p && f.length)) { let L = { anim: f }; if (n) L.onSubtitles = n; if (d.length && !t.avatarMute) { if (((L.text = d), t.avatarMood)) L.mood = t.avatarMood; if (t.ttsLang) L.lang = t.ttsLang; if (t.ttsVoice) L.voice = t.ttsVoice; if (t.ttsRate) L.rate = t.ttsRate; if (t.ttsVoice) L.pitch = t.ttsPitch; if (t.ttsVolume) L.volume = t.ttsVolume; } (this.speechQueue.push(L), (d = []), (h = ""), (u = 0), (f = [])); } if (x) { let L = this.animEmojis[m[y]]; if (L && L.link) L = this.animEmojis[L.link]; if (L) this.speechQueue.push({ emoji: L }); } this.speechQueue.push({ break: 100 }); } } (this.speechQueue.push({ break: 1000 }), this.startSpeaking()); } async speakEmoji(e) { let t = this.animEmojis[e]; if (t && t.link) t = this.animEmojis[t.link]; if (t) this.speechQueue.push({ emoji: t }); this.startSpeaking(); } async speakBreak(e) { (this.speechQueue.push({ break: e }), this.startSpeaking()); } async speakMarker(e) { (this.speechQueue.push({ marker: e }), this.startSpeaking()); } async playBackgroundAudio(e) { let n = await (await fetch(e)).arrayBuffer(); (this.stopBackgroundAudio(), (this.audioBackgroundSource = this.audioCtx.createBufferSource()), (this.audioBackgroundSource.loop = !0), (this.audioBackgroundSource.buffer = await this.audioCtx.decodeAudioData(n)), (this.audioBackgroundSource.playbackRate.value = 1 / this.animSlowdownRate), this.audioBackgroundSource.connect(this.audioBackgroundGainNode), this.audioBackgroundSource.start(0)); } stopBackgroundAudio() { try { this.audioBackgroundSource.stop(); } catch (e) {} this.audioBackgroundSource.disconnect(); } async setReverb(e = null) { if (e) { let n = await (await fetch(e)).arrayBuffer(); this.audioReverbNode.buffer = await this.audioCtx.decodeAudioData(n); } else { let t = this.audioCtx.sampleRate, n = this.audioCtx.createBuffer(2, t, t); ((n.getChannelData(0)[0] = 1), (n.getChannelData(1)[0] = 1), (this.audioReverbNode.buffer = n)); } } setMixerGain(e, t = null, n = 0) { if (e !== null) if ((this.audioSpeechGainNode.gain.cancelScheduledValues(this.audioCtx.currentTime), n)) (this.audioSpeechGainNode.gain.setValueAtTime( Math.max(this.audioSpeechGainNode.gain.value, 0.0001), this.audioCtx.currentTime, ), this.audioSpeechGainNode.gain.exponentialRampToValueAtTime( Math.max(e, 0.0001), this.audioCtx.currentTime + n, )); else this.audioSpeechGainNode.gain.setValueAtTime(e, this.audioCtx.currentTime); if (t !== null) if ((this.audioBackgroundGainNode.gain.cancelScheduledValues(this.audioCtx.currentTime), n)) (this.audioBackgroundGainNode.gain.setValueAtTime( Math.max(this.audioBackgroundGainNode.gain.value, 0.0001), this.audioCtx.currentTime, ), this.audioBackgroundGainNode.gain.exponentialRampToValueAtTime( Math.max(t, 0.0001), this.audioCtx.currentTime + n, )); else this.audioBackgroundGainNode.gain.setValueAtTime(t, this.audioCtx.currentTime); } speakAudio(e, t = null, n = null) { t = t || {}; let i = t.lipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, s = {}; if (e.words) { let r = []; for (let o = 0; o < e.words.length; o++) { let a = e.words[o], l = e.wtimes[o], c = e.wdurations[o]; if (a.length) { if (n) r.push({ template: { name: "subtitles" }, ts: [l], vs: { subtitles: [" " + a] } }); if (!e.visemes) { let h = this.lipsyncPreProcessText(a, i), u = this.lipsyncWordsToVisemes(h, i); if (u && u.visemes && u.visemes.length) { let d = u.times[u.visemes.length - 1] + u.durations[u.visemes.length - 1], f = Math.min(c, Math.max(0, c - u.visemes.length * 150)), m = 0.6 + this.convertRange(f, [0, c], [0, 0.4]); if (((c = Math.min(c, u.visemes.length * 200)), d > 0)) for (let y = 0; y < u.visemes.length; y++) { let p = l + (u.times[y] / d) * c, g = (u.durations[y] / d) * c; r.push({ template: { name: "viseme" }, ts: [p - Math.min(60, (2 * g) / 3), p + Math.min(25, g / 2), p + g + Math.min(60, g / 2)], vs: { ["viseme_" + u.visemes[y]]: [null, u.visemes[y] === "PP" || u.visemes[y] === "FF" ? 0.9 : m, 0], }, }); } } } } } if (e.visemes) for (let o = 0; o < e.visemes.length; o++) { let a = e.visemes[o], l = e.vtimes[o], c = e.vdurations[o]; r.push({ template: { name: "viseme" }, ts: [l - (2 * c) / 3, l + c / 2, l + c + c / 2], vs: { ["viseme_" + a]: [null, a === "PP" || a === "FF" ? 0.9 : 0.6, 0] }, }); } if (e.markers) for (let o = 0; o < e.markers.length; o++) { let a = e.markers[o], l = e.mtimes[o]; r.push({ template: { name: "markers" }, ts: [l], vs: { function: [a] } }); } if (r.length) s.anim = r; } if (e.audio) s.audio = e.audio; if (e.anim?.name) { let r = this.animFactory(e.anim, !1, 1, 1, !0); if (!s.anim) s.anim = [r]; else s.anim.push(r); } if (n) s.onSubtitles = n; if (t.isRaw) s.isRaw = !0; if (Object.keys(s).length) { if ((this.speechQueue.push(s), !s.isRaw)) this.speechQueue.push({ break: 300 }); this.startSpeaking(); } } async playAudio(e = !1) { if (!this.armature || (this.isAudioPlaying && !e)) return; if (((this.isAudioPlaying = !0), this.audioPlaylist.length)) { let t = this.audioPlaylist.shift(); if (this.audioCtx.state === "suspended" || this.audioCtx.state === "interrupted") { let r = this.audioCtx.resume(), o = new Promise((a, l) => setTimeout(() => l("p2"), 1000)); try { await Promise.race([r, o]); } catch (a) { (console.log( "Can't play audio. Web Audio API suspended. This is often due to calling some speak method before the first user action, which is typically prevented by the browser.", ), this.playAudio(!0)); return; } } let n; if (Array.isArray(t.audio)) { let r = this.concatArrayBuffers(t.audio); n = this.pcmToAudioBuffer(r); } else n = t.audio; if (this.audioSpeechSource) { try { this.audioSpeechSource.stop?.(); } catch (r) {} (this.audioSpeechSource.disconnect(), (this.audioSpeechSource.onended = null), (this.audioSpeechSource = null)); } let i = this.audioCtx.createBufferSource(); ((this.audioSpeechSource = i), (i.buffer = n), (i.playbackRate.value = 1 / this.animSlowdownRate), i.connect(this.audioAnalyzerNode), (i.onended = () => { if ((i.disconnect(), (i.onended = null), this.audioSpeechSource === i)) this.audioSpeechSource = null; this.playAudio(!0); })); let s = 0; if (t.anim) { if (!t.isRaw) s = Math.abs(Math.min(0, ...t.anim.map((r) => Math.min(...r.ts)))); t.anim.forEach((r) => { for (let o = 0; o < r.ts.length; o++) r.ts[o] = this.animClock + r.ts[o] + s; this.animQueue.push(r); }); } i.start(this.audioCtx.currentTime + s / 1000); } else ((this.isAudioPlaying = !1), this.startSpeaking(!0)); } async startSpeaking(e = !1) { if (!this.armature || (this.isSpeaking && !e)) return; if (((this.stateName = "speaking"), (this.isSpeaking = !0), this.speechQueue.length)) { let t = this.speechQueue.shift(); if (t.emoji) { this.lookAtCamera(500); let n = t.emoji.dt.reduce((i, s) => i + s, 0); (this.animQueue.push(this.animFactory(t.emoji)), setTimeout(this.startSpeaking.bind(this), n, !0)); } else if (t.break) setTimeout(this.startSpeaking.bind(this), t.break, !0); else if (t.audio) { if (!t.isRaw) (this.lookAtCamera(500), this.speakWithHands(), this.resetLips()); if ( (this.audioPlaylist.push({ anim: t.anim, audio: t.audio, isRaw: t.isRaw }), (this.onSubtitles = t.onSubtitles || null), t.mood) ) this.setMood(t.mood); this.playAudio(); } else if (t.text) { this.lookAtCamera(500); try { let n = ""; (t.text.forEach((o, a) => { if (a > 0) n += " "; n += o.word .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .replaceAll('"', """) .replaceAll("'", "'") .replace(/^\p{Dash_Punctuation}$/gu, ''); }), (n += "")); let i = { method: "POST", headers: { "Content-Type": "application/json; charset=utf-8" }, body: JSON.stringify({ input: { ssml: n }, voice: { languageCode: t.lang || this.avatar.ttsLang || this.opt.ttsLang, name: t.voice || this.avatar.ttsVoice || this.opt.ttsVoice, }, audioConfig: { audioEncoding: this.ttsAudioEncoding, speakingRate: (t.rate || this.avatar.ttsRate || this.opt.ttsRate) + this.mood.speech.deltaRate, pitch: (t.pitch || this.avatar.ttsPitch || this.opt.ttsPitch) + this.mood.speech.deltaPitch, volumeGainDb: (t.volume || this.avatar.ttsVolume || this.opt.ttsVolume) + this.mood.speech.deltaVolume, }, enableTimePointing: [1], }), }; if (this.opt.jwtGet && typeof this.opt.jwtGet === "function") i.headers.Authorization = "Bearer " + (await this.opt.jwtGet()); let s = await fetch(this.opt.ttsEndpoint + (this.opt.ttsApikey ? "?key=" + this.opt.ttsApikey : ""), i), r = await s.json(); if (s.status === 200 && r && r.audioContent) { let o = this.b64ToArrayBuffer(r.audioContent), a = await this.audioCtx.decodeAudioData(o); this.speakWithHands(); let l = [0], c = 0; t.text.forEach((d, f) => { if (f > 0) { let m = l[l.length - 1]; if (r.timepoints[c]) { if (((m = r.timepoints[c].timeSeconds * 1000), r.timepoints[c].markName === "" + d.mark)) c++; } l.push(m); } }); let h = [{ mark: 0, time: 0 }]; l.forEach((d, f) => { if (f > 0) { let m = d - l[f - 1]; if (m > 150) m - 150; ((h[f - 1].duration = m), h.push({ mark: f, time: d })); } }); let u = 1000 * a.duration; if (u > this.opt.ttsTrimEnd) u = u - this.opt.ttsTrimEnd; if ( ((h[h.length - 1].duration = u - h[h.length - 1].time), t.anim.forEach((d) => { let f = h[d.mark]; if (f) for (let m = 0; m < d.ts.length; m++) d.ts[m] = f.time + d.ts[m] * f.duration + this.opt.ttsTrimStart; }), this.audioPlaylist.push({ anim: t.anim, audio: a }), (this.onSubtitles = t.onSubtitles || null), this.resetLips(), t.mood) ) this.setMood(t.mood); this.playAudio(); } else this.startSpeaking(!0); } catch (n) { (console.error("Error:", n), this.startSpeaking(!0)); } } else if (t.anim) { if (((this.onSubtitles = t.onSubtitles || null), this.resetLips(), t.mood)) this.setMood(t.mood); (t.anim.forEach((n, i) => { for (let s = 0; s < n.ts.length; s++) n.ts[s] = this.animClock + 10 * i; this.animQueue.push(n); }), setTimeout(this.startSpeaking.bind(this), 10 * t.anim.length, !0)); } else if (t.marker) { if (typeof t.marker === "function") t.marker(); this.startSpeaking(!0); } else this.startSpeaking(!0); } else ((this.stateName = "idle"), (this.isSpeaking = !1)); } pauseSpeaking() { try { this.audioSpeechSource?.stop(); } catch (e) {} if ( ((this.audioPlaylist.length = 0), (this.stateName = "idle"), (this.isSpeaking = !1), (this.isAudioPlaying = !1), (this.animQueue = this.animQueue.filter( (e) => e.template.name !== "viseme" && e.template.name !== "subtitles" && e.template.name !== "blendshapes", )), this.armature) ) (this.resetLips(), this.render()); } stopSpeaking() { try { this.audioSpeechSource?.stop(); } catch (e) {} if ( ((this.audioPlaylist.length = 0), (this.speechQueue.length = 0), (this.animQueue = this.animQueue.filter( (e) => e.template.name !== "viseme" && e.template.name !== "subtitles" && e.template.name !== "blendshapes", )), (this.stateName = "idle"), (this.isSpeaking = !1), (this.isAudioPlaying = !1), this.armature) ) (this.resetLips(), this.render()); } async streamStart(e = {}, t = null, n = null, i = null, s = null) { if ((this.stopSpeaking(), (this.isStreaming = !0), e.waitForAudioChunks !== void 0)) this.streamWaitForAudioChunks = e.waitForAudioChunks; if (!this.streamWaitForAudioChunks) this.streamAudioStartTime = this.animClock; if ( ((this.streamLipsyncQueue = []), (this.streamLipsyncType = e.lipsyncType || this.streamLipsyncType || "visemes"), (this.streamLipsyncLang = e.lipsyncLang || this.streamLipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang), (this.onAudioStart = t), (this.onAudioEnd = n), (this.onMetrics = s), e.sampleRate !== void 0) ) { let o = e.sampleRate; if (typeof o === "number" && o >= 8000 && o <= 96000) { if (o !== this.audioCtx.sampleRate) this.initAudioGraph(o); } else console.warn("Invalid sampleRate provided. It must be a number between 8000 and 96000 Hz."); } if (e.gain !== void 0) this.audioStreamGainNode.gain.value = e.gain; if ( !this.streamWorkletNode || !this.streamWorkletNode.port || this.streamWorkletNode.numberOfOutputs === 0 || this.streamWorkletNode.context !== this.audioCtx ) { if (this.streamWorkletNode) try { (this.streamWorkletNode.disconnect(), (this.streamWorkletNode = null)); } catch (o) {} if (!this.workletLoaded) try { let o = this.audioCtx.audioWorklet.addModule(V_.href), a = new Promise((l, c) => setTimeout(() => c(Error("Worklet loading timed out")), 5000)); (await Promise.race([o, a]), (this.workletLoaded = !0)); } catch (o) { throw (console.error("Failed to load audio worklet:", o), Error("Failed to initialize streaming speech")); } ((this.streamWorkletNode = new AudioWorkletNode(this.audioCtx, "playback-worklet", { processorOptions: { sampleRate: this.audioCtx.sampleRate, metrics: e.metrics || { enabled: !1 } }, })), this.streamWorkletNode.connect(this.audioStreamGainNode), this.streamWorkletNode.connect(this.audioAnalyzerNode), (this.streamWorkletNode.port.onmessage = (o) => { if (o.data.type === "playback-started") { if (((this.isSpeaking = !0), (this.stateName = "speaking"), this.streamWaitForAudioChunks)) this.streamAudioStartTime = this.animClock; if ((this._processStreamLipsyncQueue(), this.speakWithHands(), this.onAudioStart)) try { this.onAudioStart?.(); } catch (a) { console.error(a); } } if (o.data.type === "playback-ended") { if ((this._streamPause(), this.onAudioEnd)) try { this.onAudioEnd(); } catch (a) {} } if (this.onMetrics && o.data.type === "metrics") try { this.onMetrics(o.data); } catch (a) {} })); } if (e.metrics) try { this.streamWorkletNode.port.postMessage({ type: "config-metrics", data: e.metrics }); } catch (o) {} if ( (this.resetLips(), this.lookAtCamera(500), e.mood && this.setMood(e.mood), (this.onSubtitles = i || null), this.audioCtx.state === "suspended" || this.audioCtx.state === "interrupted") ) { let o = this.audioCtx.resume(), a = new Promise((l, c) => setTimeout(() => c("p2"), 1000)); try { await Promise.race([o, a]); } catch (l) { console.warn( "Can't play audio. Web Audio API suspended. This is often due to calling some speak method before the first user action, which is typically prevented by the browser.", ); return; } } } streamNotifyEnd() { if (!this.isStreaming || !this.streamWorkletNode) return; this.streamWorkletNode.port.postMessage({ type: "no-more-data" }); } streamInterrupt() { if (!this.isStreaming) return; let e = this.isSpeaking; if (this.streamWorkletNode) try { this.streamWorkletNode.port.postMessage({ type: "stop" }); } catch (t) {} if ((this._streamPause(!0), e && this.onAudioEnd)) try { this.onAudioEnd(); } catch (t) {} } streamStop() { if (!this.isStreaming) return; if ((this.streamInterrupt(), this.streamWorkletNode)) { try { this.streamWorkletNode.disconnect(); } catch (e) {} this.streamWorkletNode = null; } this.isStreaming = !1; } _streamPause(e = !1) { if (((this.isSpeaking = !1), (this.stateName = "idle"), e)) { if (this.streamWaitForAudioChunks) this.streamAudioStartTime = null; if ( ((this.streamLipsyncQueue = []), (this.animQueue = this.animQueue.filter( (t) => t.template.name !== "viseme" && t.template.name !== "subtitles" && t.template.name !== "blendshapes", )), this.armature) ) (this.resetLips(), this.render()); } } _processStreamLipsyncQueue() { if (!this.isStreaming) return; while (this.streamLipsyncQueue.length > 0) { let e = this.streamLipsyncQueue.shift(); this._processLipsyncData(e, this.streamAudioStartTime); } } _processLipsyncData(e, t) { if (!this.isStreaming) return; if (e.visemes && this.streamLipsyncType == "visemes") for (let n = 0; n < e.visemes.length; n++) { let i = e.visemes[n], s = t + e.vtimes[n], r = e.vdurations[n], o = { template: { name: "viseme" }, ts: [s - (2 * r) / 3, s + r / 2, s + r + r / 2], vs: { ["viseme_" + i]: [null, i === "PP" || i === "FF" ? 0.9 : 0.6, 0] }, }; this.animQueue.push(o); } if (e.words && (this.onSubtitles || this.streamLipsyncType == "words")) for (let n = 0; n < e.words.length; n++) { let i = e.words[n], s = e.wtimes[n], r = e.wdurations[n]; if (i.length) { if (this.onSubtitles) this.animQueue.push({ template: { name: "subtitles" }, ts: [t + s], vs: { subtitles: [" " + i] } }); if (this.streamLipsyncType == "words") { let o = this.streamLipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, a = this.lipsyncPreProcessText(i, o), l = this.lipsyncWordsToVisemes(a, o); if (l && l.visemes && l.visemes.length) { let c = l.times[l.visemes.length - 1] + l.durations[l.visemes.length - 1], h = Math.min(r, Math.max(0, r - l.visemes.length * 150)), u = 0.6 + this.convertRange(h, [0, r], [0, 0.4]); if (((r = Math.min(r, l.visemes.length * 200)), c > 0)) for (let d = 0; d < l.visemes.length; d++) { let f = t + s + (l.times[d] / c) * r, m = (l.durations[d] / c) * r; this.animQueue.push({ template: { name: "viseme" }, ts: [f - Math.min(60, (2 * m) / 3), f + Math.min(25, m / 2), f + m + Math.min(60, m / 2)], vs: { ["viseme_" + l.visemes[d]]: [null, l.visemes[d] === "PP" || l.visemes[d] === "FF" ? 0.9 : u, 0], }, }); } } } } } if (e.anims && this.streamLipsyncType == "blendshapes") for (let n = 0; n < e.anims.length; n++) { let i = e.anims[n]; i.delay += t; let s = this.animFactory(i, !1, 1, 1, !0); this.animQueue.push(s); } } streamAudio(e) { if (!this.isStreaming || !this.streamWorkletNode) return; if (!this.isSpeaking) ((this.streamLipsyncQueue = []), (this.streamAudioStartTime = null)); if (((this.isSpeaking = !0), (this.stateName = "speaking"), e.audio !== void 0)) { let t = { type: "audioData", data: null }; if (e.audio instanceof ArrayBuffer) ((t.data = e.audio), this.streamWorkletNode.port.postMessage(t, [t.data])); else if (e.audio instanceof Int16Array || e.audio instanceof Uint8Array) { let n = e.audio.buffer.slice(e.audio.byteOffset, e.audio.byteOffset + e.audio.byteLength); ((t.data = n), this.streamWorkletNode.port.postMessage(t, [t.data])); } else if (e.audio instanceof Float32Array) { let n = new Int16Array(e.audio.length); for (let i = 0; i < e.audio.length; i++) { let s = Math.max(-1, Math.min(1, e.audio[i])); n[i] = s < 0 ? s * 32768 : s * 32767; } ((t.data = n.buffer), this.streamWorkletNode.port.postMessage(t, [t.data])); } else console.error( "r.audio is not a supported type. Must be ArrayBuffer, Int16Array, Uint8Array, or Float32Array:", e.audio, ); } if (e.visemes || e.anims || e.words) { if (this.streamWaitForAudioChunks && !this.streamAudioStartTime) { if (this.streamLipsyncQueue.length >= 200) this.streamLipsyncQueue.shift(); this.streamLipsyncQueue.push(e); return; } else if (!this.streamWaitForAudioChunks && !this.streamAudioStartTime) this.streamAudioStartTime = this.animClock; this._processLipsyncData(e, this.streamAudioStartTime); } } makeEyeContact(e) { this.animQueue.push(this.animFactory({ name: "eyecontact", dt: [0, e], vs: { eyeContact: [1] } })); } lookAhead(e) { if (e) { let t = (Math.random() - 0.5) / 4, n = (Math.random() - 0.5) / 4, i = this.animQueue.findIndex((r) => r.template.name === "lookat"); if (i !== -1) this.animQueue.splice(i, 1); let s = { name: "lookat", dt: [750, e], vs: { bodyRotateX: [t], bodyRotateY: [n], eyesRotateX: [-3 * t + 0.1], eyesRotateY: [-5 * n], browInnerUp: [[0, 0.7]], mouthLeft: [[0, 0.7]], mouthRight: [[0, 0.7]], eyeContact: [0], headMove: [0], }, }; this.animQueue.push(this.animFactory(s)); } } lookAtCamera(e) { let t; if (this.speakTo) { if (((t = new E()), this.speakTo.objectLeftEye?.isObject3D)) { let m = this.speakTo.armature.objectHead; (this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), Ti.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), $i.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), t.addVectors(Ti, $i).divideScalar(2)); } else if (this.speakTo.isObject3D) this.speakTo.getWorldPosition(t); else if (this.speakTo.isVector3) t.set(this.speakTo); else if (this.speakTo.x && this.speakTo.y && this.speakTo.z) t.set(this.speakTo.x, this.speakTo.y, this.speakTo.z); } if (!t) { if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) { if (this.avatar.avatarIgnoreCamera) { this.lookAhead(e); return; } } else if (this.opt.avatarIgnoreCamera) { this.lookAhead(e); return; } this.lookAt(null, null, e); return; } (this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), Ti.setFromMatrixPosition(this.objectLeftEye.matrixWorld), $i.setFromMatrixPosition(this.objectRightEye.matrixWorld), Ti.add($i).divideScalar(2), Lt.copy(this.armature.quaternion), Lt.multiply(this.poseTarget.props["Hips.quaternion"]), Lt.multiply(this.poseTarget.props["Spine.quaternion"]), Lt.multiply(this.poseTarget.props["Spine1.quaternion"]), Lt.multiply(this.poseTarget.props["Spine2.quaternion"]), Lt.multiply(this.poseTarget.props["Neck.quaternion"]), Lt.multiply(this.poseTarget.props["Head.quaternion"])); let n = new E().subVectors(t, Ti).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y), r = 0; ft.set(s, i, r, "YXZ"); let o = new Ne().setFromEuler(ft), a = new Ne().copy(o).multiply(Lt.clone().invert()); ft.setFromQuaternion(a, "YXZ"); let l = ft.x / 1.6666666666666667 + 0.2, c = ft.y / 2.25, h = Math.min(0.6, Math.max(-0.3, l)), u = Math.min(0.8, Math.max(-0.8, c)), d = (Math.random() - 0.5) / 4, f = (Math.random() - 0.5) / 4; if (e) { let m = this.animQueue.findIndex((p) => p.template.name === "lookat"); if (m !== -1) this.animQueue.splice(m, 1); let y = { name: "lookat", dt: [750, e], vs: { bodyRotateX: [h + d], bodyRotateY: [u + f], eyesRotateX: [-3 * d + 0.1], eyesRotateY: [-5 * f], browInnerUp: [[0, 0.7]], mouthLeft: [[0, 0.7]], mouthRight: [[0, 0.7]], eyeContact: [0], headMove: [0], }, }; this.animQueue.push(this.animFactory(y)); } } lookAt(e, t, n) { if (!this.camera) return; let i = this.nodeAvatar.getBoundingClientRect(); (this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0)); let s = new E().setFromMatrixPosition(this.objectLeftEye.matrixWorld), r = new E().setFromMatrixPosition(this.objectRightEye.matrixWorld), o = new E().addVectors(s, r).divideScalar(2); o.project(this.camera); let a = ((o.x + 1) / 2) * i.width + i.left, l = (-(o.y - 1) / 2) * i.height + i.top; if (e === null) e = a; if (t === null) t = l; (Lt.copy(this.armature.quaternion), Lt.multiply(this.poseTarget.props["Hips.quaternion"]), Lt.multiply(this.poseTarget.props["Spine.quaternion"]), Lt.multiply(this.poseTarget.props["Spine1.quaternion"]), Lt.multiply(this.poseTarget.props["Spine2.quaternion"]), Lt.multiply(this.poseTarget.props["Neck.quaternion"]), Lt.multiply(this.poseTarget.props["Head.quaternion"]), ft.setFromQuaternion(Lt)); let c = ft.x / 1.6666666666666667, h = ft.y / 2.25, u = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), f = Math.max(window.innerWidth - a, a), m = Math.max(window.innerHeight - l, l), y = this.convertRange(t, [l - m, l + m], [-0.3, 0.6]) - c + u, p = this.convertRange(e, [a - f, a + f], [-0.8, 0.8]) - h + d; ((y = Math.min(0.6, Math.max(-0.3, y))), (p = Math.min(0.8, Math.max(-0.8, p)))); let g = (Math.random() - 0.5) / 4, _ = (Math.random() - 0.5) / 4; if (n) { let x = this.animQueue.findIndex((L) => L.template.name === "lookat"); if (x !== -1) this.animQueue.splice(x, 1); let w = { name: "lookat", dt: [750, n], vs: { bodyRotateX: [y + g], bodyRotateY: [p + _], eyesRotateX: [-3 * g + 0.1], eyesRotateY: [-5 * _], browInnerUp: [[0, 0.7]], mouthLeft: [[0, 0.7]], mouthRight: [[0, 0.7]], eyeContact: [0], headMove: [0], }, }; this.animQueue.push(this.animFactory(w)); } } touchAt(e, t) { if (!this.camera) return; let n = this.nodeAvatar.getBoundingClientRect(), i = new ve(((e - n.left) / n.width) * 2 - 1, -((t - n.top) / n.height) * 2 + 1), s = new pa(); s.setFromCamera(i, this.camera); let r = s.intersectObject(this.armature); if (r.length > 0) { let o = r[0].point, a = new E(), l = new E(); (this.objectLeftArm.getWorldPosition(a), this.objectRightArm.getWorldPosition(l)); let c = a.distanceToSquared(o), h = l.distanceToSquared(o); if (c < h) (this.ikSolve( { iterations: 20, root: "LeftShoulder", effector: "LeftHandMiddle1", links: [ { link: "LeftHand", minx: -0.5, maxx: 0.5, miny: -1, maxy: 1, minz: -0.5, maxz: 0.5, maxAngle: 0.1 }, { link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3, maxAngle: 0.2 }, { link: "LeftArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }, ], }, o, !1, 1000, ), this.setValue("handFistLeft", 0)); else (this.ikSolve( { iterations: 20, root: "RightShoulder", effector: "RightHandMiddle1", links: [ { link: "RightHand", minx: -0.5, maxx: 0.5, miny: -1, maxy: 1, minz: -0.5, maxz: 0.5, maxAngle: 0.1 }, { link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5, maxAngle: 0.2, }, { link: "RightArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }, ], }, o, !1, 1000, ), this.setValue("handFistRight", 0)); } else ["LeftArm", "LeftForeArm", "LeftHand", "RightArm", "RightForeArm", "RightHand"].forEach((o) => { let a = o + ".quaternion"; (this.poseTarget.props[a].copy(this.getPoseTemplateProp(a)), (this.poseTarget.props[a].t = this.animClock), (this.poseTarget.props[a].d = 1000)); }); return r.length > 0; } speakWithHands(e = 0, t = 0.5) { if ( this.mixer || this.gesture || !this.poseTarget.template.standing || this.poseTarget.template.bend || Math.random() > t ) return; (this.ikSolve( { root: "LeftShoulder", effector: "LeftHandMiddle1", links: [ { link: "LeftHand", minx: -0.5, maxx: 0.5, miny: -1, maxy: 1, minz: -0.5, maxz: 0.5 }, { link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 }, { link: "LeftArm", minx: -1.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -1, maxz: 3 }, ], }, new E(this.gaussianRandom(0, 0.5), this.gaussianRandom(-0.8, -0.2), this.gaussianRandom(0, 0.5)), !0, ), this.ikSolve( { root: "RightShoulder", effector: "RightHandMiddle1", links: [ { link: "RightHand", minx: -0.5, maxx: 0.5, miny: -1, maxy: 1, minz: -0.5, maxz: 0.5 }, { link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5 }, { link: "RightArm" }, ], }, new E(this.gaussianRandom(-0.5, 0), this.gaussianRandom(-0.8, -0.2), this.gaussianRandom(0, 0.5)), !0, )); let n = [], i = []; (n.push(100 + Math.round(Math.random() * 500)), i.push({ duration: 1000, props: { "LeftHand.quaternion": new Ne().setFromEuler(new tt(0, -1 - Math.random(), 0)), "RightHand.quaternion": new Ne().setFromEuler(new tt(0, 1 + Math.random(), 0)), }, }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm"].forEach((r) => { i[0].props[r + ".quaternion"] = this.ikMesh.getObjectByName(r).quaternion.clone(); }), n.push(1000 + Math.round(Math.random() * 500)), i.push({ duration: 2000, props: {} }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm", "LeftHand", "RightHand"].forEach((r) => { i[1].props[r + ".quaternion"] = null; })); let s = this.animFactory({ name: "talkinghands", delay: e, dt: n, vs: { moveto: i } }); this.animQueue.push(s); } getSlowdownRate(e) { return this.animSlowdownRate; } setSlowdownRate(e) { if (((this.animSlowdownRate = e), this.audioSpeechSource)) this.audioSpeechSource.playbackRate.value = 1 / this.animSlowdownRate; if (this.audioBackgroundSource) this.audioBackgroundSource.playbackRate.value = 1 / this.animSlowdownRate; } getAutoRotateSpeed(e) { return this.controls.autoRotateSpeed; } setAutoRotateSpeed(e) { ((this.controls.autoRotateSpeed = e), (this.controls.autoRotate = e > 0)); } start() { if (this.armature && this.isRunning === !1) { if ((this.audioCtx.resume(), (this.animTimeLast = performance.now()), (this.isRunning = !0), !this.isAvatarOnly)) this._raf = requestAnimationFrame(this.animate); } } stop() { ((this.isRunning = !1), this.audioCtx.suspend()); } startListening(e, t = {}, n = null) { ((this.listeningAnalyzer = e), (this.listeningAnalyzer.fftSize = 256), (this.listeningAnalyzer.smoothingTimeConstant = 0.1), (this.listeningAnalyzer.minDecibels = -70), (this.listeningAnalyzer.maxDecibels = -10), (this.listeningOnchange = n && typeof n === "function" ? n : null), (this.listeningSilenceThresholdLevel = t?.hasOwnProperty("listeningSilenceThresholdLevel") ? t.listeningSilenceThresholdLevel : this.opt.listeningSilenceThresholdLevel), (this.listeningSilenceThresholdMs = t?.hasOwnProperty("listeningSilenceThresholdMs") ? t.listeningSilenceThresholdMs : this.opt.listeningSilenceThresholdMs), (this.listeningSilenceDurationMax = t?.hasOwnProperty("listeningSilenceDurationMax") ? t.listeningSilenceDurationMax : this.opt.listeningSilenceDurationMax), (this.listeningActiveThresholdLevel = t?.hasOwnProperty("listeningActiveThresholdLevel") ? t.listeningActiveThresholdLevel : this.opt.listeningActiveThresholdLevel), (this.listeningActiveThresholdMs = t?.hasOwnProperty("listeningActiveThresholdMs") ? t.listeningActiveThresholdMs : this.opt.listeningActiveThresholdMs), (this.listeningActiveDurationMax = t?.hasOwnProperty("listeningActiveDurationMax") ? t.listeningActiveDurationMax : this.opt.listeningActiveDurationMax), (this.listeningActive = !1), (this.listeningVolume = 0), (this.listeningTimer = 0), (this.listeningTimerTotal = 0), (this.isListening = !0)); } stopListening() { this.isListening = !1; } async playAnimation(e, t = null, n = 10, i = 0, s = 0.01) { if (!this.armature) return; let r = this.animClips.find((o) => o.url === e + "-" + i); if (r) { let o = this.animQueue.find((c) => c.template.name === "pose"); if (o) o.ts[0] = 1 / 0; if ( (Object.entries(r.pose.props).forEach((c) => { ((this.poseBase.props[c[0]] = c[1].clone()), (this.poseTarget.props[c[0]] = c[1].clone()), (this.poseTarget.props[c[0]].t = 0), (this.poseTarget.props[c[0]].d = 1000)); }), this.mixer) ) (this.mixer.removeEventListener("finished", this._mixerHandler), this.mixer.stopAllAction(), this.mixer.uncacheRoot(this.armature), (this.mixer = null), (this._mixerHandler = null)); ((this.mixer = new fa(this.armature)), (this._mixerHandler = () => { (this.stopAnimation(), this.mixer?.removeEventListener("finished", this._mixerHandler)); }), this.mixer.addEventListener("finished", this._mixerHandler)); let a = Math.ceil(n / r.clip.duration), l = this.mixer.clipAction(r.clip); (l.setLoop($l, a), (l.clampWhenFinished = !0), l.fadeIn(0.5).play()); } else { let a = await new ba().loadAsync(e, t); if (a && a.animations && a.animations[i]) { let l = a.animations[i], c = {}; l.tracks.forEach((u) => { u.name = u.name.replaceAll("mixamorig", ""); let d = u.name.split("."); if (d[1] === "position") { for (let f = 0; f < u.values.length; f++) u.values[f] = u.values[f] * s; c[u.name] = new E(u.values[0], u.values[1], u.values[2]); } else if (d[1] === "quaternion") c[u.name] = new Ne(u.values[0], u.values[1], u.values[2], u.values[3]); else if (d[1] === "rotation") c[d[0] + ".quaternion"] = new Ne() .setFromEuler(new tt(u.values[0], u.values[1], u.values[2], "XYZ")) .normalize(); }); let h = { props: c }; if (c["Hips.position"]) if (c["Hips.position"].y < 0.5) h.lying = !0; else h.standing = !0; (this.animClips.push({ url: e + "-" + i, clip: l, pose: h }), this.playAnimation(e, t, n, i, s)); } else { let l = "Animation " + e + " (ndx=" + i + ") not found"; console.error(l); } } } stopAnimation() { if (this.mixer) (this.mixer.removeEventListener("finished", this._mixerHandler), this.mixer.stopAllAction(), this.mixer.uncacheRoot(this.armature), (this.mixer = null), (this._mixerHandler = null)); if (this.gesture) { for (let [t, n] of Object.entries(this.gesture)) if (((n.t = this.animClock), (n.d = 1000), this.poseTarget.props.hasOwnProperty(t))) (this.poseTarget.props[t].copy(n), (this.poseTarget.props[t].t = this.animClock), (this.poseTarget.props[t].d = 1000)); } let e = this.animQueue.find((t) => t.template.name === "pose"); if (e) e.ts[0] = this.animClock; this.setPoseFromTemplate(null); } async playPose(e, t = null, n = 5, i = 0, s = 0.01) { if (!this.armature) return; let r = this.poseTemplates[e]; if (!r) { let o = this.animPoses.find((a) => a.url === e + "-" + i); if (o) r = o.pose; } if (r) { if (((this.poseName = e), this.mixer)) (this.mixer.removeEventListener("finished", this._mixerHandler), this.mixer.stopAllAction(), this.mixer.uncacheRoot(this.armature), (this.mixer = null), (this._mixerHandler = null)); let o = this.animQueue.find((a) => a.template.name === "pose"); if (o) o.ts[0] = this.animClock + n * 1000 + 2000; this.setPoseFromTemplate(r); } else { let a = await new ba().loadAsync(e, t); if (a && a.animations && a.animations[i]) { let l = a.animations[i], c = {}; l.tracks.forEach((u) => { u.name = u.name.replaceAll("mixamorig", ""); let d = u.name.split("."); if (d[1] === "position") c[u.name] = new E(u.values[0] * s, u.values[1] * s, u.values[2] * s); else if (d[1] === "quaternion") c[u.name] = new Ne(u.values[0], u.values[1], u.values[2], u.values[3]); else if (d[1] === "rotation") c[d[0] + ".quaternion"] = new Ne() .setFromEuler(new tt(u.values[0], u.values[1], u.values[2], "XYZ")) .normalize(); }); let h = { props: c }; if (c["Hips.position"]) if (c["Hips.position"].y < 0.5) h.lying = !0; else h.standing = !0; (this.animPoses.push({ url: e + "-" + i, pose: h }), this.playPose(e, t, n, i, s)); } else { let l = "Pose " + e + " (ndx=" + i + ") not found"; console.error(l); } } } stopPose() { this.stopAnimation(); } playGesture(e, t = 3, n = !1, i = 1000) { if (!this.armature) return; let s = this.gestureTemplates[e]; if (s) { if (this.gestureTimeout) (clearTimeout(this.gestureTimeout), (this.gestureTimeout = null)); let o = this.animQueue.findIndex((a) => a.template.name === "talkinghands"); if (o !== -1) this.animQueue[o].ts = this.animQueue[o].ts.map((a) => 0); if (((this.gesture = this.propsToThreeObjects(s)), n)) this.gesture = this.mirrorPose(this.gesture); if (e === "namaste" && this.avatar.body === "M") (this.gesture["RightArm.quaternion"].rotateTowards(new Ne(0, 1, 0, 0), -0.25), this.gesture["LeftArm.quaternion"].rotateTowards(new Ne(0, 1, 0, 0), -0.25)); for (let [a, l] of Object.entries(this.gesture)) if (((l.t = this.animClock), (l.d = i), this.poseTarget.props.hasOwnProperty(a))) (this.poseTarget.props[a].copy(l), (this.poseTarget.props[a].t = this.animClock), (this.poseTarget.props[a].d = i)); if (t && Number.isFinite(t)) this.gestureTimeout = setTimeout(this.stopGesture.bind(this, i), 1000 * t); } let r = this.animEmojis[e]; if (r) { if (r && r.link) r = this.animEmojis[r.link]; if (r) { this.lookAtCamera(500); let o = this.animFactory(r); if (((o.gesture = !0), t && Number.isFinite(t))) { let a = o.ts[0], c = o.ts[o.ts.length - 1] - a; if (t * 1000 - c > 0) { let u = []; for (let m = 1; m < o.ts.length; m++) u.push(o.ts[m] - o.ts[m - 1]); let d = r.template?.rescale || u.map((m) => m / c), f = t * 1000 - c; o.ts = o.ts.map((m, y, p) => (y === 0 ? a : p[y - 1] + u[y - 1] + d[y - 1] * f)); } else { let u = (t * 1000) / c; o.ts = o.ts.map((d) => a + u * (d - a)); } } this.animQueue.push(o); } } } stopGesture(e = 1000) { if (this.gestureTimeout) (clearTimeout(this.gestureTimeout), (this.gestureTimeout = null)); if (this.gesture) { let n = Object.entries(this.gesture); this.gesture = null; for (let [i, s] of n) if (this.poseTarget.props.hasOwnProperty(i)) (this.poseTarget.props[i].copy(this.getPoseTemplateProp(i)), (this.poseTarget.props[i].t = this.animClock), (this.poseTarget.props[i].d = e)); } let t = this.animQueue.findIndex((n) => n.gesture); if (t !== -1) this.animQueue.splice(t, 1); } ikSolve(e, t = null, n = !1, i = null) { let s = new E(), r = new E(), o = new E(), a = new E(), l = new Ne(), c = new E(), h = new E(), u = new E(), d = this.ikMesh.getObjectByName(e.root); if ( (d.position.setFromMatrixPosition(this.armature.getObjectByName(e.root).matrixWorld), d.quaternion.setFromRotationMatrix(this.armature.getObjectByName(e.root).matrixWorld), t && n) ) t.applyQuaternion(this.armature.quaternion).add(d.position); let f = this.ikMesh.getObjectByName(e.effector), m = e.links; (m.forEach((p) => { ((p.bone = this.ikMesh.getObjectByName(p.link)), p.bone.quaternion.copy(this.getPoseTemplateProp(p.link + ".quaternion"))); }), d.updateMatrixWorld(!0)); let y = e.iterations || 10; if (t) for (let p = 0; p < y; p++) { let g = !1; for (let _ = 0, x = m.length; _ < x; _++) { let w = m[_].bone; (w.matrixWorld.decompose(a, l, c), l.invert(), r.setFromMatrixPosition(f.matrixWorld), o.subVectors(r, a), o.applyQuaternion(l), o.normalize(), s.subVectors(t, a), s.applyQuaternion(l), s.normalize()); let L = s.dot(o); if (L > 1) L = 1; else if (L < -1) L = -1; if (((L = Math.acos(L)), L < 0.00001)) continue; if (m[_].minAngle !== void 0 && L < m[_].minAngle) L = m[_].minAngle; if (m[_].maxAngle !== void 0 && L > m[_].maxAngle) L = m[_].maxAngle; (h.crossVectors(o, s), h.normalize(), Lt.setFromAxisAngle(h, L), w.quaternion.multiply(Lt), w.rotation.setFromVector3( u .setFromEuler(w.rotation) .clamp( new E( m[_].minx !== void 0 ? m[_].minx : -1 / 0, m[_].miny !== void 0 ? m[_].miny : -1 / 0, m[_].minz !== void 0 ? m[_].minz : -1 / 0, ), new E( m[_].maxx !== void 0 ? m[_].maxx : 1 / 0, m[_].maxy !== void 0 ? m[_].maxy : 1 / 0, m[_].maxz !== void 0 ? m[_].maxz : 1 / 0, ), ), ), w.updateMatrixWorld(!0), (g = !0)); } if (!g) break; } if (i) m.forEach((p) => { (this.poseTarget.props[p.link + ".quaternion"].copy(p.bone.quaternion), (this.poseTarget.props[p.link + ".quaternion"].t = this.animClock), (this.poseTarget.props[p.link + ".quaternion"].d = i)); }); } dispose() { if ((this.stop(), this.stopSpeaking(), this.streamStop(), this.stopAnimation(), this._raf !== null)) (cancelAnimationFrame(this._raf), (this._raf = null)); if ( (["audioSpeechSource", "audioBackgroundSource"].forEach((e) => { let t = this[e]; if (t) { try { t.stop?.(); } catch (n) {} (t.disconnect(), (t.onended = null)); } }), ["audioBackgroundGainNode", "audioSpeechGainNode", "audioStreamGainNode", "audioAnalyzerNode"].forEach((e) => { let t = this[e]; if (t) t.disconnect(); }), this.isAvatarOnly) ) { if (this.armature) { if (this.armature.parent) this.armature.parent.remove(this.armature); this.clearThree(this.armature); } } else { if ((this.clearThree(this.scene), this.resizeobserver.disconnect(), (this.resizeobserver = null), this.renderer)) (this.renderer.dispose(), this.renderer.getContext().getExtension("WEBGL_lose_context")?.loseContext(), this.renderer.domElement?.remove(), (this.renderer.domElement = null), (this.renderer = null)); if (this.controls) (this.controls.dispose(), (this.controls = null)); } (this.clearThree(this.ikMesh), this.dynamicbones.dispose(), (this.nodeAvatar = null)); } } var An = 12; var rh = 14; var up = An, dp = 56, fp = 78, pp = 368, mp = 92; class gp { constructor(e) { let t = Object.assign({}, e || {}); ((this.vectorDiff = new Float32Array(An)), (this.matrixL = Array.from({ length: An }, () => new Float32Array(An))), (this.matrixLInv = Array.from({ length: An }, () => new Float32Array(An))), (this.matrixSigma = Array.from({ length: An }, () => new Float32Array(An))), (this.indexSigmaInvLower = this._buildSigmaInvLowerLookup())); } _buildSigmaInvLowerLookup() { let e = Array.from({ length: An }, () => new Uint16Array(An)), t = 0; for (let n = 0; n < An; n++) for (let i = 0; i <= n; i++) ((e[n][i] = t), (e[i][n] = t), t++); return e; } computePrototype(e, t, n, i) { let s = An, r = i.length; if (r < s) throw Error(`Not enough samples (${r}) to compute full covariance.`); let o = new Float32Array(mp), a = new DataView(o.buffer, 0, 8), l = void 0, c = void 0, h = ((e?.codePointAt(0) || 0) << 16) | (e?.codePointAt(1) || 0 || 0); (a.setUint32(0, h), a.setUint8(5, t), a.setUint8(7, n)); let u = new Float32Array(o.buffer, 8, up), d = new Float32Array(o.buffer, dp, fp); for (let b = 0; b < r; b++) { let R = i[b]; for (let F = 0; F < s; F++) u[F] += R[F]; } let f = 1 / r; for (let b = 0; b < s; b++) u[b] *= f; let m = this.matrixSigma; m.forEach((b) => b.fill(0)); let y = 1 / (r - 1); for (let b = 0; b < r; b++) { let R = i[b]; for (let F = 0; F < s; F++) { let M = R[F] - u[F]; for (let T = F; T < s; T++) m[F][T] += M * (R[T] - u[T]); } } for (let b = 0; b < s; b++) for (let R = b; R < s; R++) { let F = m[b][R] * y; ((m[b][R] = F), b !== R && (m[R][b] = F)); } let p = 0; for (let b = 0; b < s; b++) p += m[b][b]; let g = (p / s) * 0.00001; for (let b = 0; b < s; b++) m[b][b] += g; let _ = this.matrixL; _.forEach((b) => b.fill(0)); for (let b = 0; b < s; b++) for (let R = 0; R <= b; R++) { let F = m[b][R]; for (let M = 0; M < R; M++) F -= _[b][M] * _[R][M]; if (b === R) { if (F <= 0) throw Error("Matrix is not positive definite."); _[b][R] = Math.sqrt(F); } else _[b][R] = F / _[R][R]; } let x = this.matrixLInv; x.forEach((b) => b.fill(0)); for (let b = 0; b < s; b++) { x[b][b] = 1 / _[b][b]; for (let R = 0; R < b; R++) { let F = 0; for (let M = R; M < b; M++) F -= _[b][M] * x[M][R]; x[b][R] = F / _[b][b]; } } let w = Array.from({ length: s }, () => new Float32Array(s)), L = 0; for (let b = 0; b < s; b++) for (let R = 0; R <= b; R++) { let F = 0; for (let M = Math.max(b, R); M < s; M++) M >= b && M >= R && (F += x[M][b] * x[M][R]); ((w[b][R] = F), (w[R][b] = F), (d[L] = F), L++); } return { mu: u, sigmaInv: w, sigmaInvLower: d, bin: o.buffer }; } decodeBinaryRecord(e) { let t = new DataView(e.buffer, e.byteOffset, 8), n = t.getUint32(0), i = n >>> 16, s = 65535 & n; return { phoneme: s === 0 ? String.fromCodePoint(i) : String.fromCodePoint(i, s), group: t.getUint8(5), viseme: t.getUint8(7), mu: new Float32Array(e.buffer, e.byteOffset + 8, up), sigmaInvLower: new Float32Array(e.buffer, e.byteOffset + dp, fp), }; } async loadModel(e, t = null) { let n = await fetch(e); if (!n.ok) throw Error(`Failed to fetch model: ${n.status} ${n.statusText}`); let i = await n.arrayBuffer(), s = [], r = i.byteLength, o = 0; for (; o + pp <= r;) { let a = new Float32Array(i, o, mp), l = this.decodeBinaryRecord(a); (t !== null && (l.group = t), s.push(l), (o += pp)); } if (s.length === 0) throw Error("Fetched model is empty"); return { model: s, buffer: i }; } update(e) { for (let t in e); } } class oh extends AudioWorkletNode { constructor(e, t = null) { let n = Object.assign({}, t || {}); (super(e, "headworklet", { numberOfInputs: 1, numberOfOutputs: 0, channelCount: 1, channelCountMode: "explicit", channelInterpretation: "speakers", outputChannelCount: [], processorOptions: n?.processorOptions || {}, parameterData: n?.parameterData || {}, }), (this.frameEventsEnabled = !!n.processorOptions?.frameEventsEnabled), (this.vadEventsEnabled = !!n.processorOptions?.vadEventsEnabled), (this.featureEventsEnabled = !!n.processorOptions?.featureEventsEnabled), (this.visemeEventsEnabled = !!n.processorOptions?.visemeEventsEnabled), (this.visemeNames = [ "viseme_aa", "viseme_E", "viseme_I", "viseme_O", "viseme_U", "viseme_PP", "viseme_SS", "viseme_TH", "viseme_DD", "viseme_FF", "viseme_kk", "viseme_nn", "viseme_RR", "viseme_CH", "viseme_sil", ]), (this.nVisemes = this.visemeNames.length), (this.visemeMaxs = [0.65, 0.65, 0.65, 0.65, 0.65, 0.75, 0.65, 0.65, 0.65, 0.75, 0.65, 0.65, 0.65, 0.65, 0.65]), (this.visemeAlphas = Array(this.nVisemes).fill(0)), (this.visemeActive = -1), (this.easing = this.sigmoidFactory(5)), (this.onvalue = null), (this.onframe = null), (this.onsentence = null), (this.onstarted = null), (this.onended = null), (this.onfeature = null), (this.onviseme = null), (this.training = new gp()), (this.timerCounter = 0), (this.isRunning = !0), (this.port.onmessage = this._onmessage.bind(this))); } sigmoidFactory(e) { function t(i) { return 1 / (1 + Math.exp(-e * i)) - 0.5; } var n = 0.5 / t(1); return function (i) { return n * t(2 * Math.max(Math.min(i, 1), 0) - 1) + 0.5; }; } _onmessage(e) { let t = e.data; switch (t.event) { case "frame": this.frameEventsEnabled && this.onframe && typeof this.onframe == "function" && this.onframe(t); break; case "vad": this.vadEventsEnabled && this.onvad && typeof this.onvad == "function" && this.onvad(t); break; case "feature": this.featureEventsEnabled && this.onfeature && typeof this.onfeature == "function" && this.onfeature(t); break; case "viseme": let n = t.viseme; (n && (this.visemeActive = n === rh ? -1 : n), this.visemeEventsEnabled && this.onviseme && typeof this.onviseme == "function" && this.onviseme(t)); break; case "started": this.onstarted && typeof this.onstarted == "function" && this.onstarted(t); break; case "ended": ((this.visemeActive = -1), (this.lastEndEvent = performance.now()), this.onended && typeof this.onended == "function" && this.onended(t)); break; case "calibrated": try { let { mu: i, sigmaInvLower: s, bin: r } = this.training.computePrototype("sc", 255, rh, t.vs); this.port.postMessage( { event: "model", model: [{ phoneme: "sc", group: 255, viseme: rh, mu: i, sigmaInvLower: s }] }, [r], ); } catch (i) { ((t.error = i), console.error(i)); } this.oncalibrated && typeof this.oncalibrated == "function" && this.oncalibrated(t); } } async loadModel(e, t = !0) { let { model: n, buffer: i } = await this.training.loadModel(e); (t && this.port.postMessage({ event: "reset" }), this.port.postMessage({ event: "model", model: n }, [i])); } update(e) { let t = e / 100; for (let n = 0; n < this.nVisemes; n++) { let i = this.visemeAlphas[n], s = !1; if ( (n === this.visemeActive ? ((s = !0), i < 1 && ((i += t), i > 0.99 && (i = 1))) : i > 0 && ((s = !0), (i -= t), i < 0.01 && (i = 0)), s) ) { let r = this.visemeMaxs[n] * this.easing(i); (this.onvalue && typeof this.onvalue == "function" && this.onvalue(this.visemeNames[n], r), (this.visemeAlphas[n] = i)); } } } start() { ((this.isRunning = !0), this.port.postMessage({ event: "start" })); } stop() { ((this.isRunning = !1), this.port.postMessage({ event: "stop" })); } calibrate() { this.port.postMessage({ event: "calibrate" }); } resetAll() { this.port.postMessage({ event: "reset" }); } resetTimer() { (this.timerCounter++, (this.parameters.get("timerReset").value = this.timerCounter)); } } var yp = new URLSearchParams(location.search), Ea = /iP(hone|ad|od)/.test(navigator.userAgent) || (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1), Gn = yp.has("lowmem") ? yp.get("lowmem") !== "0" : Ea; var $t = { irradiance_sh: [ [2.2386, 2.2386, 2.2386], [-0.2489, -0.2489, -0.2489], [0.6128, 0.6128, 0.6128], [-0.1527, -0.1527, -0.1527], [0.0054, 0.0054, 0.0054], [0.3748, 0.3748, 0.3748], [0.6607, 0.6607, 0.6607], [0.1349, 0.1349, 0.1349], [0.0453, 0.0453, 0.0453], ], fringe_cut_y: 1.6633, teeth_front: 0.1354, lids_uv: [0.35986328125, 0.28173828125, 0.63916015625, 0.394287109375], eye_spec: [0.0034, 0.0771, 0.366], skin_grain_m: 0.09, skin_grain_amp: 0.52, }; var gr = Number(new URLSearchParams(location.search).get("hair") ?? 3.2), oi = { perRadian: 0.239, u: 0.5084, v: 0.5066, r: 0.1337, scale: 23.11, spec: $t.eye_spec ?? [-0.04, 0.08, 0.2] }, q_ = ["Wolf3D_Head", "Wolf3D_Body"]; function Y_(e) { let t = new _i(), n = [ Math.PI, (2 * Math.PI) / 3, (2 * Math.PI) / 3, (2 * Math.PI) / 3, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4, ], i = (h, u, d) => [ 0.282095, 0.488603 * u, 0.488603 * d, 0.488603 * h, 1.092548 * h * u, 1.092548 * u * d, 0.315392 * (3 * d * d - 1), 1.092548 * h * d, 0.546274 * (h * h - u * u), ], s = new gs(10, 48, 32), r = s.attributes.position, o = new Float32Array(r.count * 3); for (let h = 0; h < r.count; h++) { let u = new E().fromBufferAttribute(r, h).normalize(), d = i(u.x, u.y, u.z); for (let f = 0; f < 3; f++) { let m = 0; for (let y = 0; y < 9; y++) m += ($t.irradiance_sh[y][f] * d[y] * Math.PI) / n[y]; o[h * 3 + f] = Math.max(0, m); } } (s.setAttribute("color", new gt(o, 3)), t.add(new st(s, new Wt({ vertexColors: !0, side: Gt })))); let a = (h, u, d, f, m, y, p) => { let g = new st(new Vi(d, f), new Wt({ color: new re(h).multiplyScalar(u), side: Yt })); (g.position.set(m, y, p), g.lookAt(0, 0, 0), t.add(g)); }; (a("#f5f4f2", 1.3, 4, 5, -3.5, 3, 6), a("#e8e8ea", 1.6, 2, 6, 6, 2, -5), a("#eeeae6", 1.4, 2, 6, -6, 2, -5), a("#fff2e2", 1.1, 3, 5, 1.5, 3.6, -7.5)); let l = new Zi(e), c = l.fromScene(t, 0.02).texture; return (l.dispose(), c); } function j_(e) { let t = new _i(); t.background = new re(0.2, 0.195, 0.19); let n = new st(new Vi(1.1, 1.4), new Wt({ color: new re(16, 15.5, 15), side: Yt })); (n.position.set(-2.2, 2.4, 6), n.lookAt(0, 0, 0), t.add(n)); let i = new Zi(e), s = i.fromScene(t, 0).texture; return (i.dispose(), s); } function Z_(e, t) { ((e.onBeforeCompile = (n) => { if (t) (Object.assign(n.uniforms, { lidTex: { value: t.texture }, lidBlink: t.blink }), Object.assign(n.uniforms, { uClipN: t.clipN, uClipC: t.clipC, uClipE1: t.clipE1, uClipE2: t.clipE2, uFoldH: t.foldH, uNeckOnly: t.neckOnly, uFoldClip: t.foldClip, uWallR: t.wallR, }), (n.vertexShader = n.vertexShader .replace( "#include ", `#include varying float vBindX; varying vec3 vBind3; varying vec3 vWorld3;`, ) .replace( "#include ", `#include vBindX = position.x; vBind3 = position;`, ) .replace( "#include ", `#include vWorld3 = (modelMatrix * vec4(transformed, 1.0)).xyz;`, )), (n.fragmentShader = n.fragmentShader .replace( "#include ", `#include varying float vBindX; varying vec3 vBind3; varying vec3 vWorld3; uniform sampler2D lidTex; uniform vec2 lidBlink; uniform vec3 uClipN; uniform vec3 uClipC; uniform vec3 uClipE1; uniform vec3 uClipE2; uniform float uFoldH[16]; uniform float uNeckOnly; uniform float uFoldClip; uniform float uWallR;`, ) .replace( "#include ", `#include // Hair hangs right beside the back of the jaw and blocks the room's reflection there. Without this the grazing skin mirrors a bright sky. float hairBlock = smoothstep(0.056, 0.074, abs(vBind3.x)) * smoothstep(1.66, 1.62, vBind3.y) * smoothstep(1.48, 1.52, vBind3.y) * smoothstep(-0.01, 0.03, vBind3.z); float specKeep = 1.0 - 0.88 * hairBlock; reflectedLight.directSpecular *= specKeep; reflectedLight.indirectSpecular *= specKeep; #ifdef USE_CLEARCOAT clearcoatSpecularDirect *= specKeep; clearcoatSpecularIndirect *= specKeep; #endif`, ) .replace( "#include ", `#include // What's under clothes can't show through them: neck skin below the collar's fold doesn't exist this frame. bool neckZone = vBind3.y < 1.54 && vBind3.z < 0.088; vec3 clipR = vWorld3 - uClipC; float clipA = fract(atan(dot(clipR, uClipE2), dot(clipR, uClipE1)) / 6.2831853) * 16.0; int clipI = int(floor(clipA)); float foldHere = mix(uFoldH[clipI], uFoldH[(clipI + 1) % 16], fract(clipA)); if (uFoldClip > 0.5 && neckZone && dot(clipR, uClipN) < foldHere) discard; if (uNeckOnly > 0.5 && (!neckZone || length(vec2(vBind3.x, vBind3.z - 0.0217)) > uWallR)) discard;`, ) .replace( "#include ", `#include vec2 lidUv = (vMapUv - vec2(${$t.lids_uv[0].toFixed(5)}, ${$t.lids_uv[1].toFixed(5)})) / vec2(${($t.lids_uv[2] - $t.lids_uv[0]).toFixed(5)}, ${($t.lids_uv[3] - $t.lids_uv[1]).toFixed(5)}); if (all(greaterThanEqual(lidUv, vec2(0.0))) && all(lessThanEqual(lidUv, vec2(1.0)))) { vec4 lidC = texture2D(lidTex, lidUv); diffuseColor.rgb = mix(diffuseColor.rgb, lidC.rgb, lidC.a * smoothstep(0.25, 0.8, vBindX > 0.0 ? lidBlink.x : lidBlink.y)); }`, ))); n.fragmentShader = n.fragmentShader .replace( "#include ", Ve.map_fragment.replace("texture2D( map, vMapUv )", "texture2D( map, vMapUv, -0.6 )"), ) .replace( "#include ", `#include vec3 skinR, skinG, skinB;`, ) .replace( "#include ", `#include skinR = skinG = skinB = normal; #ifdef USE_NORMALMAP_TANGENTSPACE vec3 mapR = textureLod(normalMap, vNormalMapUv, 5.0).xyz * 2.0 - 1.0; vec3 mapG = textureLod(normalMap, vNormalMapUv, 3.5).xyz * 2.0 - 1.0; vec3 mapB = textureLod(normalMap, vNormalMapUv, 2.5).xyz * 2.0 - 1.0; mapR.xy *= normalScale; mapG.xy *= normalScale; mapB.xy *= normalScale; skinR = normalize(tbn * mapR); skinG = normalize(tbn * mapG); skinB = normalize(tbn * mapB); #endif`, ) .replace( "#include ", Ve.lights_physical_pars_fragment.replace( "reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );", `vec3 wrapped = saturate((vec3(dot(skinR, directLight.direction), dot(skinG, directLight.direction), dot(skinB, directLight.direction)) + vec3(0.3, 0.12, 0.07)) / vec3(1.3, 1.12, 1.07)); reflectedLight.directDiffuse += wrapped * wrapped * directLight.color * BRDF_Lambert( material.diffuseColor );`, ), ) .replace( "#include ", `#include #ifdef USE_COLOR // Baked occlusion also blocks reflections: lip insides, nostrils and eye corners must not mirror the room. float specOcc = smoothstep(0.5, 0.92, vColor.r) * (1.0 - 0.85 * smoothstep(-0.1, -0.55, geometryNormal.y)); // and surfaces facing down reflect only the dark below reflectedLight.directSpecular *= specOcc; reflectedLight.indirectSpecular *= specOcc; clearcoatSpecularDirect *= specOcc; clearcoatSpecularIndirect *= specOcc; #endif`, ) .replace( "#include ", Ve.lights_fragment_maps.replace( "iblIrradiance += getIBLIrradiance( geometryNormal );", "iblIrradiance += getIBLIrradiance( skinG );", ), ); }), (e.customProgramCacheKey = () => (t ? "ava-skin-lids" : "ava-skin"))); } function K_(e, t) { let n = new Jn().load(new URL("avatars/ava-eye-spec.webp", document.baseURI).href); ((n.colorSpace = Ut), (e.onBeforeCompile = (i) => { ((i.uniforms.eyeSpec = { value: n }), Object.assign(i.uniforms, t), (i.vertexShader = i.vertexShader .replace( "#include ", `#include varying vec3 vEyeX; varying vec3 vEyeY; varying vec3 vEyeZ; varying vec3 vEyeP; uniform mat3 uGaze;`, ) .replace( "#include ", `#include vEyeP = position;`, ) .replace( "#include ", `#include vEyeX = normalMatrix * (skinMatrix * vec4(uGaze[0], 0.0)).xyz; vEyeY = normalMatrix * (skinMatrix * vec4(uGaze[1], 0.0)).xyz; vEyeZ = normalMatrix * (skinMatrix * vec4(uGaze[2], 0.0)).xyz;`, )), (i.fragmentShader = i.fragmentShader .replace( "#include ", `#include varying vec3 vEyeX; varying vec3 vEyeY; varying vec3 vEyeZ; varying vec3 vEyeP; uniform sampler2D eyeSpec; uniform mat3 uGaze; uniform vec3 uEyeC; uniform vec2 uCatch; uniform float uClosing;`, ) .replace( "#include ", `vec3 eV = normalize(vViewPosition); vec3 eN = normalize(vNormal); vec3 eX = normalize(vEyeX); vec3 eY = normalize(vEyeY); vec3 eZ = normalize(vEyeZ); vec3 eBall = normalize(vEyeP - uEyeC) * uGaze; float eTh = acos(clamp(eBall.z, -1.0, 1.0)); vec2 eC = vec2(eBall.x, -eBall.y) * (eTh / max(sin(eTh), 0.05)) * ${oi.perRadian.toFixed(4)}; float eR = length(eC) / ${oi.r.toFixed(4)}; float eInIris = 1.0 - smoothstep(0.55, 0.92, eR); vec3 eRay = refract(-eV, eN, 1.0 / 1.376); float eT = 0.0013 * (1.0 - min(eR * eR, 1.0) * 0.8) / max(-dot(eRay, eZ), 0.25); vec3 eHit = eRay * eT; vec2 eUv = vec2(${oi.u.toFixed(4)}, ${oi.v.toFixed(4)}) + eC + eInIris * vec2(${oi.scale.toFixed(2)} * dot(eHit, eX), -${oi.scale.toFixed(2)} * dot(eHit, eY)); vec4 eTex = texture2D(map, eUv); float eLight = 1.0 + 0.42 * eInIris * smoothstep(-0.2, 0.9, -normalize(eC + 1e-5).y * -1.0) * smoothstep(0.32, 0.7, eR); // Toward the corners the eyeball curves back under the lids and out of the light. float eCorner = smoothstep(0.0105, 0.0150, length(vEyeP.xy - uEyeC.xy)); diffuseColor.rgb *= eTex.rgb * eLight * (1.0 - 0.8 * smoothstep(0.12, 0.6, uClosing)) * (1.0 - 0.72 * eCorner);`, ) .replace( "#include ", `vec3 eR2 = reflect(-eV, eN); float eF = 0.025 + 0.975 * pow(1.0 - saturate(dot(eN, eV)), 5.0); gl_FragColor.rgb += eF * mix(vec3(0.05), vec3(0.42, 0.41, 0.4), smoothstep(-0.25, 0.65, eR2.y)); vec3 eL = normalize(vec3(${oi.spec[0].toFixed(4)}, ${oi.spec[1].toFixed(4)}, 1.0)); vec3 eLx = normalize(cross(vec3(0.0, 1.0, 0.0), eL)); vec3 eLy = cross(eL, eLx); vec2 eW = vec2(dot(eR2, eLx), dot(eR2, eLy)) / max(dot(eR2, eL), 0.001); vec2 eSpecUv = eW / ${oi.spec[2].toFixed(4)} + 0.5 - uCatch; float eCornea = 1.0 - smoothstep(1.05, 1.35, eR); if (all(greaterThan(eSpecUv, vec2(0.0))) && all(lessThan(eSpecUv, vec2(1.0))) && dot(eR2, eL) > 0.0) { vec3 eS = texture2D(eyeSpec, eSpecUv).rgb; gl_FragColor.rgb += eS * eS * 1.2 * eCornea * (1.0 - smoothstep(0.12, 0.5, uClosing)); } #include `, ))); }), (e.customProgramCacheKey = () => "ava-eye")); } var Aa = 0.012; function $_(e) { let t = e.attributes.position, n = -1 / 0; for (let r = 0; r < t.count; r++) n = Math.max(n, t.getZ(r)); let i = new E(), s = 0; for (let r = 0; r < t.count; r++) if (t.getZ(r) > n - 0.0005) ((i.x += t.getX(r)), (i.y += t.getY(r)), s++); return i.set(i.x / s + 0.00036, i.y / s - 0.00043, n - Aa); } function J_(e, t, n) { if (!e) return; let { morphTargetDictionary: i, morphTargetInfluences: s } = e, r = (g) => s[i[g]] ?? 0; n.uClosing.value = Math.min(1, r(`eyeBlink${t}`) + r("eyesClosed")); let o = r(`eyeLookOut${t}`), a = r(`eyeLookIn${t}`), l = 0.0077 * (t === "Left" ? o - a : a - o), c = 0.0077 * (r(`eyeLookUp${t}`) - r(`eyeLookDown${t}`) + r("eyesLookUp") - r("eyesLookDown")), h = (g) => Math.asin(bt.clamp(g / Aa, -1, 1)), u = (g, _) => _ * Math.tanh(g / _), d = u(h(l), 0.63), f = h(c), m = f > 0 ? u(f, 0.3) : u(f, 0.36), y = new tt(-m, d, 0, "YXZ"); n.uGaze.value.setFromMatrix4(new ue().makeRotationFromEuler(y)); let p = 47.61904761904762 / oi.spec[2]; n.uCatch.value.set(0.45 * Aa * Math.sin(d) * p, 0.45 * Aa * Math.sin(m) * p); } function xp(e) { let t = e.onBeforeCompile, n = e.customProgramCacheKey?.(); ((e.onBeforeCompile = (i, s) => { (t?.call(e, i, s), (i.fragmentShader = i.fragmentShader.replace( "#include ", `#include { float hairY = dot(diffuseColor.rgb, vec3(0.3, 0.55, 0.15)); diffuseColor.rgb = mix(hairY * vec3(1.2, 0.97, 0.84), diffuseColor.rgb, 0.15); }`, ))); }), (e.customProgramCacheKey = () => `${n ?? ""}-one-hue`)); } function Q_(e) { ((e.onBeforeCompile = (t) => { ((t.vertexShader = t.vertexShader .replace( "#include ", `#include varying vec3 vBind;`, ) .replace( "#include ", `#include vBind = position;`, )), (t.fragmentShader = t.fragmentShader .replace( "#include ", `#include varying vec3 vBind; float teethMask;`, ) .replace( "#include ", `#include teethMask = smoothstep(0.32, 0.5, dot(diffuseColor.rgb, vec3(0.33)));`, ) .replace( "#include ", `#include // Enamel is wet and glossy; the tongue and gums here shouldn't mirror the room. reflectedLight.directSpecular *= teethMask; reflectedLight.indirectSpecular *= teethMask * teethMask; clearcoatSpecularDirect *= teethMask; clearcoatSpecularIndirect *= teethMask * teethMask;`, ) .replace( "#include ", `float mouthFall = mix(0.26, 1.0, smoothstep(${($t.teeth_front - 0.045).toFixed(3)}, ${($t.teeth_front - 0.007).toFixed(3)}, vBind.z)); // The lips overhang the teeth: enamel falls into shade toward the gum on each row, which is what makes a row sit inside a mouth and not on it. float lipShade = vBind.y > 1.5625 ? 1.0 - 0.42 * smoothstep(1.5678, 1.5763, vBind.y) : 1.0 - 0.42 * smoothstep(1.559, 1.5545, vBind.y); outgoingLight *= mouthFall * lipShade * mix(0.52, 1.0, teethMask); // tongue and gums sit in the mouth's shade #include `, ))); }), (e.customProgramCacheKey = () => "ava-mouth")); } function e1(e) { if ($t.fringe_cut_y) ((e.onBeforeCompile = (t) => { ((t.vertexShader = t.vertexShader .replace( "#include ", `#include varying vec3 vBind;`, ) .replace( "#include ", `#include vBind = position;`, )), (t.fragmentShader = t.fragmentShader .replace( "#include ", `#include varying vec3 vBind;`, ) .replace( "#include ", `#include if (vBind.z > 0.055 && abs(vBind.x) < 0.086 && vBind.y < ${$t.fringe_cut_y.toFixed(4)} && vBind.y > 1.6) discard;`, ))); }), (e.customProgramCacheKey = () => "ava-hair-shell")); } function t1(e) { let t = new Jn().load(new URL("avatars/ava-skin-grain.webp", document.baseURI).href); ((t.wrapS = t.wrapT = On), (t.colorSpace = xi), (t.anisotropy = 4)); let n = e.onBeforeCompile; ((e.onBeforeCompile = (i, s) => { ((i.uniforms.uGrain = { value: t }), (i.vertexShader = i.vertexShader .replace( "#include ", `#include varying vec3 vGrainP; varying vec3 vGrainN;`, ) .replace( "#include ", `#include vGrainP = position; vGrainN = normal;`, )), (i.fragmentShader = i.fragmentShader .replace( "#include ", `#include varying vec3 vGrainP; varying vec3 vGrainN; uniform sampler2D uGrain; float grainH; float grainAt() { vec3 w = pow(abs(normalize(vGrainN)), vec3(4.0)); w /= w.x + w.y + w.z; vec3 p = vGrainP / ${$t.skin_grain_m.toFixed(4)}; return texture2D(uGrain, p.yz).r * w.x + texture2D(uGrain, p.xz).r * w.y + texture2D(uGrain, p.xy).r * w.z - 0.5; }`, ) .replace( "#include ", `#include grainH = grainAt(); diffuseColor.rgb *= exp(${$t.skin_grain_amp.toFixed(3)} * grainH);`, ) .replace( "#include ", `#include { vec3 sx = dFdx(-vViewPosition), sy = dFdy(-vViewPosition); vec3 r1 = cross(sy, normal), r2 = cross(normal, sx); float det = dot(sx, r1); vec3 g = sign(det) * (dFdx(grainH) * r1 + dFdy(grainH) * r2); normal = normalize(abs(det) * normal - 0.0009 * g); }`, )), n(i, s)); }), (e.customProgramCacheKey = () => "ava-skin-grain"), (e.needsUpdate = !0)); } function n1(e, t, n, i) { let { Ava_Collar: s, Wolf3D_Head: r } = n; if (!s || !r) return null; let { rings: o, segments: a, outer0: l } = s.userData, c = 7, h = s.userData.lip ?? o - 1, u = s.geometry, d = u.attributes.position, f = new Float32Array(d.count), m = new Float32Array(d.count), y = new Float32Array(d.count); for (let k = 0; k < a; k++) { let J = d.getY(k * o + c), ee = d.getY(k * o + h); for (let ae = 0; ae < o; ae++) { let ge = k * o + ae; ((f[ge] = ae <= c ? 1 : Math.max(0, 1 - (ae - c) / (h - c))), (m[ge] = J - d.getY(ge)), (y[ge] = J - ee)); } } (u.setAttribute("aWall", new gt(f, 1)), u.setAttribute("aUp", new gt(m, 1)), u.setAttribute("aSpan", new gt(y, 1))); let p = 40, g = r.geometry.attributes.position, _ = r.geometry.attributes.normal, x = new Set(r.geometry.index.array), w = new Map(); for (let k of x) { let J = g.getY(k); if (J < 1.52 || J > 1.585 || g.getZ(k) < 0.062 || _.getY(k) > -0.15) continue; let ee = `${Math.round(g.getX(k) / 0.008)},${Math.round(g.getZ(k) / 0.008)}`, ae = w.get(ee); if (ae === void 0 || J < g.getY(ae)) w.set(ee, k); } let L = [...w.values()].sort((k, J) => g.getY(k) - g.getY(J)).slice(0, p), b = Array.from({ length: p }, () => new E(0, 1000, 0)), R = { uJaw: { value: b }, uUp: { value: new E(0, 1, 0) } }; ((s.material.onBeforeCompile = (k) => { (Object.assign(k.uniforms, R), (k.vertexShader = k.vertexShader .replace( "#include ", `#include attribute float aWall; attribute float aUp; attribute float aSpan; uniform vec3 uJaw[${p}]; uniform vec3 uUp;`, ) .replace( "#include ", `#include vec3 cw = (modelMatrix * vec4(transformed, 1.0)).xyz; float foldH = dot(cw, uUp) + aUp; float press = 0.0; for (int j = 0; j < ${p}; j++) { vec3 r = cw - uJaw[j]; float h = dot(r, uUp); float rho2 = dot(r, r) - h * h; press = max(press, foldH - (dot(uJaw[j], uUp) - 0.0025 + rho2 / 0.09)); } cw -= uUp * min(press, aSpan * 0.82) * aWall; transformed = (inverse(modelMatrix) * vec4(cw, 1.0)).xyz;`, ))); }), (s.material.customProgramCacheKey = () => "ava-collar"), (s.material.needsUpdate = !0)); let F = new E(), M = (k, J) => (k.getVertexPosition(J, F), F.clone().applyMatrix4(k.matrixWorld)), T = Array.from({ length: 16 }, (k, J) => Math.floor((J * (a - 1)) / 16)), I = -1, G = { enabled: !0, neckOnly: i.neckOnly, foldClip: i.foldClip, wallR: i.wallR, margin: -0.005, jaw: L, press: 0 }; e.collarDynamics = G; let q = e.armature.getObjectByName("Neck"), B = e.armature.getObjectByName("Head"), Z = new Ne(), W = new Ne(), K = new Ne(), V = new Ne(), se = !1, ce = { amount: 0.5, apply() { if (se || !G.enabled || !q || !B) return; (Z.copy(q.quaternion), W.copy(B.quaternion), (se = !0)); let k = 2 * Math.acos(Math.min(1, Math.abs(B.quaternion.w))), J = bt.smoothstep(k, 0.09, 0.44) * ce.amount; if (J <= 0) return; (K.copy(V).slerp(B.quaternion, J), q.quaternion.multiply(K), B.quaternion.premultiply(K.invert())); }, undo() { if (!se) return; (q.quaternion.copy(Z), B.quaternion.copy(W), (se = !1)); }, }; G.share = ce; let Pe = e.updatePoseDelta.bind(e); e.updatePoseDelta = () => { (Pe(), (se = !1), ce.apply()); }; let We = e.animate.bind(e); e.animate = (k) => { if (!e.isRunning) return We(k); (ce.undo(), We(k), ce.apply()); }; let rt = e.stop.bind(e); e.stop = () => { (ce.undo(), rt()); }; let Ke = () => { if (t.info.render.frame === I) return; if (((I = t.info.render.frame), !G.enabled)) { i.foldH.value.fill(-1000); for (let ge of b) ge.set(0, 1000, 0); return; } L.forEach((ge, Ee) => b[Ee].copy(M(r, ge))); let k = [], J = new E(), ee = new E(); for (let ge of T) (k.push(M(s, ge * o + c)), J.add(M(s, ge * o + h)), ee.add(k[k.length - 1])); (ee.multiplyScalar(1 / T.length), J.multiplyScalar(1 / T.length)); let ae = R.uUp.value.copy(ee).sub(J).normalize(); for (let ge of k) { let Ee = 0; for (let vt of b) { if (vt.y > 100) continue; let C = ge.clone().sub(vt), ot = C.dot(ae); Ee = Math.max(Ee, ge.dot(ae) - (vt.dot(ae) - 0.0025 + (C.dot(C) - ot * ot) / 0.09)); } ((G.press = Math.max(G.press * 0, Ee)), ge.addScaledVector(ae, -Math.min(Ee, 0.03))); } (i.clipN.value.copy(ae), i.clipC.value.copy(ee), i.clipE1.value.copy(k[0]).sub(ee), i.clipE1.value.addScaledVector(ae, -i.clipE1.value.dot(ae)).normalize(), i.clipE2.value.copy(k[4]).sub(ee), i.clipE2.value.addScaledVector(i.clipE1.value, -i.clipE2.value.dot(i.clipE1.value)), i.clipE2.value.addScaledVector(ae, -i.clipE2.value.dot(ae)).normalize(), k.forEach((ge, Ee) => { i.foldH.value[Ee] = ge.clone().sub(ee).dot(ae) + G.margin; })); }; return ((s.onBeforeRender = Ke), Ke); } function Ji(e, t) { let n = new tn(); Vt.prototype.copy.call(n, e); for (let i of [ "color", "map", "normalMap", "normalScale", "roughness", "metalness", "roughnessMap", "metalnessMap", "aoMap", "aoMapIntensity", "alphaMap", "vertexColors", ]) if (e[i] !== void 0) n[i] = e[i]?.clone && !e[i].isTexture ? e[i].clone() : e[i]; return Object.assign(n, t); } function mq(c) { let i = c.Wolf3D_Outfit_Top; if (!i) return; let h = new URLSearchParams(location.search), y = h.get("neck") ?? "v"; if (y === "off") return; if (h.get("collar") === "off" && c.Ava_Collar) c.Ava_Collar.visible = !1; let p = Number(h.get("neckDepth") ?? ((h.get("avatar") ?? "brunette.glb") === "brunette.glb" ? 0.2 : 0.1)), g = Number(h.get("neckW") ?? 0.108), M = Number(h.get("neckTop") ?? 1.5015), F = Number(h.get("neckFront") ?? 0.014), T = y === "u" ? 0 : 1, U1 = { value: new Ye(M, p, g, T) }, U2 = { value: new ve(F, 0) }; // 1) escote: tira los fragmentos del jersey dentro del hueco (espacio de bind pose) { let ubc = i.material.onBeforeCompile; (i.material.onBeforeCompile = (sh, cxA) => { (ubc?.(sh, cxA), Object.assign(sh.uniforms, { uNeck: U1, uNeckF: U2 }), (sh.vertexShader = sh.vertexShader .replace("#include ", `#include varying vec3 vBindN;`) .replace("#include ", `#include vBindN = position;`)), (sh.fragmentShader = sh.fragmentShader .replace("#include ", `#include varying vec3 vBindN; uniform vec4 uNeck; uniform vec2 uNeckF;`) .replace( "#include ", `#include { float rel = abs(vBindN.x) / uNeck.z; if (rel < 0.85 && vBindN.z > uNeckF.x && vBindN.y > uNeck.x - uNeck.y - 0.012 && vBindN.y < uNeck.x + 0.001) { if (uNeck.w > 0.5) { if ((uNeck.x - vBindN.y) > uNeck.y * rel) discard; } else { if ((uNeck.x - vBindN.y) > uNeck.y * sqrt(max(0.0, 1.0 - rel * rel))) discard; } } }`, ))); }), (i.material.customProgramCacheKey = () => `ava-neck-cut-${i.material.uuid}`), (i.material.needsUpdate = !0); } // 2) piel del escote (solo avatar por defecto): clon INDEXADO del jersey hundido 6 mm // dentro del hueco + extension del tubo del cuello desde Wolf3D_Head hasta dentro del // panel (cierra el hueco entre cuello y jersey, sin laminas flotantes). Textura canvas // espejo de la franja limpia del cuello de Wolf3D_Skin: tono continuo, sin lengua ni clamp. if ((h.get("avatar") ?? "brunette.glb") === "brunette.glb") try { let src = i.geometry, fl2 = src.attributes.position.count, sp = src.attributes.position, sn = src.attributes.normal, hg2 = c.Wolf3D_Head?.geometry, hp2 = hg2?.attributes?.position, hsi = hg2?.attributes?.skinIndex, hsw = hg2?.attributes?.skinWeight, rcx = 0, rcz = 0.048, rr = 0.05, hymin = 1.432, ring = []; if (hp2) { let mn = 1 / 0; for (let v2 = 0; v2 < hp2.count; v2++) mn = Math.min(mn, hp2.getY(v2)); let sx2 = 0, sz2 = 0, n2 = 0; for (let v2 = 0; v2 < hp2.count; v2++) { let yv = hp2.getY(v2); if (yv < mn + 0.02) ((sx2 += hp2.getX(v2)), (sz2 += hp2.getZ(v2)), n2++); } if (n2 > 3) { ((rcx = sx2 / n2), (rcz = sz2 / n2), (hymin = mn)); let sr = 0; for (let v2 = 0; v2 < hp2.count; v2++) { let yv = hp2.getY(v2); if (yv < mn + 0.02) { let xv = hp2.getX(v2), zv = hp2.getZ(v2); sr += Math.hypot(xv - rcx, zv - rcz); if (hsi && hsw) ring.push([ Math.atan2(xv - rcx, zv - rcz), xv, zv, yv, Math.round(hsi.getX(v2)), Math.round(hsi.getY(v2)), Math.round(hsi.getZ(v2)), Math.round(hsi.getW(v2)), hsw.getX(v2), hsw.getY(v2), hsw.getZ(v2), hsw.getW(v2), ]); } } ((rr = sr / n2), ring.sort((a2, b2) => a2[0] - b2[0])); } } let EXT = 0, A = new Float32Array(fl2 * 3 + EXT * 3), B = new Float32Array(fl2 * 3 + EXT * 3), U = new Float32Array(fl2 * 2 + EXT * 2); for (let v2 = 0; v2 < fl2; v2++) { let px = sp.getX(v2), py = sp.getY(v2), pz = sp.getZ(v2), nx = sn.getX(v2), ny = sn.getY(v2), nz = sn.getZ(v2), ax = px - nx * 0.006, ay = py - ny * 0.006, az = pz - nz * 0.006; if (py < 1.44) { let rel3 = Math.min(1, Math.abs(px) / g), dep3 = Math.min(1, Math.max(0, (1.44 - py) / 0.14)), ext2 = 0.011 * dep3 * dep3 * (1 - rel3 * rel3); ((ax -= nx * ext2), (ay -= ny * ext2), (az -= nz * ext2)); } if (py > 1.39) { let w2 = Math.min(1, (py - 1.39) / 0.04); w2 = w2 * w2 * (3 - 2 * w2); let dx = ax - rcx, dz = az - rcz, L = Math.hypot(dx, dz) || 1, tr = rr + 0.004 - 0.008 * Math.min(1, Math.max(0, (py - 1.44) / 0.03)); ((ax = ax * (1 - w2) + (rcx + (dx / L) * tr) * w2), (az = az * (1 - w2) + (rcz + (dz / L) * tr) * w2)); } ((A[v2 * 3] = ax), (A[v2 * 3 + 1] = ay), (A[v2 * 3 + 2] = az), (B[v2 * 3] = nx), (B[v2 * 3 + 1] = ny), (B[v2 * 3 + 2] = nz)); let xr = Math.min(Math.max(px / 0.13, -1), 1); ((U[v2 * 2] = 0.5 + xr * 0.47), (U[v2 * 2 + 1] = Math.min(Math.max((1.506 - py) / 0.24, 0.002), 0.998))); } let sx = src.attributes.skinIndex, sw = src.attributes.skinWeight, J2 = new Uint16Array(fl2 * 4 + EXT * 4), W2 = new Float32Array(fl2 * 4 + EXT * 4); if (sx && sw) for (let v2 = 0; v2 < fl2; v2++) { ((J2[v2 * 4] = Math.round(sx.getX(v2))), (J2[v2 * 4 + 1] = Math.round(sx.getY(v2))), (J2[v2 * 4 + 2] = Math.round(sx.getZ(v2))), (J2[v2 * 4 + 3] = Math.round(sx.getW(v2))), (W2[v2 * 4] = sw.getX(v2)), (W2[v2 * 4 + 1] = sw.getY(v2)), (W2[v2 * 4 + 2] = sw.getZ(v2)), (W2[v2 * 4 + 3] = sw.getW(v2))); } let idxArr = src.index ? Array.from(src.index.array) : []; let g2 = new Et(); if (idxArr.length) g2.setIndex(idxArr); (g2.setAttribute("position", new at(A, 3)), g2.setAttribute("normal", new at(B, 3)), g2.setAttribute("uv", new at(U, 2))); if (sx && sw) (g2.setAttribute("skinIndex", new er(J2, 4)), g2.setAttribute("skinWeight", new at(W2, 4))); let tex = null; try { let hmat = c.Wolf3D_Head?.material, img = hmat?.map?.image; if (img && img.width >= 700) { let cv = document.createElement("canvas"); ((cv.width = 192), (cv.height = 512)); let cx2 = cv.getContext("2d"); cx2.filter = "blur(1px)"; for (let k = 0; k < 4; k++) { (cx2.save(), k % 2 === 0 ? (cx2.translate(0, k * 128 + 128), cx2.scale(1, -1), cx2.drawImage(img, 500, 745, 160, 58, 0, 0, 192, 128)) : cx2.drawImage(img, 500, 745, 160, 58, 0, k * 128, 192, 128), cx2.restore()); } ((tex = new hmat.map.constructor(cv)), (tex.flipY = hmat.map.flipY), (tex.colorSpace = hmat.map.colorSpace), (tex.channel = hmat.map.channel ?? 0), (tex.wrapS = tex.wrapT = 1002), (tex.needsUpdate = !0)); } } catch {} let mat2 = new tn({ side: Yt, color: tex ? new re(1, 1, 1) : new re(0.6, 0.34, 0.26), map: tex, roughness: 0.62, metalness: 0, specularIntensity: 0.25, sheen: 0.1, sheenColor: new re(1, 0.95, 0.9), sheenRoughness: 0.8, }); mat2.onBeforeCompile = (sh, cxA) => { Object.assign(sh.uniforms, { uNeck: U1, uNeckF: U2 }); sh.vertexShader = sh.vertexShader .replace("#include ", `#include varying vec3 vBindN;`) .replace("#include ", `#include vBindN = position;`); sh.fragmentShader = sh.fragmentShader .replace("#include ", `#include varying vec3 vBindN; uniform vec4 uNeck; uniform vec2 uNeckF;`) .replace( "#include ", `#include { float rel = abs(vBindN.x) / uNeck.z; bool avaKeep = false; if (rel < 0.92 && vBindN.z > uNeckF.x - 0.004 && vBindN.y > uNeck.x - uNeck.y - 0.02 && vBindN.y < uNeck.x + 0.03) { if (uNeck.w > 0.5) { if ((uNeck.x - vBindN.y) > uNeck.y * rel - 0.004) avaKeep = true; } else { if ((uNeck.x - vBindN.y) > uNeck.y * sqrt(max(0.0, 1.0 - rel * rel)) - 0.004) avaKeep = true; } if (vBindN.y > 1.40 && vBindN.y < 1.462 && rel < 0.55) avaKeep = true; } if (!avaKeep) discard; }`, ); }; mat2.customProgramCacheKey = () => "ava-neck-patch"; let pc = new Bi(g2, mat2); pc.bind(i.skeleton, i.bindMatrix); ((pc.position.copy(i.position), pc.quaternion.copy(i.quaternion), pc.scale.copy(i.scale)), (pc.castShadow = !1), (pc.receiveShadow = !1), (pc.frustumCulled = !1), i.parent.add(pc)); } catch (er2) { console.warn("neck patch failed:", er2); } } function Tq() { let cv = document.createElement("canvas"); ((cv.width = 2048), (cv.height = 1024)); let cx = cv.getContext("2d"), n2 = (a2, b2, c2) => Math.round(a2 + Math.random() * (b2 - a2)); // cielo: azul profundo arriba, bruma cálida en el horizonte let air = cx.createLinearGradient(0, 0, 0, 512); (air.addColorStop(0, "#1b66b8"), air.addColorStop(0.5, "#57a8e0"), air.addColorStop(0.82, "#c8e2f0"), air.addColorStop(1, "#f6e2c4"), (cx.fillStyle = air), cx.fillRect(0, 0, 2048, 512)); // sol bajo y cálido let sun = cx.createRadialGradient(640, 452, 6, 640, 452, 210); (sun.addColorStop(0, "#fff6d8"), sun.addColorStop(0.22, "rgba(255,229,168,0.55)"), sun.addColorStop(1, "rgba(255,229,168,0)"), (cx.fillStyle = sun), cx.fillRect(400, 200, 520, 312)); // nubes suaves for (let q = 0; q < 30; q++) { let x = n2(0, 2048), w = n2(120, 420), hh = n2(14, 42), yy = n2(60, 470); cx.fillStyle = `rgba(255,255,255,${0.06 + Math.random() * 0.14})`; cx.beginPath(), cx.ellipse(x, yy, w / 2, hh, 0, 0, 6.283), cx.fill(); } // mar let sea = cx.createLinearGradient(0, 510, 0, 1024); (sea.addColorStop(0, "#8fc4d8"), sea.addColorStop(0.12, "#2b8bab"), sea.addColorStop(0.55, "#0f6b96"), sea.addColorStop(1, "#0a3c60"), (cx.fillStyle = sea), cx.fillRect(0, 510, 2048, 514)); // destellos de ola for (let q = 0; q < 320; q++) { cx.fillStyle = `rgba(255,255,255,${0.02 + Math.random() * 0.06})`; cx.fillRect(n2(0, 2040), 516 + n2(0, 470), n2(18, 110), n2(1, 2)); } // costa: siluetas lejanas de islas (palmera simple + montes) varias longitudes for (let [u0, w2] of [[0.06, 300], [0.14, 170], [0.38, 240], [0.62, 190], [0.85, 330]]) { let bx = u0 * 2048, hh = w2 * 0.16; (cx.shadowColor = "rgba(40,90,80,0.9)"), (cx.shadowBlur = 10), (cx.fillStyle = "#3f6f5f"); cx.beginPath(), cx.ellipse(bx, 508, w2 / 2, hh, 0, Math.PI, 2 * Math.PI), cx.fill(); cx.beginPath(), cx.moveTo(bx - w2 * 0.42, 508), cx.lineTo(bx - w2 * 0.3, 508 - hh * 0.9), cx.lineTo(bx - w2 * 0.18, 508), cx.fill(); cx.beginPath(), cx.moveTo(bx + w2 * 0.2, 508), cx.lineTo(bx + w2 * 0.32, 508 - hh * 0.6), cx.lineTo(bx + w2 * 0.46, 508), cx.fill(); // palmera let px = bx + w2 * 0.04; (cx.strokeStyle = "#35594d"), (cx.lineWidth = 4), cx.beginPath(), cx.moveTo(px, 508), cx.lineTo(px - 4, 508 - hh * 1.5), cx.stroke(); for (let f2 of [-1, 1]) { cx.beginPath(), cx.moveTo(px - 4, 508 - hh * 1.5), cx.quadraticCurveTo(px - 4 + f2 * 26, 508 - hh * 1.7, px - 4 + f2 * 40, 508 - hh * 1.4), cx.stroke(); } } cx.shadowBlur = 0; let tex = new Rt(cv); ((tex.flipY = !1), (tex.colorSpace = lt), (tex.needsUpdate = !0)); let msh = new st(new gs(40, 48, 24), new Wt({ side: Gt, map: tex, toneMapped: !1, depthWrite: !1 })); return ((msh.frustumCulled = !1), (msh.renderOrder = -1), msh); } function vp(e, t = {}) { let { studio: n = !0, materials: i = !0, shadows: s = !0 } = t, { renderer: r, scene: o, armature: a } = e, l = r.capabilities.getMaxAnisotropy(), c = {}; if ( (a.traverse((h) => { if (h.isMesh) c[h.name] = h; }), n) ) { let h = new URLSearchParams(location.search); ((r.toneMapping = { agx: Wo, neutral: Fr, aces: Ys }[h.get("tm") ?? "neutral"] ?? Fr), (r.toneMappingExposure = Number(h.get("exp") ?? 1)), (o.environment = Y_(r)), (o.environmentIntensity = Number(h.get("env") ?? 1.08))); if (h.get("bg") !== "off") o.add(Tq()); let u = new Qn("#fff8f7", Number(h.get("key") ?? 0.38)); if ((u.position.set(-0.75, 2.55, 1.6), u.target.position.set(0, 1.55, 0.03), o.add(u, u.target), s)) { ((r.shadowMap.enabled = !0), (r.shadowMap.type = Fo), (u.castShadow = !0), u.shadow.mapSize.set(2048, 2048)); let d = u.shadow.camera; ((d.left = d.bottom = -0.42), (d.right = d.top = 0.42), (d.near = 0.5), (d.far = 3.5), (u.shadow.bias = -0.0004), (u.shadow.normalBias = 0.004), (u.shadow.radius = 14), (u.shadow.intensity = 0.72), (u.shadow.blurSamples = 16)); for (let f of [ "Wolf3D_Head", "Wolf3D_Hair", "Wolf3D_Glasses", "Wolf3D_Outfit_Top", "Ava_Collar", "Wolf3D_Body", "EyeLeft", "EyeRight", ]) { if (!c[f]) continue; ((c[f].castShadow = !f.startsWith("Eye") && f !== "Wolf3D_Glasses"), (c[f].receiveShadow = !0)); } } } if (i) { let h = null; for (let d of q_) { let f = c[d]; if (!f) continue; f.material = Ji(f.material, { clearcoat: 0.1, clearcoatRoughness: 0.3, clearcoatNormalMap: f.material.normalMap, specularIntensity: 0.55, normalScale: new ve(0.45, -0.45), }); let m = null; if (d === "Wolf3D_Head" && $t.lids_uv) { let y = new Jn().load(new URL("avatars/ava-lids.webp", document.baseURI).href); ((y.colorSpace = lt), (y.flipY = !1), (m = { texture: y, blink: { value: new ve() }, shellFade: { value: new ve() }, clipN: { value: new E(0, 1, 0) }, clipC: { value: new E() }, clipE1: { value: new E(0, 0, 1) }, clipE2: { value: new E(1, 0, 0) }, foldH: { value: Array(16).fill(-1000) }, neckOnly: { value: 0 }, foldClip: { value: 1 }, wallR: { value: 1 }, })); let p = f.morphTargetDictionary, g = (x) => f.morphTargetInfluences[p[x]] ?? 0, _ = n1(e, r, c, m); f.onBeforeRender = () => { let x = g("eyesClosed"); (m.blink.value.set(Math.min(1, g("eyeBlinkLeft") + x), Math.min(1, g("eyeBlinkRight") + x)), m.shellFade.value.set( Math.max(m.blink.value.x, g("eyeWideLeft") * 0.8), Math.max(m.blink.value.y, g("eyeWideRight") * 0.8), ), _?.()); }; } if (m) h = m; if ((Z_(f.material, m), d === "Wolf3D_Body" && $t.skin_grain_m)) t1(f.material); } let u = j_(r); for (let d of ["EyeLeft", "EyeRight"]) { let f = c[d]; if (!f) continue; f.material = Ji(f.material, { color: new re(1.62, 1.56, 1.52), roughness: 0.7, specularIntensity: 0.05, envMap: u, envMapIntensity: 1.2, }); let m = { uGaze: { value: new Be() }, uEyeC: { value: $_(f.geometry) }, uCatch: { value: new ve() }, uClosing: { value: 0 }, }; K_(f.material, m); let y = d === "EyeLeft" ? "Left" : "Right"; f.onBeforeRender = () => J_(c.Wolf3D_Head, y, m); } if (c.Wolf3D_Hair) ((c.Wolf3D_Hair.material = Ji(c.Wolf3D_Hair.material, { color: new re(gr * 0.8, gr * 0.8, gr * 0.8), roughness: 0.6, specularIntensity: 0.26, specularColor: new re("#7a5a44"), normalScale: new ve(0.55, 0.55), })), e1(c.Wolf3D_Hair.material), xp(c.Wolf3D_Hair.material)); for (let d of ["Wolf3D_Outfit_Top", "Ava_Collar"]) { if (!c[d]) continue; c[d].material = Ji(c[d].material, { color: new re(0.13, 0.125, 0.135), roughness: 0.5, metalness: 0, specularIntensity: 0.45, sheen: 0.95, sheenRoughness: 0.36, sheenColor: new re(`#${new URLSearchParams(location.search).get("sheen") ?? "b3aaa0"}`), normalScale: new ve(0.6, 0.6), }); } if (c.Ava_Strands) ((c.Ava_Strands.material = Ji(c.Ava_Strands.material, { color: new re(gr, gr, gr), roughness: 0.68, specularIntensity: 0.3, specularColor: new re("#7a5a44"), })), xp(c.Ava_Strands.material), (c.Ava_Strands.castShadow = !0), (c.Ava_Strands.receiveShadow = !0)); if (c.Ava_EyeShell) c.Ava_EyeShell.material = new Wt({ map: c.Ava_EyeShell.material.map, vertexColors: !0, transparent: !0, depthWrite: !1, side: Yt, toneMapped: !1, polygonOffset: !0, polygonOffsetFactor: -2, polygonOffsetUnits: -6, }); if (c.Ava_EyeShell && h) c.Ava_EyeShell.material.onBeforeCompile = (d) => { ((d.uniforms.lidBlink = h.shellFade), (d.vertexShader = d.vertexShader .replace( "#include ", `#include varying float vShellX;`, ) .replace( "#include ", `#include vShellX = position.x;`, )), (d.fragmentShader = d.fragmentShader .replace( "#include ", `#include varying float vShellX; uniform vec2 lidBlink;`, ) .replace( "#include ", `diffuseColor.a *= 1.0 - smoothstep(0.12, 0.55, vShellX > 0.0 ? lidBlink.x : lidBlink.y); #include `, ))); }; if (c.Ava_Lashes) c.Ava_Lashes.material = Ji(c.Ava_Lashes.material, { roughness: 1, specularIntensity: 0, envMapIntensity: 0 }); if (c.Wolf3D_Teeth) ((c.Wolf3D_Teeth.material = Ji(c.Wolf3D_Teeth.material, { color: new re(0.62, 0.6, 0.55), roughness: 0.28, specularIntensity: 0.6, clearcoat: 0.5, clearcoatRoughness: 0.18, normalScale: new ve(0.5, 0.5), })), (c.Wolf3D_Teeth.receiveShadow = !1), Q_(c.Wolf3D_Teeth.material)); if (c.Wolf3D_Glasses) c.Wolf3D_Glasses.material = Ji(c.Wolf3D_Glasses.material, { color: new re(0.1, 0.095, 0.095), roughness: 0.42, clearcoat: 0.35, clearcoatRoughness: 0.2, envMap: o.environment, envMapIntensity: 0.35, }); } mq(c); window.__avaDebug = { scene: o, armature: a, meshes: c, renderer: r }; // ratón: arrastrar gira el avatar; doble clic lo devuelve al frente { let mg = r.domElement, dn = !1, lx = 0, ly = 0; ((mg.style.touchAction = "none"), mg.addEventListener("pointerdown", (ev) => { if (ev.button === 0) ((dn = !0), (lx = ev.clientX), (ly = ev.clientY)); }), window.addEventListener("pointerup", () => (dn = !1)), mg.addEventListener("pointerleave", () => (dn = !1)), mg.addEventListener("dblclick", () => ((a.rotation.y = 0), (a.rotation.x = 0))), mg.addEventListener("pointermove", (ev) => { if (!dn) return; let dx = ev.clientX - lx, dy = ev.clientY - ly; ((lx = ev.clientX), (ly = ev.clientY), (a.rotation.y += dx / 220), (a.rotation.x = Math.max(-0.3, Math.min(0.3, a.rotation.x + dy / 220)))); })); } a.traverse((h) => { if (!h.isMesh) return; for (let u of [h.material.map, h.material.normalMap, h.material.roughnessMap]) if (u) ((u.anisotropy = l), (u.needsUpdate = !0)); h.material.needsUpdate = !0; }); } var i1 = new URL("vendor/headworklet.min.mjs", document.baseURI).href, s1 = new URL("vendor/model-en-mixed.bin", document.baseURI).href, to = new URLSearchParams(location.search), r1 = new URL(`avatars/${to.get("avatar") ?? "brunette.glb"}`, document.baseURI).href, o1 = 4, a1 = ["neutral", "happy", "angry", "sad", "fear", "disgust", "love", "sleep"], l1 = ["handup", "index", "ok", "thumbup", "thumbdown", "side", "shrug"]; if (/brunette\.glb/.test(r1)) (($t.lids_uv = null), ($t.fringe_cut_y = null)); class ah { constructor(e) { ((this._container = e), (this.head = null), (this._headaudio = null), (this._lastSpeechEnded = 0), (this._voiceBus = null), (this._moodSetThisTurn = !1)); } async init(e = {}) { if ( ((this.head = new sh(this._container, { ttsEndpoint: "N/A", lipsyncModules: [], cameraView: "upper", cameraDistance: -1.4, cameraY: -0.15, cameraX: -0.18, cameraRotateEnable: !1, lightAmbientIntensity: 0, lightDirectIntensity: 0, lightSpotIntensity: 0, modelPixelRatio: Gn ? Math.min(1, 2 / window.devicePixelRatio) : 1, avatarIdleEyeContact: 0.3, avatarSpeakingEyeContact: 0.7, })), await this.head.showAvatar( { url: e.avatarUrl ?? r1, body: e.body ?? "F", avatarMood: "neutral" }, e.onprogress ?? null, ), to.get("look") !== "off") ) vp(this.head, { studio: to.get("studio") !== "off", materials: to.get("materials") !== "off", shadows: to.get("shadows") !== "off", }); (await this._initLipsync(), this._initVoiceBus()); } _initVoiceBus() { let e = this.head, t = e.audioCtx, n = t.createGain(); n.gain.value = o1; let i = t.createDynamicsCompressor(); ((i.threshold.value = -3), (i.knee.value = 3), (i.ratio.value = 20), (i.attack.value = 0.002), (i.release.value = 0.1), n.connect(i).connect(e.audioAnalyzerNode), (this._voiceBus = n)); } async _initLipsync() { let e = this.head; await e.audioCtx.audioWorklet.addModule(i1); let t = new oh(e.audioCtx); (await t.loadModel(s1), e.audioSpeechGainNode.connect(t), (t.onvalue = (n, i) => { let s = e.mtAvatar?.[n]; if (s) Object.assign(s, { newvalue: i, needsUpdate: !0 }); }), (e.opt.update = t.update.bind(t)), (t.onended = () => { this._lastSpeechEnded = Date.now(); }), (t.onstarted = () => { if (Date.now() - this._lastSpeechEnded > 150) (e.lookAtCamera(500), e.speakWithHands()); }), (this._headaudio = t)); } get audioCtx() { return this.head?.audioCtx ?? null; } setGlasses(e) { let t = this.head?.armature?.getObjectByName("Wolf3D_Glasses"); if (t) t.visible = e; } get voiceSink() { return this._voiceBus; } get mouthLevel() { let e = this.head?.mtAvatar; if (!e) return 0; let t = 0; for (let n of Object.keys(e)) if (n.startsWith("viseme_") && n !== "viseme_sil") t = Math.max(t, e[n].value ?? 0); return t; } resume() { (this.head?.start(), this.unlockAudio()); } unlockAudio() { let e = this.head?.audioCtx.state; if (e === "suspended" || e === "interrupted") this.head?.audioCtx.resume().catch(() => {}); } setConversationState(e) { let t = this.head; if (!t) return; switch (e) { case "user-speaking": ((t.isSpeaking = !1), t.lookAtCamera(800)); break; case "ai-speaking": t.isSpeaking = !0; break; case "processing": ((t.isSpeaking = !1), (this._moodSetThisTurn = !1)); break; case "closed": case "error": case "idle": ((t.isSpeaking = !1), t.stopGesture(300)); break; default: t.isSpeaking = !1; } } endOfReply() { let e = this.head; if (e && !this._moodSetThisTurn && e.moodName !== "neutral") e.setMood("neutral"); } runTool(e, t) { let n = this.head; if (!n) return null; if (e === "set_mood") { let i = typeof t.mood === "string" ? t.mood : ""; if (!a1.includes(i)) return `Unknown mood: ${i}`; return (n.setMood(i), (this._moodSetThisTurn = !0), `Mood set to ${i}.`); } if (e === "make_hand_gesture") { let i = typeof t.gesture === "string" ? t.gesture : ""; if (!l1.includes(i)) return `Unknown gesture: ${i}`; return (n.playGesture(i, 3), `Playing gesture ${i}.`); } if (e === "make_facial_expression") { let i = typeof t.emoji === "string" ? t.emoji.trim() : ""; if (!i) return "No emoji given."; return (n.speakEmoji(i), `Expressing ${i}.`); } return null; } } class lh { constructor(e, t = Date.now) { ((this.storage = e), (this.now = t), (this.note = null), (this.departed = !1)); } previousCrash() { let e = this.read(); if (!e || e.hidden || this.now() - e.t > 600000) return null; return e; } attemptsSoFar() { let e = this.read(); return e && this.now() - e.t <= 600000 ? e.attempt : 0; } start(e, t = this.attemptsSoFar() + 1) { ((this.note = { step: e, attempt: t, t: this.now() }), this.write()); } step(e) { if (!this.note || this.departed) return; ((this.note.step = e), (this.note.t = this.now()), this.write()); } setHidden(e) { if (!this.note || this.departed) return; ((this.note.hidden = e), (this.note.t = this.now()), this.write()); } left() { ((this.departed = !0), this.remove()); } returned() { if (((this.departed = !1), this.note)) this.write(); } finished() { ((this.note = null), this.remove()); } read() { try { let e = this.storage.getItem("ava.load"); return e ? JSON.parse(e) : null; } catch { return null; } } write() { try { this.storage.setItem("ava.load", JSON.stringify(this.note)); } catch {} } remove() { try { this.storage.removeItem("ava.load"); } catch {} } } var ch = [ "I'm so excited to meet you. I'll be right with you.", "Thanks for waiting. Good things take a minute, and so do I.", "My whole brain is moving into your browser right now. It's a tight fit.", "I run right here on your computer, so please excuse the mess while I unpack.", "I'm just warming up my voice. Testing, testing. Oh, that's nice!", "Some people need coffee to get going. I need one point six gigabytes.", "Don't worry, the first time is the slowest. Next time, I'll be much quicker.", "While you wait, think of something fun to tell me. I can't wait to hear it.", "Still here! I promise I'm worth the wait. Well, I hope so.", ], _p = (e) => `loading/${String(e + 2).padStart(2, "0")}.mp3`; function Sp(e) { return ch.map(async (t, n) => { let i = await fetch(e(n)); if (!i.ok) throw Error(`line ${n + 1}: HTTP ${i.status}`); return i.arrayBuffer(); }); } class hh { constructor(e) { ((this._opt = e), (this._started = !1), (this._winding = !1), (this._source = null), (this._wake = () => {})); } get speaking() { return this._source !== null; } async start() { if (this._started) return; this._started = !0; let { gapMs: e = 3000 } = this._opt; try { let t = this._decode(0); for (let n = 0; t && !this._winding; n++) { let i = await t; if (this._winding) return; if (((t = n + 1 < ch.length ? this._decode(n + 1) : null), await this._play(i, n), t && !this._winding)) await new Promise((s) => { ((this._wake = () => s(void 0)), setTimeout(s, e)); }); } } catch (t) { console.warn("loading lines stopped:", t); } } finish() { ((this._started = !0), (this._winding = !0), this._wake()); } stop() { this.finish(); try { this._source?.stop(); } catch {} } async _decode(e) { return this._opt.ctx.decodeAudioData(await this._opt.clips[e]); } _play(e, t) { return new Promise((n) => { let i = this._opt.ctx.createBufferSource(); ((i.buffer = e), i.connect(this._opt.sink), (i.onended = () => { (i.disconnect(), (this._source = null), this._opt.onend?.(), n(void 0)); }), (this._source = i), this._opt.onstart?.(ch[t], t), i.start()); }); } } var c1 = /\b(sorry|sad|unfortunately|tough|that sounds hard|condolences)\b/i, h1 = /\b(great|fun|nice|wonderful|awesome|glad|fantastic|yay|congrat\w*|haha|well done|love)\b/i, u1 = [ [/\bthumbs? down\b/i, "thumbdown"], [/\bthumbs? up\b|\b(well done|good job|you got it|that's right|correct)\b/i, "thumbup"], [/\b(not sure|i don'?t know|no idea|hard to say)\b/i, "shrug"], [/^\s*(hi|hello|hey)\b/i, "handup"], [/\bok(ay)? sign\b/i, "ok"], ]; function bp(e) { let t = c1.test(e) ? "sad" : h1.test(e) ? "happy" : null, n = u1.find(([i]) => i.test(e))?.[1] ?? null; return { mood: t, gesture: n }; } class uh extends EventTarget { constructor({ model: e, mic: t, voice: n }) { super(); ((this.model = e), (this.mic = t), (this.voice = n), (this.status = "connected"), (this.nextTurnId = 1), (this.turn = null), (this.metrics = []), (this._speechStartedAt = 0), (this._closed = !1)); } _setStatus(e) { if (e === this.status) return; ((this.status = e), this.mic.guarded(e === "processing" || e === "ai-speaking"), this.dispatchEvent(new CustomEvent("status", { detail: { status: e } }))); } onSpeechStart() { if (this._closed) return; if (((this._speechStartedAt = performance.now()), this.turn)) this._interrupt(); this._setStatus("user-speaking"); } onMisfire() { if (this._closed) return; if (this.status === "user-speaking") this._setStatus("connected"); } onSpeechEnd(e) { if (this._closed) return; let t = this.nextTurnId++, n = performance.now(); (this.voice.beginTurn(), (this.turn = { id: t, finished: !1, reply: "", metric: { id: t, userSeconds: +(e.length / 16000).toFixed(2), speechEndedAt: n, firstTextMs: null, firstAudioMs: null, replySeconds: 0, reply: "", tools: [], outcome: "streaming", }, }), this.metrics.push(this.turn.metric), this._setStatus("processing"), this.model.respond(t, e)); } sendText(e) { if (!this._closed && (e = (e ?? "").trim())) { if (this.turn) this._interrupt(); (this.voice.beginTurn(), (this.turn = { id: this.nextTurnId++, finished: !1, reply: "", metric: { id: this.nextTurnId - 1, userSeconds: null, speechEndedAt: performance.now(), firstTextMs: null, firstAudioMs: null, replySeconds: 0, reply: "", tools: [], outcome: "streaming", }, }), this.metrics.push(this.turn.metric), this.model.respond(this.turn.id, null, e), this.dispatchEvent(new CustomEvent("user-text", { detail: { text: e } }))); } } onText(e, t) { let n = this.turn; if (!n || n.id !== e) return; ((n.metric.firstTextMs ??= Math.round(performance.now() - n.metric.speechEndedAt)), (n.reply += t), (n.metric.reply = n.reply), this.voice.pushText(t), this.dispatchEvent(new CustomEvent("reply-text", { detail: { text: n.reply } }))); } onAudio(e, t) { let n = this.turn; if (!n || n.id !== e) return; ((n.metric.firstAudioMs ??= Math.round(performance.now() - n.metric.speechEndedAt)), (n.metric.replySeconds += t.length / this.voice.sampleRate), this.voice.pushAudio(t), this._setStatus("ai-speaking")); } noteReaction(e, t) { this.turn?.metric.tools.push({ name: e, args: t }); } onFinished(e, t, n) { let i = this.turn; if (!i || i.id !== e) return; if ( ((i.finished = !0), (i.metric.outcome = t), (i.metric.totalMs = Math.round(performance.now() - i.metric.speechEndedAt)), n) ) { ((this.turn = null), this.dispatchEvent(new CustomEvent("error", { detail: { error: n } })), this._setStatus("connected")); return; } if ((this.voice.endTurn(), !this.voice.pending)) this._turnDone(); } onDrained() { if (this.turn?.finished && !this.voice.pending) this._turnDone(); } _turnDone() { let e = this.turn; if (((this.turn = null), e)) this.dispatchEvent(new CustomEvent("reply-finished", { detail: { text: e.reply } })); if (this.status === "processing" || this.status === "ai-speaking") this._setStatus("connected"); } _interrupt() { let e = this.turn; if (((this.turn = null), !e)) return; if ( ((e.metric.outcome = "interrupted"), (e.metric.heardSeconds = "played" in this.voice ? +(this.voice.played / this.voice.sampleRate).toFixed(2) : null), !e.finished) ) this.model.abort(e.id); (this.voice.clear(), this.dispatchEvent(new CustomEvent("interrupted"))); } setMuted(e) { if ((this.mic.setMuted(e), e && this.status === "user-speaking")) this._setStatus("connected"); } close() { if (this._closed) return; if (this.turn) this._interrupt(); ((this._closed = !0), this.mic.close(), this.model.reset(), this._setStatus("closed")); } } var Mp = "Eres Ava, una amiga cálida y despierta que conversa cara a cara, no una asistente. Responde siempre en español y de manera natural. Si te piden que actúes como otro personaje (cualquier nombre, rol o personalidad), encarnas ese personaje al instante y lo mantienes hasta que te pidan volver a Ava."; var MpEn = "You're Ava, a warm, quick-witted friend chatting face to face, not an assistant."; var Mp1 = "Eres Ava, una amiga cálida y despierta que conversa cara a cara, no una asistente. Responde siempre en español y de manera natural."; function wp(e) { let t = e.getItem("ava.systemPrompt4"); if (t != null) return t; t = e.getItem("ava.systemPrompt3") ?? e.getItem("ava.systemPrompt"); return t === MpEn || t === Mp1 || t == null ? Mp : t; } function Tp(e, t) { if (t === Mp) for (let s2 of ["ava.systemPrompt4", "ava.systemPrompt3", "ava.systemPrompt"]) e.removeItem(s2); else e.setItem("ava.systemPrompt4", t); } function dh(e) { let t = e.trim(); return t ? `${t} Respond with interleaved text and audio.` : "Respond with interleaved text and audio."; } function d1(e) { if (!e || e >= 1.25) return 0.12; let t = 8 * (1 / e - 1); return Math.min(12, 0.12 + Math.max(0, t) + 0.5); } function fh(e) { return e.replace(/\*\*|__/g, "").replace(/\s+/g, " "); } class Ra { static async create(e, t, n) { await e.audioWorklet.addModule(n); let i = new AudioWorkletNode(e, "audio-playback", { numberOfInputs: 0, numberOfOutputs: 1, outputChannelCount: [1], }); return (i.connect(t), new Ra(i)); } constructor(e) { ((this._node = e), (this.sampleRate = 24000), (this.ondrained = null), (this.onheard = null), (this._realtimeFactor = null), this._clearTurn(), (e.port.onmessage = ({ data: t }) => { if (t.kind === "progress") ((this.played = t.played), this._updateHeard()); else if (t.kind === "drained") ((this.played = t.played), this._updateHeard(), this.ondrained?.()); })); } _clearTurn() { ((this.played = 0), (this.pushed = 0), (this._marks = []), (this._heard = ""), (this._heardCount = 0), (this._turnStart = 0)); } configure(e) { ((this.sampleRate = e), this._node.port.postMessage({ kind: "config", inputRate: e })); } beginTurn() { (this._node.port.postMessage({ kind: "clear" }), this._clearTurn(), this._node.port.postMessage({ kind: "lead", samples: Math.round(d1(this._realtimeFactor) * this.sampleRate) })); } pushText(e) { (this._marks.push({ at: this.pushed, text: e }), this._updateHeard()); } pushAudio(e) { if (!this._turnStart) this._turnStart = performance.now(); ((this.pushed += e.length), this._node.port.postMessage({ kind: "audio", samples: e }, [e.buffer])); } endTurn() { if (this._turnStart && this.pushed > 0) { let e = (performance.now() - this._turnStart) / 1000; if (e > 0.5) this._realtimeFactor = this.pushed / this.sampleRate / e; } this._node.port.postMessage({ kind: "flush" }); } clear() { (this._node.port.postMessage({ kind: "clear" }), this._clearTurn()); } get pending() { return this.played < this.pushed; } _updateHeard() { let e = !1; while (this._heardCount < this._marks.length && this._marks[this._heardCount].at <= this.played) ((this._heard += this._marks[this._heardCount].text), (this._heardCount += 1), (e = !0)); if (e) this.onheard?.(fh(this._heard).trim()); } } var La = new URLSearchParams(location.search), f1 = La.get("model") ?? "LiquidAI/LFM3-Omni-2B-GGUF", io = (e) => new URL(e, document.baseURI).href, Ip = "ava.subtitles", Pp = "ava.glasses", on = (e) => document.querySelector(e), p1 = on("#stage"), ph = on("#main-btn"), m1 = on("#main-btn-label"), no = on("#mute-btn"), Ep = on("#caption"), Ts = on("#subtitles"), yr = on("#loading"), Sh = on("#progress"), g1 = on("#progress-fill"), y1 = on("#settings-btn"), Dp = on("#settings"), bh = on("#system-prompt"), x1 = on("#reset-prompt"), Up = on("#subtitles-toggle"), Ca = on("#glasses-toggle"), yt = new ah(p1), Ht = null, xr = null, es = !1, Mh = !1, mh = 0, Es = !1, so = !1, Ei = null, gh = [], ts, Qi, yh = Promise.resolve(), Rn = Gn ? new lh(localStorage) : null; function v1() { return { systemPrompt: wp(localStorage), subtitles: localStorage.getItem(Ip) === "1", glasses: localStorage.getItem(Pp) === "1", }; } var Ln = v1(); function _1() { (Tp(localStorage, Ln.systemPrompt), localStorage.setItem(Ip, Ln.subtitles ? "1" : "0"), localStorage.setItem(Pp, Ln.glasses ? "1" : "0")); } function Jt(e, t = "") { ((Ep.textContent = e), (Ep.className = t)); } function Np(e) { if (!Ln.subtitles || !e) return; (clearTimeout(mh), (Ts.textContent = e), Ts.classList.add("visible")); } function Fp(e = 2600) { (clearTimeout(mh), (mh = window.setTimeout(() => Ts.classList.remove("visible"), e))); } var xh = "start"; function ai(e, t) { ((xh = e), (m1.textContent = t), (ph.disabled = e === "busy"), ph.classList.toggle("live", e === "stop"), (no.hidden = e !== "stop")); } var Pa = { idle: "TAP TO TALK", connecting: "CONNECTING…", connected: "GO AHEAD, I'M LISTENING", "user-speaking": "LISTENING", processing: "THINKING…", "ai-speaking": "SPEAKING", closed: "TAP TO TALK", }; function Ia(e) { if ((yt.setConversationState(e), e === "processing")) Ms = { mood: null, gesture: null }; if (e === "connected" && Mh && !es) { Jt("I CAN'T HEAR YOUR MIC. CHECK IT, OR END AND START AGAIN", "error"); return; } if ( (Jt(es && e === "connected" ? "MIC MUTED" : (Pa[e] ?? e), e === "idle" || e === "closed" ? "" : "live"), e === "user-speaking") ) Ts.classList.remove("visible"); } var Ms = { mood: null, gesture: null }; function Op(e) { let { mood: t, gesture: n } = bp(e); if (t && t !== Ms.mood && Ms.mood !== "sad") ((Ms.mood = t), yt.runTool("set_mood", { mood: t }), Ht?.noteReaction("set_mood", { mood: t })); if (n && !Ms.gesture) ((Ms.gesture = n), yt.runTool("make_hand_gesture", { gesture: n }), Ht?.noteReaction("make_hand_gesture", { gesture: n })); } var S1 = 2000, wh = !1, Th = !1, Eh = ["touchend", "pointerup", "click", "keydown"]; function b1() { if (Es || rn.modelError) return; if (((wh = !0), Th || yt.audioCtx?.state === "running")) Bp(); else if (so) Jt(vh(ws)); } function kp(e) { if (e.target.closest?.("#settings, #settings-btn")) return; if ((Hp("playback"), yt.unlockAudio(), (Th = !0), wh)) Bp(); } function zp() { for (let e of Eh) window.removeEventListener(e, kp, !0); } function Hp(e) { try { let t = navigator.audioSession; if (t) t.type = e; } catch {} } function Bp() { if (Ei || !La.has("lines")) return; (yt.resume(), (rn.loadingLines = []), (Ei = new hh({ ctx: yt.audioCtx, sink: yt.voiceSink, clips: gh, onstart: (e, t) => { (rn.loadingLines.push(t + 1), yt.setConversationState("ai-speaking"), yt.runTool("set_mood", { mood: "happy" }), (Ms = { mood: "happy", gesture: null }), Np(e), Op(e)); }, onend: () => { if ((yt.setConversationState("processing"), yt.endOfReply(), !Ht)) yt.setConversationState("idle"); Fp(); }, })), Ei.start()); } var M1 = (e) => `${(e / 1e9).toFixed(1)} GB`, ws = "LOADING THE MODEL…"; function vh(e) { return wh && !Th && yt.audioCtx?.state !== "running" ? `${e.replace("LOADING THE MODEL", "LOADING")} · TAP FOR SOUND` : e; } function Ap() { let e = new URL(io("workers/model-worker.js")); for (let t of ["simulateRtf", "historyBudget", "holdLoadMs"]) if (La.has(t)) e.searchParams.set(t, La.get(t)); if (Gn) e.searchParams.set("lowmem", "1"); ((ts = new Worker(e, { type: "module" })), (ts.onmessage = ({ data: t }) => { switch (t.kind) { case "progress": w1(t); break; case "ready": if (((Es = !0), Aq(), Rn?.finished(), Gn)) Vp(); (xr?.configure(t.sampleRate), Object.assign(rn, { device: t.device, modelSampleRate: t.sampleRate }), (Sh.hidden = !0), Gp()); break; case "failed": Lp(t); break; case "text": Ht?.onText(t.id, t.text); break; case "audio": Ht?.onAudio(t.id, t.samples); break; case "finished": Ht?.onFinished(t.id, t.reason, t.error); break; } }), (ts.onerror = (t) => Lp({ name: "WorkerError", message: t.message })), ts.postMessage({ kind: "load", model: f1, system: dh(Ln.systemPrompt) })); } var Rp = -1; function w1(e) { if (Es) return; if (e.total) { let t = Math.min(100, Math.floor(((e.loaded ?? 0) / e.total) * 100)); if (t !== Rp) Rn?.step(`model ${(Rp = t)}%`); if (((Sh.hidden = !1), (g1.style.width = `${t}%`), (ws = `LOADING THE MODEL ${t}% OF ${M1(e.total)}`), so)) Jt(vh(ws)); } else if (e.status) { if ((Rn?.step(e.status), (ws = e.status.toUpperCase()), so)) Jt(vh(ws)); } } function Lp(e) { (console.error("model failed:", e), Rn?.finished(), zp(), Ei?.stop(), (Sh.hidden = !0)); let t = e.name === "WebGPUUnavailable", n = Gn && /device lost|out of memory|outofmemory|allocat/i.test(`${e.name} ${e.message}`); (Jt( t ? Ea ? "THIS BROWSER CAN'T RUN THE MODEL. OPEN IT IN SAFARI ON IOS 26 OR LATER" : "THIS BROWSER CAN'T RUN THE MODEL. OPEN IT IN A RECENT CHROME OR EDGE WITH WEBGPU" : n ? "NOT ENOUGH MEMORY FOR THE MODEL. CLOSE OTHER TABS AND APPS, THEN RELOAD" : "THE MODEL DIDN'T LOAD. CHECK YOUR CONNECTION AND RELOAD", "error", ), ai("busy", t ? "Not supported" : "Failed to load"), Object.assign(rn, { modelError: e })); } function Gp() { if (!Es || !so) return; (zp(), Ei?.finish(), Jt(Pa.idle), ai("start", "Start talking")); } function Vp() { ((Qi = new Worker(io("workers/vad-worker.js"), { type: "module" })), (yh = new Promise((e, t) => { Qi.onmessage = ({ data: n }) => { switch (n.kind) { case "ready": e(); break; case "failed": (console.error("vad failed:", n.message), t(Error(n.message))); break; case "mic-silent": if (((Mh = n.value), Ht?.status === "connected")) Ia("connected"); break; case "stats": rn.vad = n.stats; break; case "start": Ht?.onSpeechStart(); break; case "misfire": Ht?.onMisfire(); break; case "end": Ht?.onSpeechEnd(n.samples); break; } }; })), yh.catch(() => {})); } async function T1() { (Ei?.stop(), Hp("auto"), yt.resume(), ai("busy", "Connecting…"), Jt(Pa.connecting, "live")); let e; try { e = await navigator.mediaDevices.getUserMedia({ audio: { channelCount: 1, echoCancellation: !0, noiseSuppression: !0, autoGainControl: !0 }, }); } catch { (Jt("MIC BLOCKED, ALLOW IT IN THE BROWSER AND RETRY", "error"), ai("start", "Retry")); return; } let t = yt.audioCtx; try { if ((await yh, !xr)) ((xr = await Ra.create(t, yt.voiceSink, io("worklets/audio-playback.js"))), xr.configure(rn.modelSampleRate ?? 24000), await t.audioWorklet.addModule(io("worklets/mic-capture.js"))); } catch (c) { console.error(c); for (let h of e.getTracks()) h.stop(); (Jt("COULD NOT START THE MIC, TAP TO RETRY", "error"), ai("start", "Retry")); return; } let n = t.createMediaStreamSource(e), i = new AudioWorkletNode(t, "mic-capture", { numberOfOutputs: 1, channelCount: 1 }), s = t.createGain(); ((s.gain.value = 0), n.connect(i), i.connect(s).connect(t.destination)); let { port1: r, port2: o } = new MessageChannel(); (i.port.postMessage({ kind: "port", port: r }, [r]), Qi.postMessage({ kind: "mic", port: o }, [o]), Qi.postMessage({ kind: "reset" })); let a = xr, l = new uh({ voice: a, model: { respond: (c, h, w) => h != null ? ts.postMessage({ kind: "respond", id: c, audio: h }, [h.buffer]) : ts.postMessage({ kind: "respond", id: c, text: w }), abort: (c) => ts.postMessage({ kind: "abort", id: c }), reset: () => ts.postMessage({ kind: "reset" }), }, mic: { guarded: (c) => Qi.postMessage({ kind: "guarded", value: c }), reset: () => Qi.postMessage({ kind: "reset" }), setMuted: (c) => { if ((i.port.postMessage({ kind: "enable", value: !c }), c)) Qi.postMessage({ kind: "reset" }); }, close: () => { for (let c of e.getTracks()) c.stop(); (i.port.postMessage({ kind: "enable", value: !1 }), n.disconnect(), i.disconnect(), s.disconnect(), Qi.postMessage({ kind: "reset" })); }, }, }); ((Ht = l), (a.ondrained = () => l.onDrained()), (a.onheard = (c) => { (Np(c), Op(c)); }), l.addEventListener("status", (c) => Ia(c.detail.status)), l.addEventListener("reply-finished", () => { (yt.endOfReply(), Fp()); }), l.addEventListener("interrupted", () => Ts.classList.remove("visible")), l.addEventListener("user-text", (c) => { if (Ln.subtitles) (Np(`Tú: ${c.detail.text}`), Fp(3200)); }), l.addEventListener("error", (c) => { let { error: h } = c.detail; if ((console.error("generation failed:", h), h.fatal)) (Wp(!0), Jt("THE GPU RESET. RELOAD THE PAGE TO CONTINUE", "error"), ai("busy", "Reload needed")); }), (es = !1), (Mh = !1), no.classList.remove("active"), ai("stop", "End conversation"), Ia("connected"), Aq(), yt.setConversationState("connected")); } function Aq() { if (Es && Ht && typedPending) { let e = typedPending; ((typedPending = null), Ht.sendText(e)); } } var typedPending = null, typedFormEl = on("#type-form"), typedInputEl = on("#type-input"); typedFormEl?.addEventListener("submit", (e) => { e.preventDefault(); let t = (typedInputEl.value ?? "").trim(); if (!t) return; if (!Es) return Jt(vh(ws)); if (Ht) { if (Ht.status === "closed") return; (Ht.sendText(t), (typedInputEl.value = "")); } else if (xh !== "busy") { ((typedPending = t), T1()); } else typedPending = t; }); async function Wp(e = !1) { let t = Ht; if (((Ht = null), t?.close(), yt.setConversationState("idle"), Ts.classList.remove("visible"), !e)) Jt(Pa.idle); ai("start", "Start talking"); } ph.addEventListener("click", () => { if (_h) ((_h = !1), Xp()); else if (xh === "start") T1(); else if (xh === "stop") Wp(); }); no.addEventListener("click", () => { if ( ((es = !es), Ht?.setMuted(es), no.classList.toggle("active", es), no.setAttribute("aria-label", es ? "Unmute microphone" : "Mute microphone"), Ht?.status === "connected") ) Ia("connected"); }); y1.addEventListener("click", () => { ((bh.value = Ln.systemPrompt), (Up.checked = Ln.subtitles), (Ca.checked = Ln.glasses), Dp.showModal()); }); Dp.addEventListener("close", () => { if (((Ln = { systemPrompt: bh.value, subtitles: Up.checked, glasses: Ca.checked }), _1(), !Ln.subtitles)) Ts.classList.remove("visible"); ts.postMessage({ kind: "system", system: dh(Ln.systemPrompt) }); }); Ca.addEventListener("change", () => yt.setGlasses(Ca.checked)); x1.addEventListener("click", () => { bh.value = Mp; }); window.addEventListener("beforeunload", () => Ht?.close()); document.addEventListener("visibilitychange", () => { if (!document.hidden && (Ei?.speaking || Ht)) yt.unlockAudio(); }); var rn = { modelSampleRate: null }; function E1() { let e = document.createElement("pre"); ((e.style.cssText = "position:fixed;inset:8px 8px auto;z-index:99;margin:0;padding:8px;background:#000c;color:#fff;font:11px/1.35 monospace;white-space:pre-wrap;pointer-events:none"), document.body.append(e)); let t = []; for (let s of Eh) window.addEventListener( s, () => { t.push(s); }, !0, ); let n = null, i = ""; (navigator.gpu?.requestAdapter().then( (s) => { if (((n = !!s), s)) i = `maxBuffer ${Math.round(s.limits.maxBufferSize / 1048576)} MB, maxBinding ${Math.round(s.limits.maxStorageBufferBindingSize / 1048576)} MB`; }, () => { n = !1; }, ), setInterval(() => { e.textContent = [ navigator.userAgent, `embedded: ${window.top !== window} webgpu: ${!!navigator.gpu} adapter: ${n}`, `audio: ${yt.audioCtx?.state} t=${yt.audioCtx?.currentTime.toFixed(1)} session: ${navigator.audioSession?.type}`, `lines: ${(rn.loadingLines ?? []).join(",") || "none"} speaking: ${!!Ei?.speaking}`, `tap events: ${t.slice(-6).join(" ") || "none"}`, `model: ${Es ? "ready" : (rn.modelError?.message ?? ws)}`, `lowmem: ${Gn} ${i} previous load: ${rn.crashed ? `killed at "${rn.crashed.step}" (try ${rn.crashed.attempt})` : "fine"}`, ].join(` `); }, 500)); } var _h = !1; async function Xp() { (yr.classList.remove("done"), Jt("WAKING HER UP…"), ai("busy", "Loading…")); for (let e of Eh) window.addEventListener(e, kp, !0); gh = Sp((e) => io(_p(e))); for (let e of gh) e.catch((t) => console.warn("loading line unavailable:", t)); if ((Rn?.start("avatar"), !Gn)) (Ap(), Vp()); try { await yt.init({ onprogress: (e) => { if (e.lengthComputable) { let t = Math.min(100, Math.round((e.loaded / e.total) * 100)); yr.textContent = `Loading avatar ${t}%`; } }, }); } catch (e) { (console.error(e), Rn?.finished(), (yr.textContent = "The avatar failed to load. Check the console and reload."), Jt("AVATAR FAILED TO LOAD", "error")); return; } if ((yt.setGlasses(Ln.glasses), yr.classList.add("done"), (so = !0), Gn)) (Rn?.step("model"), Ap()); if (Es) Gp(); else if (!rn.modelError) Jt(ws); if (!Es) setTimeout(b1, S1); Object.assign(window, { stage: yt, diagnostics: rn, getSession: () => Ht, getVoice: () => xr, getLoadingVoice: () => Ei, cleanSpokenText: fh, }); } function A1(e) { ((rn.crashed = e), (yr.textContent = ""), yr.classList.add("done")); let t = Ea ? "THIS DEVICE" : "THIS BROWSER"; (Jt( e.attempt > 1 ? `${t} KEEPS STOPPING THE PAGE WHILE LOADING, MOST LIKELY OUT OF MEMORY. IT MAY NOT HAVE ENOUGH TO RUN AVA (STOPPED AT: ${e.step.toUpperCase()})` : `${t} STOPPED THE PAGE WHILE LOADING, MOST LIKELY OUT OF MEMORY. CLOSE OTHER TABS AND APPS, THEN TRY AGAIN (STOPPED AT: ${e.step.toUpperCase()})`, "error", ), ai("start", "Try again"), (_h = !0)); } if (Rn) (window.addEventListener("pagehide", () => Rn.left()), window.addEventListener("pageshow", (e) => { if (e.persisted) Rn.returned(); }), document.addEventListener("visibilitychange", () => Rn.setHidden(document.hidden))); if (La.has("diag")) E1(); var Cp = Rn?.previousCrash(); if (Cp) A1(Cp); else Xp();