@expofp/floorplan
Version:
Interactive floor plan library for expos and events
24,316 lines • 1.1 MB
JavaScript
(function() {
try {
var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {};
e.SENTRY_RELEASE = { id: "3.39.1" };
var t = new e.Error().stack;
t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "ee5a6f36-307c-4428-97e5-320186c5b934", e._sentryDebugIdIdentifier = "sentry-dbid-ee5a6f36-307c-4428-97e5-320186c5b934");
} catch {}
})();
import { n as e, r as t, t as n } from "./rolldown-runtime-BOCG9HEF.js";
import { t as r } from "./react-CM7l092i.js";
import { t as i } from "./jsx-runtime-BGutO_I9.js";
import { t as a } from "./scheduler-CYuaS4GW.js";
//#region ../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.8/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
var o = /* @__PURE__ */ n(((e) => {
var t = r();
function n(e, t) {
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
}
var i = typeof Object.is == "function" ? Object.is : n, a = t.useState, o = t.useEffect, s = t.useLayoutEffect, c = t.useDebugValue;
function l(e, t) {
var n = t(), r = a({ inst: {
value: n,
getSnapshot: t
} }), i = r[0].inst, l = r[1];
return s(function() {
i.value = n, i.getSnapshot = t, u(i) && l({ inst: i });
}, [
e,
n,
t
]), o(function() {
return u(i) && l({ inst: i }), e(function() {
u(i) && l({ inst: i });
});
}, [e]), c(n), n;
}
function u(e) {
var t = e.getSnapshot;
e = e.value;
try {
var n = t();
return !i(e, n);
} catch {
return !0;
}
}
function d(e, t) {
return t();
}
var f = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? d : l;
e.useSyncExternalStore = t.useSyncExternalStore === void 0 ? f : t.useSyncExternalStore;
})), s = /* @__PURE__ */ n(((e, t) => {
t.exports = o();
})), c = /* @__PURE__ */ t(r(), 1), l, u, d, f, p, m, h, g, _, v = {
LEFT: 0,
MIDDLE: 1,
RIGHT: 2,
ROTATE: 0,
DOLLY: 1,
PAN: 2
}, y = {
ROTATE: 0,
PAN: 1,
DOLLY_PAN: 2,
DOLLY_ROTATE: 3
}, b = "attached", x = "detached", S = 1e3, C = 1001, w = 1002, T = 1003, E = 1004, D = 1004, O = 1005, k = 1005, A = 1006, ee = 1007, te = 1007, ne = 1008, j = 1008, M = 1009, re = 1010, ie = 1011, ae = 1012, oe = 1013, se = 1014, N = 1015, ce = 1016, le = 1017, ue = 1018, de = 1020, fe = 35902, pe = 35899, me = 1021, he = 1022, ge = 1023, _e = 1026, ve = 1027, ye = 1028, be = 1029, xe = 1030, Se = 1031, Ce = 1032, we = 1033, Te = 33776, Ee = 33777, De = 33778, Oe = 33779, ke = 35840, Ae = 35841, je = 35842, Me = 35843, Ne = 36196, Pe = 37492, P = 37496, Fe = 37488, Ie = 37489, Le = 37490, F = 37491, Re = 37808, I = 37809, ze = 37810, Be = 37811, Ve = 37812, He = 37813, Ue = 37814, We = 37815, Ge = 37816, Ke = 37817, qe = 37818, Je = 37819, Ye = 37820, Xe = 37821, Ze = 36492, Qe = 36494, $e = 36495, et = 36283, tt = 36284, nt = 36285, rt = 36286, it = 2200, at = 2201, ot = 2202, st = 2300, ct = 2301, lt = 2302, ut = 2303, dt = 2400, ft = 2401, pt = 2402, mt = 2500, ht = 2501, gt = 3200, _t = 3201, vt = 3202, yt = 3203, bt = "srgb", xt = "srgb-linear", St = "linear", Ct = "srgb", wt = 7680, Tt = 7681, Et = 7682, Dt = 7683, Ot = 34055, kt = 34056, At = 5386, jt = 35044, Mt = 35048, Nt = 35040, Pt = 35045, Ft = 35049, It = 35041, Lt = 35046, Rt = 35050, zt = 35042, Bt = "300 es", Vt = 2e3, Ht = 2001, Ut = {
COMPUTE: "compute",
RENDER: "render"
}, Wt = {
PERSPECTIVE: "perspective",
LINEAR: "linear",
FLAT: "flat"
}, Gt = {
NORMAL: "normal",
CENTROID: "centroid",
SAMPLE: "sample",
FIRST: "first",
EITHER: "either"
}, Kt = { TEXTURE_COMPARE: "depthTextureCompare" };
function qt(e) {
for (let t = e.length - 1; t >= 0; --t) if (e[t] >= 65535) return !0;
return !1;
}
var Jt = {
Int8Array,
Uint8Array,
Uint8ClampedArray,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array
};
function Yt(e, t) {
return new Jt[e](t);
}
function Xt(e) {
return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function Zt(e) {
return document.createElementNS("http://www.w3.org/1999/xhtml", e);
}
function Qt() {
let e = Zt("canvas");
return e.style.display = "block", e;
}
var $t = {}, en = null;
function tn(e) {
en = e;
}
function nn() {
return en;
}
function rn(...e) {
let t = "THREE." + e.shift();
en ? en("log", t, ...e) : console.log(t, ...e);
}
function an(e) {
let t = e[0];
if (typeof t == "string" && t.startsWith("TSL:")) {
let t = e[1];
t && t.isStackTrace ? e[0] += " " + t.getLocation() : e[1] = "Stack trace not available. Enable \"THREE.Node.captureStackTrace\" to capture stack traces.";
}
return e;
}
function L(...e) {
e = an(e);
let t = "THREE." + e.shift();
if (en) en("warn", t, ...e);
else {
let n = e[0];
n && n.isStackTrace ? console.warn(n.getError(t)) : console.warn(t, ...e);
}
}
function R(...e) {
e = an(e);
let t = "THREE." + e.shift();
if (en) en("error", t, ...e);
else {
let n = e[0];
n && n.isStackTrace ? console.error(n.getError(t)) : console.error(t, ...e);
}
}
function on(...e) {
let t = e.join(" ");
t in $t || ($t[t] = !0, L(...e));
}
function sn(e, t, n) {
return new Promise(function(r, i) {
function a() {
switch (e.clientWaitSync(t, e.SYNC_FLUSH_COMMANDS_BIT, 0)) {
case e.WAIT_FAILED:
i();
break;
case e.TIMEOUT_EXPIRED:
setTimeout(a, n);
break;
default: r();
}
}
setTimeout(a, n);
});
}
var cn = {
0: 1,
2: 6,
4: 7,
3: 5,
1: 0,
6: 2,
7: 4,
5: 3
}, ln = class {
addEventListener(e, t) {
this._listeners === void 0 && (this._listeners = {});
let n = this._listeners;
n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t);
}
hasEventListener(e, t) {
let n = this._listeners;
return n !== void 0 && n[e] !== void 0 && n[e].indexOf(t) !== -1;
}
removeEventListener(e, t) {
let n = this._listeners;
if (n === void 0) return;
let r = n[e];
if (r !== void 0) {
let e = r.indexOf(t);
e !== -1 && r.splice(e, 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 t = n.slice(0);
for (let n = 0, r = t.length; n < r; n++) t[n].call(this, e);
e.target = null;
}
}
}, un = /* @__PURE__ */ "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".split("."), dn = 1234567, fn = Math.PI / 180, pn = 180 / Math.PI;
function mn() {
let e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0, r = Math.random() * 4294967295 | 0;
return (un[e & 255] + un[e >> 8 & 255] + un[e >> 16 & 255] + un[e >> 24 & 255] + "-" + un[t & 255] + un[t >> 8 & 255] + "-" + un[t >> 16 & 15 | 64] + un[t >> 24 & 255] + "-" + un[n & 63 | 128] + un[n >> 8 & 255] + "-" + un[n >> 16 & 255] + un[n >> 24 & 255] + un[r & 255] + un[r >> 8 & 255] + un[r >> 16 & 255] + un[r >> 24 & 255]).toLowerCase();
}
function z(e, t, n) {
return Math.max(t, Math.min(n, e));
}
function hn(e, t) {
return (e % t + t) % t;
}
function gn(e, t, n, r, i) {
return r + (e - t) * (i - r) / (n - t);
}
function _n(e, t, n) {
return e === t ? 0 : (n - e) / (t - e);
}
function vn(e, t, n) {
return (1 - n) * e + n * t;
}
function yn(e, t, n, r) {
return vn(e, t, 1 - Math.exp(-n * r));
}
function bn(e, t = 1) {
return t - Math.abs(hn(e, t * 2) - t);
}
function xn(e, t, n) {
return e <= t ? 0 : e >= n ? 1 : (e = (e - t) / (n - t), e * e * (3 - 2 * e));
}
function Sn(e, t, n) {
return e <= t ? 0 : e >= n ? 1 : (e = (e - t) / (n - t), e * e * e * (e * (e * 6 - 15) + 10));
}
function Cn(e, t) {
return e + Math.floor(Math.random() * (t - e + 1));
}
function wn(e, t) {
return e + Math.random() * (t - e);
}
function Tn(e) {
return e * (.5 - Math.random());
}
function En(e) {
e !== void 0 && (dn = e);
let t = dn += 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 Dn(e) {
return e * fn;
}
function On(e) {
return e * pn;
}
function kn(e) {
return (e & e - 1) == 0 && e !== 0;
}
function An(e) {
return 2 ** Math.ceil(Math.log(e) / Math.LN2);
}
function jn(e) {
return 2 ** Math.floor(Math.log(e) / Math.LN2);
}
function Mn(e, t, n, r, i) {
let a = Math.cos, o = Math.sin, s = a(n / 2), c = o(n / 2), l = a((t + r) / 2), u = o((t + r) / 2), d = a((t - r) / 2), f = o((t - r) / 2), p = a((r - t) / 2), m = o((r - t) / 2);
switch (i) {
case "XYX":
e.set(s * u, c * d, c * f, s * l);
break;
case "YZY":
e.set(c * f, s * u, c * d, s * l);
break;
case "ZXZ":
e.set(c * d, c * f, s * u, s * l);
break;
case "XZX":
e.set(s * u, c * m, c * p, s * l);
break;
case "YXY":
e.set(c * p, s * u, c * m, s * l);
break;
case "ZYZ":
e.set(c * m, c * p, s * u, s * l);
break;
default: L("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i);
}
}
function Nn(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("THREE.MathUtils: Invalid component type.");
}
}
function B(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("THREE.MathUtils: Invalid component type.");
}
}
var Pn = {
DEG2RAD: fn,
RAD2DEG: pn,
generateUUID: mn,
clamp: z,
euclideanModulo: hn,
mapLinear: gn,
inverseLerp: _n,
lerp: vn,
damp: yn,
pingpong: bn,
smoothstep: xn,
smootherstep: Sn,
randInt: Cn,
randFloat: wn,
randFloatSpread: Tn,
seededRandom: En,
degToRad: Dn,
radToDeg: On,
isPowerOfTwo: kn,
ceilPowerOfTwo: An,
floorPowerOfTwo: jn,
setQuaternionFromProperEuler: Mn,
normalize: B,
denormalize: Nn
};
h = Symbol.iterator;
var V = class {
constructor(e = 0, t = 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("THREE.Vector2: 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("THREE.Vector2: 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, r = e.elements;
return this.x = r[0] * t + r[3] * n + r[6], this.y = r[1] * t + r[4] * n + r[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 = z(this.x, e.x, t.x), this.y = z(this.y, e.y, t.y), this;
}
clampScalar(e, t) {
return this.x = z(this.x, e, t), this.y = z(this.y, e, t), this;
}
clampLength(e, t) {
let n = this.length();
return this.divideScalar(n || 1).multiplyScalar(z(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(z(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), r = Math.sin(t), i = this.x - e.x, a = this.y - e.y;
return this.x = i * n - a * r + e.x, this.y = i * r + a * n + e.y, this;
}
random() {
return this.x = Math.random(), this.y = Math.random(), this;
}
*[h]() {
yield this.x, yield this.y;
}
};
l = V, l.prototype.isVector2 = !0;
var Fn = class {
constructor(e = 0, t = 0, n = 0, r = 1) {
this.isQuaternion = !0, this._x = e, this._y = t, this._z = n, this._w = r;
}
static slerpFlat(e, t, n, r, i, a, o) {
let s = n[r + 0], c = n[r + 1], l = n[r + 2], u = n[r + 3], d = i[a + 0], f = i[a + 1], p = i[a + 2], m = i[a + 3];
if (u !== m || s !== d || c !== f || l !== p) {
let e = s * d + c * f + l * p + u * m;
e < 0 && (d = -d, f = -f, p = -p, m = -m, e = -e);
let t = 1 - o;
if (e < .9995) {
let n = Math.acos(e), r = Math.sin(n);
t = Math.sin(t * n) / r, o = Math.sin(o * n) / r, s = s * t + d * o, c = c * t + f * o, l = l * t + p * o, u = u * t + m * o;
} else {
s = s * t + d * o, c = c * t + f * o, l = l * t + p * o, u = u * t + m * o;
let e = 1 / Math.sqrt(s * s + c * c + l * l + u * u);
s *= e, c *= e, l *= e, u *= e;
}
}
e[t] = s, e[t + 1] = c, e[t + 2] = l, e[t + 3] = u;
}
static multiplyQuaternionsFlat(e, t, n, r, i, a) {
let o = n[r], s = n[r + 1], c = n[r + 2], l = n[r + 3], u = i[a], d = i[a + 1], f = i[a + 2], p = i[a + 3];
return e[t] = o * p + l * u + s * f - c * d, e[t + 1] = s * p + l * d + c * u - o * f, e[t + 2] = c * p + l * f + o * d - s * u, e[t + 3] = l * p - o * u - s * d - c * f, e;
}
get x() {
return this._x;
}
set x(e) {
this._x = e, this._onChangeCallback();
}
get y() {
return this._y;
}
set y(e) {
this._y = e, this._onChangeCallback();
}
get z() {
return this._z;
}
set z(e) {
this._z = e, this._onChangeCallback();
}
get w() {
return this._w;
}
set w(e) {
this._w = e, this._onChangeCallback();
}
set(e, t, n, r) {
return this._x = e, this._y = t, this._z = n, this._w = r, 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 n = e._x, r = e._y, i = e._z, a = e._order, o = Math.cos, s = Math.sin, c = o(n / 2), l = o(r / 2), u = o(i / 2), d = s(n / 2), f = s(r / 2), p = s(i / 2);
switch (a) {
case "XYZ":
this._x = d * l * u + c * f * p, this._y = c * f * u - d * l * p, this._z = c * l * p + d * f * u, this._w = c * l * u - d * f * p;
break;
case "YXZ":
this._x = d * l * u + c * f * p, this._y = c * f * u - d * l * p, this._z = c * l * p - d * f * u, this._w = c * l * u + d * f * p;
break;
case "ZXY":
this._x = d * l * u - c * f * p, this._y = c * f * u + d * l * p, this._z = c * l * p + d * f * u, this._w = c * l * u - d * f * p;
break;
case "ZYX":
this._x = d * l * u - c * f * p, this._y = c * f * u + d * l * p, this._z = c * l * p - d * f * u, this._w = c * l * u + d * f * p;
break;
case "YZX":
this._x = d * l * u + c * f * p, this._y = c * f * u + d * l * p, this._z = c * l * p - d * f * u, this._w = c * l * u - d * f * p;
break;
case "XZY":
this._x = d * l * u - c * f * p, this._y = c * f * u - d * l * p, this._z = c * l * p + d * f * u, this._w = c * l * u + d * f * p;
break;
default: L("Quaternion: .setFromEuler() encountered an unknown order: " + a);
}
return t === !0 && this._onChangeCallback(), this;
}
setFromAxisAngle(e, t) {
let n = t / 2, r = Math.sin(n);
return this._x = e.x * r, this._y = e.y * r, this._z = e.z * r, this._w = Math.cos(n), this._onChangeCallback(), this;
}
setFromRotationMatrix(e) {
let t = e.elements, n = t[0], r = t[4], i = t[8], a = t[1], o = t[5], s = t[9], c = t[2], l = t[6], u = t[10], d = n + o + u;
if (d > 0) {
let e = .5 / Math.sqrt(d + 1);
this._w = .25 / e, this._x = (l - s) * e, this._y = (i - c) * e, this._z = (a - r) * e;
} else if (n > o && n > u) {
let e = 2 * Math.sqrt(1 + n - o - u);
this._w = (l - s) / e, this._x = .25 * e, this._y = (r + a) / e, this._z = (i + c) / e;
} else if (o > u) {
let e = 2 * Math.sqrt(1 + o - n - u);
this._w = (i - c) / e, this._x = (r + a) / e, this._y = .25 * e, this._z = (s + l) / e;
} else {
let e = 2 * Math.sqrt(1 + u - n - o);
this._w = (a - r) / e, this._x = (i + c) / e, this._y = (s + l) / e, this._z = .25 * e;
}
return this._onChangeCallback(), this;
}
setFromUnitVectors(e, t) {
let n = e.dot(t) + 1;
return n < 1e-8 ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize();
}
angleTo(e) {
return 2 * Math.acos(Math.abs(z(this.dot(e), -1, 1)));
}
rotateTowards(e, t) {
let n = this.angleTo(e);
if (n === 0) return this;
let r = Math.min(1, t / n);
return this.slerp(e, r), this;
}
identity() {
return this.set(0, 0, 0, 1);
}
invert() {
return this.conjugate();
}
conjugate() {
return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
}
dot(e) {
return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;
}
lengthSq() {
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
}
length() {
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
}
normalize() {
let e = this.length();
return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x *= e, this._y *= e, this._z *= e, this._w *= e), this._onChangeCallback(), this;
}
multiply(e) {
return this.multiplyQuaternions(this, e);
}
premultiply(e) {
return this.multiplyQuaternions(e, this);
}
multiplyQuaternions(e, t) {
let n = e._x, r = e._y, i = e._z, a = e._w, o = t._x, s = t._y, c = t._z, l = t._w;
return this._x = n * l + a * o + r * c - i * s, this._y = r * l + a * s + i * o - n * c, this._z = i * l + a * c + n * s - r * o, this._w = a * l - n * o - r * s - i * c, this._onChangeCallback(), this;
}
slerp(e, t) {
let n = e._x, r = e._y, i = e._z, a = e._w, o = this.dot(e);
o < 0 && (n = -n, r = -r, i = -i, a = -a, o = -o);
let s = 1 - t;
if (o < .9995) {
let e = Math.acos(o), c = Math.sin(e);
s = Math.sin(s * e) / c, t = Math.sin(t * e) / c, this._x = this._x * s + n * t, this._y = this._y * s + r * t, this._z = this._z * s + i * t, this._w = this._w * s + a * t, this._onChangeCallback();
} else this._x = this._x * s + n * t, this._y = this._y * s + r * t, this._z = this._z * s + i * t, this._w = this._w * s + a * t, this.normalize();
return 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(), r = Math.sqrt(1 - n), i = Math.sqrt(n);
return this.set(r * Math.sin(e), r * Math.cos(e), i * Math.sin(t), i * 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;
}
};
g = Symbol.iterator;
var H = class {
constructor(e = 0, t = 0, n = 0) {
this.x = e, this.y = t, this.z = n;
}
set(e, t, n) {
return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this;
}
setScalar(e) {
return this.x = e, this.y = e, this.z = e, this;
}
setX(e) {
return this.x = e, this;
}
setY(e) {
return this.y = e, this;
}
setZ(e) {
return this.z = e, this;
}
setComponent(e, t) {
switch (e) {
case 0:
this.x = t;
break;
case 1:
this.y = t;
break;
case 2:
this.z = t;
break;
default: throw Error("THREE.Vector3: 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("THREE.Vector3: 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(Ln.setFromEuler(e));
}
applyAxisAngle(e, t) {
return this.applyQuaternion(Ln.setFromAxisAngle(e, t));
}
applyMatrix3(e) {
let t = this.x, n = this.y, r = this.z, i = e.elements;
return this.x = i[0] * t + i[3] * n + i[6] * r, this.y = i[1] * t + i[4] * n + i[7] * r, this.z = i[2] * t + i[5] * n + i[8] * r, this;
}
applyNormalMatrix(e) {
return this.applyMatrix3(e).normalize();
}
applyMatrix4(e) {
let t = this.x, n = this.y, r = this.z, i = e.elements, a = 1 / (i[3] * t + i[7] * n + i[11] * r + i[15]);
return this.x = (i[0] * t + i[4] * n + i[8] * r + i[12]) * a, this.y = (i[1] * t + i[5] * n + i[9] * r + i[13]) * a, this.z = (i[2] * t + i[6] * n + i[10] * r + i[14]) * a, this;
}
applyQuaternion(e) {
let t = this.x, n = this.y, r = this.z, i = e.x, a = e.y, o = e.z, s = e.w, c = 2 * (a * r - o * n), l = 2 * (o * t - i * r), u = 2 * (i * n - a * t);
return this.x = t + s * c + a * u - o * l, this.y = n + s * l + o * c - i * u, this.z = r + s * u + i * l - a * c, 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, r = this.z, i = e.elements;
return this.x = i[0] * t + i[4] * n + i[8] * r, this.y = i[1] * t + i[5] * n + i[9] * r, this.z = i[2] * t + i[6] * n + i[10] * r, 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 = z(this.x, e.x, t.x), this.y = z(this.y, e.y, t.y), this.z = z(this.z, e.z, t.z), this;
}
clampScalar(e, t) {
return this.x = z(this.x, e, t), this.y = z(this.y, e, t), this.z = z(this.z, e, t), this;
}
clampLength(e, t) {
let n = this.length();
return this.divideScalar(n || 1).multiplyScalar(z(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 n = e.x, r = e.y, i = e.z, a = t.x, o = t.y, s = t.z;
return this.x = r * s - i * o, this.y = i * a - n * s, this.z = n * o - r * a, 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 In.copy(this).projectOnVector(e), this.sub(In);
}
reflect(e) {
return this.sub(In.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(z(n, -1, 1));
}
distanceTo(e) {
return Math.sqrt(this.distanceToSquared(e));
}
distanceToSquared(e) {
let t = this.x - e.x, n = this.y - e.y, r = this.z - e.z;
return t * t + n * n + r * r;
}
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 r = Math.sin(t) * e;
return this.x = r * Math.sin(n), this.y = Math.cos(t) * e, this.z = r * 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(), r = this.setFromMatrixColumn(e, 2).length();
return this.x = t, this.y = n, this.z = r, 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;
}
*[g]() {
yield this.x, yield this.y, yield this.z;
}
};
u = H, u.prototype.isVector3 = !0;
var In = /*@__PURE__*/ new H(), Ln = /*@__PURE__*/ new Fn(), U = class {
constructor(e, t, n, r, i, a, o, s, c) {
this.elements = [
1,
0,
0,
0,
1,
0,
0,
0,
1
], e !== void 0 && this.set(e, t, n, r, i, a, o, s, c);
}
set(e, t, n, r, i, a, o, s, c) {
let l = this.elements;
return l[0] = e, l[1] = r, l[2] = o, l[3] = t, l[4] = i, l[5] = s, l[6] = n, l[7] = a, l[8] = c, 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, r = t.elements, i = this.elements, a = n[0], o = n[3], s = n[6], c = n[1], l = n[4], u = n[7], d = n[2], f = n[5], p = n[8], m = r[0], h = r[3], g = r[6], _ = r[1], v = r[4], y = r[7], b = r[2], x = r[5], S = r[8];
return i[0] = a * m + o * _ + s * b, i[3] = a * h + o * v + s * x, i[6] = a * g + o * y + s * S, i[1] = c * m + l * _ + u * b, i[4] = c * h + l * v + u * x, i[7] = c * g + l * y + u * S, i[2] = d * m + f * _ + p * b, i[5] = d * h + f * v + p * x, i[8] = d * g + f * y + p * S, 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], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8];
return t * a * l - t * o * c - n * i * l + n * o * s + r * i * c - r * a * s;
}
invert() {
let e = this.elements, t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = l * a - o * c, d = o * s - l * i, f = c * i - a * s, p = t * u + n * d + r * f;
if (p === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
let m = 1 / p;
return e[0] = u * m, e[1] = (r * c - l * n) * m, e[2] = (o * n - r * a) * m, e[3] = d * m, e[4] = (l * t - r * s) * m, e[5] = (r * i - o * t) * m, e[6] = f * m, e[7] = (n * s - c * t) * m, e[8] = (a * t - n * i) * 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, r, i, a, o) {
let s = Math.cos(i), c = Math.sin(i);
return this.set(n * s, n * c, -n * (s * a + c * o) + a + e, -r * c, r * s, -r * (-c * a + s * o) + o + t, 0, 0, 1), this;
}
scale(e, t) {
return on("Matrix3: .scale() is deprecated. Use .makeScale() instead."), this.premultiply(Rn.makeScale(e, t)), this;
}
rotate(e) {
return on("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."), this.premultiply(Rn.makeRotation(-e)), this;
}
translate(e, t) {
return on("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."), this.premultiply(Rn.makeTranslation(e, t)), this;
}
makeTranslation(e, t) {
return e.isVector2 ? this.set(1, 0, e.x, 0, 1, e.y, 0, 0, 1) : this.set(1, 0, e, 0, 1, t, 0, 0, 1), this;
}
makeRotation(e) {
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 e = 0; e < 9; e++) if (t[e] !== n[e]) 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);
}
};
d = U, d.prototype.isMatrix3 = !0;
var Rn = /*@__PURE__*/ new U(), zn = /*@__PURE__*/ new U().set(.4123908, .3575843, .1804808, .212639, .7151687, .0721923, .0193308, .1191948, .9505322), Bn = /*@__PURE__*/ new U().set(3.2409699, -1.5373832, -.4986108, -.9692436, 1.8759675, .0415551, .0556301, -.203977, 1.0569715);
function Vn() {
let e = {
enabled: !0,
workingColorSpace: xt,
spaces: {},
convert: function(e, t, n) {
return this.enabled === !1 || t === n || !t || !n ? e : (this.spaces[t].transfer === "srgb" && (e.r = Un(e.r), e.g = Un(e.g), e.b = Un(e.b)), this.spaces[t].primaries !== this.spaces[n].primaries && (e.applyMatrix3(this.spaces[t].toXYZ), e.applyMatrix3(this.spaces[n].fromXYZ)), this.spaces[n].transfer === "srgb" && (e.r = Wn(e.r), e.g = Wn(e.g), e.b = Wn(e.b)), e);
},
workingToColorSpace: function(e, t) {
return this.convert(e, this.workingColorSpace, t);
},
colorSpaceToWorking: function(e, t) {
return this.convert(e, t, this.workingColorSpace);
},
getPrimaries: function(e) {
return this.spaces[e].primaries;
},
getTransfer: function(e) {
return e === "" ? St : this.spaces[e].transfer;
},
getToneMappingMode: function(e) {
return this.spaces[e].outputColorSpaceConfig.toneMappingMode || "standard";
},
getLuminanceCoefficients: function(e, t = this.workingColorSpace) {
return e.fromArray(this.spaces[t].luminanceCoefficients);
},
define: function(e) {
Object.assign(this.spaces, e);
},
_getMatrix: function(e, t, n) {
return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ);
},
_getDrawingBufferColorSpace: function(e) {
return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace;
},
_getUnpackColorSpace: function(e = this.workingColorSpace) {
return this.spaces[e].workingColorSpaceConfig.unpackColorSpace;
},
fromWorkingColorSpace: function(t, n) {
return on("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."), e.workingToColorSpace(t, n);
},
toWorkingColorSpace: function(t, n) {
return on("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."), e.colorSpaceToWorking(t, n);
}
}, t = [
.64,
.33,
.3,
.6,
.15,
.06
], n = [
.2126,
.7152,
.0722
], r = [.3127, .329];
return e.define({
[xt]: {
primaries: t,
whitePoint: r,
transfer: St,
toXYZ: zn,
fromXYZ: Bn,
luminanceCoefficients: n,
workingColorSpaceConfig: { unpackColorSpace: bt },
outputColorSpaceConfig: { drawingBufferColorSpace: bt }
},
[bt]: {
primaries: t,
whitePoint: r,
transfer: Ct,
toXYZ: zn,
fromXYZ: Bn,
luminanceCoefficients: n,
outputColorSpaceConfig: { drawingBufferColorSpace: bt }
}
}), e;
}
var Hn = /*@__PURE__*/ Vn();
function Un(e) {
return e < .04045 ? e * .0773993808 : (e * .9478672986 + .0521327014) ** 2.4;
}
function Wn(e) {
return e < .0031308 ? e * 12.92 : 1.055 * e ** .41666 - .055;
}
var Gn, Kn = class {
static getDataURL(e, t = "image/png") {
if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") return e.src;
let n;
if (e instanceof HTMLCanvasElement) n = e;
else {
Gn === void 0 && (Gn = Zt("canvas")), Gn.width = e.width, Gn.height = e.height;
let t = Gn.getContext("2d");
e instanceof ImageData ? t.putImageData(e, 0, 0) : t.drawImage(e, 0, 0, e.width, e.height), n = Gn;
}
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 = Zt("canvas");
t.width = e.width, t.height = e.height;
let n = t.getContext("2d");
n.drawImage(e, 0, 0, e.width, e.height);
let r = n.getImageData(0, 0, e.width, e.height), i = r.data;
for (let e = 0; e < i.length; e++) i[e] = Un(i[e] / 255) * 255;
return n.putImageData(r, 0, 0), t;
} else if (e.data) {
let t = e.data.slice(0);
for (let e = 0; e < t.length; e++) t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[e] = Math.floor(Un(t[e] / 255) * 255) : t[e] = Un(t[e]);
return {
data: t,
width: e.width,
height: e.height
};
} else return L("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e;
}
}, qn = 0, Jn = class {
constructor(e = null) {
this.isSource = !0, Object.defineProperty(this, "id", { value: qn++ }), this.uuid = mn(), this.data = e, this.dataReady = !0, this.version = 0;
}
getSize(e) {
let t = this.data;
return typeof HTMLVideoElement < "u" && t instanceof HTMLVideoElement ? e.set(t.videoWidth, t.videoHeight, 0) : typeof VideoFrame < "u" && t instanceof VideoFrame ? e.set(t.displayWidth, t.displayHeight, 0) : t === null ? e.set(0, 0, 0) : e.set(t.width, t.height, t.depth || 0), e;
}
set needsUpdate(e) {
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: ""
}, r = this.data;
if (r !== null) {
let e;
if (Array.isArray(r)) {
e = [];
for (let t = 0, n = r.length; t < n; t++) r[t].isDataTexture ? e.push(Yn(r[t].image)) : e.push(Yn(r[t]));
} else e = Yn(r);
n.url = e;
}
return t || (e.images[this.uuid] = n), n;
}
};
function Yn(e) {
return typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap ? Kn.getDataURL(e) : e.data ? {
data: Array.from(e.data),
width: e.width,
height: e.height,
type: e.data.constructor.name
} : (L("Texture: Unable to serialize Texture."), {});
}
var Xn = 0, Zn = /*@__PURE__*/ new H(), Qn = class e extends ln {
constructor(t = e.DEFAULT_IMAGE, n = e.DEFAULT_MAPPING, r = C, i = C, a = A, o = ne, s = ge, c = M, l = e.DEFAULT_ANISOTROPY, u = "") {
super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: Xn++ }), this.uuid = mn(), this.name = "", this.source = new Jn(t), this.mipmaps = [], this.mapping = n, this.channel = 0, this.wrapS = r, this.wrapT = i, this.magFilter = a, this.minFilter = o, this.anisotropy = l, this.format = s, this.internalFormat = null, this.type = c, this.offset = new V(0, 0), this.repeat = new V(1, 1), this.center = new V(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new U(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = u, this.userData = {}, this.updateRanges = [], this.version = 0, this.onUpdate = null, this.renderTarget = null, this.isRenderTargetTexture = !1, this.isArrayTexture = !!(t && t.depth && t.depth > 1), this.pmremVersion = 0, this.normalized = !1;
}
get width() {
return this.source.getSize(Zn).x;
}
get height() {
return this.source.getSize(Zn).y;
}
get depth() {
return this.source.getSize(Zn).z;
}
get image() {
return this.source.data;
}
set image(e) {
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.normalized = e.normalized, 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) {
L(`Texture.setValues(): parameter '${t}' has value of undefined.`);
continue;
}
let r = this[t];
if (r === void 0) {
L(`Texture.setValues(): property '${t}' does not exist.`);
continue;
}
r && n && r.isVector2 && n.isVector2 || r && n && r.isVector3 && n.isVector3 || r && n && r.isMatrix3 && n.isMatrix3 ? r.copy(n) : 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,
normalized: this.normalized,
colorSpace: this.colorSpace,
minFilter: this.minFilter,
magFilter: this.magFilter,
anisotropy: this.anisotropy,
flipY: this.flipY,
generateMipmaps: this.generateMipmaps,
premultiplyAlpha: this.premultiplyAlpha,
unpackAlignment: this.unpackAlignment
};
return Object.keys(this.userData).length > 0 && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n;
}
dispose() {
this.dispatchEvent({ type: "dispose" });
}
transformUv(e) {
if (this.mapping !== 300) return e;
if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch (this.wrapS) {
case S:
e.x -= Math.floor(e.x);
break;
case C:
e.x = e.x < 0 ? 0 : 1;
break;
case w:
Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x -= Math.floor(e.x);
break;
}
if (e.y < 0 || e.y > 1) switch (this.wrapT) {
case S:
e.y -= Math.floor(e.y);
break;
case C:
e.y = e.y < 0 ? 0 : 1;
break;
case w:
Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y -= Math.floor(e.y);
break;
}
return this.flipY && (e.y = 1 - e.y), e;
}
set needsUpdate(e) {
e === !0 && (this.version++, this.source.needsUpdate = !0);
}
set needsPMREMUpdate(e) {
e === !0 && this.pmremVersion++;
}
};
Qn.DEFAULT_IMAGE = null, Qn.DEFAULT_MAPPING = 300, Qn.DEFAULT_ANISOTROPY = 1, _ = Symbol.iterator;
var $n = class {
constructor(e = 0, t = 0, n = 0, r = 1) {
this.x = e, this.y = t, this.z = n, this.w = r;
}
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, r) {
return this.x = e, this.y = t, this.z = n, this.w = r, 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("THREE.Vector4: 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("THREE.Vector4: 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 ? 1 : e.w, 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, r = this.z, i = this.w, a = e.elements;
return this.x = a[0] * t + a[4] * n + a[8] * r + a[12] * i, this.y = a[1] * t + a[5] * n + a[9] * r + a[13] * i, this.z = a[2] * t + a[6] * n + a[10] * r + a[14] * i, this.w = a[3] * t + a[7] * n + a[11] * r + a[15] * i, 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);
return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this;
}
setAxisAngleFromRotationMatrix(e) {
let t, n, r, i, a = .01, o = .1, s = e.elements, c = s[0], l = s[4], u = s[8], d = s[1], f = s[5], p = s[9], m = s[2], h = s[6], g = s[10];
if (Math.abs(l - d) < a && Math.abs(u - m) < a && Math.abs(p - h) < a) {
if (Math.abs(l + d) < o && Math.abs(u + m) < o && Math.abs(p + h) < o && Math.abs(c + f + g - 3) < o) return this.set(1, 0, 0, 0), this;
t = Math.PI;
let e = (c + 1) / 2, s = (f + 1) / 2, _ = (g + 1) / 2, v = (l + d) / 4, y = (u + m) / 4, b = (p + h) / 4;
return e > s && e > _ ? e < a ? (n = 0, r = .707106781, i = .707106781) : (n = Math.sqrt(e), r = v / n, i = y / n) : s > _ ? s < a ? (n = .707106781, r = 0, i = .707106781) : (r = Math.sqrt(s), n = v / r, i = b / r) : _ < a ? (n = .707106781, r = .707106781, i = 0) : (i = Math.sqrt(_), n = y / i, r = b / i), this.set(n, r, i, t), this;
}
let _ = Math.sqrt((h - p) * (h - p) + (u - m) * (u - m) + (d - l) * (d - l));
return Math.abs(_) < .001 && (_ = 1), this.x = (h - p) / _, this.y = (u - m) / _, this.z = (d - l) / _, this.w = Math.acos((c + f + g - 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 = z(this.x, e.x, t.x), this.y = z(this.y, e.y, t.y), this.z = z(this.z, e.z, t.z), this.w = z(this.w, e.w, t.w), this;
}
clampScalar(e, t) {
return this.x = z(this.x, e, t), this.y = z(this.y, e, t), this.z = z(this.z, e, t), this.w = z(this.w, e, t), this;
}
clampLength(e, t) {
let n = this.length();
return this.divideScalar(n || 1).multiplyScalar(z(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;
}
*[_]() {
yield this.x, yield this.y, yield this.z, yield this.w;
}
};
f = $n, f.prototype.isVector4 = !0;
var er = class extends ln {
constructor(e = 1, t = 1, n = {}) {
super(), n = Object.assign({
generateMipmaps: !1,
internalFormat: null,
minFilter: A,
depthBuffer: !0,
stencilBuffer: !1,
resolveDepthBuffer: !0,
resolveStencilBuffer: !0,
depthTexture: null,
samples: 0,
count: 1,
depth: 1,
multiview: !1,
useArrayDepthTexture: !1
}, n), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = n.depth, this.scissor = new $n(0, 0, e, t), this.scissorTest = !1, this.viewport = new $n(0, 0, e, t), this.textures = [];
let r = new Qn({
width: e,
height: t,
depth: n.depth
}), i = n.count;
for (let e = 0; e < i; e++) this.textures[e] = r.clone(), this.textures[e].isRenderTargetTexture = !0, this.textures[e].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, this.useArrayDepthTexture = n.useArrayDepthTexture;
}
_setTextureOptions(e = {}) {
let t = {
minFilter: A,
generateMipmaps: !1,
flipY: !1,
internalFormat: null
};
e.mapping !== void 0 && (t.mapping = e.mapping), e.wrapS !== void 0 && (t.wrapS = e.wrapS), e.wrapT !== void 0 && (t.wrapT = e.wrapT), e.wrapR !== void 0 && (t.wrapR = e.wrapR), e.magFilter !== void 0 && (t.magFilter = e.magFilter), e.minFilter !== void 0 && (t.minFilter = e.minFilter), e.format !== void 0 && (t.format = e.format), e.type !== void 0 && (t.type = e.type), e.anisotropy !== void 0 && (t.anisotropy = e.anisotropy), e.colorSpace !== void 0 && (t.colorSpace = e.colorSpace), e.flipY !== void 0 && (t.flipY = e.flipY), e.generateMipmaps !== void 0 && (t.generateMipmaps = e.generateMipmaps), e.internalFormat !== void 0 && (t.internalFormat = e.internalFormat);
for (let e = 0; e < this.textures.length; e++) this.textures[e].setValues(t);
}
get texture() {
return this.textures[0];
}
set texture(e) {
this.textures[0] = e;
}
set depthTexture(e) {
this._depthTexture !== null && (this._depthTexture.renderTarget = null), 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 r = 0, i = this.textures.length; r < i; r++) this.textures[r].image.width = e, this.textures[r].image.height = t, this.textures[r].image.depth = n, this.textures[r].isData3DTexture !== !0 && (this.textures[r].isArrayTexture = this.textures[r].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 n = Object.assign({}, e.textures[t].image);
this.textures[t].source = new Jn(n);
}
return this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.resolveDepthBuffer = e.resolveDepthBuffer, this.resolveStencilBuffer = e.resolveStencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this.multiview = e.multiview, this.useArrayDepthTexture = e.useArrayDepthTexture, this;
}
dispose() {
this.dispatchEvent({ type: "dispose" });
}
}, tr = class extends er {
constructor(e = 1, t = 1, n = {}) {
super(e, t, n), this.isWebGLRenderTarget = !0;
}
}, nr = class extends Qn {
constructor(e = null, t = 1, n = 1, r = 1) {
super(null), this.isDataArrayTexture = !0, this.image = {
data: e,
width: t,
height: n,
depth: r
}, this.magFilter = T, this.minFilter = T, this.wrapR = C, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set();
}
addLayerUpdate(e) {
this.layerUpdates.add(e);
}
clearLayerUpdates() {
this.layerUpdates.clear();
}
}, rr = class extends tr {
constructor(e = 1, t = 1, n = 1, r = {}) {
super(e, t, r), this.isWebGLArrayRenderTarget = !0, this.depth = n, this.texture = new nr(null, e, t, n), this._setTextureOptions(r), this.texture.isRenderTargetTexture = !0;
}
}, ir = class extends Qn {
constructor(e = null, t = 1, n = 1, r = 1) {
super(null), this.isData3DTexture = !0, this.image = {
data: e,
width: t,
height: n,
depth: r
}, this.magFilter = T, this.minFilter = T, this.wrapR = C, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
}
}, ar = class extends tr {
constructor(e = 1, t = 1, n = 1, r = {}) {
super(e, t, r), this.isWebGL3DRenderTarget = !0, this.depth = n, this.texture = new ir(null, e, t, n), this._setTextureOptions(r), this.texture.isRenderTargetTexture = !0;
}
}, W = class e {
constructor(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) {
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, r, i, a, o, s, c, l, u, d, f, p, m, h);
}
set(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) {
let g = this.elements;
return g[0] = e, g[4] = t, g[8] = n, g[12] = r, g[1] = i, g[5] = a, g[9] = o, g[13] = s, g[2] = c, g[6] = l, g[10] = u, g[14] = d, g[3] = f, g[7] = p, g[11] = m, g[15] = h, 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 e().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 this.determinantAffine() === 0 ? (e.set(1, 0, 0), t.set(0, 1, 0), n.set(0, 0, 1), this) : (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) {
if (e.determinantAffine() === 0) return this.identity();
let t = this.elements, n = e.elements, r = 1 / or.setFromMatrixColumn(e, 0).length(), i = 1 / or.setFromMatrixColumn(e, 1).length(), a = 1 / or.setFromMatrixColumn(e, 2).length();
return t[0] = n[0] * r, t[1] = n[1] * r, t[2] = n[2] * r, t[3] = 0, t[4] = n[4] * i, t[5] = n[5] * i, t[6] = n[6] * i, t[7] = 0, t[8] = n[8] * a, t[9] = n[9] * a, t[10] = n[10] * a, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;
}
makeRotationFromEuler(e) {
let t = this.elements, n = e.x, r = e.y, i = e.z, a = Math.cos(n), o = Math.sin(n), s = Math.cos(r), c = Math.sin(r), l = Math.cos(i), u = Math.sin(i);
if (e.order === "XYZ") {
let e = a * l, n = a * u, r = o * l, i = o * u;
t[0] = s * l, t[4] = -s * u, t[8] = c, t[1] = n + r * c, t[5] = e - i * c, t[9] = -o * s, t[2] = i - e * c, t[6] = r + n * c, t[10] = a * s;
} else if (e.order === "YXZ") {
let e = s * l, n = s * u, r = c * l, i = c * u;
t[0] = e + i * o, t[4] = r * o - n, t[8] = a * c, t[1] = a * u, t[5] = a * l, t[9] = -o, t[2] = n * o - r, t[6] = i + e * o, t[10] = a * s;
} else if (e.order === "ZXY") {
let e = s * l, n = s * u, r = c * l, i = c * u;
t[0] = e - i * o, t[4] = -a * u, t[8] = r + n * o, t[1] = n + r * o, t[5] = a * l, t[9] = i - e * o, t[2] = -a * c, t[6] = o, t[10] = a * s;
} else if (e.order === "ZYX") {
let e = a * l, n = a * u, r = o * l, i = o * u;
t[0] = s * l, t[4] = r * c - n, t[8] = e * c + i, t[1] = s * u, t[5] = i * c + e, t[9] = n * c - r, t[2] = -c, t[6] = o * s, t[10] = a * s;
} else if (e.order === "YZX") {
let e = a * s, n = a * c, r = o * s, i = o * c;
t[0] = s * l, t[4] = i - e * u, t[8] = r * u + n, t[1] = u, t[5] = a * l, t[9] = -o * l, t[2] = -c * l, t[6] = n * u + r, t[10] = e - i * u;
} else if (e.order === "XZY") {
let e = a * s, n = a * c, r = o * s, i = o * c;
t[0] = s * l, t[4] = -u, t[8] = c * l, t[1] = e * u + i, t[5] = a * l, t[9] = n * u - r, t[2] = r * u - n, t[6] = o * l, t[10] = i * u + e;
}
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(cr, e, lr);
}
lookAt(e, t, n) {
let r = this.elements;
return fr.subVectors(e, t), fr.lengthSq() === 0 && (fr.z = 1), fr.normalize(), ur.crossVectors(n, fr), ur.lengthSq() === 0 && (Math.abs(n.z) === 1 ? fr.x += 1e-4 : fr.z += 1e-4, fr.normalize(), ur.crossVectors(n, fr)), ur.normalize(), dr.crossVectors(fr, ur), r[0] = ur.x, r[4] = dr.x, r[8] = fr.x, r[1] = ur.y, r[5] = dr.y, r[9] = fr.y, r[2] = ur.z, r[6] = dr.z, r[10] = fr.z, this;
}
multiply(e) {
return this.multiplyMatrices(this, e);
}
premultiply(e) {
return this.multiplyMatrices(e, this);
}
multiplyMatrices(e, t) {
let n = e.elements, r = t.elements, i = this.elements, a = n[0], o = n[4], s = n[8], c = n[12], l = n[1], u = n[5], d = n[9], f = n[13], p = n[2], m = n[6], h = n[10], g = n[14], _ = n[3], v = n[7], y = n[11], b = n[15], x = r[0], S = r[4], C = r[8], w = r[12], T = r[1], E = r[5], D = r[9], O = r[13], k = r[2], A = r[6], ee = r[10], te = r[14], ne = r[3], j = r[7], M = r[11], re = r[15];
return i[0] = a * x + o * T + s * k + c * ne, i[4] = a * S + o * E + s * A + c * j, i[8] = a * C + o * D + s * ee + c * M, i[12] = a * w + o * O + s * te + c * re, i[1] = l * x + u * T + d * k + f * ne, i[5] = l * S + u * E + d * A + f * j, i[9] = l * C + u * D + d * ee + f * M, i[13] = l * w + u * O + d * te + f * re, i[2] = p * x + m * T + h * k + g * ne, i[6] = p * S + m * E + h * A + g * j, i[10] = p * C + m * D + h * ee + g * M, i[14] = p * w + m * O + h * te + g * re, i[3] = _ * x + v * T + y * k + b * ne, i[7] = _ * S + v * E + y * A + b * j, i[11] = _ * C + v * D + y * ee + b * M, i[15] = _ * w + v * O + y * te + b * re, 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], r = e[8], i = e[12], a = e[1], o = e[5], s = e[9], c = e[13], l = e[2], u = e[6], d = e[10], f = e[14], p = e[3], m = e[7], h = e[11], g = e[15], _ = s * f - c * d, v = o * f - c * u, y = o * d - s * u, b = a * f - c * l, x = a * d - s * l, S = a * u - o * l;
return t * (m * _ - h * v + g * y) - n * (p * _ - h * b + g * x) + r * (p * v - m * b + g * S) - i * (p * y - m * x + h * S);
}
determinantAffine() {
let e = this.elements, t = e[0], n = e[4], r = e[8], i = e[1], a = e[5], o = e[9], s = e[2], c = e[6], l = e[10];
return t * (a * l - o * c) - n * (i * l - o * s) + r * (i * c - a * s);
}
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 r = this.elements;
return e.isVector3 ? (r[12] = e.x, r[13] = e.y, r[14] = e.z) : (r[12] = e, r[13] = t, r[14] = n), this;
}
invert() {
let e = this.elements, t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = e[9], d = e[10], f = e[11], p = e[12], m = e[13], h = e[14], g = e[15], _ = t * o - n * a, v = t * s - r * a, y = t * c - i * a, b = n * s - r * o, x = n * c - i * o, S = r * c - i * s, C = l * m - u * p, w = l * h - d * p, T = l * g - f * p, E = u * h - d * m, D = u * g - f * m, O = d * g - f * h, k = _ * O - v * D + y * E + b * T - x * w + S * C;
if (k === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
let A = 1 / k;
return e[0] = (o * O - s * D + c * E) * A, e[1] = (r * D - n * O - i * E) * A, e[2] = (m * S - h * x + g * b) * A, e[3] = (d * x - u * S - f * b) * A, e[4] = (s * T - a * O - c * w) * A, e[5] = (t * O - r * T + i * w) * A, e[6] = (h * y - p * S - g * v) * A, e[7] = (l * S - d * y + f * v) * A, e[8] = (a * D - o * T + c * C) * A, e[9] = (n * T - t * D - i * C) * A, e[10] = (p * x - m * y + g * _) * A, e[11] = (u * y - l * x - f * _) * A, e[12] = (o * w - a * E - s * C) * A, e[13] = (t * E - n * w + r * C) * A, e[14] = (m * v - p * b - h * _) * A, e[15] = (l * b - u * v + d * _) * A, this;
}
scale(e) {
let t = this.elements, n = e.x, r = e.y, i = e.z;
return t[0] *= n, t[4] *= r, t[8] *= i, t[1] *= n, t[5] *= r, t[9] *= i, t[2] *= n, t[6] *= r, t[10] *= i, t[3] *= n, t[7] *= r, t[11] *= i, 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], r = e[8] * e[8] + e[9] * e[9] + e[10] * e[10];
return Math.sqrt(Math.max(t, n, r));
}
makeTranslation(e, t, n) {
return e.isVector3 ? this.set(1, 0, 0, e.x, 0, 1, 0, e.y, 0, 0, 1, e.z, 0, 0, 0, 1) : this.set(1, 0, 0, e, 0, 1, 0, t, 0, 0, 1, n, 0, 0, 0, 1), 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), r = Math.sin(t), i = 1 - n, a = e.x, o = e.y, s = e.z, c = i * a, l = i * o;
return this.set(c * a + n, c * o - r * s, c * s + r * o, 0, c * o + r * s, l * o + n, l * s - r * a, 0, c * s - r * o, l * s + r * a, i * s * s + 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, r, i, a) {
return this.set(1, n, i, 0, e, 1, a, 0, t, r, 1, 0, 0, 0, 0, 1), this;
}
compose(e, t, n) {
let r = this.elements, i = t._x, a = t._y, o = t._z, s = t._w, c = i + i, l = a + a, u = o + o, d = i * c, f = i * l, p = i * u, m = a * l, h = a * u, g = o * u, _ = s * c, v = s * l, y = s * u, b = n.x, x = n.y, S = n.z;
return r[0] = (1 - (m + g)) * b, r[1] = (f + y) * b, r[2] = (p - v) * b, r[3] = 0, r[4] = (f - y) * x, r[5] = (1 - (d + g)) * x, r[6] = (h + _) * x, r[7] = 0, r[8] = (p + v) * S, r[9] = (h - _) * S, r[10] = (1 - (d + m)) * S, r[11] = 0, r[12] = e.x, r[13] = e.y, r[14] = e.z, r[15] = 1, this;
}
decompose(e, t, n) {
let r = this.elements;
e.x = r[12], e.y = r[13], e.z = r[14];
let i = this.determinantAffine();
if (i === 0) return n.set(1, 1, 1), t.identity(), this;
let a = or.set(r[0], r[1], r[2]).length(), o = or.set(r[4], r[5], r[6]).length(), s = or.set(r[8], r[9], r[10]).length();
i < 0 && (a = -a), sr.copy(this);
let c = 1 / a, l = 1 / o, u = 1 / s;
return sr.elements[0] *= c, sr.elements[1] *= c, sr.elements[2] *= c, sr.elements[4] *= l, sr.elements[5] *= l, sr.elements[6] *= l, sr.elements[8] *= u, sr.elements[9] *= u, sr.elements[10] *= u, t.setFromRotationMatrix(sr), n.x = a, n.y = o, n.z = s, this;
}
makePerspective(e, t, n, r, i, a, o = Vt, s = !1) {
let c = this.elements, l = 2 * i / (t - e), u = 2 * i / (n - r), d = (t + e) / (t - e), f = (n + r) / (n - r), p, m;
if (s) p = i / (a - i), m = a * i / (a - i);
else if (o === 2e3) p = -(a + i) / (a - i), m = -2 * a * i / (a - i);
else if (o === 2001) p = -a / (a - i), m = -a * i / (a - i);
else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o);
return c[0] = l, c[4] = 0, c[8] = d, c[12] = 0, c[1] = 0, c[5] = u, c[9] = f, c[13] = 0, c[2] = 0, c[6] = 0, c[10] = p, c[14] = m, c[3] = 0, c[7] = 0, c[11] = -1, c[15] = 0, this;
}
makeOrthographic(e, t, n, r, i, a, o = Vt, s = !1) {
let c = this.elements, l = 2 / (t - e), u = 2 / (n - r), d = -(t + e) / (t - e), f = -(n + r) / (n - r), p, m;
if (s) p = 1 / (a - i), m = a / (a - i);
else if (o === 2e3) p = -2 / (a - i), m = -(a + i) / (a - i);
else if (o === 2001) p = -1 / (a - i), m = -i / (a - i);
else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o);
return c[0] = l, c[4] = 0, c[8] = 0, c[12] = d, c[1] = 0, c[5] = u, c[9] = 0, c[13] = f, c[2] = 0, c[6] = 0, c[10] = p, c[14] = m, c[3] = 0, c[7] = 0, c[11] = 0, c[15] = 1, this;
}
equals(e) {
let t = this.elements, n = e.elements;
for (let e = 0; e < 16; e++) if (t[e] !== n[e]) 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;
}
};
p = W, p.prototype.isMatrix4 = !0;
var or = /*@__PURE__*/ new H(), sr = /*@__PURE__*/ new W(), cr = /*@__PURE__*/ new H(0, 0, 0), lr = /*@__PURE__*/ new H(1, 1, 1), ur = /*@__PURE__*/ new H(), dr = /*@__PURE__*/ new H(), fr = /*@__PURE__*/ new H(), pr = /*@__PURE__*/ new W(), mr = /*@__PURE__*/ new Fn(), hr = class e {
constructor(t = 0, n = 0, r = 0, i = e.DEFAULT_ORDER) {
this.isEuler = !0, this._x = t, this._y = n, this._z = r, 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, r = this._order) {
return this._x = e, this._y = t, this._z = n, this._order = r, 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 r = e.elements, i = r[0], a = r[4], o = r[8], s = r[1], c = r[5], l = r[9], u = r[2], d = r[6], f = r[10];
switch (t) {
case "XYZ":
this._y = Math.asin(z(o, -1, 1)), Math.abs(o) < .9999999 ? (this._x = Math.atan2(-l, f), this._z = Math.atan2(-a, i)) : (this._x = Math.atan2(d, c), this._z = 0);
break;
case "YXZ":
this._x = Math.asin(-z(l, -1, 1)), Math.abs(l) < .9999999 ? (this._y = Math.atan2(o, f), this._z = Math.atan2(s, c)) : (this._y = Math.atan2(-u, i), this._z = 0);
break;
case "ZXY":
this._x = Math.asin(z(d, -1, 1)), Math.abs(d) < .9999999 ? (this._y = Math.atan2(-u, f), this._z = Math.atan2(-a, c)) : (this._y = 0, this._z = Math.atan2(s, i));
break;
case "ZYX":
this._y = Math.asin(-z(u, -1, 1)), Math.abs(u) < .9999999 ? (this._x = Math.atan2(d, f), this._z = Math.atan2(s, i)) : (this._x = 0, this._z = Math.atan2(-a, c));
break;
case "YZX":
this._z = Math.asin(z(s, -1, 1)), Math.abs(s) < .9999999 ? (this._x = Math.atan2(-l, c), this._y = Math.atan2(-u, i)) : (this._x = 0, this._y = Math.atan2(o, f));
break;
case "XZY":
this._z = Math.asin(-z(a, -1, 1)), Math.abs(a) < .9999999 ? (this._x = Math.atan2(d, c), this._y = Math.atan2(o, i)) : (this._x = Math.atan2(-l, f), this._y = 0);
break;
default: L("Euler: .setFromRotationMatrix() encountered an unknown order: " + t);
}
return this._order = t, n === !0 && this._onChangeCallback(), this;
}
setFromQuaternion(e, t, n) {
return pr.makeRotationFromQuaternion(e), this.setFromRotationMatrix(pr, t, n);
}
setFromVector3(e, t = this._order) {
return this.set(e.x, e.y, e.z, t);
}
reorder(e) {
return mr.setFromEuler(this), this.setFromQuaternion(mr, e);
}
equals(e) {
return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order;
}
fromArray(e) {
return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[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._order, e;
}
_onChange(e) {
return this._onChangeCallback = e, this;
}
_onChangeCallback() {}
*[Symbol.iterator]() {
yield this._x, yield this._y, yield this._z, yield this._order;
}
};
hr.DEFAULT_ORDER = "XYZ";
var gr = class {
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;
}
}, _r = 0, vr = /*@__PURE__*/ new H(), yr = /*@__PURE__*/ new Fn(), br = /*@__PURE__*/ new W(), xr = /*@__PURE__*/ new H(), Sr = /*@__PURE__*/ new H(), Cr = /*@__PURE__*/ new H(), wr = /*@__PURE__*/ new Fn(), Tr = /*@__PURE__*/ new H(1, 0, 0), Er = /*@__PURE__*/ new H(0, 1, 0), Dr = /*@__PURE__*/ new H(0, 0, 1), Or = { type: "added" }, kr = { type: "removed" }, Ar = {
type: "childadded",
child: null
}, jr = {
type: "childremoved",
child: null
}, Mr = class e extends ln {
constructor() {
super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: _r++ }), this.uuid = mn(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = e.DEFAULT_UP.clone();
let t = new H(), n = new hr(), r = new Fn(), i = new H(1, 1, 1);
function a() {
r.setFromEuler(n, !1);
}
function o() {
n.setFromQuaternion(r, void 0, !1);
}
n._onChange(a), r._onChange(o), Object.defineProperties(this, {
position: {
configurable: !0,
enumerable: !0,
value: t
},
rotation: {
configurable: !0,
enumerable: !0,
value: n
},
quaternion: {
configurable: !0,
enumerable: !0,
value: r
},
scale: {
configurable: !0,
enumerable: !0,
value: i
},
modelViewMatrix: { value: new W() },
normalMatrix: { value: new U() }
}), this.matrix = new W(), this.matrixWorld = new W(), this.matrixAutoUpdate = e.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new gr(), 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.static = !1, this.userData = {}, this.pivot = null;
}
onBeforeShadow() {}
onAfterShadow() {}
onBeforeRender() {}
onAfterRender() {}
applyMatrix4(e) {
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 yr.setFromAxisAngle(e, t), this.quaternion.multiply(yr), this;
}
rotateOnWorldAxis(e, t) {
return yr.setFromAxisAngle(e, t), this.quaternion.premultiply(yr), this;
}
rotateX(e) {
return this.rotateOnAxis(Tr, e);
}
rotateY(e) {
return this.rotateOnAxis(Er, e);
}
rotateZ(e) {
return this.rotateOnAxis(Dr, e);
}
translateOnAxis(e, t) {
return vr.copy(e).applyQuaternion(this.quaternion), this.position.add(vr.multiplyScalar(t)), this;
}
translateX(e) {
return this.translateOnAxis(Tr, e);
}
translateY(e) {
return this.translateOnAxis(Er, e);
}
translateZ(e) {
return this.translateOnAxis(Dr, e);
}
localToWorld(e) {
return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld);
}
worldToLocal(e) {
return this.updateWorldMatrix(!0, !1), e.applyMatrix4(br.copy(this.matrixWorld).invert());
}
lookAt(e, t, n) {
e.isVector3 ? xr.copy(e) : xr.set(e, t, n);
let r = this.parent;
this.updateWorldMatrix(!0, !1), Sr.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? br.lookAt(Sr, xr, this.up) : br.lookAt(xr, Sr, this.up), this.quaternion.setFromRotationMatrix(br), r && (br.extractRotation(r.matrixWorld), yr.setFromRotationMatrix(br), this.quaternion.premultiply(yr.invert()));
}
add(e) {
if (arguments.length > 1) {
for (let e = 0; e < arguments.length; e++) this.add(arguments[e]);
return this;
}
return e === this ? (R("Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.removeFromParent(), e.parent = this, this.children.push(e), e.dispatchEvent(Or), Ar.child = e, this.dispatchEvent(Ar), Ar.child = null) : R("Object3D.add: object not an instance of THREE.Object3D.", e), this);
}
remove(e) {
if (arguments.length > 1) {
for (let e = 0; e < arguments.length; e++) this.remove(arguments[e]);
return this;
}
let t = this.children.indexOf(e);
return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(kr), jr.child = e, this.dispatchEvent(jr), jr.child = null), this;
}
removeFromParent() {
let e = this.parent;
return e !== null && e.remove(this), this;
}
clear() {
return this.remove(...this.children);
}
attach(e) {
return this.updateWorldMatrix(!0, !1), br.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), br.multiply(e.parent.matrixWorld)), e.applyMatrix4(br), e.removeFromParent(), e.parent = this, this.children.push(e), e.updateWorldMatrix(!1, !0), e.dispatchEvent(Or), Ar.child = e, this.dispatchEvent(Ar), Ar.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, r = this.children.length; n < r; n++) {
let r = this.children[n].getObjectByProperty(e, t);
if (r !== void 0) return r;
}
}
getObjectsByProperty(e, t, n = []) {
this[e] === t && n.push(this);
let r = this.children;
for (let i = 0, a = r.length; i < a; i++) r[i].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(Sr, e, Cr), e;
}
getWorldScale(e) {
return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Sr, wr, 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, r = t.length; n < r; n++) t[n].traverse(e);
}
traverseVisible(e) {
if (this.visible === !1) return;
e(this);
let t = this.children;
for (let n = 0, r = t.length; n < r; n++) t[n].traverseVisible(e);
}
traverseAncestors(e) {
let t = this.parent;
t !== null && (e(t), t.traverseAncestors(e));
}
updateMatrix() {
this.matrix.compose(this.position, this.quaternion, this.scale);
let e = this.pivot;
if (e !== null) {
let t = e.x, n = e.y, r = e.z, i = this.matrix.elements;
i[12] += t - i[0] * t - i[4] * n - i[8] * r, i[13] += n - i[1] * t - i[5] * n - i[9] * r, i[14] += r - i[2] * t - i[6] * n - i[10] * r;
}
this.matrixWorldNeedsUpdate = !0;
}
updateMatrixWorld(e) {
this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1, e = !0);
let t = this.children;
for (let n = 0, r = t.length; n < r; n++) t[n].updateMatrixWorld(e);
}
updateWorldMatrix(e, t, n = !1) {
let r = this.parent;
if (e === !0 && r !== null && r.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || n) && (this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1, n = !0), t === !0) {
let e = this.children;
for (let t = 0, r = e.length; t < r; t++) e[t].updateWorldMatrix(!1, !0, n);
}
}
toJSON(e) {
let t = e === void 0 || typeof e == "string", n = {};
t && (e = {
geometries: {},
materials: {},
textures: {},
images: {},
shapes: {},
skeletons: {},
animations: {},
nodes: {}
}, n.metadata = {
version: 4.7,
type: "Object",
generator: "Object3D.toJSON"
});
let r = {};
r.uuid = this.uuid, r.type = this.type, this.name !== "" && (r.name = this.name), this.castShadow === !0 && (r.castShadow = !0), this.receiveShadow === !0 && (r.receiveShadow = !0), this.visible === !1 && (r.visible = !1), this.frustumCulled === !1 && (r.frustumCulled = !1), this.renderOrder !== 0 && (r.renderOrder = this.renderOrder), this.static !== !1 && (r.static = this.static), Object.keys(this.userData).length > 0 && (r.userData = this.userData), r.layers = this.layers.mask, r.matrix = this.matrix.toArray(), r.up = this.up.toArray(), this.pivot !== null && (r.pivot = this.pivot.toArray()), this.matrixAutoUpdate === !1 && (r.matrixAutoUpdate = !1), this.morphTargetDictionary !== void 0 && (r.morphTargetDictionary = Object.assign({}, this.morphTargetDictionary)), this.morphTargetInfluences !== void 0 && (r.morphTargetInfluences = this.morphTargetInfluences.slice()), this.isInstancedMesh && (r.type = "InstancedMesh", r.count = this.count, r.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (r.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (r.type = "BatchedMesh", r.perObjectFrustumCulled = this.perObjectFrustumCulled, r.sortObjects = this.sortObjects, r.drawRanges = this._drawRanges, r.reservedRanges = this._reservedRanges, r.geometryInfo = this._geometryInfo.map((e) => ({
...e,
boundingBox: e.boundingBox ? e.boundingBox.toJSON() : void 0,
boundingSphere: e.boundingSphere ? e.boundingSphere.toJSON() : void 0
})), r.instanceInfo = this._instanceInfo.map((e) => ({ ...e })), r.availableInstanceIds = this._availableInstanceIds.slice(), r.availableGeometryIds = this._availableGeometryIds.slice(), r.nextIndexStart = this._nextIndexStart, r.nextVertexStart = this._nextVertexStart, r.geometryCount = this._geometryCount, r.maxInstanceCount = this._maxInstanceCount, r.maxVertexCount = this._maxVertexCount, r.maxIndexCount = this._maxIndexCount, r.geometryInitialized = this._geometryInitialized, r.matricesTexture = this._matricesTexture.toJSON(e), r.indirectTexture = this._indirectTexture.toJSON(e), this._colorsTexture !== null && (r.colorsTexture = this._colorsTexture.toJSON(e)), this.boundingSphere !== null && (r.boundingSphere = this.boundingSphere.toJSON()), this.boundingBox !== null && (r.boundingBox = this.boundingBox.toJSON()));
function i(t, n) {
return t[n.uuid] === void 0 && (t[n.uuid] = n.toJSON(e)), n.uuid;
}
if (this.isScene) this.background && (this.background.isColor ? r.background = this.background.toJSON() : this.background.isTexture && (r.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (r.environment = this.environment.toJSON(e).uuid);
else if (this.isMesh || this.isLine || this.isPoints) {
r.geometry = i(e.geometries, this.geometry);
let t = this.geometry.parameters;
if (t !== void 0 && t.shapes !== void 0) {
let n = t.shapes;
if (Array.isArray(n)) for (let t = 0, r = n.length; t < r; t++) {
let r = n[t];
i(e.shapes, r);
}
else i(e.shapes, n);
}
}
if (this.isSkinnedMesh && (r.bindMode = this.bindMode, r.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (i(e.skeletons, this.skeleton), r.skeleton = this.skeleton.uuid)), this.material !== void 0) if (Array.isArray(this.material)) {
let t = [];
for (let n = 0, r = this.material.length; n < r; n++) t.push(i(e.materials, this.material[n]));
r.material = t;
} else r.material = i(e.materials, this.material);
if (this.children.length > 0) {
r.children = [];
for (let t = 0; t < this.children.length; t++) r.children.push(this.children[t].toJSON(e).object);
}
if (this.animations.length > 0) {
r.animations = [];
for (let t = 0; t < this.animations.length; t++) {
let n = this.animations[t];
r.animations.push(i(e.animations, n));
}
}
if (t) {
let t = a(e.geometries), r = a(e.materials), i = a(e.textures), o = a(e.images), s = a(e.shapes), c = a(e.skeletons), l = a(e.animations), u = a(e.nodes);
t.length > 0 && (n.geometries = t), r.length > 0 && (n.materials = r), i.length > 0 && (n.textures = i), o.length > 0 && (n.images = o), s.length > 0 && (n.shapes = s), c.length > 0 && (n.skeletons = c), l.length > 0 && (n.animations = l), u.length > 0 && (n.nodes = u);
}
return n.object = r, n;
function a(e) {
let t = [];
for (let n in e) {
let r = e[n];
delete r.metadata, t.push(r);
}
return t;
}
}
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.pivot = e.pivot === null ? null : e.pivot.clone(), 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.static = e.static, this.animations = e.animations.slice(), this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0) for (let t = 0; t < e.children.length; t++) {
let n = e.children[t];
this.add(n.clone());
}
return this;
}
};
Mr.DEFAULT_UP = /*@__PURE__*/ new H(0, 1, 0), Mr.DEFAULT_MATRIX_AUTO_UPDATE = !0, Mr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
var Nr = class extends Mr {
constructor() {
super(), this.isGroup = !0, this.type = "Group";
}
}, Pr = { type: "move" }, Fr = class {
constructor() {
this._targetRay = null, this._grip = null, this._hand = null;
}
getHandSpace() {
return this._hand === null && (this._hand = new Nr(), this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { pinching: !1 }), this._hand;
}
getTargetRaySpace() {
return this._targetRay === null && (this._targetRay = new Nr(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new H(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new H()), this._targetRay;
}
getGripSpace() {
return this._grip === null && (this._grip = new Nr(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new H(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new H(), this._grip.eventsEnabled = !1), this._grip;
}
dispatchEvent(e) {
return this._targetRay !== null && this._targetRay.dispatchEvent(e), this._grip !== null && this._grip.dispatchEvent(e), this._hand !== null && this._hand.dispatchEvent(e), 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) {
return this.dispatchEvent({
type: "disconnected",
data: e
}), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this;
}
update(e, t, n) {
let r = null, i = null, a = null, o = this._targetRay, s = this._grip, c = this._hand;
if (e && t.session.visibilityState !== "visible-blurred") {
if (c && e.hand) {
a = !0;
for (let r of e.hand.values()) {
let e = t.getJointPose(r, n), i = this._getHandJoint(c, r);
e !== null && (i.matrix.fromArray(e.transform.matrix), i.matrix.decompose(i.position, i.rotation, i.scale), i.matrixWorldNeedsUpdate = !0, i.jointRadius = e.radius), i.visible = e !== null;
}
let r = c.joints["index-finger-tip"], i = c.joints["thumb-tip"], o = r.position.distanceTo(i.position);
c.inputState.pinching && o > .025 ? (c.inputState.pinching = !1, this.dispatchEvent({
type: "pinchend",
handedness: e.handedness,
target: this
})) : !c.inputState.pinching && o <= .015 && (c.inputState.pinching = !0, this.dispatchEvent({
type: "pinchstart",
handedness: e.handedness,
target: this
}));
} else s !== null && e.gripSpace && (i = t.getPose(e.gripSpace, n), i !== null && (s.matrix.fromArray(i.transform.matrix), s.matrix.decompose(s.position, s.rotation, s.scale), s.matrixWorldNeedsUpdate = !0, i.linearVelocity ? (s.hasLinearVelocity = !0, s.linearVelocity.copy(i.linearVelocity)) : s.hasLinearVelocity = !1, i.angularVelocity ? (s.hasAngularVelocity = !0, s.angularVelocity.copy(i.angularVelocity)) : s.hasAngularVelocity = !1, s.eventsEnabled && s.dispatchEvent({
type: "gripUpdated",
data: e,
target: this
})));
o !== null && (r = t.getPose(e.targetRaySpace, n), r === null && i !== null && (r = i), r !== null && (o.matrix.fromArray(r.transform.matrix), o.matrix.decompose(o.position, o.rotation, o.scale), o.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (o.hasLinearVelocity = !0, o.linearVelocity.copy(r.linearVelocity)) : o.hasLinearVelocity = !1, r.angularVelocity ? (o.hasAngularVelocity = !0, o.angularVelocity.copy(r.angularVelocity)) : o.hasAngularVelocity = !1, this.dispatchEvent(Pr)));
}
return o !== null && (o.visible = r !== null), s !== null && (s.visible = i !== null), c !== null && (c.visible = a !== null), this;
}
_getHandJoint(e, t) {
if (e.joints[t.jointName] === void 0) {
let n = new Nr();
n.matrixAutoUpdate = !1, n.visible = !1, e.joints[t.jointName] = n, e.add(n);
}
return e.joints[t.jointName];
}
}, Ir = {
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
}, Lr = {
h: 0,
s: 0,
l: 0
}, Rr = {
h: 0,
s: 0,
l: 0
};
function zr(e, t, n) {
return n < 0 && (n += 1), n > 1 && --n, n < 1 / 6 ? e + (t - e) * 6 * n : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * 6 * (2 / 3 - n) : e;
}
var G = class {
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 t = e;
t && t.isColor ? this.copy(t) : typeof t == "number" ? this.setHex(t) : typeof t == "string" && this.setStyle(t);
} else this.setRGB(e, t, n);
return this;
}
setScalar(e) {
return this.r = e, this.g = e, this.b = e, this;
}
setHex(e, t = bt) {
return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, Hn.colorSpaceToWorking(this, t), this;
}
setRGB(e, t, n, r = Hn.workingColorSpace) {
return this.r = e, this.g = t, this.b = n, Hn.colorSpaceToWorking(this, r), this;
}
setHSL(e, t, n, r = Hn.workingColorSpace) {
if (e = hn(e, 1), t = z(t, 0, 1), n = z(n, 0, 1), t === 0) this.r = this.g = this.b = n;
else {
let r = n <= .5 ? n * (1 + t) : n + t - n * t, i = 2 * n - r;
this.r = zr(i, r, e + 1 / 3), this.g = zr(i, r, e), this.b = zr(i, r, e - 1 / 3);
}
return Hn.colorSpaceToWorking(this, r), this;
}
setStyle(e, t = bt) {
function n(t) {
t !== void 0 && parseFloat(t) < 1 && L("Color: Alpha component of " + e + " will be ignored.");
}
let r;
if (r = /^(\w+)\(([^\)]*)\)/.exec(e)) {
let i, a = r[1], o = r[2];
switch (a) {
case "rgb":
case "rgba":
if (i = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(i[4]), this.setRGB(Math.min(255, parseInt(i[1], 10)) / 255, Math.min(255, parseInt(i[2], 10)) / 255, Math.min(255, parseInt(i[3], 10)) / 255, t);
if (i = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(i[4]), this.setRGB(Math.min(100, parseInt(i[1], 10)) / 100, Math.min(100, parseInt(i[2], 10)) / 100, Math.min(100, parseInt(i[3], 10)) / 100, t);
break;
case "hsl":
case "hsla":
if (i = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(i[4]), this.setHSL(parseFloat(i[1]) / 360, parseFloat(i[2]) / 100, parseFloat(i[3]) / 100, t);
break;
default: L("Color: Unknown color model " + e);
}
} else if (r = /^\#([A-Fa-f\d]+)$/.exec(e)) {
let n = r[1], i = n.length;
if (i === 3) return this.setRGB(parseInt(n.charAt(0), 16) / 15, parseInt(n.charAt(1), 16) / 15, parseInt(n.charAt(2), 16) / 15, t);
if (i === 6) return this.setHex(parseInt(n, 16), t);
L("Color: Invalid hex color " + e);
} else if (e && e.length > 0) return this.setColorName(e, t);
return this;
}
setColorName(e, t = bt) {
let n = Ir[e.toLowerCase()];
return n === void 0 ? L("Color: Unknown color " + e) : this.setHex(n, t), 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 = Un(e.r), this.g = Un(e.g), this.b = Un(e.b), this;
}
copyLinearToSRGB(e) {
return this.r = Wn(e.r), this.g = Wn(e.g), this.b = Wn(e.b), this;
}
convertSRGBToLinear() {
return this.copySRGBToLinear(this), this;
}
convertLinearToSRGB() {
return this.copyLinearToSRGB(this), this;
}
getHex(e = bt) {
return Hn.workingToColorSpace(Br.copy(this), e), Math.round(z(Br.r * 255, 0, 255)) * 65536 + Math.round(z(Br.g * 255, 0, 255)) * 256 + Math.round(z(Br.b * 255, 0, 255));
}
getHexString(e = bt) {
return ("000000" + this.getHex(e).toString(16)).slice(-6);
}
getHSL(e, t = Hn.workingColorSpace) {
Hn.workingToColorSpace(Br.copy(this), t);
let n = Br.r, r = Br.g, i = Br.b, a = Math.max(n, r, i), o = Math.min(n, r, i), s, c, l = (o + a) / 2;
if (o === a) s = 0, c = 0;
else {
let e = a - o;
switch (c = l <= .5 ? e / (a + o) : e / (2 - a - o), a) {
case n:
s = (r - i) / e + (r < i ? 6 : 0);
break;
case r:
s = (i - n) / e + 2;
break;
case i:
s = (n - r) / e + 4;
break;
}
s /= 6;
}
return e.h = s, e.s = c, e.l = l, e;
}
getRGB(e, t = Hn.workingColorSpace) {
return Hn.workingToColorSpace(Br.copy(this), t), e.r = Br.r, e.g = Br.g, e.b = Br.b, e;
}
getStyle(e = bt) {
Hn.workingToColorSpace(Br.copy(this), e);
let t = Br.r, n = Br.g, r = Br.b;
return e === "srgb" ? `rgb(${Math.round(t * 255)},${Math.round(n * 255)},${Math.round(r * 255)})` : `color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`;
}
offsetHSL(e, t, n) {
return this.getHSL(Lr), this.setHSL(Lr.h + e, Lr.s + t, Lr.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(Lr), e.getHSL(Rr);
let n = vn(Lr.h, Rr.h, t), r = vn(Lr.s, Rr.s, t), i = vn(Lr.l, Rr.l, t);
return this.setHSL(n, r, i), 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, r = this.b, i = e.elements;
return this.r = i[0] * t + i[3] * n + i[6] * r, this.g = i[1] * t + i[4] * n + i[7] * r, this.b = i[2] * t + i[5] * n + i[8] * r, 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;
}
}, Br = /*@__PURE__*/ new G();
G.NAMES = Ir;
var Vr = class e {
constructor(e, t = 25e-5) {
this.isFogExp2 = !0, this.name = "", this.color = new G(e), this.density = t;
}
clone() {
return new e(this.color, this.density);
}
toJSON() {
return {
type: "FogExp2",
name: this.name,
color: this.color.getHex(),
density: this.density
};
}
}, Hr = class e {
constructor(e, t = 1, n = 1e3) {
this.isFog = !0, this.name = "", this.color = new G(e), this.near = t, this.far = n;
}
clone() {
return new e(this.color, this.near, this.far);
}
toJSON() {
return {
type: "Fog",
name: this.name,
color: this.color.getHex(),
near: this.near,
far: this.far
};
}
}, Ur = class extends Mr {
constructor() {
super(), this.isScene = !0, this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.backgroundBlurriness = 0, this.backgroundIntensity = 1, this.backgroundRotation = new hr(), this.environmentIntensity = 1, this.environmentRotation = new hr(), this.overrideMaterial = null, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
}
copy(e, t) {
return super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), 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()), this.matrixAutoUpdate = e.matrixAutoUpdate, this;
}
toJSON(e) {
let t = super.toJSON(e);
return this.fog !== null && (t.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (t.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (t.object.backgroundIntensity = this.backgroundIntensity), t.object.backgroundRotation = this.backgroundRotation.toArray(), this.environmentIntensity !== 1 && (t.object.environmentIntensity = this.environmentIntensity), t.object.environmentRotation = this.environmentRotation.toArray(), t;
}
}, Wr = /*@__PURE__*/ new H(), Gr = /*@__PURE__*/ new H(), Kr = /*@__PURE__*/ new H(), qr = /*@__PURE__*/ new H(), Jr = /*@__PURE__*/ new H(), Yr = /*@__PURE__*/ new H(), Xr = /*@__PURE__*/ new H(), Zr = /*@__PURE__*/ new H(), Qr = /*@__PURE__*/ new H(), $r = /*@__PURE__*/ new H(), ei = /*@__PURE__*/ new $n(), ti = /*@__PURE__*/ new $n(), ni = /*@__PURE__*/ new $n(), ri = class e {
constructor(e = new H(), t = new H(), n = new H()) {
this.a = e, this.b = t, this.c = n;
}
static getNormal(e, t, n, r) {
r.subVectors(n, t), Wr.subVectors(e, t), r.cross(Wr);
let i = r.lengthSq();
return i > 0 ? r.multiplyScalar(1 / Math.sqrt(i)) : r.set(0, 0, 0);
}
static getBarycoord(e, t, n, r, i) {
Wr.subVectors(r, t), Gr.subVectors(n, t), Kr.subVectors(e, t);
let a = Wr.dot(Wr), o = Wr.dot(Gr), s = Wr.dot(Kr), c = Gr.dot(Gr), l = Gr.dot(Kr), u = a * c - o * o;
if (u === 0) return i.set(0, 0, 0), null;
let d = 1 / u, f = (c * s - o * l) * d, p = (a * l - o * s) * d;
return i.set(1 - f - p, p, f);
}
static containsPoint(e, t, n, r) {
return this.getBarycoord(e, t, n, r, qr) !== null && qr.x >= 0 && qr.y >= 0 && qr.x + qr.y <= 1;
}
static getInterpolation(e, t, n, r, i, a, o, s) {
return this.getBarycoord(e, t, n, r, qr) === null ? (s.x = 0, s.y = 0, "z" in s && (s.z = 0), "w" in s && (s.w = 0), null) : (s.setScalar(0), s.addScaledVector(i, qr.x), s.addScaledVector(a, qr.y), s.addScaledVector(o, qr.z), s);
}
static getInterpolatedAttribute(e, t, n, r, i, a) {
return ei.setScalar(0), ti.setScalar(0), ni.setScalar(0), ei.fromBufferAttribute(e, t), ti.fromBufferAttribute(e, n), ni.fromBufferAttribute(e, r), a.setScalar(0), a.addScaledVector(ei, i.x), a.addScaledVector(ti, i.y), a.addScaledVector(ni, i.z), a;
}
static isFrontFacing(e, t, n, r) {
return Wr.subVectors(n, t), Gr.subVectors(e, t), Wr.cross(Gr).dot(r) < 0;
}
set(e, t, n) {
return this.a.copy(e), this.b.copy(t), this.c.copy(n), this;
}
setFromPointsAndIndices(e, t, n, r) {
return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[r]), this;
}
setFromAttributeAndIndices(e, t, n, r) {
return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, r), 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 Wr.subVectors(this.c, this.b), Gr.subVectors(this.a, this.b), Wr.cross(Gr).length() * .5;
}
getMidpoint(e) {
return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
}
getNormal(t) {
return e.getNormal(this.a, this.b, this.c, t);
}
getPlane(e) {
return e.setFromCoplanarPoints(this.a, this.b, this.c);
}
getBarycoord(t, n) {
return e.getBarycoord(t, this.a, this.b, this.c, n);
}
getInterpolation(t, n, r, i, a) {
return e.getInterpolation(t, this.a, this.b, this.c, n, r, i, a);
}
containsPoint(t) {
return e.containsPoint(t, this.a, this.b, this.c);
}
isFrontFacing(t) {
return e.isFrontFacing(this.a, this.b, this.c, t);
}
intersectsBox(e) {
return e.intersectsTriangle(this);
}
closestPointToPoint(e, t) {
let n = this.a, r = this.b, i = this.c, a, o;
Jr.subVectors(r, n), Yr.subVectors(i, n), Zr.subVectors(e, n);
let s = Jr.dot(Zr), c = Yr.dot(Zr);
if (s <= 0 && c <= 0) return t.copy(n);
Qr.subVectors(e, r);
let l = Jr.dot(Qr), u = Yr.dot(Qr);
if (l >= 0 && u <= l) return t.copy(r);
let d = s * u - l * c;
if (d <= 0 && s >= 0 && l <= 0) return a = s / (s - l), t.copy(n).addScaledVector(Jr, a);
$r.subVectors(e, i);
let f = Jr.dot($r), p = Yr.dot($r);
if (p >= 0 && f <= p) return t.copy(i);
let m = f * c - s * p;
if (m <= 0 && c >= 0 && p <= 0) return o = c / (c - p), t.copy(n).addScaledVector(Yr, o);
let h = l * p - f * u;
if (h <= 0 && u - l >= 0 && f - p >= 0) return Xr.subVectors(i, r), o = (u - l) / (u - l + (f - p)), t.copy(r).addScaledVector(Xr, o);
let g = 1 / (h + m + d);
return a = m * g, o = d * g, t.copy(n).addScaledVector(Jr, a).addScaledVector(Yr, o);
}
equals(e) {
return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c);
}
}, ii = class {
constructor(e = new H(Infinity, Infinity, Infinity), t = new H(-Infinity, -Infinity, -Infinity)) {
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(oi.fromArray(e, t));
return this;
}
setFromBufferAttribute(e) {
this.makeEmpty();
for (let t = 0, n = e.count; t < n; t++) this.expandByPoint(oi.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 = oi.copy(t).multiplyScalar(.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 = Infinity, this.max.x = this.max.y = this.max.z = -Infinity, 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(.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 r = n.getAttribute("position");
if (t === !0 && r !== void 0 && e.isInstancedMesh !== !0) for (let t = 0, n = r.count; t < n; t++) e.isMesh === !0 ? e.getVertexPosition(t, oi) : oi.fromBufferAttribute(r, t), oi.applyMatrix4(e.matrixWorld), this.expandByPoint(oi);
else e.boundingBox === void 0 ? (n.boundingBox === null && n.computeBoundingBox(), si.copy(n.boundingBox)) : (e.boundingBox === null && e.computeBoundingBox(), si.copy(e.boundingBox)), si.applyMatrix4(e.matrixWorld), this.union(si);
}
let r = e.children;
for (let e = 0, n = r.length; e < n; e++) this.expandByObject(r[e], 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, oi), oi.distanceToSquared(e.center) <= e.radius * e.radius;
}
intersectsPlane(e) {
let t, n;
return e.normal.x > 0 ? (t = e.normal.x * this.min.x, n = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, n = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, n += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, n += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, n += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, n += e.normal.z * this.min.z), t <= -e.constant && n >= -e.constant;
}
intersectsTriangle(e) {
if (this.isEmpty()) return !1;
this.getCenter(mi), hi.subVectors(this.max, mi), ci.subVectors(e.a, mi), li.subVectors(e.b, mi), ui.subVectors(e.c, mi), di.subVectors(li, ci), fi.subVectors(ui, li), pi.subVectors(ci, ui);
let t = [
0,
-di.z,
di.y,
0,
-fi.z,
fi.y,
0,
-pi.z,
pi.y,
di.z,
0,
-di.x,
fi.z,
0,
-fi.x,
pi.z,
0,
-pi.x,
-di.y,
di.x,
0,
-fi.y,
fi.x,
0,
-pi.y,
pi.x,
0
];
return !vi(t, ci, li, ui, hi) || (t = [
1,
0,
0,
0,
1,
0,
0,
0,
1
], !vi(t, ci, li, ui, hi)) ? !1 : (gi.crossVectors(di, fi), t = [
gi.x,
gi.y,
gi.z
], vi(t, ci, li, ui, hi));
}
clampPoint(e, t) {
return t.copy(e).clamp(this.min, this.max);
}
distanceToPoint(e) {
return this.clampPoint(e, oi).distanceTo(e);
}
getBoundingSphere(e) {
return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(oi).length() * .5), e;
}
intersect(e) {
return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this;
}
union(e) {
return this.min.min(e.min), this.max.max(e.max), this;
}
applyMatrix4(e) {
return this.isEmpty() ? this : (ai[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), ai[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), ai[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), ai[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), ai[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), ai[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), ai[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), ai[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(ai), 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;
}
}, ai = [
/*@__PURE__*/ new H(),
/*@__PURE__*/ new H(),
/*@__PURE__*/ new H(),
/*@__PURE__*/ new H(),
/*@__PURE__*/ new H(),
/*@__PURE__*/ new H(),
/*@__PURE__*/ new H(),
/*@__PURE__*/ new H()
], oi = /*@__PURE__*/ new H(), si = /*@__PURE__*/ new ii(), ci = /*@__PURE__*/ new H(), li = /*@__PURE__*/ new H(), ui = /*@__PURE__*/ new H(), di = /*@__PURE__*/ new H(), fi = /*@__PURE__*/ new H(), pi = /*@__PURE__*/ new H(), mi = /*@__PURE__*/ new H(), hi = /*@__PURE__*/ new H(), gi = /*@__PURE__*/ new H(), _i = /*@__PURE__*/ new H();
function vi(e, t, n, r, i) {
for (let a = 0, o = e.length - 3; a <= o; a += 3) {
_i.fromArray(e, a);
let o = i.x * Math.abs(_i.x) + i.y * Math.abs(_i.y) + i.z * Math.abs(_i.z), s = t.dot(_i), c = n.dot(_i), l = r.dot(_i);
if (Math.max(-Math.max(s, c, l), Math.min(s, c, l)) > o) return !1;
}
return !0;
}
var yi = /*@__PURE__*/ bi();
function bi() {
let e = /* @__PURE__ */ new ArrayBuffer(4), t = new Float32Array(e), n = new Uint32Array(e), r = /* @__PURE__ */ new Uint32Array(512), i = /* @__PURE__ */ new Uint32Array(512);
for (let e = 0; e < 256; ++e) {
let t = e - 127;
t < -27 ? (r[e] = 0, r[e | 256] = 32768, i[e] = 24, i[e | 256] = 24) : t < -14 ? (r[e] = 1024 >> -t - 14, r[e | 256] = 1024 >> -t - 14 | 32768, i[e] = -t - 1, i[e | 256] = -t - 1) : t <= 15 ? (r[e] = t + 15 << 10, r[e | 256] = t + 15 << 10 | 32768, i[e] = 13, i[e | 256] = 13) : t < 128 ? (r[e] = 31744, r[e | 256] = 64512, i[e] = 24, i[e | 256] = 24) : (r[e] = 31744, r[e | 256] = 64512, i[e] = 13, i[e | 256] = 13);
}
let a = /* @__PURE__ */ new Uint32Array(2048), o = /* @__PURE__ */ new Uint32Array(64), s = /* @__PURE__ */ new Uint32Array(64);
for (let e = 1; e < 1024; ++e) {
let t = e << 13, n = 0;
for (; !(t & 8388608);) t <<= 1, n -= 8388608;
t &= -8388609, n += 947912704, a[e] = t | n;
}
for (let e = 1024; e < 2048; ++e) a[e] = 939524096 + (e - 1024 << 13);
for (let e = 1; e < 31; ++e) o[e] = e << 23;
o[31] = 1199570944, o[32] = 2147483648;
for (let e = 33; e < 63; ++e) o[e] = 2147483648 + (e - 32 << 23);
o[63] = 3347054592;
for (let e = 1; e < 64; ++e) e !== 32 && (s[e] = 1024);
return {
floatView: t,
uint32View: n,
baseTable: r,
shiftTable: i,
mantissaTable: a,
exponentTable: o,
offsetTable: s
};
}
function xi(e) {
Math.abs(e) > 65504 && L("DataUtils.toHalfFloat(): Value out of range."), e = z(e, -65504, 65504), yi.floatView[0] = e;
let t = yi.uint32View[0], n = t >> 23 & 511;
return yi.baseTable[n] + ((t & 8388607) >> yi.shiftTable[n]);
}
function Si(e) {
let t = e >> 10;
return yi.uint32View[0] = yi.mantissaTable[yi.offsetTable[t] + (e & 1023)] + yi.exponentTable[t], yi.floatView[0];
}
var Ci = class {
static toHalfFloat(e) {
return xi(e);
}
static fromHalfFloat(e) {
return Si(e);
}
}, wi = /*@__PURE__*/ new H(), Ti = /*@__PURE__*/ new V(), Ei = 0, Di = class extends ln {
constructor(e, t, n = !1) {
if (super(), Array.isArray(e)) throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");
this.isBufferAttribute = !0, Object.defineProperty(this, "id", { value: Ei++ }), this.name = "", this.array = e, this.itemSize = t, this.count = e === void 0 ? 0 : e.length / t, this.normalized = n, this.usage = jt, this.updateRanges = [], this.gpuType = N, this.version = 0;
}
onUploadCallback() {}
set needsUpdate(e) {
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 r = 0, i = this.itemSize; r < i; r++) this.array[e + r] = t.array[n + r];
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++) Ti.fromBufferAttribute(this, t), Ti.applyMatrix3(e), this.setXY(t, Ti.x, Ti.y);
else if (this.itemSize === 3) for (let t = 0, n = this.count; t < n; t++) wi.fromBufferAttribute(this, t), wi.applyMatrix3(e), this.setXYZ(t, wi.x, wi.y, wi.z);
return this;
}
applyMatrix4(e) {
for (let t = 0, n = this.count; t < n; t++) wi.fromBufferAttribute(this, t), wi.applyMatrix4(e), this.setXYZ(t, wi.x, wi.y, wi.z);
return this;
}
applyNormalMatrix(e) {
for (let t = 0, n = this.count; t < n; t++) wi.fromBufferAttribute(this, t), wi.applyNormalMatrix(e), this.setXYZ(t, wi.x, wi.y, wi.z);
return this;
}
transformDirection(e) {
for (let t = 0, n = this.count; t < n; t++) wi.fromBufferAttribute(this, t), wi.transformDirection(e), this.setXYZ(t, wi.x, wi.y, wi.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];
return this.normalized && (n = Nn(n, this.array)), n;
}
setComponent(e, t, n) {
return this.normalized && (n = B(n, this.array)), this.array[e * this.itemSize + t] = n, this;
}
getX(e) {
let t = this.array[e * this.itemSize];
return this.normalized && (t = Nn(t, this.array)), t;
}
setX(e, t) {
return this.normalized && (t = B(t, this.array)), this.array[e * this.itemSize] = t, this;
}
getY(e) {
let t = this.array[e * this.itemSize + 1];
return this.normalized && (t = Nn(t, this.array)), t;
}
setY(e, t) {
return this.normalized && (t = B(t, this.array)), this.array[e * this.itemSize + 1] = t, this;
}
getZ(e) {
let t = this.array[e * this.itemSize + 2];
return this.normalized && (t = Nn(t, this.array)), t;
}
setZ(e, t) {
return this.normalized && (t = B(t, this.array)), this.array[e * this.itemSize + 2] = t, this;
}
getW(e) {
let t = this.array[e * this.itemSize + 3];
return this.normalized && (t = Nn(t, this.array)), t;
}
setW(e, t) {
return this.normalized && (t = B(t, this.array)), this.array[e * this.itemSize + 3] = t, this;
}
setXY(e, t, n) {
return e *= this.itemSize, this.normalized && (t = B(t, this.array), n = B(n, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this;
}
setXYZ(e, t, n, r) {
return e *= this.itemSize, this.normalized && (t = B(t, this.array), n = B(n, this.array), r = B(r, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this;
}
setXYZW(e, t, n, r, i) {
return e *= this.itemSize, this.normalized && (t = B(t, this.array), n = B(n, this.array), r = B(r, this.array), i = B(i, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this.array[e + 3] = i, 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
};
return this.name !== "" && (e.name = this.name), this.usage !== 35044 && (e.usage = this.usage), e;
}
dispose() {
this.dispatchEvent({ type: "dispose" });
}
}, Oi = class extends Di {
constructor(e, t, n) {
super(new Int8Array(e), t, n);
}
}, ki = class extends Di {
constructor(e, t, n) {
super(new Uint8Array(e), t, n);
}
}, Ai = class extends Di {
constructor(e, t, n) {
super(new Uint8ClampedArray(e), t, n);
}
}, ji = class extends Di {
constructor(e, t, n) {
super(new Int16Array(e), t, n);
}
}, Mi = class extends Di {
constructor(e, t, n) {
super(new Uint16Array(e), t, n);
}
}, Ni = class extends Di {
constructor(e, t, n) {
super(new Int32Array(e), t, n);
}
}, Pi = class extends Di {
constructor(e, t, n) {
super(new Uint32Array(e), t, n);
}
}, Fi = class extends Di {
constructor(e, t, n) {
super(new Uint16Array(e), t, n), this.isFloat16BufferAttribute = !0;
}
getX(e) {
let t = Si(this.array[e * this.itemSize]);
return this.normalized && (t = Nn(t, this.array)), t;
}
setX(e, t) {
return this.normalized && (t = B(t, this.array)), this.array[e * this.itemSize] = xi(t), this;
}
getY(e) {
let t = Si(this.array[e * this.itemSize + 1]);
return this.normalized && (t = Nn(t, this.array)), t;
}
setY(e, t) {
return this.normalized && (t = B(t, this.array)), this.array[e * this.itemSize + 1] = xi(t), this;
}
getZ(e) {
let t = Si(this.array[e * this.itemSize + 2]);
return this.normalized && (t = Nn(t, this.array)), t;
}
setZ(e, t) {
return this.normalized && (t = B(t, this.array)), this.array[e * this.itemSize + 2] = xi(t), this;
}
getW(e) {
let t = Si(this.array[e * this.itemSize + 3]);
return this.normalized && (t = Nn(t, this.array)), t;
}
setW(e, t) {
return this.normalized && (t = B(t, this.array)), this.array[e * this.itemSize + 3] = xi(t), this;
}
setXY(e, t, n) {
return e *= this.itemSize, this.normalized && (t = B(t, this.array), n = B(n, this.array)), this.array[e + 0] = xi(t), this.array[e + 1] = xi(n), this;
}
setXYZ(e, t, n, r) {
return e *= this.itemSize, this.normalized && (t = B(t, this.array), n = B(n, this.array), r = B(r, this.array)), this.array[e + 0] = xi(t), this.array[e + 1] = xi(n), this.array[e + 2] = xi(r), this;
}
setXYZW(e, t, n, r, i) {
return e *= this.itemSize, this.normalized && (t = B(t, this.array), n = B(n, this.array), r = B(r, this.array), i = B(i, this.array)), this.array[e + 0] = xi(t), this.array[e + 1] = xi(n), this.array[e + 2] = xi(r), this.array[e + 3] = xi(i), this;
}
}, K = class extends Di {
constructor(e, t, n) {
super(new Float32Array(e), t, n);
}
}, Ii = /*@__PURE__*/ new ii(), Li = /*@__PURE__*/ new H(), Ri = /*@__PURE__*/ new H(), zi = class {
constructor(e = new H(), 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;
t === void 0 ? Ii.setFromPoints(e).getCenter(n) : n.copy(t);
let r = 0;
for (let t = 0, i = e.length; t < i; t++) r = Math.max(r, n.distanceToSquared(e[t]));
return this.radius = Math.sqrt(r), 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);
return t.copy(e), n > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t;
}
getBoundingBox(e) {
return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e);
}
applyMatrix4(e) {
return this.center.applyMatrix4(e), 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;
Li.subVectors(e, this.center);
let t = Li.lengthSq();
if (t > this.radius * this.radius) {
let e = Math.sqrt(t), n = (e - this.radius) * .5;
this.center.addScaledVector(Li, n / e), this.radius += n;
}
return this;
}
union(e) {
return e.isEmpty() ? this : this.isEmpty() ? (this.copy(e), this) : (this.center.equals(e.center) === !0 ? this.radius = Math.max(this.radius, e.radius) : (Ri.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(Li.copy(e.center).add(Ri)), this.expandByPoint(Li.copy(e.center).sub(Ri))), 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;
}
}, Bi = 0, Vi = /*@__PURE__*/ new W(), Hi = /*@__PURE__*/ new Mr(), Ui = /*@__PURE__*/ new H(), Wi = /*@__PURE__*/ new ii(), Gi = /*@__PURE__*/ new ii(), Ki = /*@__PURE__*/ new H(), q = class e extends ln {
constructor() {
super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: Bi++ }), this.uuid = mn(), this.name = "", this.type = "BufferGeometry", this.index = null, this.indirect = null, this.indirectOffset = 0, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = {
start: 0,
count: Infinity
}, this.userData = {}, this._transformed = !1;
}
getIndex() {
return this.index;
}
setIndex(e) {
return Array.isArray(e) ? this.index = new (qt(e) ? Pi : Mi)(e, 1) : this.index = e, this;
}
setIndirect(e, t = 0) {
return this.indirect = e, this.indirectOffset = t, 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;
t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0);
let n = this.attributes.normal;
if (n !== void 0) {
let t = new U().getNormalMatrix(e);
n.applyNormalMatrix(t), n.needsUpdate = !0;
}
let r = this.attributes.tangent;
return r !== void 0 && (r.transformDirection(e), r.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this._transformed = !0, this;
}
applyQuaternion(e) {
return Vi.makeRotationFromQuaternion(e), this.applyMatrix4(Vi), this;
}
rotateX(e) {
return Vi.makeRotationX(e), this.applyMatrix4(Vi), this;
}
rotateY(e) {
return Vi.makeRotationY(e), this.applyMatrix4(Vi), this;
}
rotateZ(e) {
return Vi.makeRotationZ(e), this.applyMatrix4(Vi), this;
}
translate(e, t, n) {
return Vi.makeTranslation(e, t, n), this.applyMatrix4(Vi), this;
}
scale(e, t, n) {
return Vi.makeScale(e, t, n), this.applyMatrix4(Vi), this;
}
lookAt(e) {
return Hi.lookAt(e), Hi.updateMatrix(), this.applyMatrix4(Hi.matrix), this;
}
center() {
return this.computeBoundingBox(), this.boundingBox.getCenter(Ui).negate(), this.translate(Ui.x, Ui.y, Ui.z), this;
}
setFromPoints(e) {
let t = this.getAttribute("position");
if (t === void 0) {
let t = [];
for (let n = 0, r = e.length; n < r; n++) {
let r = e[n];
t.push(r.x, r.y, r.z || 0);
}
this.setAttribute("position", new K(t, 3));
} else {
let n = Math.min(e.length, t.count);
for (let r = 0; r < n; r++) {
let n = e[r];
t.setXYZ(r, n.x, n.y, n.z || 0);
}
e.length > t.count && L("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."), t.needsUpdate = !0;
}
return this;
}
computeBoundingBox() {
this.boundingBox === null && (this.boundingBox = new ii());
let e = this.attributes.position, t = this.morphAttributes.position;
if (e && e.isGLBufferAttribute) {
R("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this), this.boundingBox.set(new H(-Infinity, -Infinity, -Infinity), new H(Infinity, Infinity, Infinity));
return;
}
if (e !== void 0) {
if (this.boundingBox.setFromBufferAttribute(e), t) for (let e = 0, n = t.length; e < n; e++) {
let n = t[e];
Wi.setFromBufferAttribute(n), this.morphTargetsRelative ? (Ki.addVectors(this.boundingBox.min, Wi.min), this.boundingBox.expandByPoint(Ki), Ki.addVectors(this.boundingBox.max, Wi.max), this.boundingBox.expandByPoint(Ki)) : (this.boundingBox.expandByPoint(Wi.min), this.boundingBox.expandByPoint(Wi.max));
}
} else this.boundingBox.makeEmpty();
(isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && R("BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.", this);
}
computeBoundingSphere() {
this.boundingSphere === null && (this.boundingSphere = new zi());
let e = this.attributes.position, t = this.morphAttributes.position;
if (e && e.isGLBufferAttribute) {
R("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this), this.boundingSphere.set(new H(), Infinity);
return;
}
if (e) {
let n = this.boundingSphere.center;
if (Wi.setFromBufferAttribute(e), t) for (let e = 0, n = t.length; e < n; e++) {
let n = t[e];
Gi.setFromBufferAttribute(n), this.morphTargetsRelative ? (Ki.addVectors(Wi.min, Gi.min), Wi.expandByPoint(Ki), Ki.addVectors(Wi.max, Gi.max), Wi.expandByPoint(Ki)) : (Wi.expandByPoint(Gi.min), Wi.expandByPoint(Gi.max));
}
Wi.getCenter(n);
let r = 0;
for (let t = 0, i = e.count; t < i; t++) Ki.fromBufferAttribute(e, t), r = Math.max(r, n.distanceToSquared(Ki));
if (t) for (let i = 0, a = t.length; i < a; i++) {
let a = t[i], o = this.morphTargetsRelative;
for (let t = 0, i = a.count; t < i; t++) Ki.fromBufferAttribute(a, t), o && (Ui.fromBufferAttribute(e, t), Ki.add(Ui)), r = Math.max(r, n.distanceToSquared(Ki));
}
this.boundingSphere.radius = Math.sqrt(r), isNaN(this.boundingSphere.radius) && R("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) {
R("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");
return;
}
let n = t.position, r = t.normal, i = t.uv, a = this.getAttribute("tangent");
(a === void 0 || a.count !== n.count) && (a = new Di(new Float32Array(4 * n.count), 4), this.setAttribute("tangent", a));
let o = [], s = [];
for (let e = 0; e < n.count; e++) o[e] = new H(), s[e] = new H();
let c = new H(), l = new H(), u = new H(), d = new V(), f = new V(), p = new V(), m = new H(), h = new H();
function g(e, t, r) {
c.fromBufferAttribute(n, e), l.fromBufferAttribute(n, t), u.fromBufferAttribute(n, r), d.fromBufferAttribute(i, e), f.fromBufferAttribute(i, t), p.fromBufferAttribute(i, r), l.sub(c), u.sub(c), f.sub(d), p.sub(d);
let a = 1 / (f.x * p.y - p.x * f.y);
isFinite(a) && (m.copy(l).multiplyScalar(p.y).addScaledVector(u, -f.y).multiplyScalar(a), h.copy(u).multiplyScalar(f.x).addScaledVector(l, -p.x).multiplyScalar(a), o[e].add(m), o[t].add(m), o[r].add(m), s[e].add(h), s[t].add(h), s[r].add(h));
}
let _ = this.groups;
_.length === 0 && (_ = [{
start: 0,
count: e.count
}]);
for (let t = 0, n = _.length; t < n; ++t) {
let n = _[t], r = n.start, i = n.count;
for (let t = r, n = r + i; t < n; t += 3) g(e.getX(t + 0), e.getX(t + 1), e.getX(t + 2));
}
let v = new H(), y = new H(), b = new H(), x = new H();
function S(e) {
b.fromBufferAttribute(r, e), x.copy(b);
let t = o[e];
v.copy(t), v.sub(b.multiplyScalar(b.dot(t))).normalize(), y.crossVectors(x, t);
let n = y.dot(s[e]) < 0 ? -1 : 1;
a.setXYZW(e, v.x, v.y, v.z, n);
}
for (let t = 0, n = _.length; t < n; ++t) {
let n = _[t], r = n.start, i = n.count;
for (let t = r, n = r + i; t < n; t += 3) S(e.getX(t + 0)), S(e.getX(t + 1)), S(e.getX(t + 2));
}
this._transformed = !0;
}
computeVertexNormals() {
let e = this.index, t = this.getAttribute("position");
if (t !== void 0) {
let n = this.getAttribute("normal");
if (n === void 0 || n.count !== t.count) n = new Di(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n);
else for (let e = 0, t = n.count; e < t; e++) n.setXYZ(e, 0, 0, 0);
let r = new H(), i = new H(), a = new H(), o = new H(), s = new H(), c = new H(), l = new H(), u = new H();
if (e) for (let d = 0, f = e.count; d < f; d += 3) {
let f = e.getX(d + 0), p = e.getX(d + 1), m = e.getX(d + 2);
r.fromBufferAttribute(t, f), i.fromBufferAttribute(t, p), a.fromBufferAttribute(t, m), l.subVectors(a, i), u.subVectors(r, i), l.cross(u), o.fromBufferAttribute(n, f), s.fromBufferAttribute(n, p), c.fromBufferAttribute(n, m), o.add(l), s.add(l), c.add(l), n.setXYZ(f, o.x, o.y, o.z), n.setXYZ(p, s.x, s.y, s.z), n.setXYZ(m, c.x, c.y, c.z);
}
else for (let e = 0, o = t.count; e < o; e += 3) r.fromBufferAttribute(t, e + 0), i.fromBufferAttribute(t, e + 1), a.fromBufferAttribute(t, e + 2), l.subVectors(a, i), u.subVectors(r, i), l.cross(u), n.setXYZ(e + 0, l.x, l.y, l.z), n.setXYZ(e + 1, l.x, l.y, l.z), n.setXYZ(e + 2, l.x, l.y, l.z);
this.normalizeNormals(), n.needsUpdate = !0;
}
}
normalizeNormals() {
let e = this.attributes.normal;
for (let t = 0, n = e.count; t < n; t++) Ki.fromBufferAttribute(e, t), Ki.normalize(), e.setXYZ(t, Ki.x, Ki.y, Ki.z);
}
toNonIndexed() {
function t(e, t) {
let n = e.array, r = e.itemSize, i = e.normalized, a = new n.constructor(t.length * r), o = 0, s = 0;
for (let i = 0, c = t.length; i < c; i++) {
o = e.isInterleavedBufferAttribute ? t[i] * e.data.stride + e.offset : t[i] * r;
for (let e = 0; e < r; e++) a[s++] = n[o++];
}
return new Di(a, r, i);
}
if (this.index === null) return L("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this;
let n = new e(), r = this.index.array, i = this.attributes;
for (let e in i) {
let a = i[e], o = t(a, r);
n.setAttribute(e, o);
}
let a = this.morphAttributes;
for (let e in a) {
let i = [], o = a[e];
for (let e = 0, n = o.length; e < n; e++) {
let n = o[e], a = t(n, r);
i.push(a);
}
n.morphAttributes[e] = i;
}
n.morphTargetsRelative = this.morphTargetsRelative;
let o = this.groups;
for (let e = 0, t = o.length; e < t; e++) {
let t = o[e];
n.addGroup(t.start, t.count, t.materialIndex);
}
return n;
}
toJSON() {
let e = { metadata: {
version: 4.7,
type: "BufferGeometry",
generator: "BufferGeometry.toJSON"
} };
if (e.uuid = this.uuid, e.type = this.parameters !== void 0 && this._transformed === !0 ? "BufferGeometry" : this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0 && this._transformed !== !0) {
let t = this.parameters;
for (let n in t) t[n] !== void 0 && (e[n] = t[n]);
return e;
}
e.data = { attributes: {} };
let t = this.index;
t !== null && (e.data.index = {
type: t.array.constructor.name,
array: Array.prototype.slice.call(t.array)
});
let n = this.attributes;
for (let t in n) {
let r = n[t];
e.data.attributes[t] = r.toJSON(e.data);
}
let r = {}, i = !1;
for (let t in this.morphAttributes) {
let n = this.morphAttributes[t], a = [];
for (let t = 0, r = n.length; t < r; t++) {
let r = n[t];
a.push(r.toJSON(e.data));
}
a.length > 0 && (r[t] = a, i = !0);
}
i && (e.data.morphAttributes = r, e.data.morphTargetsRelative = this.morphTargetsRelative);
let a = this.groups;
a.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(a)));
let o = this.boundingSphere;
return o !== null && (e.data.boundingSphere = o.toJSON()), 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;
n !== null && this.setIndex(n.clone());
let r = e.attributes;
for (let e in r) {
let n = r[e];
this.setAttribute(e, n.clone(t));
}
let i = e.morphAttributes;
for (let e in i) {
let n = [], r = i[e];
for (let e = 0, i = r.length; e < i; e++) n.push(r[e].clone(t));
this.morphAttributes[e] = n;
}
this.morphTargetsRelative = e.morphTargetsRelative;
let a = e.groups;
for (let e = 0, t = a.length; e < t; e++) {
let t = a[e];
this.addGroup(t.start, t.count, t.materialIndex);
}
let o = e.boundingBox;
o !== null && (this.boundingBox = o.clone());
let s = e.boundingSphere;
return s !== null && (this.boundingSphere = s.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, this._transformed = e._transformed, this;
}
dispose() {
this.dispatchEvent({ type: "dispose" });
}
}, qi = class {
constructor(e, t) {
this.isInterleavedBuffer = !0, this.array = e, this.stride = t, this.count = e === void 0 ? 0 : e.length / t, this.usage = jt, this.updateRanges = [], this.version = 0, this.uuid = mn();
}
onUploadCallback() {}
set needsUpdate(e) {
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 r = 0, i = this.stride; r < i; r++) this.array[e + r] = t.array[n + r];
return this;
}
set(e, t = 0) {
return this.array.set(e, t), this;
}
clone(e) {
e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = mn()), 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) {
return e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = mn()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer))), {
uuid: this.uuid,
buffer: this.array.buffer._uuid,
type: this.array.constructor.name,
stride: this.stride
};
}
}, Ji = /*@__PURE__*/ new H(), Yi = class e {
constructor(e, t, n, r = !1) {
this.isInterleavedBufferAttribute = !0, this.name = "", this.data = e, this.itemSize = t, this.offset = n, this.normalized = r;
}
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++) Ji.fromBufferAttribute(this, t), Ji.applyMatrix4(e), this.setXYZ(t, Ji.x, Ji.y, Ji.z);
return this;
}
applyNormalMatrix(e) {
for (let t = 0, n = this.count; t < n; t++) Ji.fromBufferAttribute(this, t), Ji.applyNormalMatrix(e), this.setXYZ(t, Ji.x, Ji.y, Ji.z);
return this;
}
transformDirection(e) {
for (let t = 0, n = this.count; t < n; t++) Ji.fromBufferAttribute(this, t), Ji.transformDirection(e), this.setXYZ(t, Ji.x, Ji.y, Ji.z);
return this;
}
getComponent(e, t) {
let n = this.array[e * this.data.stride + this.offset + t];
return this.normalized && (n = Nn(n, this.array)), n;
}
setComponent(e, t, n) {
return this.normalized && (n = B(n, this.array)), this.data.array[e * this.data.stride + this.offset + t] = n, this;
}
setX(e, t) {
return this.normalized && (t = B(t, this.array)), this.data.array[e * this.data.stride + this.offset] = t, this;
}
setY(e, t) {
return this.normalized && (t = B(t, this.array)), this.data.array[e * this.data.stride + this.offset + 1] = t, this;
}
setZ(e, t) {
return this.normalized && (t = B(t, this.array)), this.data.array[e * this.data.stride + this.offset + 2] = t, this;
}
setW(e, t) {
return this.normalized && (t = B(t, this.array)), 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];
return this.normalized && (t = Nn(t, this.array)), t;
}
getY(e) {
let t = this.data.array[e * this.data.stride + this.offset + 1];
return this.normalized && (t = Nn(t, this.array)), t;
}
getZ(e) {
let t = this.data.array[e * this.data.stride + this.offset + 2];
return this.normalized && (t = Nn(t, this.array)), t;
}
getW(e) {
let t = this.data.array[e * this.data.stride + this.offset + 3];
return this.normalized && (t = Nn(t, this.array)), t;
}
setXY(e, t, n) {
return e = e * this.data.stride + this.offset, this.normalized && (t = B(t, this.array), n = B(n, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this;
}
setXYZ(e, t, n, r) {
return e = e * this.data.stride + this.offset, this.normalized && (t = B(t, this.array), n = B(n, this.array), r = B(r, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = r, this;
}
setXYZW(e, t, n, r, i) {
return e = e * this.data.stride + this.offset, this.normalized && (t = B(t, this.array), n = B(n, this.array), r = B(r, this.array), i = B(i, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = r, this.data.array[e + 3] = i, this;
}
clone(t) {
if (t === void 0) {
rn("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");
let e = [];
for (let t = 0; t < this.count; t++) {
let n = t * this.data.stride + this.offset;
for (let t = 0; t < this.itemSize; t++) e.push(this.data.array[n + t]);
}
return new Di(new this.array.constructor(e), this.itemSize, this.normalized);
} else return t.interleavedBuffers === void 0 && (t.interleavedBuffers = {}), t.interleavedBuffers[this.data.uuid] === void 0 && (t.interleavedBuffers[this.data.uuid] = this.data.clone(t)), new e(t.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized);
}
toJSON(e) {
if (e === void 0) {
rn("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");
let e = [];
for (let t = 0; t < this.count; t++) {
let n = t * this.data.stride + this.offset;
for (let t = 0; t < this.itemSize; t++) e.push(this.data.array[n + t]);
}
return {
itemSize: this.itemSize,
type: this.array.constructor.name,
array: e,
normalized: this.normalized
};
} else return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)), {
isInterleavedBufferAttribute: !0,
itemSize: this.itemSize,
data: this.data.uuid,
offset: this.offset,
normalized: this.normalized
};
}
}, Xi = 0, Zi = class extends ln {
constructor() {
super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: Xi++ }), this.uuid = mn(), 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 G(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 = wt, this.stencilZFail = wt, this.stencilZPass = wt, 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) {
this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e;
}
onBeforeRender() {}
onBeforeCompile() {}
customProgramCacheKey() {
return this.onBeforeCompile.toString();
}
setValues(e) {
if (e !== void 0) for (let t in e) {
let n = e[t];
if (n === void 0) {
L(`Material: parameter '${t}' has value of undefined.`);
continue;
}
let r = this[t];
if (r === void 0) {
L(`Material: '${t}' is not a property of THREE.${this.type}.`);
continue;
}
r && r.isColor ? r.set(n) : r && r.isVector2 && n && n.isVector2 || r && r.isEuler && n && n.isEuler || r && r.isVector3 && n && n.isVector3 ? r.copy(n) : this[t] = n;
}
}
toJSON(e) {
let t = e === void 0 || typeof e == "string";
t && (e = {
textures: {},
images: {}
});
let n = { metadata: {
version: 4.7,
type: "Material",
generator: "Material.toJSON"
} };
n.uuid = this.uuid, n.type = this.type, this.name !== "" && (n.name = this.name), this.color && this.color.isColor && (n.color = this.color.getHex()), this.roughness !== void 0 && (n.roughness = this.roughness), this.metalness !== void 0 && (n.metalness = this.metalness), this.sheen !== void 0 && (n.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (n.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (n.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (n.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (n.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (n.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (n.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (n.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (n.shininess = this.shininess), this.clearcoat !== void 0 && (n.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (n.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (n.clearcoatMap = this.clearcoatMap.toJSON(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.sheenColorMap && this.sheenColorMap.isTexture && (n.sheenColorMap = this.sheenColorMap.toJSON(e).uuid), this.sheenRoughnessMap && this.sheenRoughnessMap.isTexture && (n.sheenRoughnessMap = this.sheenRoughnessMap.toJSON(e).uuid), this.dispersion !== void 0 && (n.dispersion = this.dispersion), this.iridescence !== void 0 && (n.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (n.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (n.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (n.iridescenceMap = this.iridescenceMap.toJSON(e).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (n.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid), this.anisotropy !== void 0 && (n.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (n.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (n.anisotropyMap = this.anisotropyMap.toJSON(e).uuid), this.map && this.map.isTexture && (n.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(e).uuid, n.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(e).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(e).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(e).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(e).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (n.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (n.combine = this.combine)), this.envMapRotation !== void 0 && (n.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (n.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (n.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (n.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (n.gradientMap = this.gradientMap.toJSON(e).uuid), this.transmission !== void 0 && (n.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (n.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (n.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (n.thicknessMap = this.thicknessMap.toJSON(e).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== Infinity && (n.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (n.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (n.size = this.size), this.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== 1 && (n.blending = this.blending), this.side !== 0 && (n.side = this.side), this.vertexColors === !0 && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.transparent === !0 && (n.transparent = !0), this.blendSrc !== 204 && (n.blendSrc = this.blendSrc), this.blendDst !== 205 && (n.blendDst = this.blendDst), this.blendEquation !== 100 && (n.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (n.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (n.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (n.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (n.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (n.blendAlpha = this.blendAlpha), this.depthFunc !== 3 && (n.depthFunc = this.depthFunc), this.depthTest === !1 && (n.depthTest = this.depthTest), this.depthWrite === !1 && (n.depthWrite = this.depthWrite), this.colorWrite === !1 && (n.colorWrite = this.colorWrite), this.stencilWriteMask !== 255 && (n.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== 519 && (n.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (n.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (n.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== 7680 && (n.stencilFail = this.stencilFail), this.stencilZFail !== 7680 && (n.stencilZFail = this.stencilZFail), this.stencilZPass !== 7680 && (n.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (n.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (n.linewidth = this.linewidth), this.dashSize !== void 0 && (n.dashSize = this.dashSize), this.gapSize !== void 0 && (n.gapSize = this.gapSize), this.scale !== void 0 && (n.scale = this.scale), this.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaHash === !0 && (n.alphaHash = !0), this.alphaToCoverage === !0 && (n.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = !0), this.forceSinglePass === !0 && (n.forceSinglePass = !0), this.allowOverride === !1 && (n.allowOverride = !1), this.wireframe === !0 && (n.wireframe = !0), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = !0), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), this.fog === !1 && (n.fog = !1), Object.keys(this.userData).length > 0 && (n.userData = this.userData);
function r(e) {
let t = [];
for (let n in e) {
let r = e[n];
delete r.metadata, t.push(r);
}
return t;
}
if (t) {
let t = r(e.textures), i = r(e.images);
t.length > 0 && (n.textures = t), i.length > 0 && (n.images = i);
}
return n;
}
fromJSON(e, t) {
if (e.uuid !== void 0 && (this.uuid = e.uuid), e.name !== void 0 && (this.name = e.name), e.color !== void 0 && this.color !== void 0 && this.color.setHex(e.color), e.roughness !== void 0 && (this.roughness = e.roughness), e.metalness !== void 0 && (this.metalness = e.metalness), e.sheen !== void 0 && (this.sheen = e.sheen), e.sheenColor !== void 0 && (this.sheenColor = new G().setHex(e.sheenColor)), e.sheenRoughness !== void 0 && (this.sheenRoughness = e.sheenRoughness), e.emissive !== void 0 && this.emissive !== void 0 && this.emissive.setHex(e.emissive), e.specular !== void 0 && this.specular !== void 0 && this.specular.setHex(e.specular), e.specularIntensity !== void 0 && (this.specularIntensity = e.specularIntensity), e.specularColor !== void 0 && this.specularColor !== void 0 && this.specularColor.setHex(e.specularColor), e.shininess !== void 0 && (this.shininess = e.shininess), e.clearcoat !== void 0 && (this.clearcoat = e.clearcoat), e.clearcoatRoughness !== void 0 && (this.clearcoatRoughness = e.clearcoatRoughness), e.dispersion !== void 0 && (this.dispersion = e.dispersion), e.iridescence !== void 0 && (this.iridescence = e.iridescence), e.iridescenceIOR !== void 0 && (this.iridescenceIOR = e.iridescenceIOR), e.iridescenceThicknessRange !== void 0 && (this.iridescenceThicknessRange = e.iridescenceThicknessRange), e.transmission !== void 0 && (this.transmission = e.transmission), e.thickness !== void 0 && (this.thickness = e.thickness), e.attenuationDistance !== void 0 && (this.attenuationDistance = e.attenuationDistance), e.attenuationColor !== void 0 && this.attenuationColor !== void 0 && this.attenuationColor.setHex(e.attenuationColor), e.anisotropy !== void 0 && (this.anisotropy = e.anisotropy), e.anisotropyRotation !== void 0 && (this.anisotropyRotation = e.anisotropyRotation), e.fog !== void 0 && (this.fog = e.fog), e.flatShading !== void 0 && (this.flatShading = e.flatShading), e.blending !== void 0 && (this.blending = e.blending), e.combine !== void 0 && (this.combine = e.combine), e.side !== void 0 && (this.side = e.side), e.shadowSide !== void 0 && (this.shadowSide = e.shadowSide), e.opacity !== void 0 && (this.opacity = e.opacity), e.transparent !== void 0 && (this.transparent = e.transparent), e.alphaTest !== void 0 && (this.alphaTest = e.alphaTest), e.alphaHash !== void 0 && (this.alphaHash = e.alphaHash), e.depthFunc !== void 0 && (this.depthFunc = e.depthFunc), e.depthTest !== void 0 && (this.depthTest = e.depthTest), e.depthWrite !== void 0 && (this.depthWrite = e.depthWrite), e.colorWrite !== void 0 && (this.colorWrite = e.colorWrite), e.blendSrc !== void 0 && (this.blendSrc = e.blendSrc), e.blendDst !== void 0 && (this.blendDst = e.blendDst), e.blendEquation !== void 0 && (this.blendEquation = e.blendEquation), e.blendSrcAlpha !== void 0 && (this.blendSrcAlpha = e.blendSrcAlpha), e.blendDstAlpha !== void 0 && (this.blendDstAlpha = e.blendDstAlpha), e.blendEquationAlpha !== void 0 && (this.blendEquationAlpha = e.blendEquationAlpha), e.blendColor !== void 0 && this.blendColor !== void 0 && this.blendColor.setHex(e.blendColor), e.blendAlpha !== void 0 && (this.blendAlpha = e.blendAlpha), e.stencilWriteMask !== void 0 && (this.stencilWriteMask = e.stencilWriteMask), e.stencilFunc !== void 0 && (this.stencilFunc = e.stencilFunc), e.stencilRef !== void 0 && (this.stencilRef = e.stencilRef), e.stencilFuncMask !== void 0 && (this.stencilFuncMask = e.stencilFuncMask), e.stencilFail !== void 0 && (this.stencilFail = e.stencilFail), e.stencilZFail !== void 0 && (this.stencilZFail = e.stencilZFail), e.stencilZPass !== void 0 && (this.stencilZPass = e.stencilZPass), e.stencilWrite !== void 0 && (this.stencilWrite = e.stencilWrite), e.wireframe !== void 0 && (this.wireframe = e.wireframe), e.wireframeLinewidth !== void 0 && (this.wireframeLinewidth = e.wireframeLinewidth), e.wireframeLinecap !== void 0 && (this.wireframeLinecap = e.wireframeLinecap), e.wireframeLinejoin !== void 0 && (this.wireframeLinejoin = e.wireframeLinejoin), e.rotation !== void 0 && (this.rotation = e.rotation), e.linewidth !== void 0 && (this.linewidth = e.linewidth), e.dashSize !== void 0 && (this.dashSize = e.dashSize), e.gapSize !== void 0 && (this.gapSize = e.gapSize), e.scale !== void 0 && (this.scale = e.scale), e.polygonOffset !== void 0 && (this.polygonOffset = e.polygonOffset), e.polygonOffsetFactor !== void 0 && (this.polygonOffsetFactor = e.polygonOffsetFactor), e.polygonOffsetUnits !== void 0 && (this.polygonOffsetUnits = e.polygonOffsetUnits), e.dithering !== void 0 && (this.dithering = e.dithering), e.alphaToCoverage !== void 0 && (this.alphaToCoverage = e.alphaToCoverage), e.premultipliedAlpha !== void 0 && (this.premultipliedAlpha = e.premultipliedAlpha), e.forceSinglePass !== void 0 && (this.forceSinglePass = e.forceSinglePass), e.allowOverride !== void 0 && (this.allowOverride = e.allowOverride), e.visible !== void 0 && (this.visible = e.visible), e.toneMapped !== void 0 && (this.toneMapped = e.toneMapped), e.userData !== void 0 && (this.userData = e.userData), e.vertexColors !== void 0 && (typeof e.vertexColors == "number" ? this.vertexColors = e.vertexColors > 0 : this.vertexColors = e.vertexColors), e.size !== void 0 && (this.size = e.size), e.sizeAttenuation !== void 0 && (this.sizeAttenuation = e.sizeAttenuation), e.map !== void 0 && (this.map = t[e.map] || null), e.matcap !== void 0 && (this.matcap = t[e.matcap] || null), e.alphaMap !== void 0 && (this.alphaMap = t[e.alphaMap] || null), e.bumpMap !== void 0 && (this.bumpMap = t[e.bumpMap] || null), e.bumpScale !== void 0 && (this.bumpScale = e.bumpScale), e.normalMap !== void 0 && (this.normalMap = t[e.normalMap] || null), e.normalMapType !== void 0 && (this.normalMapType = e.normalMapType), e.normalScale !== void 0) {
let t = e.normalScale;
Array.isArray(t) === !1 && (t = [t, t]), this.normalScale = new V().fromArray(t);
}
return e.displacementMap !== void 0 && (this.displacementMap = t[e.displacementMap] || null), e.displacementScale !== void 0 && (this.displacementScale = e.displacementScale), e.displacementBias !== void 0 && (this.displacementBias = e.displacementBias), e.roughnessMap !== void 0 && (this.roughnessMap = t[e.roughnessMap] || null), e.metalnessMap !== void 0 && (this.metalnessMap = t[e.metalnessMap] || null), e.emissiveMap !== void 0 && (this.emissiveMap = t[e.emissiveMap] || null), e.emissiveIntensity !== void 0 && (this.emissiveIntensity = e.emissiveIntensity), e.specularMap !== void 0 && (this.specularMap = t[e.specularMap] || null), e.specularIntensityMap !== void 0 && (this.specularIntensityMap = t[e.specularIntensityMap] || null), e.specularColorMap !== void 0 && (this.specularColorMap = t[e.specularColorMap] || null), e.envMap !== void 0 && (this.envMap = t[e.envMap] || null), e.envMapRotation !== void 0 && this.envMapRotation.fromArray(e.envMapRotation), e.envMapIntensity !== void 0 && (this.envMapIntensity = e.envMapIntensity), e.reflectivity !== void 0 && (this.reflectivity = e.reflectivity), e.refractionRatio !== void 0 && (this.refractionRatio = e.refractionRatio), e.lightMap !== void 0 && (this.lightMap = t[e.lightMap] || null), e.lightMapIntensity !== void 0 && (this.lightMapIntensity = e.lightMapIntensity), e.aoMap !== void 0 && (this.aoMap = t[e.aoMap] || null), e.aoMapIntensity !== void 0 && (this.aoMapIntensity = e.aoMapIntensity), e.gradientMap !== void 0 && (this.gradientMap = t[e.gradientMap] || null), e.clearcoatMap !== void 0 && (this.clearcoatMap = t[e.clearcoatMap] || null), e.clearcoatRoughnessMap !== void 0 && (this.clearcoatRoughnessMap = t[e.clearcoatRoughnessMap] || null), e.clearcoatNormalMap !== void 0 && (this.clearcoatNormalMap = t[e.clearcoatNormalMap] || null), e.clearcoatNormalScale !== void 0 && (this.clearcoatNormalScale = new V().fromArray(e.clearcoatNormalScale)), e.iridescenceMap !== void 0 && (this.iridescenceMap = t[e.iridescenceMap] || null), e.iridescenceThicknessMap !== void 0 && (this.iridescenceThicknessMap = t[e.iridescenceThicknessMap] || null), e.transmissionMap !== void 0 && (this.transmissionMap = t[e.transmissionMap] || null), e.thicknessMap !== void 0 && (this.thicknessMap = t[e.thicknessMap] || null), e.anisotropyMap !== void 0 && (this.anisotropyMap = t[e.anisotropyMap] || null), e.sheenColorMap !== void 0 && (this.sheenColorMap = t[e.sheenColorMap] || null), e.sheenRoughnessMap !== void 0 && (this.sheenRoughnessMap = t[e.sheenRoughnessMap] || null), this;
}
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 e = t.length;
n = Array(e);
for (let r = 0; r !== e; ++r) n[r] = t[r].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.allowOverride = e.allowOverride, 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) {
e === !0 && this.version++;
}
}, Qi = class extends Zi {
constructor(e) {
super(), this.isSpriteMaterial = !0, this.type = "SpriteMaterial", this.color = new G(16777215), this.map = null, this.alphaMap = null, this.rotation = 0, this.sizeAttenuation = !0, this.transparent = !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.rotation = e.rotation, this.sizeAttenuation = e.sizeAttenuation, this.fog = e.fog, this;
}
}, $i, ea = /*@__PURE__*/ new H(), ta = /*@__PURE__*/ new H(), na = /*@__PURE__*/ new H(), ra = /*@__PURE__*/ new V(), ia = /*@__PURE__*/ new V(), aa = /*@__PURE__*/ new W(), oa = /*@__PURE__*/ new H(), sa = /*@__PURE__*/ new H(), ca = /*@__PURE__*/ new H(), la = /*@__PURE__*/ new V(), ua = /*@__PURE__*/ new V(), da = /*@__PURE__*/ new V(), fa = class extends Mr {
constructor(e = new Qi()) {
if (super(), this.isSprite = !0, this.type = "Sprite", $i === void 0) {
$i = new q();
let e = new qi(new Float32Array([
-.5,
-.5,
0,
0,
0,
.5,
-.5,
0,
1,
0,
.5,
.5,
0,
1,
1,
-.5,
.5,
0,
0,
1
]), 5);
$i.setIndex([
0,
1,
2,
0,
2,
3
]), $i.setAttribute("position", new Yi(e, 3, 0, !1)), $i.setAttribute("uv", new Yi(e, 2, 3, !1));
}
this.geometry = $i, this.material = e, this.center = new V(.5, .5), this.count = 1;
}
raycast(e, t) {
e.camera === null && R("Sprite: \"Raycaster.camera\" needs to be set in order to raycast against sprites."), ta.setFromMatrixScale(this.matrixWorld), aa.copy(e.camera.matrixWorld), this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse, this.matrixWorld), na.setFromMatrixPosition(this.modelViewMatrix), e.camera.isPerspectiveCamera && this.material.sizeAttenuation === !1 && ta.multiplyScalar(-na.z);
let n = this.material.rotation, r, i;
n !== 0 && (i = Math.cos(n), r = Math.sin(n));
let a = this.center;
pa(oa.set(-.5, -.5, 0), na, a, ta, r, i), pa(sa.set(.5, -.5, 0), na, a, ta, r, i), pa(ca.set(.5, .5, 0), na, a, ta, r, i), la.set(0, 0), ua.set(1, 0), da.set(1, 1);
let o = e.ray.intersectTriangle(oa, sa, ca, !1, ea);
if (o === null && (pa(sa.set(-.5, .5, 0), na, a, ta, r, i), ua.set(0, 1), o = e.ray.intersectTriangle(oa, ca, sa, !1, ea), o === null)) return;
let s = e.ray.origin.distanceTo(ea);
s < e.near || s > e.far || t.push({
distance: s,
point: ea.clone(),
uv: ri.getInterpolation(ea, oa, sa, ca, la, ua, da, new V()),
face: null,
object: this
});
}
copy(e, t) {
return super.copy(e, t), e.center !== void 0 && this.center.copy(e.center), this.material = e.material, this;
}
};
function pa(e, t, n, r, i, a) {
ra.subVectors(e, n).addScalar(.5).multiply(r), i === void 0 ? ia.copy(ra) : (ia.x = a * ra.x - i * ra.y, ia.y = i * ra.x + a * ra.y), e.copy(t), e.x += ia.x, e.y += ia.y, e.applyMatrix4(aa);
}
var ma = /*@__PURE__*/ new H(), ha = /*@__PURE__*/ new H(), ga = class extends Mr {
constructor() {
super(), this.isLOD = !0, this._currentLevel = 0, this.type = "LOD", Object.defineProperties(this, { levels: {
enumerable: !0,
value: []
} }), this.autoUpdate = !0;
}
copy(e) {
super.copy(e, !1);
let t = e.levels;
for (let e = 0, n = t.length; e < n; e++) {
let n = t[e];
this.addLevel(n.object.clone(), n.distance, n.hysteresis);
}
return this.autoUpdate = e.autoUpdate, this;
}
addLevel(e, t = 0, n = 0) {
t = Math.abs(t);
let r = this.levels, i;
for (i = 0; i < r.length && !(t < r[i].distance); i++);
return r.splice(i, 0, {
distance: t,
hysteresis: n,
object: e
}), this.add(e), this;
}
removeLevel(e) {
let t = this.levels;
for (let n = 0; n < t.length; n++) if (t[n].distance === e) {
let e = t.splice(n, 1);
return this.remove(e[0].object), !0;
}
return !1;
}
getCurrentLevel() {
return this._currentLevel;
}
getObjectForDistance(e) {
let t = this.levels;
if (t.length > 0) {
let n, r;
for (n = 1, r = t.length; n < r; n++) {
let r = t[n].distance;
if (t[n].object.visible && (r -= r * t[n].hysteresis), e < r) break;
}
return t[n - 1].object;
}
return null;
}
raycast(e, t) {
if (this.levels.length > 0) {
ma.setFromMatrixPosition(this.matrixWorld);
let n = e.ray.origin.distanceTo(ma);
this.getObjectForDistance(n).raycast(e, t);
}
}
update(e) {
let t = this.levels;
if (t.length > 1) {
ma.setFromMatrixPosition(e.matrixWorld), ha.setFromMatrixPosition(this.matrixWorld);
let n = ma.distanceTo(ha) / e.zoom;
t[0].object.visible = !0;
let r, i;
for (r = 1, i = t.length; r < i; r++) {
let e = t[r].distance;
if (t[r].object.visible && (e -= e * t[r].hysteresis), n >= e) t[r - 1].object.visible = !1, t[r].object.visible = !0;
else break;
}
for (this._currentLevel = r - 1; r < i; r++) t[r].object.visible = !1;
}
}
toJSON(e) {
let t = super.toJSON(e);
this.autoUpdate === !1 && (t.object.autoUpdate = !1), t.object.levels = [];
let n = this.levels;
for (let e = 0, r = n.length; e < r; e++) {
let r = n[e];
t.object.levels.push({
object: r.object.uuid,
distance: r.distance,
hysteresis: r.hysteresis
});
}
return t;
}
}, _a = /*@__PURE__*/ new H(), va = /*@__PURE__*/ new H(), ya = /*@__PURE__*/ new H(), ba = /*@__PURE__*/ new H(), xa = /*@__PURE__*/ new H(), Sa = /*@__PURE__*/ new H(), Ca = /*@__PURE__*/ new H(), wa = class {
constructor(e = new H(), t = new H(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, _a)), this;
}
closestPointToPoint(e, t) {
t.subVectors(e, this.origin);
let n = t.dot(this.direction);
return n < 0 ? t.copy(this.origin) : t.copy(this.origin).addScaledVector(this.direction, n);
}
distanceToPoint(e) {
return Math.sqrt(this.distanceSqToPoint(e));
}
distanceSqToPoint(e) {
let t = _a.subVectors(e, this.origin).dot(this.direction);
return t < 0 ? this.origin.distanceToSquared(e) : (_a.copy(this.origin).addScaledVector(this.direction, t), _a.distanceToSquared(e));
}
distanceSqToSegment(e, t, n, r) {
va.copy(e).add(t).multiplyScalar(.5), ya.copy(t).sub(e).normalize(), ba.copy(this.origin).sub(va);
let i = e.distanceTo(t) * .5, a = -this.direction.dot(ya), o = ba.dot(this.direction), s = -ba.dot(ya), c = ba.lengthSq(), l = Math.abs(1 - a * a), u, d, f, p;
if (l > 0) if (u = a * s - o, d = a * o - s, p = i * l, u >= 0) if (d >= -p) if (d <= p) {
let e = 1 / l;
u *= e, d *= e, f = u * (u + a * d + 2 * o) + d * (a * u + d + 2 * s) + c;
} else d = i, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * s) + c;
else d = -i, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * s) + c;
else d <= -p ? (u = Math.max(0, -(-a * i + o)), d = u > 0 ? -i : Math.min(Math.max(-i, -s), i), f = -u * u + d * (d + 2 * s) + c) : d <= p ? (u = 0, d = Math.min(Math.max(-i, -s), i), f = d * (d + 2 * s) + c) : (u = Math.max(0, -(a * i + o)), d = u > 0 ? i : Math.min(Math.max(-i, -s), i), f = -u * u + d * (d + 2 * s) + c);
else d = a > 0 ? -i : i, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * s) + c;
return n && n.copy(this.origin).addScaledVector(this.direction, u), r && r.copy(va).addScaledVector(ya, d), f;
}
intersectSphere(e, t) {
_a.subVectors(e.center, this.origin);
let n = _a.dot(this.direction), r = _a.dot(_a) - n * n, i = e.radius * e.radius;
if (r > i) return null;
let a = Math.sqrt(i - r), o = n - a, s = n + a;
return s < 0 ? null : o < 0 ? this.at(s, t) : this.at(o, t);
}
intersectsSphere(e) {
return e.radius < 0 ? !1 : this.distanceSqToPoint(e.center) <= e.radius * e.radius;
}
distanceToPlane(e) {
let t = e.normal.dot(this.direction);
if (t === 0) return e.distanceToPoint(this.origin) === 0 ? 0 : null;
let n = -(this.origin.dot(e.normal) + e.constant) / t;
return n >= 0 ? n : null;
}
intersectPlane(e, t) {
let n = this.distanceToPlane(e);
return n === null ? null : this.at(n, t);
}
intersectsPlane(e) {
let t = e.distanceToPoint(this.origin);
return t === 0 || e.normal.dot(this.direction) * t < 0;
}
intersectBox(e, t) {
let n, r, i, a, o, s, c = 1 / this.direction.x, l = 1 / this.direction.y, u = 1 / this.direction.z, d = this.origin;
return c >= 0 ? (n = (e.min.x - d.x) * c, r = (e.max.x - d.x) * c) : (n = (e.max.x - d.x) * c, r = (e.min.x - d.x) * c), l >= 0 ? (i = (e.min.y - d.y) * l, a = (e.max.y - d.y) * l) : (i = (e.max.y - d.y) * l, a = (e.min.y - d.y) * l), n > a || i > r || ((i > n || isNaN(n)) && (n = i), (a < r || isNaN(r)) && (r = a), u >= 0 ? (o = (e.min.z - d.z) * u, s = (e.max.z - d.z) * u) : (o = (e.max.z - d.z) * u, s = (e.min.z - d.z) * u), n > s || o > r) || ((o > n || n !== n) && (n = o), (s < r || r !== r) && (r = s), r < 0) ? null : this.at(n >= 0 ? n : r, t);
}
intersectsBox(e) {
return this.intersectBox(e, _a) !== null;
}
intersectTriangle(e, t, n, r, i) {
xa.subVectors(t, e), Sa.subVectors(n, e), Ca.crossVectors(xa, Sa);
let a = this.direction.dot(Ca), o;
if (a > 0) {
if (r) return null;
o = 1;
} else if (a < 0) o = -1, a = -a;
else return null;
ba.subVectors(this.origin, e);
let s = o * this.direction.dot(Sa.crossVectors(ba, Sa));
if (s < 0) return null;
let c = o * this.direction.dot(xa.cross(ba));
if (c < 0 || s + c > a) return null;
let l = -o * ba.dot(Ca);
return l < 0 ? null : this.at(l / a, i);
}
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);
}
}, Ta = class extends Zi {
constructor(e) {
super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new G(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 hr(), this.combine = 0, this.reflectivity = 1, this.refractionRatio = .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;
}
}, Ea = /*@__PURE__*/ new W(), Da = /*@__PURE__*/ new wa(), Oa = /*@__PURE__*/ new zi(), ka = /*@__PURE__*/ new H(), Aa = /*@__PURE__*/ new H(), ja = /*@__PURE__*/ new H(), Ma = /*@__PURE__*/ new H(), Na = /*@__PURE__*/ new H(), Pa = /*@__PURE__*/ new H(), Fa = /*@__PURE__*/ new H(), Ia = /*@__PURE__*/ new H(), La = class extends Mr {
constructor(e = new q(), t = new Ta()) {
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) {
return super.copy(e, t), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this;
}
updateMorphTargets() {
let e = this.geometry.morphAttributes, t = Object.keys(e);
if (t.length > 0) {
let n = e[t[0]];
if (n !== void 0) {
this.morphTargetInfluences = [], this.morphTargetDictionary = {};
for (let e = 0, t = n.length; e < t; e++) {
let t = n[e].name || String(e);
this.morphTargetInfluences.push(0), this.morphTargetDictionary[t] = e;
}
}
}
}
getVertexPosition(e, t) {
let n = this.geometry, r = n.attributes.position, i = n.morphAttributes.position, a = n.morphTargetsRelative;
t.fromBufferAttribute(r, e);
let o = this.morphTargetInfluences;
if (i && o) {
Pa.set(0, 0, 0);
for (let n = 0, r = i.length; n < r; n++) {
let r = o[n], s = i[n];
r !== 0 && (Na.fromBufferAttribute(s, e), a ? Pa.addScaledVector(Na, r) : Pa.addScaledVector(Na.sub(t), r));
}
t.add(Pa);
}
return t;
}
raycast(e, t) {
let n = this.geometry, r = this.material, i = this.matrixWorld;
r !== void 0 && (n.boundingSphere === null && n.computeBoundingSphere(), Oa.copy(n.boundingSphere), Oa.applyMatrix4(i), Da.copy(e.ray).recast(e.near), !(Oa.containsPoint(Da.origin) === !1 && (Da.intersectSphere(Oa, ka) === null || Da.origin.distanceToSquared(ka) > (e.far - e.near) ** 2)) && (Ea.copy(i).invert(), Da.copy(e.ray).applyMatrix4(Ea), !(n.boundingBox !== null && Da.intersectsBox(n.boundingBox) === !1) && this._computeIntersections(e, t, Da)));
}
_computeIntersections(e, t, n) {
let r, i = this.geometry, a = this.material, o = i.index, s = i.attributes.position, c = i.attributes.uv, l = i.attributes.uv1, u = i.attributes.normal, d = i.groups, f = i.drawRange;
if (o !== null) if (Array.isArray(a)) for (let i = 0, s = d.length; i < s; i++) {
let s = d[i], p = a[s.materialIndex], m = Math.max(s.start, f.start), h = Math.min(o.count, Math.min(s.start + s.count, f.start + f.count));
for (let i = m, a = h; i < a; i += 3) {
let a = o.getX(i), d = o.getX(i + 1), f = o.getX(i + 2);
r = za(this, p, e, n, c, l, u, a, d, f), r && (r.faceIndex = Math.floor(i / 3), r.face.materialIndex = s.materialIndex, t.push(r));
}
}
else {
let i = Math.max(0, f.start), s = Math.min(o.count, f.start + f.count);
for (let d = i, f = s; d < f; d += 3) {
let i = o.getX(d), s = o.getX(d + 1), f = o.getX(d + 2);
r = za(this, a, e, n, c, l, u, i, s, f), r && (r.faceIndex = Math.floor(d / 3), t.push(r));
}
}
else if (s !== void 0) if (Array.isArray(a)) for (let i = 0, o = d.length; i < o; i++) {
let o = d[i], p = a[o.materialIndex], m = Math.max(o.start, f.start), h = Math.min(s.count, Math.min(o.start + o.count, f.start + f.count));
for (let i = m, a = h; i < a; i += 3) {
let a = i, s = i + 1, d = i + 2;
r = za(this, p, e, n, c, l, u, a, s, d), r && (r.faceIndex = Math.floor(i / 3), r.face.materialIndex = o.materialIndex, t.push(r));
}
}
else {
let i = Math.max(0, f.start), o = Math.min(s.count, f.start + f.count);
for (let s = i, d = o; s < d; s += 3) {
let i = s, o = s + 1, d = s + 2;
r = za(this, a, e, n, c, l, u, i, o, d), r && (r.faceIndex = Math.floor(s / 3), t.push(r));
}
}
}
};
function Ra(e, t, n, r, i, a, o, s) {
let c;
if (c = t.side === 1 ? r.intersectTriangle(o, a, i, !0, s) : r.intersectTriangle(i, a, o, t.side === 0, s), c === null) return null;
Ia.copy(s), Ia.applyMatrix4(e.matrixWorld);
let l = n.ray.origin.distanceTo(Ia);
return l < n.near || l > n.far ? null : {
distance: l,
point: Ia.clone(),
object: e
};
}
function za(e, t, n, r, i, a, o, s, c, l) {
e.getVertexPosition(s, Aa), e.getVertexPosition(c, ja), e.getVertexPosition(l, Ma);
let u = Ra(e, t, n, r, Aa, ja, Ma, Fa);
if (u) {
let e = new H();
ri.getBarycoord(Fa, Aa, ja, Ma, e), i && (u.uv = ri.getInterpolatedAttribute(i, s, c, l, e, new V())), a && (u.uv1 = ri.getInterpolatedAttribute(a, s, c, l, e, new V())), o && (u.normal = ri.getInterpolatedAttribute(o, s, c, l, e, new H()), u.normal.dot(r.direction) > 0 && u.normal.multiplyScalar(-1));
let t = {
a: s,
b: c,
c: l,
normal: new H(),
materialIndex: 0
};
ri.getNormal(Aa, ja, Ma, t.normal), u.face = t, u.barycoord = e;
}
return u;
}
var Ba = /*@__PURE__*/ new $n(), Va = /*@__PURE__*/ new $n(), Ha = /*@__PURE__*/ new $n(), Ua = /*@__PURE__*/ new $n(), Wa = /*@__PURE__*/ new W(), J = /*@__PURE__*/ new H(), Ga = /*@__PURE__*/ new zi(), Ka = /*@__PURE__*/ new W(), qa = /*@__PURE__*/ new wa(), Ja = class extends La {
constructor(e, t) {
super(e, t), this.isSkinnedMesh = !0, this.type = "SkinnedMesh", this.bindMode = b, this.bindMatrix = new W(), this.bindMatrixInverse = new W(), this.boundingBox = null, this.boundingSphere = null;
}
computeBoundingBox() {
let e = this.geometry;
this.boundingBox === null && (this.boundingBox = new ii()), this.boundingBox.makeEmpty();
let t = e.getAttribute("position");
for (let e = 0; e < t.count; e++) this.getVertexPosition(e, J), this.boundingBox.expandByPoint(J);
}
computeBoundingSphere() {
let e = this.geometry;
this.boundingSphere === null && (this.boundingSphere = new zi()), this.boundingSphere.makeEmpty();
let t = e.getAttribute("position");
for (let e = 0; e < t.count; e++) this.getVertexPosition(e, J), this.boundingSphere.expandByPoint(J);
}
copy(e, t) {
return 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()), e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()), this;
}
raycast(e, t) {
let n = this.material, r = this.matrixWorld;
n !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), Ga.copy(this.boundingSphere), Ga.applyMatrix4(r), e.ray.intersectsSphere(Ga) !== !1 && (Ka.copy(r).invert(), qa.copy(e.ray).applyMatrix4(Ka), !(this.boundingBox !== null && qa.intersectsBox(this.boundingBox) === !1) && this._computeIntersections(e, t, qa)));
}
getVertexPosition(e, t) {
return super.getVertexPosition(e, t), this.applyBoneTransform(e, t), t;
}
bind(e, t) {
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 $n(), t = this.geometry.attributes.skinWeight;
for (let n = 0, r = t.count; n < r; n++) {
e.fromBufferAttribute(t, n);
let r = 1 / e.manhattanLength();
r === Infinity ? e.set(1, 0, 0, 0) : e.multiplyScalar(r), t.setXYZW(n, e.x, e.y, e.z, e.w);
}
}
updateMatrixWorld(e) {
super.updateMatrixWorld(e), this.bindMode === "attached" ? this.bindMatrixInverse.copy(this.matrixWorld).invert() : this.bindMode === "detached" ? this.bindMatrixInverse.copy(this.bindMatrix).invert() : L("SkinnedMesh: Unrecognized bindMode: " + this.bindMode);
}
applyBoneTransform(e, t) {
let n = this.skeleton, r = this.geometry;
Va.fromBufferAttribute(r.attributes.skinIndex, e), Ha.fromBufferAttribute(r.attributes.skinWeight, e), t.isVector4 ? (Ba.copy(t), t.set(0, 0, 0, 0)) : (Ba.set(...t, 1), t.set(0, 0, 0)), Ba.applyMatrix4(this.bindMatrix);
for (let e = 0; e < 4; e++) {
let r = Ha.getComponent(e);
if (r !== 0) {
let i = Va.getComponent(e);
Wa.multiplyMatrices(n.bones[i].matrixWorld, n.boneInverses[i]), t.addScaledVector(Ua.copy(Ba).applyMatrix4(Wa), r);
}
}
return t.isVector4 && (t.w = Ba.w), t.applyMatrix4(this.bindMatrixInverse);
}
}, Ya = class extends Mr {
constructor() {
super(), this.isBone = !0, this.type = "Bone";
}
}, Xa = class extends Qn {
constructor(e = null, t = 1, n = 1, r, i, a, o, s, c = T, l = T, u, d) {
super(null, a, o, s, c, l, r, i, u, d), this.isDataTexture = !0, this.image = {
data: e,
width: t,
height: n
}, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
}
}, Za = /*@__PURE__*/ new W(), Qa = /*@__PURE__*/ new W(), $a = class e {
constructor(e = [], t = []) {
this.uuid = mn(), 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) {
L("Skeleton: Number of inverse bone matrices does not match amount of bones."), this.boneInverses = [];
for (let e = 0, t = this.bones.length; e < t; e++) this.boneInverses.push(new W());
}
}
calculateInverses() {
this.boneInverses.length = 0;
for (let e = 0, t = this.bones.length; e < t; e++) {
let t = new W();
this.bones[e] && t.copy(this.bones[e].matrixWorld).invert(), this.boneInverses.push(t);
}
}
pose() {
for (let e = 0, t = this.bones.length; e < t; e++) {
let t = this.bones[e];
t && t.matrixWorld.copy(this.boneInverses[e]).invert();
}
for (let e = 0, t = this.bones.length; e < t; e++) {
let t = this.bones[e];
t && (t.parent && t.parent.isBone ? (t.matrix.copy(t.parent.matrixWorld).invert(), t.matrix.multiply(t.matrixWorld)) : t.matrix.copy(t.matrixWorld), t.matrix.decompose(t.position, t.quaternion, t.scale));
}
}
update() {
let e = this.bones, t = this.boneInverses, n = this.boneMatrices, r = this.boneTexture;
for (let r = 0, i = e.length; r < i; r++) {
let i = e[r] ? e[r].matrixWorld : Qa;
Za.multiplyMatrices(i, t[r]), Za.toArray(n, r * 16);
}
r !== null && (r.needsUpdate = !0);
}
clone() {
return new e(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 Xa(t, e, e, ge, N);
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 n = this.bones[t];
if (n.name === e) return n;
}
}
dispose() {
this.boneTexture !== null && (this.boneTexture.dispose(), this.boneTexture = null);
}
fromJSON(e, t) {
this.uuid = e.uuid;
for (let n = 0, r = e.bones.length; n < r; n++) {
let r = e.bones[n], i = t[r];
i === void 0 && (L("Skeleton: No bone found with UUID:", r), i = new Ya()), this.bones.push(i), this.boneInverses.push(new W().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 r = 0, i = t.length; r < i; r++) {
let i = t[r];
e.bones.push(i.uuid);
let a = n[r];
e.boneInverses.push(a.toArray());
}
return e;
}
}, eo = class extends Di {
constructor(e, t, n, r = 1) {
super(e, t, n), this.isInstancedBufferAttribute = !0, this.meshPerAttribute = r;
}
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;
}
}, to = /*@__PURE__*/ new W(), no = /*@__PURE__*/ new W(), ro = [], io = /*@__PURE__*/ new ii(), ao = /*@__PURE__*/ new W(), oo = /*@__PURE__*/ new La(), so = /*@__PURE__*/ new zi(), co = class extends La {
constructor(e, t, n) {
super(e, t), this.isInstancedMesh = !0, this.instanceMatrix = new eo(new Float32Array(n * 16), 16), this.instanceColor = null, this.morphTexture = null, this.count = n, this.boundingBox = null, this.boundingSphere = null;
for (let e = 0; e < n; e++) this.setMatrixAt(e, ao);
}
computeBoundingBox() {
let e = this.geometry, t = this.count;
this.boundingBox === null && (this.boundingBox = new ii()), e.boundingBox === null && e.computeBoundingBox(), this.boundingBox.makeEmpty();
for (let n = 0; n < t; n++) this.getMatrixAt(n, to), io.copy(e.boundingBox).applyMatrix4(to), this.boundingBox.union(io);
}
computeBoundingSphere() {
let e = this.geometry, t = this.count;
this.boundingSphere === null && (this.boundingSphere = new zi()), e.boundingSphere === null && e.computeBoundingSphere(), this.boundingSphere.makeEmpty();
for (let n = 0; n < t; n++) this.getMatrixAt(n, to), so.copy(e.boundingSphere).applyMatrix4(to), this.boundingSphere.union(so);
}
copy(e, t) {
return super.copy(e, t), this.instanceMatrix.copy(e.instanceMatrix), e.morphTexture !== null && (this.morphTexture = e.morphTexture.clone()), e.instanceColor !== null && (this.instanceColor = e.instanceColor.clone()), this.count = e.count, e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()), e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()), this;
}
getColorAt(e, t) {
return this.instanceColor === null ? t.setRGB(1, 1, 1) : t.fromArray(this.instanceColor.array, e * 3);
}
getMatrixAt(e, t) {
return t.fromArray(this.instanceMatrix.array, e * 16);
}
getMorphAt(e, t) {
let n = t.morphTargetInfluences, r = this.morphTexture.source.data.data, i = e * (n.length + 1) + 1;
for (let e = 0; e < n.length; e++) n[e] = r[i + e];
}
raycast(e, t) {
let n = this.matrixWorld, r = this.count;
if (oo.geometry = this.geometry, oo.material = this.material, oo.material !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), so.copy(this.boundingSphere), so.applyMatrix4(n), e.ray.intersectsSphere(so) !== !1)) for (let i = 0; i < r; i++) {
this.getMatrixAt(i, to), no.multiplyMatrices(n, to), oo.matrixWorld = no, oo.raycast(e, ro);
for (let e = 0, n = ro.length; e < n; e++) {
let n = ro[e];
n.instanceId = i, n.object = this, t.push(n);
}
ro.length = 0;
}
}
setColorAt(e, t) {
return this.instanceColor === null && (this.instanceColor = new eo(new Float32Array(this.instanceMatrix.count * 3).fill(1), 3)), t.toArray(this.instanceColor.array, e * 3), this;
}
setMatrixAt(e, t) {
return t.toArray(this.instanceMatrix.array, e * 16), this;
}
setMorphAt(e, t) {
let n = t.morphTargetInfluences, r = n.length + 1;
this.morphTexture === null && (this.morphTexture = new Xa(new Float32Array(r * this.count), r, this.count, ye, N));
let i = this.morphTexture.source.data.data, a = 0;
for (let e = 0; e < n.length; e++) a += n[e];
let o = this.geometry.morphTargetsRelative ? 1 : 1 - a, s = r * e;
return i[s] = o, i.set(n, s + 1), this;
}
updateMorphTargets() {}
dispose() {
this.dispatchEvent({ type: "dispose" }), this.morphTexture !== null && (this.morphTexture.dispose(), this.morphTexture = null);
}
}, lo = /*@__PURE__*/ new H(), uo = /*@__PURE__*/ new H(), fo = /*@__PURE__*/ new U(), po = class {
constructor(e = new H(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, r) {
return this.normal.set(e, t, n), this.constant = r, this;
}
setFromNormalAndCoplanarPoint(e, t) {
return this.normal.copy(e), this.constant = -t.dot(this.normal), this;
}
setFromCoplanarPoints(e, t, n) {
let r = lo.subVectors(n, t).cross(uo.subVectors(e, t)).normalize();
return this.setFromNormalAndCoplanarPoint(r, 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, n = !0) {
let r = e.delta(lo), i = this.normal.dot(r);
if (i === 0) return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null;
let a = -(e.start.dot(this.normal) + this.constant) / i;
return n === !0 && (a < 0 || a > 1) ? null : t.copy(e.start).addScaledVector(r, a);
}
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 || fo.getNormalMatrix(e), r = this.coplanarPoint(lo).applyMatrix4(e), i = this.normal.applyMatrix3(n).normalize();
return this.constant = -r.dot(i), 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);
}
}, mo = /*@__PURE__*/ new zi(), ho = /*@__PURE__*/ new V(.5, .5), go = /*@__PURE__*/ new H(), _o = class {
constructor(e = new po(), t = new po(), n = new po(), r = new po(), i = new po(), a = new po()) {
this.planes = [
e,
t,
n,
r,
i,
a
];
}
set(e, t, n, r, i, a) {
let o = this.planes;
return o[0].copy(e), o[1].copy(t), o[2].copy(n), o[3].copy(r), o[4].copy(i), o[5].copy(a), 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 = Vt, n = !1) {
let r = this.planes, i = e.elements, a = i[0], o = i[1], s = i[2], c = i[3], l = i[4], u = i[5], d = i[6], f = i[7], p = i[8], m = i[9], h = i[10], g = i[11], _ = i[12], v = i[13], y = i[14], b = i[15];
if (r[0].setComponents(c - a, f - l, g - p, b - _).normalize(), r[1].setComponents(c + a, f + l, g + p, b + _).normalize(), r[2].setComponents(c + o, f + u, g + m, b + v).normalize(), r[3].setComponents(c - o, f - u, g - m, b - v).normalize(), n) r[4].setComponents(s, d, h, y).normalize(), r[5].setComponents(c - s, f - d, g - h, b - y).normalize();
else if (r[4].setComponents(c - s, f - d, g - h, b - y).normalize(), t === 2e3) r[5].setComponents(c + s, f + d, g + h, b + y).normalize();
else if (t === 2001) r[5].setComponents(s, d, h, y).normalize();
else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + t);
return this;
}
intersectsObject(e) {
if (e.boundingSphere !== void 0) e.boundingSphere === null && e.computeBoundingSphere(), mo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);
else {
let t = e.geometry;
t.boundingSphere === null && t.computeBoundingSphere(), mo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld);
}
return this.intersectsSphere(mo);
}
intersectsSprite(e) {
return mo.center.set(0, 0, 0), mo.radius = .7071067811865476 + ho.distanceTo(e.center), mo.applyMatrix4(e.matrixWorld), this.intersectsSphere(mo);
}
intersectsSphere(e) {
let t = this.planes, n = e.center, r = -e.radius;
for (let e = 0; e < 6; e++) if (t[e].distanceToPoint(n) < r) return !1;
return !0;
}
intersectsBox(e) {
let t = this.planes;
for (let n = 0; n < 6; n++) {
let r = t[n];
if (go.x = r.normal.x > 0 ? e.max.x : e.min.x, go.y = r.normal.y > 0 ? e.max.y : e.min.y, go.z = r.normal.z > 0 ? e.max.z : e.min.z, r.distanceToPoint(go) < 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);
}
}, vo = /*@__PURE__*/ new W(), yo = class e {
constructor() {
this.coordinateSystem = Vt, this._frustums = [], this._count = 0;
}
setFromArrayCamera(e) {
let t = e.cameras, n = this._frustums;
for (let e = 0; e < t.length; e++) {
let r = t[e];
vo.multiplyMatrices(r.projectionMatrix, r.matrixWorldInverse), n[e] === void 0 && (n[e] = new _o()), n[e].setFromProjectionMatrix(vo, r.coordinateSystem, r.reversedDepth);
}
return this._count = t.length, this;
}
intersectsObject(e) {
let t = this._frustums;
for (let n = 0; n < this._count; n++) if (t[n].intersectsObject(e)) return !0;
return !1;
}
intersectsSprite(e) {
let t = this._frustums;
for (let n = 0; n < this._count; n++) if (t[n].intersectsSprite(e)) return !0;
return !1;
}
intersectsSphere(e) {
let t = this._frustums;
for (let n = 0; n < this._count; n++) if (t[n].intersectsSphere(e)) return !0;
return !1;
}
intersectsBox(e) {
let t = this._frustums;
for (let n = 0; n < this._count; n++) if (t[n].intersectsBox(e)) return !0;
return !1;
}
containsPoint(e) {
let t = this._frustums;
for (let n = 0; n < this._count; n++) if (t[n].containsPoint(e)) return !0;
return !1;
}
copy(e) {
this.coordinateSystem = e.coordinateSystem;
let t = this._frustums, n = e._frustums;
for (let r = 0; r < e._count; r++) t[r] === void 0 && (t[r] = new _o()), t[r].copy(n[r]);
return this._count = e._count, this;
}
clone() {
return new e().copy(this);
}
};
function bo(e, t) {
return e - t;
}
function xo(e, t) {
return e.z - t.z;
}
function So(e, t) {
return t.z - e.z;
}
var Co = class {
constructor() {
this.index = 0, this.pool = [], this.list = [];
}
push(e, t, n, r) {
let i = this.pool, a = this.list;
this.index >= i.length && i.push({
start: -1,
count: -1,
z: -1,
index: -1
});
let o = i[this.index];
a.push(o), this.index++, o.start = e, o.count = t, o.z = n, o.index = r;
}
reset() {
this.list.length = 0, this.index = 0;
}
}, wo = /*@__PURE__*/ new W(), To = /*@__PURE__*/ new G(1, 1, 1), Eo = /*@__PURE__*/ new _o(), Do = /*@__PURE__*/ new yo(), Oo = /*@__PURE__*/ new ii(), ko = /*@__PURE__*/ new zi(), Ao = /*@__PURE__*/ new H(), jo = /*@__PURE__*/ new H(), Mo = /*@__PURE__*/ new H(), No = /*@__PURE__*/ new Co(), Po = /*@__PURE__*/ new La(), Fo = [];
function Io(e, t, n = 0) {
let r = t.itemSize;
if (e.isInterleavedBufferAttribute || e.array.constructor !== t.array.constructor) {
let i = e.count;
for (let a = 0; a < i; a++) for (let i = 0; i < r; i++) t.setComponent(a + n, i, e.getComponent(a, i));
} else t.array.set(e.array, n * r);
t.needsUpdate = !0;
}
function Lo(e, t) {
if (e.constructor !== t.constructor) {
let n = Math.min(e.length, t.length);
for (let r = 0; r < n; r++) t[r] = e[r];
} else {
let n = Math.min(e.length, t.length);
t.set(new e.constructor(e.buffer, 0, n));
}
}
var Ro = class extends La {
constructor(e, t, n = t * 2, r) {
super(new q(), r), this.isBatchedMesh = !0, this.perObjectFrustumCulled = !0, this.sortObjects = !0, this.boundingBox = null, this.boundingSphere = null, this.customSort = null, this._instanceInfo = [], this._geometryInfo = [], this._availableInstanceIds = [], this._availableGeometryIds = [], this._nextIndexStart = 0, this._nextVertexStart = 0, this._geometryCount = 0, this._visibilityChanged = !0, this._geometryInitialized = !1, this._maxInstanceCount = e, this._maxVertexCount = t, this._maxIndexCount = n, this._multiDrawCounts = new Int32Array(e), this._multiDrawStarts = new Int32Array(e), this._multiDrawCount = 0, this._matricesTexture = null, this._indirectTexture = null, this._colorsTexture = null, this._initMatricesTexture(), this._initIndirectTexture();
}
get maxInstanceCount() {
return this._maxInstanceCount;
}
get instanceCount() {
return this._instanceInfo.length - this._availableInstanceIds.length;
}
get unusedVertexCount() {
return this._maxVertexCount - this._nextVertexStart;
}
get unusedIndexCount() {
return this._maxIndexCount - this._nextIndexStart;
}
_initMatricesTexture() {
let e = Math.sqrt(this._maxInstanceCount * 4);
e = Math.ceil(e / 4) * 4, e = Math.max(e, 4);
let t = new Xa(new Float32Array(e * e * 4), e, e, ge, N);
this._matricesTexture = t;
}
_initIndirectTexture() {
let e = Math.sqrt(this._maxInstanceCount);
e = Math.ceil(e);
let t = new Xa(new Uint32Array(e * e), e, e, be, se);
this._indirectTexture = t;
}
_initColorsTexture() {
let e = Math.sqrt(this._maxInstanceCount);
e = Math.ceil(e);
let t = new Xa(new Float32Array(e * e * 4).fill(1), e, e, ge, N);
t.colorSpace = Hn.workingColorSpace, this._colorsTexture = t;
}
_initializeGeometry(e) {
let t = this.geometry, n = this._maxVertexCount, r = this._maxIndexCount;
if (this._geometryInitialized === !1) {
for (let r in e.attributes) {
let { array: i, itemSize: a, normalized: o } = e.getAttribute(r), s = new Di(new i.constructor(n * a), a, o);
t.setAttribute(r, s);
}
if (e.getIndex() !== null) {
let e = n > 65535 ? new Uint32Array(r) : new Uint16Array(r);
t.setIndex(new Di(e, 1));
}
this._geometryInitialized = !0;
}
}
_validateGeometry(e) {
let t = this.geometry;
if (!!e.getIndex() != !!t.getIndex()) throw Error("THREE.BatchedMesh: All geometries must consistently have \"index\".");
for (let n in t.attributes) {
if (!e.hasAttribute(n)) throw Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);
let r = e.getAttribute(n), i = t.getAttribute(n);
if (r.itemSize !== i.itemSize || r.normalized !== i.normalized) throw Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.");
}
}
validateInstanceId(e) {
let t = this._instanceInfo;
if (e < 0 || e >= t.length || t[e].active === !1) throw Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`);
}
validateGeometryId(e) {
let t = this._geometryInfo;
if (e < 0 || e >= t.length || t[e].active === !1) throw Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`);
}
setCustomSort(e) {
return this.customSort = e, this;
}
computeBoundingBox() {
this.boundingBox === null && (this.boundingBox = new ii());
let e = this.boundingBox, t = this._instanceInfo;
e.makeEmpty();
for (let n = 0, r = t.length; n < r; n++) {
if (t[n].active === !1) continue;
let r = t[n].geometryIndex;
this.getMatrixAt(n, wo), this.getBoundingBoxAt(r, Oo).applyMatrix4(wo), e.union(Oo);
}
}
computeBoundingSphere() {
this.boundingSphere === null && (this.boundingSphere = new zi());
let e = this.boundingSphere, t = this._instanceInfo;
e.makeEmpty();
for (let n = 0, r = t.length; n < r; n++) {
if (t[n].active === !1) continue;
let r = t[n].geometryIndex;
this.getMatrixAt(n, wo), this.getBoundingSphereAt(r, ko).applyMatrix4(wo), e.union(ko);
}
}
addInstance(e) {
if (this._instanceInfo.length >= this.maxInstanceCount && this._availableInstanceIds.length === 0) throw Error("THREE.BatchedMesh: Maximum item count reached.");
let t = {
visible: !0,
active: !0,
geometryIndex: e
}, n = null;
this._availableInstanceIds.length > 0 ? (this._availableInstanceIds.sort(bo), n = this._availableInstanceIds.shift(), this._instanceInfo[n] = t) : (n = this._instanceInfo.length, this._instanceInfo.push(t));
let r = this._matricesTexture;
wo.identity().toArray(r.image.data, n * 16), r.needsUpdate = !0;
let i = this._colorsTexture;
return i && (To.toArray(i.image.data, n * 4), i.needsUpdate = !0), this._visibilityChanged = !0, n;
}
addGeometry(e, t = -1, n = -1) {
this._initializeGeometry(e), this._validateGeometry(e);
let r = {
vertexStart: -1,
vertexCount: -1,
reservedVertexCount: -1,
indexStart: -1,
indexCount: -1,
reservedIndexCount: -1,
start: -1,
count: -1,
boundingBox: null,
boundingSphere: null,
active: !0
}, i = this._geometryInfo;
r.vertexStart = this._nextVertexStart, r.reservedVertexCount = t === -1 ? e.getAttribute("position").count : t;
let a = e.getIndex();
if (a !== null && (r.indexStart = this._nextIndexStart, r.reservedIndexCount = n === -1 ? a.count : n), r.indexStart !== -1 && r.indexStart + r.reservedIndexCount > this._maxIndexCount || r.vertexStart + r.reservedVertexCount > this._maxVertexCount) throw Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");
let o;
return this._availableGeometryIds.length > 0 ? (this._availableGeometryIds.sort(bo), o = this._availableGeometryIds.shift(), i[o] = r) : (o = this._geometryCount, this._geometryCount++, i.push(r)), this.setGeometryAt(o, e), this._nextIndexStart = r.indexStart + r.reservedIndexCount, this._nextVertexStart = r.vertexStart + r.reservedVertexCount, o;
}
setGeometryAt(e, t) {
if (e >= this._geometryCount) throw Error("THREE.BatchedMesh: Maximum geometry count reached.");
this._validateGeometry(t);
let n = this.geometry, r = n.getIndex() !== null, i = n.getIndex(), a = t.getIndex(), o = this._geometryInfo[e];
if (r && a.count > o.reservedIndexCount || t.attributes.position.count > o.reservedVertexCount) throw Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");
let s = o.vertexStart, c = o.reservedVertexCount;
o.vertexCount = t.getAttribute("position").count;
for (let e in n.attributes) {
let r = t.getAttribute(e), i = n.getAttribute(e);
Io(r, i, s);
let a = r.itemSize;
for (let e = r.count, t = c; e < t; e++) {
let t = s + e;
for (let e = 0; e < a; e++) i.setComponent(t, e, 0);
}
i.needsUpdate = !0, i.addUpdateRange(s * a, c * a);
}
if (r) {
let e = o.indexStart, n = o.reservedIndexCount;
o.indexCount = t.getIndex().count;
for (let t = 0; t < a.count; t++) i.setX(e + t, s + a.getX(t));
for (let t = a.count, r = n; t < r; t++) i.setX(e + t, s);
i.needsUpdate = !0, i.addUpdateRange(e, o.reservedIndexCount);
}
return o.start = r ? o.indexStart : o.vertexStart, o.count = r ? o.indexCount : o.vertexCount, o.boundingBox = null, t.boundingBox !== null && (o.boundingBox = t.boundingBox.clone()), o.boundingSphere = null, t.boundingSphere !== null && (o.boundingSphere = t.boundingSphere.clone()), this._visibilityChanged = !0, e;
}
deleteGeometry(e) {
let t = this._geometryInfo;
if (e >= t.length || t[e].active === !1) return this;
let n = this._instanceInfo;
for (let t = 0, r = n.length; t < r; t++) n[t].active && n[t].geometryIndex === e && this.deleteInstance(t);
return t[e].active = !1, this._availableGeometryIds.push(e), this._visibilityChanged = !0, this;
}
deleteInstance(e) {
return this.validateInstanceId(e), this._instanceInfo[e].active = !1, this._availableInstanceIds.push(e), this._visibilityChanged = !0, this;
}
optimize() {
let e = 0, t = 0, n = this._geometryInfo, r = n.map((e, t) => t).sort((e, t) => n[e].vertexStart - n[t].vertexStart), i = this.geometry;
for (let a = 0, o = n.length; a < o; a++) {
let o = n[r[a]];
if (o.active !== !1) {
if (i.index !== null) {
if (o.indexStart !== t) {
let { indexStart: n, vertexStart: r, reservedIndexCount: a } = o, s = i.index, c = s.array, l = e - r;
for (let e = n; e < n + a; e++) c[e] = c[e] + l;
s.array.copyWithin(t, n, n + a), s.addUpdateRange(t, a), s.needsUpdate = !0, o.indexStart = t;
}
t += o.reservedIndexCount;
}
if (o.vertexStart !== e) {
let { vertexStart: t, reservedVertexCount: n } = o, r = i.attributes;
for (let i in r) {
let a = r[i], { array: o, itemSize: s } = a;
o.copyWithin(e * s, t * s, (t + n) * s), a.addUpdateRange(e * s, n * s), a.needsUpdate = !0;
}
o.vertexStart = e;
}
e += o.reservedVertexCount, o.start = i.index ? o.indexStart : o.vertexStart;
}
}
return this._nextIndexStart = t, this._nextVertexStart = e, this._visibilityChanged = !0, this;
}
getBoundingBoxAt(e, t) {
if (e >= this._geometryCount) return null;
let n = this.geometry, r = this._geometryInfo[e];
if (r.boundingBox === null) {
let e = new ii(), t = n.index, i = n.attributes.position;
for (let n = r.start, a = r.start + r.count; n < a; n++) {
let r = n;
t && (r = t.getX(r)), e.expandByPoint(Ao.fromBufferAttribute(i, r));
}
r.boundingBox = e;
}
return t.copy(r.boundingBox), t;
}
getBoundingSphereAt(e, t) {
if (e >= this._geometryCount) return null;
let n = this.geometry, r = this._geometryInfo[e];
if (r.boundingSphere === null) {
let t = new zi();
this.getBoundingBoxAt(e, Oo), Oo.getCenter(t.center);
let i = n.index, a = n.attributes.position, o = 0;
for (let e = r.start, n = r.start + r.count; e < n; e++) {
let n = e;
i && (n = i.getX(n)), Ao.fromBufferAttribute(a, n), o = Math.max(o, t.center.distanceToSquared(Ao));
}
t.radius = Math.sqrt(o), r.boundingSphere = t;
}
return t.copy(r.boundingSphere), t;
}
setMatrixAt(e, t) {
this.validateInstanceId(e);
let n = this._matricesTexture, r = this._matricesTexture.image.data;
return t.toArray(r, e * 16), n.needsUpdate = !0, this;
}
getMatrixAt(e, t) {
return this.validateInstanceId(e), t.fromArray(this._matricesTexture.image.data, e * 16);
}
setColorAt(e, t) {
return this.validateInstanceId(e), this._colorsTexture === null && this._initColorsTexture(), t.toArray(this._colorsTexture.image.data, e * 4), this._colorsTexture.needsUpdate = !0, this;
}
getColorAt(e, t) {
return this.validateInstanceId(e), this._colorsTexture === null ? t.isVector4 ? t.set(1, 1, 1, 1) : t.setRGB(1, 1, 1) : t.fromArray(this._colorsTexture.image.data, e * 4);
}
setVisibleAt(e, t) {
return this.validateInstanceId(e), this._instanceInfo[e].visible === t ? this : (this._instanceInfo[e].visible = t, this._visibilityChanged = !0, this);
}
getVisibleAt(e) {
return this.validateInstanceId(e), this._instanceInfo[e].visible;
}
setGeometryIdAt(e, t) {
return this.validateInstanceId(e), this.validateGeometryId(t), this._instanceInfo[e].geometryIndex = t, this;
}
getGeometryIdAt(e) {
return this.validateInstanceId(e), this._instanceInfo[e].geometryIndex;
}
getGeometryRangeAt(e, t = {}) {
this.validateGeometryId(e);
let n = this._geometryInfo[e];
return t.vertexStart = n.vertexStart, t.vertexCount = n.vertexCount, t.reservedVertexCount = n.reservedVertexCount, t.indexStart = n.indexStart, t.indexCount = n.indexCount, t.reservedIndexCount = n.reservedIndexCount, t.start = n.start, t.count = n.count, t;
}
setInstanceCount(e) {
let t = this._availableInstanceIds, n = this._instanceInfo;
for (t.sort(bo); t[t.length - 1] === n.length - 1;) n.pop(), t.pop();
if (e < n.length) throw Error(`THREE.BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);
let r = new Int32Array(e), i = new Int32Array(e);
Lo(this._multiDrawCounts, r), Lo(this._multiDrawStarts, i), this._multiDrawCounts = r, this._multiDrawStarts = i, this._maxInstanceCount = e;
let a = this._indirectTexture, o = this._matricesTexture, s = this._colorsTexture;
a.dispose(), this._initIndirectTexture(), Lo(a.image.data, this._indirectTexture.image.data), o.dispose(), this._initMatricesTexture(), Lo(o.image.data, this._matricesTexture.image.data), s && (s.dispose(), this._initColorsTexture(), Lo(s.image.data, this._colorsTexture.image.data));
}
setGeometrySize(e, t) {
let n = [...this._geometryInfo].filter((e) => e.active);
if (Math.max(...n.map((e) => e.vertexStart + e.reservedVertexCount)) > e) throw Error(`THREE.BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);
if (this.geometry.index && Math.max(...n.map((e) => e.indexStart + e.reservedIndexCount)) > t) throw Error(`THREE.BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);
let r = this.geometry;
r.dispose(), this._maxVertexCount = e, this._maxIndexCount = t, this._geometryInitialized && (this._geometryInitialized = !1, this.geometry = new q(), this._initializeGeometry(r));
let i = this.geometry;
r.index && Lo(r.index.array, i.index.array);
for (let e in r.attributes) Lo(r.attributes[e].array, i.attributes[e].array);
}
raycast(e, t) {
let n = this._instanceInfo, r = this._geometryInfo, i = this.matrixWorld, a = this.geometry;
Po.material = this.material, Po.geometry.index = a.index, Po.geometry.attributes = a.attributes, Po.geometry.boundingBox === null && (Po.geometry.boundingBox = new ii()), Po.geometry.boundingSphere === null && (Po.geometry.boundingSphere = new zi());
for (let a = 0, o = n.length; a < o; a++) {
if (!n[a].visible || !n[a].active) continue;
let o = n[a].geometryIndex, s = r[o];
Po.geometry.setDrawRange(s.start, s.count), this.getMatrixAt(a, Po.matrixWorld).premultiply(i), this.getBoundingBoxAt(o, Po.geometry.boundingBox), this.getBoundingSphereAt(o, Po.geometry.boundingSphere), Po.raycast(e, Fo);
for (let e = 0, n = Fo.length; e < n; e++) {
let n = Fo[e];
n.object = this, n.batchId = a, t.push(n);
}
Fo.length = 0;
}
Po.material = null, Po.geometry.index = null, Po.geometry.attributes = {}, Po.geometry.setDrawRange(0, Infinity);
}
copy(e) {
return super.copy(e), this.geometry = e.geometry.clone(), this.perObjectFrustumCulled = e.perObjectFrustumCulled, this.sortObjects = e.sortObjects, this.boundingBox = e.boundingBox === null ? null : e.boundingBox.clone(), this.boundingSphere = e.boundingSphere === null ? null : e.boundingSphere.clone(), this._geometryInfo = e._geometryInfo.map((e) => ({
...e,
boundingBox: e.boundingBox === null ? null : e.boundingBox.clone(),
boundingSphere: e.boundingSphere === null ? null : e.boundingSphere.clone()
})), this._instanceInfo = e._instanceInfo.map((e) => ({ ...e })), this._availableInstanceIds = e._availableInstanceIds.slice(), this._availableGeometryIds = e._availableGeometryIds.slice(), this._nextIndexStart = e._nextIndexStart, this._nextVertexStart = e._nextVertexStart, this._geometryCount = e._geometryCount, this._maxInstanceCount = e._maxInstanceCount, this._maxVertexCount = e._maxVertexCount, this._maxIndexCount = e._maxIndexCount, this._geometryInitialized = e._geometryInitialized, this._multiDrawCounts = e._multiDrawCounts.slice(), this._multiDrawStarts = e._multiDrawStarts.slice(), this._indirectTexture = e._indirectTexture.clone(), this._indirectTexture.image.data = this._indirectTexture.image.data.slice(), this._matricesTexture = e._matricesTexture.clone(), this._matricesTexture.image.data = this._matricesTexture.image.data.slice(), this._colorsTexture !== null && (this._colorsTexture = e._colorsTexture.clone(), this._colorsTexture.image.data = this._colorsTexture.image.data.slice()), this;
}
dispose() {
this.geometry.dispose(), this._matricesTexture.dispose(), this._matricesTexture = null, this._indirectTexture.dispose(), this._indirectTexture = null, this._colorsTexture !== null && (this._colorsTexture.dispose(), this._colorsTexture = null);
}
onBeforeRender(e, t, n, r, i) {
if (!this._visibilityChanged && !this.perObjectFrustumCulled && !this.sortObjects) return;
let a = r.getIndex(), o = a === null ? 1 : a.array.BYTES_PER_ELEMENT, s = 1;
i.wireframe && (s = 2, o = r.attributes.position.count > 65535 ? 4 : 2);
let c = this._instanceInfo, l = this._multiDrawStarts, u = this._multiDrawCounts, d = this._geometryInfo, f = this.perObjectFrustumCulled, p = this._indirectTexture, m = p.image.data, h = n.isArrayCamera ? Do : Eo;
f && (n.isArrayCamera ? h.setFromArrayCamera(n) : (wo.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse).multiply(this.matrixWorld), h.setFromProjectionMatrix(wo, n.coordinateSystem, n.reversedDepth)));
let g = 0;
if (this.sortObjects) {
wo.copy(this.matrixWorld).invert(), Ao.setFromMatrixPosition(n.matrixWorld).applyMatrix4(wo), jo.set(0, 0, -1).transformDirection(n.matrixWorld).transformDirection(wo);
for (let e = 0, t = c.length; e < t; e++) if (c[e].visible && c[e].active) {
let t = c[e].geometryIndex;
this.getMatrixAt(e, wo), this.getBoundingSphereAt(t, ko).applyMatrix4(wo);
let n = !1;
if (f && (n = !h.intersectsSphere(ko)), !n) {
let n = d[t], r = Mo.subVectors(ko.center, Ao).dot(jo);
No.push(n.start, n.count, r, e);
}
}
let e = No.list, t = this.customSort;
t === null ? e.sort(i.transparent ? So : xo) : t.call(this, e, n);
for (let t = 0, n = e.length; t < n; t++) {
let n = e[t];
l[g] = n.start * o * s, u[g] = n.count * s, m[g] = n.index, g++;
}
No.reset();
} else for (let e = 0, t = c.length; e < t; e++) if (c[e].visible && c[e].active) {
let t = c[e].geometryIndex, n = !1;
if (f && (this.getMatrixAt(e, wo), this.getBoundingSphereAt(t, ko).applyMatrix4(wo), n = !h.intersectsSphere(ko)), !n) {
let n = d[t];
l[g] = n.start * o * s, u[g] = n.count * s, m[g] = e, g++;
}
}
p.needsUpdate = !0, this._multiDrawCount = g, this._visibilityChanged = !1;
}
onBeforeShadow(e, t, n, r, i, a) {
this.onBeforeRender(e, null, r, i, a);
}
}, zo = class extends Zi {
constructor(e) {
super(), this.isLineBasicMaterial = !0, this.type = "LineBasicMaterial", this.color = new G(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;
}
}, Bo = /*@__PURE__*/ new H(), Vo = /*@__PURE__*/ new H(), Ho = /*@__PURE__*/ new W(), Uo = /*@__PURE__*/ new wa(), Wo = /*@__PURE__*/ new zi(), Go = /*@__PURE__*/ new H(), Ko = /*@__PURE__*/ new H(), qo = class extends Mr {
constructor(e = new q(), t = new zo()) {
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 e = 1, r = t.count; e < r; e++) Bo.fromBufferAttribute(t, e - 1), Vo.fromBufferAttribute(t, e), n[e] = n[e - 1], n[e] += Bo.distanceTo(Vo);
e.setAttribute("lineDistance", new K(n, 1));
} else L("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
return this;
}
raycast(e, t) {
let n = this.geometry, r = this.matrixWorld, i = e.params.Line.threshold, a = n.drawRange;
if (n.boundingSphere === null && n.computeBoundingSphere(), Wo.copy(n.boundingSphere), Wo.applyMatrix4(r), Wo.radius += i, e.ray.intersectsSphere(Wo) === !1) return;
Ho.copy(r).invert(), Uo.copy(e.ray).applyMatrix4(Ho);
let o = i / ((this.scale.x + this.scale.y + this.scale.z) / 3), s = o * o, c = this.isLineSegments ? 2 : 1, l = n.index, u = n.attributes.position;
if (l !== null) {
let n = Math.max(0, a.start), r = Math.min(l.count, a.start + a.count);
for (let i = n, a = r - 1; i < a; i += c) {
let n = l.getX(i), r = l.getX(i + 1), a = Jo(this, e, Uo, s, n, r, i);
a && t.push(a);
}
if (this.isLineLoop) {
let i = l.getX(r - 1), a = l.getX(n), o = Jo(this, e, Uo, s, i, a, r - 1);
o && t.push(o);
}
} else {
let n = Math.max(0, a.start), r = Math.min(u.count, a.start + a.count);
for (let i = n, a = r - 1; i < a; i += c) {
let n = Jo(this, e, Uo, s, i, i + 1, i);
n && t.push(n);
}
if (this.isLineLoop) {
let i = Jo(this, e, Uo, s, r - 1, n, r - 1);
i && t.push(i);
}
}
}
updateMorphTargets() {
let e = this.geometry.morphAttributes, t = Object.keys(e);
if (t.length > 0) {
let n = e[t[0]];
if (n !== void 0) {
this.morphTargetInfluences = [], this.morphTargetDictionary = {};
for (let e = 0, t = n.length; e < t; e++) {
let t = n[e].name || String(e);
this.morphTargetInfluences.push(0), this.morphTargetDictionary[t] = e;
}
}
}
}
};
function Jo(e, t, n, r, i, a, o) {
let s = e.geometry.attributes.position;
if (Bo.fromBufferAttribute(s, i), Vo.fromBufferAttribute(s, a), n.distanceSqToSegment(Bo, Vo, Go, Ko) > r) return;
Go.applyMatrix4(e.matrixWorld);
let c = t.ray.origin.distanceTo(Go);
if (!(c < t.near || c > t.far)) return {
distance: c,
point: Ko.clone().applyMatrix4(e.matrixWorld),
index: o,
face: null,
faceIndex: null,
barycoord: null,
object: e
};
}
var Yo = /*@__PURE__*/ new H(), Xo = /*@__PURE__*/ new H(), Zo = class extends qo {
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 e = 0, r = t.count; e < r; e += 2) Yo.fromBufferAttribute(t, e), Xo.fromBufferAttribute(t, e + 1), n[e] = e === 0 ? 0 : n[e - 1], n[e + 1] = n[e] + Yo.distanceTo(Xo);
e.setAttribute("lineDistance", new K(n, 1));
} else L("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
return this;
}
}, Qo = class extends qo {
constructor(e, t) {
super(e, t), this.isLineLoop = !0, this.type = "LineLoop";
}
}, $o = class extends Zi {
constructor(e) {
super(), this.isPointsMaterial = !0, this.type = "PointsMaterial", this.color = new G(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;
}
}, es = /*@__PURE__*/ new W(), ts = /*@__PURE__*/ new wa(), ns = /*@__PURE__*/ new zi(), rs = /*@__PURE__*/ new H(), is = class extends Mr {
constructor(e = new q(), t = new $o()) {
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, r = this.matrixWorld, i = e.params.Points.threshold, a = n.drawRange;
if (n.boundingSphere === null && n.computeBoundingSphere(), ns.copy(n.boundingSphere), ns.applyMatrix4(r), ns.radius += i, e.ray.intersectsSphere(ns) === !1) return;
es.copy(r).invert(), ts.copy(e.ray).applyMatrix4(es);
let o = i / ((this.scale.x + this.scale.y + this.scale.z) / 3), s = o * o, c = n.index, l = n.attributes.position;
if (c !== null) {
let n = Math.max(0, a.start), i = Math.min(c.count, a.start + a.count);
for (let a = n, o = i; a < o; a++) {
let n = c.getX(a);
rs.fromBufferAttribute(l, n), as(rs, n, s, r, e, t, this);
}
} else {
let n = Math.max(0, a.start), i = Math.min(l.count, a.start + a.count);
for (let a = n, o = i; a < o; a++) rs.fromBufferAttribute(l, a), as(rs, a, s, r, e, t, this);
}
}
updateMorphTargets() {
let e = this.geometry.morphAttributes, t = Object.keys(e);
if (t.length > 0) {
let n = e[t[0]];
if (n !== void 0) {
this.morphTargetInfluences = [], this.morphTargetDictionary = {};
for (let e = 0, t = n.length; e < t; e++) {
let t = n[e].name || String(e);
this.morphTargetInfluences.push(0), this.morphTargetDictionary[t] = e;
}
}
}
}
};
function as(e, t, n, r, i, a, o) {
let s = ts.distanceSqToPoint(e);
if (s < n) {
let n = new H();
ts.closestPointToPoint(e, n), n.applyMatrix4(r);
let c = i.ray.origin.distanceTo(n);
if (c < i.near || c > i.far) return;
a.push({
distance: c,
distanceToRay: Math.sqrt(s),
point: n,
index: t,
face: null,
faceIndex: null,
barycoord: null,
object: o
});
}
}
var os = class extends Qn {
constructor(e, t, n, r, i = A, a = A, o, s, c) {
super(e, t, n, r, i, a, o, s, c), this.isVideoTexture = !0, this.generateMipmaps = !1, this._requestVideoFrameCallbackId = 0;
let l = this;
function u() {
l.needsUpdate = !0, l._requestVideoFrameCallbackId = e.requestVideoFrameCallback(u);
}
"requestVideoFrameCallback" in e && (this._requestVideoFrameCallbackId = e.requestVideoFrameCallback(u));
}
clone() {
return new this.constructor(this.image).copy(this);
}
update() {
let e = this.image;
!("requestVideoFrameCallback" in e) && e.readyState >= e.HAVE_CURRENT_DATA && (this.needsUpdate = !0);
}
dispose() {
this._requestVideoFrameCallbackId !== 0 && (this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId), this._requestVideoFrameCallbackId = 0), super.dispose();
}
}, ss = class extends os {
constructor(e, t, n, r, i, a, o, s) {
super({}, e, t, n, r, i, a, o, s), this.isVideoFrameTexture = !0;
}
update() {}
clone() {
return new this.constructor().copy(this);
}
setFrame(e) {
this.image = e, this.needsUpdate = !0;
}
}, cs = class extends Qn {
constructor(e, t) {
super({
width: e,
height: t
}), this.isFramebufferTexture = !0, this.magFilter = T, this.minFilter = T, this.generateMipmaps = !1, this.needsUpdate = !0;
}
}, ls = class extends Qn {
constructor(e, t, n, r, i, a, o, s, c, l, u, d) {
super(null, a, o, s, c, l, r, i, u, d), this.isCompressedTexture = !0, this.image = {
width: t,
height: n
}, this.mipmaps = e, this.flipY = !1, this.generateMipmaps = !1;
}
}, us = class extends ls {
constructor(e, t, n, r, i, a) {
super(e, t, n, i, a), this.isCompressedArrayTexture = !0, this.image.depth = r, this.wrapR = C, this.layerUpdates = /* @__PURE__ */ new Set();
}
addLayerUpdate(e) {
this.layerUpdates.add(e);
}
clearLayerUpdates() {
this.layerUpdates.clear();
}
}, ds = class extends ls {
constructor(e, t, n) {
super(void 0, e[0].width, e[0].height, t, n, 301), this.isCompressedCubeTexture = !0, this.isCubeTexture = !0, this.image = e;
}
}, fs = class extends Qn {
constructor(e = [], t = 301, n, r, i, a, o, s, c, l) {
super(e, t, n, r, i, a, o, s, c, l), this.isCubeTexture = !0, this.flipY = !1;
}
get images() {
return this.image;
}
set images(e) {
this.image = e;
}
}, ps = class extends Qn {
constructor(e, t, n, r, i, a, o, s, c) {
super(e, t, n, r, i, a, o, s, c), this.isCanvasTexture = !0, this.needsUpdate = !0;
}
}, ms = class extends Qn {
constructor(e, t, n, r, i, a, o, s, c) {
super(e, t, n, r, i, a, o, s, c), this.isHTMLTexture = !0, this.generateMipmaps = !1, this.needsUpdate = !0;
let l = e ? e.parentNode : null;
l !== null && "requestPaint" in l && (l.onpaint = () => {
this.needsUpdate = !0;
}, l.requestPaint());
}
dispose() {
let e = this.image ? this.image.parentNode : null;
e !== null && "onpaint" in e && (e.onpaint = null), super.dispose();
}
}, hs = class extends Qn {
constructor(e, t, n = se, r, i, a, o = T, s = T, c, l = _e, u = 1) {
if (l !== 1026 && l !== 1027) throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
super({
width: e,
height: t,
depth: u
}, r, i, a, o, s, l, n, c), this.isDepthTexture = !0, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;
}
copy(e) {
return super.copy(e), this.source = new Jn(Object.assign({}, e.image)), this.compareFunction = e.compareFunction, this;
}
toJSON(e) {
let t = super.toJSON(e);
return this.compareFunction !== null && (t.compareFunction = this.compareFunction), t;
}
}, gs = class extends hs {
constructor(e, t = se, n = 301, r, i, a = T, o = T, s, c = _e) {
let l = {
width: e,
height: e,
depth: 1
}, u = [
l,
l,
l,
l,
l,
l
];
super(e, e, t, n, r, i, a, o, s, c), this.image = u, this.isCubeDepthTexture = !0, this.isCubeTexture = !0;
}
get images() {
return this.image;
}
set images(e) {
this.image = e;
}
}, _s = class extends Qn {
constructor(e = null) {
super(), this.sourceTexture = e, this.isExternalTexture = !0;
}
copy(e) {
return super.copy(e), this.sourceTexture = e.sourceTexture, this;
}
}, vs = class e extends q {
constructor(e = 1, t = 1, n = 1, r = 1, i = 1, a = 1) {
super(), this.type = "BoxGeometry", this.parameters = {
width: e,
height: t,
depth: n,
widthSegments: r,
heightSegments: i,
depthSegments: a
};
let o = this;
r = Math.floor(r), i = Math.floor(i), a = Math.floor(a);
let s = [], c = [], l = [], u = [], d = 0, f = 0;
p("z", "y", "x", -1, -1, n, t, e, a, i, 0), p("z", "y", "x", 1, -1, n, t, -e, a, i, 1), p("x", "z", "y", 1, 1, e, n, t, r, a, 2), p("x", "z", "y", 1, -1, e, n, -t, r, a, 3), p("x", "y", "z", 1, -1, e, t, n, r, i, 4), p("x", "y", "z", -1, -1, e, t, -n, r, i, 5), this.setIndex(s), this.setAttribute("position", new K(c, 3)), this.setAttribute("normal", new K(l, 3)), this.setAttribute("uv", new K(u, 2));
function p(e, t, n, r, i, a, p, m, h, g, _) {
let v = a / h, y = p / g, b = a / 2, x = p / 2, S = m / 2, C = h + 1, w = g + 1, T = 0, E = 0, D = new H();
for (let a = 0; a < w; a++) {
let o = a * y - x;
for (let s = 0; s < C; s++) D[e] = (s * v - b) * r, D[t] = o * i, D[n] = S, c.push(D.x, D.y, D.z), D[e] = 0, D[t] = 0, D[n] = m > 0 ? 1 : -1, l.push(D.x, D.y, D.z), u.push(s / h), u.push(1 - a / g), T += 1;
}
for (let e = 0; e < g; e++) for (let t = 0; t < h; t++) {
let n = d + t + C * e, r = d + t + C * (e + 1), i = d + (t + 1) + C * (e + 1), a = d + (t + 1) + C * e;
s.push(n, r, a), s.push(r, i, a), E += 6;
}
o.addGroup(f, E, _), f += E, d += T;
}
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.width, t.height, t.depth, t.widthSegments, t.heightSegments, t.depthSegments);
}
}, ys = class e extends q {
constructor(e = 1, t = 1, n = 4, r = 8, i = 1) {
super(), this.type = "CapsuleGeometry", this.parameters = {
radius: e,
height: t,
capSegments: n,
radialSegments: r,
heightSegments: i
}, t = Math.max(0, t), n = Math.max(1, Math.floor(n)), r = Math.max(3, Math.floor(r)), i = Math.max(1, Math.floor(i));
let a = [], o = [], s = [], c = [], l = t / 2, u = Math.PI / 2 * e, d = t, f = 2 * u + d, p = n * 2 + i, m = r + 1, h = new H(), g = new H();
for (let _ = 0; _ <= p; _++) {
let v = 0, y = 0, b = 0, x = 0;
if (_ <= n) {
let t = _ / n, r = t * Math.PI / 2;
y = -l - e * Math.cos(r), b = e * Math.sin(r), x = -e * Math.cos(r), v = t * u;
} else if (_ <= n + i) {
let r = (_ - n) / i;
y = -l + r * t, b = e, x = 0, v = u + r * d;
} else {
let t = (_ - n - i) / n, r = t * Math.PI / 2;
y = l + e * Math.sin(r), b = e * Math.cos(r), x = e * Math.sin(r), v = u + d + t * u;
}
let S = Math.max(0, Math.min(1, v / f)), C = 0;
_ === 0 ? C = .5 / r : _ === p && (C = -.5 / r);
for (let e = 0; e <= r; e++) {
let t = e / r, n = t * Math.PI * 2, i = Math.sin(n), a = Math.cos(n);
g.x = -b * a, g.y = y, g.z = b * i, o.push(g.x, g.y, g.z), h.set(-b * a, x, b * i), h.normalize(), s.push(h.x, h.y, h.z), c.push(t + C, S);
}
if (_ > 0) {
let e = (_ - 1) * m;
for (let t = 0; t < r; t++) {
let n = e + t, r = e + t + 1, i = _ * m + t, o = _ * m + t + 1;
a.push(n, r, i), a.push(r, o, i);
}
}
}
this.setIndex(a), this.setAttribute("position", new K(o, 3)), this.setAttribute("normal", new K(s, 3)), this.setAttribute("uv", new K(c, 2));
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.radius, t.height, t.capSegments, t.radialSegments, t.heightSegments);
}
}, bs = class e extends q {
constructor(e = 1, t = 32, n = 0, r = Math.PI * 2) {
super(), this.type = "CircleGeometry", this.parameters = {
radius: e,
segments: t,
thetaStart: n,
thetaLength: r
}, t = Math.max(3, t);
let i = [], a = [], o = [], s = [], c = new H(), l = new V();
a.push(0, 0, 0), o.push(0, 0, 1), s.push(.5, .5);
for (let i = 0, u = 3; i <= t; i++, u += 3) {
let d = n + i / t * r;
c.x = e * Math.cos(d), c.y = e * Math.sin(d), a.push(c.x, c.y, c.z), o.push(0, 0, 1), l.x = (a[u] / e + 1) / 2, l.y = (a[u + 1] / e + 1) / 2, s.push(l.x, l.y);
}
for (let e = 1; e <= t; e++) i.push(e, e + 1, 0);
this.setIndex(i), this.setAttribute("position", new K(a, 3)), this.setAttribute("normal", new K(o, 3)), this.setAttribute("uv", new K(s, 2));
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.radius, t.segments, t.thetaStart, t.thetaLength);
}
}, xs = class e extends q {
constructor(e = 1, t = 1, n = 1, r = 32, i = 1, a = !1, o = 0, s = Math.PI * 2) {
super(), this.type = "CylinderGeometry", this.parameters = {
radiusTop: e,
radiusBottom: t,
height: n,
radialSegments: r,
heightSegments: i,
openEnded: a,
thetaStart: o,
thetaLength: s
};
let c = this;
r = Math.floor(r), i = Math.floor(i);
let l = [], u = [], d = [], f = [], p = 0, m = [], h = n / 2, g = 0;
_(), a === !1 && (e > 0 && v(!0), t > 0 && v(!1)), this.setIndex(l), this.setAttribute("position", new K(u, 3)), this.setAttribute("normal", new K(d, 3)), this.setAttribute("uv", new K(f, 2));
function _() {
let a = new H(), _ = new H(), v = 0, y = (t - e) / n;
for (let c = 0; c <= i; c++) {
let l = [], g = c / i, v = g * (t - e) + e;
for (let e = 0; e <= r; e++) {
let t = e / r, i = t * s + o, c = Math.sin(i), m = Math.cos(i);
_.x = v * c, _.y = -g * n + h, _.z = v * m, u.push(_.x, _.y, _.z), a.set(c, y, m).normalize(), d.push(a.x, a.y, a.z), f.push(t, 1 - g), l.push(p++);
}
m.push(l);
}
for (let n = 0; n < r; n++) for (let r = 0; r < i; r++) {
let a = m[r][n], o = m[r + 1][n], s = m[r + 1][n + 1], c = m[r][n + 1];
(e > 0 || r !== 0) && (l.push(a, o, c), v += 3), (t > 0 || r !== i - 1) && (l.push(o, s, c), v += 3);
}
c.addGroup(g, v, 0), g += v;
}
function v(n) {
let i = p, a = new V(), m = new H(), _ = 0, v = n === !0 ? e : t, y = n === !0 ? 1 : -1;
for (let e = 1; e <= r; e++) u.push(0, h * y, 0), d.push(0, y, 0), f.push(.5, .5), p++;
let b = p;
for (let e = 0; e <= r; e++) {
let t = e / r * s + o, n = Math.cos(t), i = Math.sin(t);
m.x = v * i, m.y = h * y, m.z = v * n, u.push(m.x, m.y, m.z), d.push(0, y, 0), a.x = n * .5 + .5, a.y = i * .5 * y + .5, f.push(a.x, a.y), p++;
}
for (let e = 0; e < r; e++) {
let t = i + e, r = b + e;
n === !0 ? l.push(r, r + 1, t) : l.push(r + 1, r, t), _ += 3;
}
c.addGroup(g, _, n === !0 ? 1 : 2), g += _;
}
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.radiusTop, t.radiusBottom, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength);
}
}, Ss = class e extends xs {
constructor(e = 1, t = 1, n = 32, r = 1, i = !1, a = 0, o = Math.PI * 2) {
super(0, e, t, n, r, i, a, o), this.type = "ConeGeometry", this.parameters = {
radius: e,
height: t,
radialSegments: n,
heightSegments: r,
openEnded: i,
thetaStart: a,
thetaLength: o
};
}
static fromJSON(t) {
return new e(t.radius, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength);
}
}, Cs = class e extends q {
constructor(e = [], t = [], n = 1, r = 0) {
super(), this.type = "PolyhedronGeometry", this.parameters = {
vertices: e,
indices: t,
radius: n,
detail: r
};
let i = [], a = [];
o(r), c(n), l(), this.setAttribute("position", new K(i, 3)), this.setAttribute("normal", new K(i.slice(), 3)), this.setAttribute("uv", new K(a, 2)), r === 0 ? this.computeVertexNormals() : this.normalizeNormals();
function o(e) {
let n = new H(), r = new H(), i = new H();
for (let a = 0; a < t.length; a += 3) f(t[a + 0], n), f(t[a + 1], r), f(t[a + 2], i), s(n, r, i, e);
}
function s(e, t, n, r) {
let i = r + 1, a = [];
for (let r = 0; r <= i; r++) {
a[r] = [];
let o = e.clone().lerp(n, r / i), s = t.clone().lerp(n, r / i), c = i - r;
for (let e = 0; e <= c; e++) e === 0 && r === i ? a[r][e] = o : a[r][e] = o.clone().lerp(s, e / c);
}
for (let e = 0; e < i; e++) for (let t = 0; t < 2 * (i - e) - 1; t++) {
let n = Math.floor(t / 2);
t % 2 == 0 ? (d(a[e][n + 1]), d(a[e + 1][n]), d(a[e][n])) : (d(a[e][n + 1]), d(a[e + 1][n + 1]), d(a[e + 1][n]));
}
}
function c(e) {
let t = new H();
for (let n = 0; n < i.length; n += 3) t.x = i[n + 0], t.y = i[n + 1], t.z = i[n + 2], t.normalize().multiplyScalar(e), i[n + 0] = t.x, i[n + 1] = t.y, i[n + 2] = t.z;
}
function l() {
let e = new H();
for (let t = 0; t < i.length; t += 3) {
e.x = i[t + 0], e.y = i[t + 1], e.z = i[t + 2];
let n = h(e) / 2 / Math.PI + .5, r = g(e) / Math.PI + .5;
a.push(n, 1 - r);
}
p(), u();
}
function u() {
for (let e = 0; e < a.length; e += 6) {
let t = a[e + 0], n = a[e + 2], r = a[e + 4];
Math.max(t, n, r) > .9 && Math.min(t, n, r) < .1 && (t < .2 && (a[e + 0] += 1), n < .2 && (a[e + 2] += 1), r < .2 && (a[e + 4] += 1));
}
}
function d(e) {
i.push(e.x, e.y, e.z);
}
function f(t, n) {
let r = t * 3;
n.x = e[r + 0], n.y = e[r + 1], n.z = e[r + 2];
}
function p() {
let e = new H(), t = new H(), n = new H(), r = new H(), o = new V(), s = new V(), c = new V();
for (let l = 0, u = 0; l < i.length; l += 9, u += 6) {
e.set(i[l + 0], i[l + 1], i[l + 2]), t.set(i[l + 3], i[l + 4], i[l + 5]), n.set(i[l + 6], i[l + 7], i[l + 8]), o.set(a[u + 0], a[u + 1]), s.set(a[u + 2], a[u + 3]), c.set(a[u + 4], a[u + 5]), r.copy(e).add(t).add(n).divideScalar(3);
let d = h(r);
m(o, u + 0, e, d), m(s, u + 2, t, d), m(c, u + 4, n, d);
}
}
function m(e, t, n, r) {
r < 0 && e.x === 1 && (a[t] = e.x - 1), n.x === 0 && n.z === 0 && (a[t] = r / 2 / Math.PI + .5);
}
function h(e) {
return Math.atan2(e.z, -e.x);
}
function g(e) {
return Math.atan2(-e.y, Math.sqrt(e.x * e.x + e.z * e.z));
}
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.vertices, t.indices, t.radius, t.detail);
}
}, ws = class e extends Cs {
constructor(e = 1, t = 0) {
let n = (1 + Math.sqrt(5)) / 2, r = 1 / n, i = [
-1,
-1,
-1,
-1,
-1,
1,
-1,
1,
-1,
-1,
1,
1,
1,
-1,
-1,
1,
-1,
1,
1,
1,
-1,
1,
1,
1,
0,
-r,
-n,
0,
-r,
n,
0,
r,
-n,
0,
r,
n,
-r,
-n,
0,
-r,
n,
0,
r,
-n,
0,
r,
n,
0,
-n,
0,
-r,
n,
0,
-r,
-n,
0,
r,
n,
0,
r
];
super(i, [
3,
11,
7,
3,
7,
15,
3,
15,
13,
7,
19,
17,
7,
17,
6,
7,
6,
15,
17,
4,
8,
17,
8,
10,
17,
10,
6,
8,
0,
16,
8,
16,
2,
8,
2,
10,
0,
12,
1,
0,
1,
18,
0,
18,
16,
6,
10,
2,
6,
2,
13,
6,
13,
15,
2,
16,
18,
2,
18,
3,
2,
3,
13,
18,
1,
9,
18,
9,
11,
18,
11,
3,
4,
14,
12,
4,
12,
0,
4,
0,
8,
11,
9,
5,
11,
5,
19,
11,
19,
7,
19,
5,
14,
19,
14,
4,
19,
4,
17,
1,
12,
14,
1,
14,
5,
1,
5,
9
], e, t), this.type = "DodecahedronGeometry", this.parameters = {
radius: e,
detail: t
};
}
static fromJSON(t) {
return new e(t.radius, t.detail);
}
}, Ts = /*@__PURE__*/ new H(), Es = /*@__PURE__*/ new H(), Ds = /*@__PURE__*/ new H(), Os = /*@__PURE__*/ new ri(), ks = class extends q {
constructor(e = null, t = 1) {
if (super(), this.type = "EdgesGeometry", this.parameters = {
geometry: e,
thresholdAngle: t
}, e !== null) {
let n = 10 ** 4, r = Math.cos(fn * t), i = e.getIndex(), a = e.getAttribute("position"), o = i ? i.count : a.count, s = [
0,
0,
0
], c = [
"a",
"b",
"c"
], l = [
,
,
,
], u = {}, d = [];
for (let e = 0; e < o; e += 3) {
i ? (s[0] = i.getX(e), s[1] = i.getX(e + 1), s[2] = i.getX(e + 2)) : (s[0] = e, s[1] = e + 1, s[2] = e + 2);
let { a: t, b: o, c: f } = Os;
if (t.fromBufferAttribute(a, s[0]), o.fromBufferAttribute(a, s[1]), f.fromBufferAttribute(a, s[2]), Os.getNormal(Ds), l[0] = `${Math.round(t.x * n)},${Math.round(t.y * n)},${Math.round(t.z * n)}`, l[1] = `${Math.round(o.x * n)},${Math.round(o.y * n)},${Math.round(o.z * n)}`, l[2] = `${Math.round(f.x * n)},${Math.round(f.y * n)},${Math.round(f.z * n)}`, !(l[0] === l[1] || l[1] === l[2] || l[2] === l[0])) for (let e = 0; e < 3; e++) {
let t = (e + 1) % 3, n = l[e], i = l[t], a = Os[c[e]], o = Os[c[t]], f = `${n}_${i}`, p = `${i}_${n}`;
p in u && u[p] ? (Ds.dot(u[p].normal) <= r && (d.push(a.x, a.y, a.z), d.push(o.x, o.y, o.z)), u[p] = null) : f in u || (u[f] = {
index0: s[e],
index1: s[t],
normal: Ds.clone()
});
}
}
for (let e in u) if (u[e]) {
let { index0: t, index1: n } = u[e];
Ts.fromBufferAttribute(a, t), Es.fromBufferAttribute(a, n), d.push(Ts.x, Ts.y, Ts.z), d.push(Es.x, Es.y, Es.z);
}
this.setAttribute("position", new K(d, 3));
}
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
}, As = class {
constructor() {
this.type = "Curve", this.arcLengthDivisions = 200, this.needsUpdate = !1, this.cacheArcLengths = null;
}
getPoint() {
L("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, r = this.getPoint(0), i = 0;
t.push(0);
for (let a = 1; a <= e; a++) n = this.getPoint(a / e), i += n.distanceTo(r), t.push(i), r = n;
return this.cacheArcLengths = t, t;
}
updateArcLengths() {
this.needsUpdate = !0, this.getLengths();
}
getUtoTmapping(e, t = null) {
let n = this.getLengths(), r = 0, i = n.length, a;
a = t || e * n[i - 1];
let o = 0, s = i - 1, c;
for (; o <= s;) if (r = Math.floor(o + (s - o) / 2), c = n[r] - a, c < 0) o = r + 1;
else if (c > 0) s = r - 1;
else {
s = r;
break;
}
if (r = s, n[r] === a) return r / (i - 1);
let l = n[r], u = n[r + 1] - l, d = (a - l) / u;
return (r + d) / (i - 1);
}
getTangent(e, t) {
let n = 1e-4, r = e - n, i = e + n;
r < 0 && (r = 0), i > 1 && (i = 1);
let a = this.getPoint(r), o = this.getPoint(i), s = t || (a.isVector2 ? new V() : new H());
return s.copy(o).sub(a).normalize(), s;
}
getTangentAt(e, t) {
let n = this.getUtoTmapping(e);
return this.getTangent(n, t);
}
computeFrenetFrames(e, t = !1) {
let n = new H(), r = [], i = [], a = [], o = new H(), s = new W();
for (let t = 0; t <= e; t++) {
let n = t / e;
r[t] = this.getTangentAt(n, new H());
}
i[0] = new H(), a[0] = new H();
let c = Number.MAX_VALUE, l = Math.abs(r[0].x), u = Math.abs(r[0].y), d = Math.abs(r[0].z);
l <= c && (c = l, n.set(1, 0, 0)), u <= c && (c = u, n.set(0, 1, 0)), d <= c && n.set(0, 0, 1), o.crossVectors(r[0], n).normalize(), i[0].crossVectors(r[0], o), a[0].crossVectors(r[0], i[0]);
for (let t = 1; t <= e; t++) {
if (i[t] = i[t - 1].clone(), a[t] = a[t - 1].clone(), o.crossVectors(r[t - 1], r[t]), o.length() > 2 ** -52) {
o.normalize();
let e = Math.acos(z(r[t - 1].dot(r[t]), -1, 1));
i[t].applyMatrix4(s.makeRotationAxis(o, e));
}
a[t].crossVectors(r[t], i[t]);
}
if (t === !0) {
let t = Math.acos(z(i[0].dot(i[e]), -1, 1));
t /= e, r[0].dot(o.crossVectors(i[0], i[e])) > 0 && (t = -t);
for (let n = 1; n <= e; n++) i[n].applyMatrix4(s.makeRotationAxis(r[n], t * n)), a[n].crossVectors(r[n], i[n]);
}
return {
tangents: r,
normals: i,
binormals: a
};
}
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;
}
}, js = class extends As {
constructor(e = 0, t = 0, n = 1, r = 1, i = 0, a = Math.PI * 2, o = !1, s = 0) {
super(), this.isEllipseCurve = !0, this.type = "EllipseCurve", this.aX = e, this.aY = t, this.xRadius = n, this.yRadius = r, this.aStartAngle = i, this.aEndAngle = a, this.aClockwise = o, this.aRotation = s;
}
getPoint(e, t = new V()) {
let n = t, r = Math.PI * 2, i = this.aEndAngle - this.aStartAngle, a = Math.abs(i) < 2 ** -52;
for (; i < 0;) i += r;
for (; i > r;) i -= r;
i < 2 ** -52 && (i = a ? 0 : r), this.aClockwise === !0 && !a && (i === r ? i = -r : i -= r);
let o = this.aStartAngle + e * i, s = this.aX + this.xRadius * Math.cos(o), c = this.aY + this.yRadius * Math.sin(o);
if (this.aRotation !== 0) {
let e = Math.cos(this.aRotation), t = Math.sin(this.aRotation), n = s - this.aX, r = c - this.aY;
s = n * e - r * t + this.aX, c = n * t + r * e + this.aY;
}
return n.set(s, c);
}
copy(e) {
return super.copy(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this;
}
toJSON() {
let e = super.toJSON();
return e.aX = this.aX, e.aY = this.aY, e.xRadius = this.xRadius, e.yRadius = this.yRadius, e.aStartAngle = this.aStartAngle, e.aEndAngle = this.aEndAngle, e.aClockwise = this.aClockwise, e.aRotation = this.aRotation, e;
}
fromJSON(e) {
return super.fromJSON(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this;
}
}, Ms = class extends js {
constructor(e, t, n, r, i, a) {
super(e, t, n, n, r, i, a), this.isArcCurve = !0, this.type = "ArcCurve";
}
};
function Ns() {
let e = 0, t = 0, n = 0, r = 0;
function i(i, a, o, s) {
e = i, t = o, n = -3 * i + 3 * a - 2 * o - s, r = 2 * i - 2 * a + o + s;
}
return {
initCatmullRom: function(e, t, n, r, a) {
i(t, n, a * (n - e), a * (r - t));
},
initNonuniformCatmullRom: function(e, t, n, r, a, o, s) {
let c = (t - e) / a - (n - e) / (a + o) + (n - t) / o, l = (n - t) / o - (r - t) / (o + s) + (r - n) / s;
c *= o, l *= o, i(t, n, c, l);
},
calc: function(i) {
let a = i * i, o = a * i;
return e + t * i + n * a + r * o;
}
};
}
var Ps = /*@__PURE__*/ new H(), Fs = /*@__PURE__*/ new H(), Is = /*@__PURE__*/ new Ns(), Ls = /*@__PURE__*/ new Ns(), Rs = /*@__PURE__*/ new Ns(), zs = class extends As {
constructor(e = [], t = !1, n = "centripetal", r = .5) {
super(), this.isCatmullRomCurve3 = !0, this.type = "CatmullRomCurve3", this.points = e, this.closed = t, this.curveType = n, this.tension = r;
}
getPoint(e, t = new H()) {
let n = t, r = this.points, i = r.length, a = (i - +!this.closed) * e, o = Math.floor(a), s = a - o;
this.closed ? o += o > 0 ? 0 : (Math.floor(Math.abs(o) / i) + 1) * i : s === 0 && o === i - 1 && (o = i - 2, s = 1);
let c, l;
this.closed || o > 0 ? c = r[(o - 1) % i] : (Fs.subVectors(r[0], r[1]).add(r[0]), c = Fs);
let u = r[o % i], d = r[(o + 1) % i];
if (this.closed || o + 2 < i ? l = r[(o + 2) % i] : (Ps.subVectors(r[i - 1], r[i - 2]).add(r[i - 1]), l = Ps), this.curveType === "centripetal" || this.curveType === "chordal") {
let e = this.curveType === "chordal" ? .5 : .25, t = c.distanceToSquared(u) ** +e, n = u.distanceToSquared(d) ** +e, r = d.distanceToSquared(l) ** +e;
n < 1e-4 && (n = 1), t < 1e-4 && (t = n), r < 1e-4 && (r = n), Is.initNonuniformCatmullRom(c.x, u.x, d.x, l.x, t, n, r), Ls.initNonuniformCatmullRom(c.y, u.y, d.y, l.y, t, n, r), Rs.initNonuniformCatmullRom(c.z, u.z, d.z, l.z, t, n, r);
} else this.curveType === "catmullrom" && (Is.initCatmullRom(c.x, u.x, d.x, l.x, this.tension), Ls.initCatmullRom(c.y, u.y, d.y, l.y, this.tension), Rs.initCatmullRom(c.z, u.z, d.z, l.z, this.tension));
return n.set(Is.calc(s), Ls.calc(s), Rs.calc(s)), n;
}
copy(e) {
super.copy(e), this.points = [];
for (let t = 0, n = e.points.length; t < n; t++) {
let n = e.points[t];
this.points.push(n.clone());
}
return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this;
}
toJSON() {
let e = super.toJSON();
e.points = [];
for (let t = 0, n = this.points.length; t < n; t++) {
let n = this.points[t];
e.points.push(n.toArray());
}
return e.closed = this.closed, e.curveType = this.curveType, e.tension = this.tension, e;
}
fromJSON(e) {
super.fromJSON(e), this.points = [];
for (let t = 0, n = e.points.length; t < n; t++) {
let n = e.points[t];
this.points.push(new H().fromArray(n));
}
return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this;
}
};
function Bs(e, t, n, r, i) {
let a = (r - t) * .5, o = (i - n) * .5, s = e * e, c = e * s;
return (2 * n - 2 * r + a + o) * c + (-3 * n + 3 * r - 2 * a - o) * s + a * e + n;
}
function Vs(e, t) {
let n = 1 - e;
return n * n * t;
}
function Hs(e, t) {
return 2 * (1 - e) * e * t;
}
function Us(e, t) {
return e * e * t;
}
function Ws(e, t, n, r) {
return Vs(e, t) + Hs(e, n) + Us(e, r);
}
function Gs(e, t) {
let n = 1 - e;
return n * n * n * t;
}
function Ks(e, t) {
let n = 1 - e;
return 3 * n * n * e * t;
}
function qs(e, t) {
return 3 * (1 - e) * e * e * t;
}
function Js(e, t) {
return e * e * e * t;
}
function Ys(e, t, n, r, i) {
return Gs(e, t) + Ks(e, n) + qs(e, r) + Js(e, i);
}
var Xs = class extends As {
constructor(e = new V(), t = new V(), n = new V(), r = new V()) {
super(), this.isCubicBezierCurve = !0, this.type = "CubicBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = r;
}
getPoint(e, t = new V()) {
let n = t, r = this.v0, i = this.v1, a = this.v2, o = this.v3;
return n.set(Ys(e, r.x, i.x, a.x, o.x), Ys(e, r.y, i.y, a.y, o.y)), n;
}
copy(e) {
return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this;
}
toJSON() {
let e = super.toJSON();
return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e;
}
fromJSON(e) {
return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this;
}
}, Zs = class extends As {
constructor(e = new H(), t = new H(), n = new H(), r = new H()) {
super(), this.isCubicBezierCurve3 = !0, this.type = "CubicBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = r;
}
getPoint(e, t = new H()) {
let n = t, r = this.v0, i = this.v1, a = this.v2, o = this.v3;
return n.set(Ys(e, r.x, i.x, a.x, o.x), Ys(e, r.y, i.y, a.y, o.y), Ys(e, r.z, i.z, a.z, o.z)), n;
}
copy(e) {
return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this;
}
toJSON() {
let e = super.toJSON();
return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e;
}
fromJSON(e) {
return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this;
}
}, Qs = class extends As {
constructor(e = new V(), t = new V()) {
super(), this.isLineCurve = !0, this.type = "LineCurve", this.v1 = e, this.v2 = t;
}
getPoint(e, t = new V()) {
let n = t;
return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n;
}
getPointAt(e, t) {
return this.getPoint(e, t);
}
getTangent(e, t = new V()) {
return t.subVectors(this.v2, this.v1).normalize();
}
getTangentAt(e, t) {
return this.getTangent(e, t);
}
copy(e) {
return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
}
toJSON() {
let e = super.toJSON();
return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e;
}
fromJSON(e) {
return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
}
}, $s = class extends As {
constructor(e = new H(), t = new H()) {
super(), this.isLineCurve3 = !0, this.type = "LineCurve3", this.v1 = e, this.v2 = t;
}
getPoint(e, t = new H()) {
let n = t;
return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n;
}
getPointAt(e, t) {
return this.getPoint(e, t);
}
getTangent(e, t = new H()) {
return t.subVectors(this.v2, this.v1).normalize();
}
getTangentAt(e, t) {
return this.getTangent(e, t);
}
copy(e) {
return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
}
toJSON() {
let e = super.toJSON();
return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e;
}
fromJSON(e) {
return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
}
}, ec = class extends As {
constructor(e = new V(), t = new V(), n = new V()) {
super(), this.isQuadraticBezierCurve = !0, this.type = "QuadraticBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n;
}
getPoint(e, t = new V()) {
let n = t, r = this.v0, i = this.v1, a = this.v2;
return n.set(Ws(e, r.x, i.x, a.x), Ws(e, r.y, i.y, a.y)), n;
}
copy(e) {
return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
}
toJSON() {
let e = super.toJSON();
return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e;
}
fromJSON(e) {
return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
}
}, tc = class extends As {
constructor(e = new H(), t = new H(), n = new H()) {
super(), this.isQuadraticBezierCurve3 = !0, this.type = "QuadraticBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n;
}
getPoint(e, t = new H()) {
let n = t, r = this.v0, i = this.v1, a = this.v2;
return n.set(Ws(e, r.x, i.x, a.x), Ws(e, r.y, i.y, a.y), Ws(e, r.z, i.z, a.z)), n;
}
copy(e) {
return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
}
toJSON() {
let e = super.toJSON();
return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e;
}
fromJSON(e) {
return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
}
}, nc = class extends As {
constructor(e = []) {
super(), this.isSplineCurve = !0, this.type = "SplineCurve", this.points = e;
}
getPoint(e, t = new V()) {
let n = t, r = this.points, i = (r.length - 1) * e, a = Math.floor(i), o = i - a, s = r[a === 0 ? a : a - 1], c = r[a], l = r[a > r.length - 2 ? r.length - 1 : a + 1], u = r[a > r.length - 3 ? r.length - 1 : a + 2];
return n.set(Bs(o, s.x, c.x, l.x, u.x), Bs(o, s.y, c.y, l.y, u.y)), n;
}
copy(e) {
super.copy(e), this.points = [];
for (let t = 0, n = e.points.length; t < n; t++) {
let n = e.points[t];
this.points.push(n.clone());
}
return this;
}
toJSON() {
let e = super.toJSON();
e.points = [];
for (let t = 0, n = this.points.length; t < n; t++) {
let n = this.points[t];
e.points.push(n.toArray());
}
return e;
}
fromJSON(e) {
super.fromJSON(e), this.points = [];
for (let t = 0, n = e.points.length; t < n; t++) {
let n = e.points[t];
this.points.push(new V().fromArray(n));
}
return this;
}
}, rc = /*#__PURE__*/ Object.freeze({
__proto__: null,
ArcCurve: Ms,
CatmullRomCurve3: zs,
CubicBezierCurve: Xs,
CubicBezierCurve3: Zs,
EllipseCurve: js,
LineCurve: Qs,
LineCurve3: $s,
QuadraticBezierCurve: ec,
QuadraticBezierCurve3: tc,
SplineCurve: nc
}), ic = class extends As {
constructor() {
super(), this.type = "CurvePath", this.curves = [], this.autoClose = !1;
}
add(e) {
this.curves.push(e);
}
closePath() {
let e = this.curves[0].getPoint(0), t = this.curves[this.curves.length - 1].getPoint(1);
if (!e.equals(t)) {
let n = e.isVector2 === !0 ? "LineCurve" : "LineCurve3";
this.curves.push(new rc[n](t, e));
}
return this;
}
getPoint(e, t) {
let n = e * this.getLength(), r = this.getCurveLengths(), i = 0;
for (; i < r.length;) {
if (r[i] >= n) {
let e = r[i] - n, a = this.curves[i], o = a.getLength(), s = o === 0 ? 0 : 1 - e / o;
return a.getPointAt(s, t);
}
i++;
}
return null;
}
getLength() {
let e = this.getCurveLengths();
return e[e.length - 1];
}
updateArcLengths() {
this.needsUpdate = !0, this.cacheLengths = null, this.getCurveLengths();
}
getCurveLengths() {
if (this.cacheLengths && this.cacheLengths.length === this.curves.length) return this.cacheLengths;
let e = [], t = 0;
for (let n = 0, r = this.curves.length; n < r; n++) t += this.curves[n].getLength(), e.push(t);
return this.cacheLengths = e, e;
}
getSpacedPoints(e = 40) {
let t = [];
for (let n = 0; n <= e; n++) t.push(this.getPoint(n / e));
return this.autoClose && t.push(t[0]), t;
}
getPoints(e = 12) {
let t = [], n;
for (let r = 0, i = this.curves; r < i.length; r++) {
let a = i[r], o = a.isEllipseCurve ? e * 2 : a.isLineCurve || a.isLineCurve3 ? 1 : a.isSplineCurve ? e * a.points.length : e, s = a.getPoints(o);
for (let e = 0; e < s.length; e++) {
let r = s[e];
n && n.equals(r) || (t.push(r), n = r);
}
}
return this.autoClose && t.length > 1 && !t[t.length - 1].equals(t[0]) && t.push(t[0]), t;
}
copy(e) {
super.copy(e), this.curves = [];
for (let t = 0, n = e.curves.length; t < n; t++) {
let n = e.curves[t];
this.curves.push(n.clone());
}
return this.autoClose = e.autoClose, this;
}
toJSON() {
let e = super.toJSON();
e.autoClose = this.autoClose, e.curves = [];
for (let t = 0, n = this.curves.length; t < n; t++) {
let n = this.curves[t];
e.curves.push(n.toJSON());
}
return e;
}
fromJSON(e) {
super.fromJSON(e), this.autoClose = e.autoClose, this.curves = [];
for (let t = 0, n = e.curves.length; t < n; t++) {
let n = e.curves[t];
this.curves.push(new rc[n.type]().fromJSON(n));
}
return this;
}
}, ac = class extends ic {
constructor(e) {
super(), this.type = "Path", this.currentPoint = new V(), e && this.setFromPoints(e);
}
setFromPoints(e) {
this.moveTo(e[0].x, e[0].y);
for (let t = 1, n = e.length; t < n; t++) this.lineTo(e[t].x, e[t].y);
return this;
}
moveTo(e, t) {
return this.currentPoint.set(e, t), this;
}
lineTo(e, t) {
let n = new Qs(this.currentPoint.clone(), new V(e, t));
return this.curves.push(n), this.currentPoint.set(e, t), this;
}
quadraticCurveTo(e, t, n, r) {
let i = new ec(this.currentPoint.clone(), new V(e, t), new V(n, r));
return this.curves.push(i), this.currentPoint.set(n, r), this;
}
bezierCurveTo(e, t, n, r, i, a) {
let o = new Xs(this.currentPoint.clone(), new V(e, t), new V(n, r), new V(i, a));
return this.curves.push(o), this.currentPoint.set(i, a), this;
}
splineThru(e) {
let t = new nc([this.currentPoint.clone()].concat(e));
return this.curves.push(t), this.currentPoint.copy(e[e.length - 1]), this;
}
arc(e, t, n, r, i, a) {
let o = this.currentPoint.x, s = this.currentPoint.y;
return this.absarc(e + o, t + s, n, r, i, a), this;
}
absarc(e, t, n, r, i, a) {
return this.absellipse(e, t, n, n, r, i, a), this;
}
ellipse(e, t, n, r, i, a, o, s) {
let c = this.currentPoint.x, l = this.currentPoint.y;
return this.absellipse(e + c, t + l, n, r, i, a, o, s), this;
}
absellipse(e, t, n, r, i, a, o, s) {
let c = new js(e, t, n, r, i, a, o, s);
if (this.curves.length > 0) {
let e = c.getPoint(0);
e.equals(this.currentPoint) || this.lineTo(e.x, e.y);
}
this.curves.push(c);
let l = c.getPoint(1);
return this.currentPoint.copy(l), this;
}
copy(e) {
return super.copy(e), this.currentPoint.copy(e.currentPoint), this;
}
toJSON() {
let e = super.toJSON();
return e.currentPoint = this.currentPoint.toArray(), e;
}
fromJSON(e) {
return super.fromJSON(e), this.currentPoint.fromArray(e.currentPoint), this;
}
}, oc = class extends ac {
constructor(e) {
super(e), this.uuid = mn(), this.type = "Shape", this.holes = [];
}
getPointsHoles(e) {
let t = [];
for (let n = 0, r = this.holes.length; n < r; n++) t[n] = this.holes[n].getPoints(e);
return t;
}
extractPoints(e) {
return {
shape: this.getPoints(e),
holes: this.getPointsHoles(e)
};
}
copy(e) {
super.copy(e), this.holes = [];
for (let t = 0, n = e.holes.length; t < n; t++) {
let n = e.holes[t];
this.holes.push(n.clone());
}
return this;
}
toJSON() {
let e = super.toJSON();
e.uuid = this.uuid, e.holes = [];
for (let t = 0, n = this.holes.length; t < n; t++) {
let n = this.holes[t];
e.holes.push(n.toJSON());
}
return e;
}
fromJSON(e) {
super.fromJSON(e), this.uuid = e.uuid, this.holes = [];
for (let t = 0, n = e.holes.length; t < n; t++) {
let n = e.holes[t];
this.holes.push(new ac().fromJSON(n));
}
return this;
}
};
function sc(e, t, n = 2) {
let r = t && t.length, i = r ? t[0] * n : e.length, a = cc(e, 0, i, n, !0), o = [];
if (!a || a.next === a.prev) return o;
let s, c, l;
if (r && (a = hc(e, t, a, n)), e.length > 80 * n) {
s = e[0], c = e[1];
let t = s, r = c;
for (let a = n; a < i; a += n) {
let n = e[a], i = e[a + 1];
n < s && (s = n), i < c && (c = i), n > t && (t = n), i > r && (r = i);
}
l = Math.max(t - s, r - c), l = l === 0 ? 0 : 32767 / l;
}
return uc(a, o, n, s, c, l, 0), o;
}
function cc(e, t, n, r, i) {
let a;
if (i === zc(e, t, n, r) > 0) for (let i = t; i < n; i += r) a = Ic(i / r | 0, e[i], e[i + 1], a);
else for (let i = n - r; i >= t; i -= r) a = Ic(i / r | 0, e[i], e[i + 1], a);
return a && Oc(a, a.next) && (Lc(a), a = a.next), a;
}
function lc(e, t) {
if (!e) return e;
t || (t = e);
let n = e, r;
do
if (r = !1, !n.steiner && (Oc(n, n.next) || Dc(n.prev, n, n.next) === 0)) {
if (Lc(n), n = t = n.prev, n === n.next) break;
r = !0;
} else n = n.next;
while (r || n !== t);
return t;
}
function uc(e, t, n, r, i, a, o) {
if (!e) return;
!o && a && bc(e, r, i, a);
let s = e;
for (; e.prev !== e.next;) {
let c = e.prev, l = e.next;
if (a ? fc(e, r, i, a) : dc(e)) {
t.push(c.i, e.i, l.i), Lc(e), e = l.next, s = l.next;
continue;
}
if (e = l, e === s) {
o ? o === 1 ? (e = pc(lc(e), t), uc(e, t, n, r, i, a, 2)) : o === 2 && mc(e, t, n, r, i, a) : uc(lc(e), t, n, r, i, a, 1);
break;
}
}
}
function dc(e) {
let t = e.prev, n = e, r = e.next;
if (Dc(t, n, r) >= 0) return !1;
let i = t.x, a = n.x, o = r.x, s = t.y, c = n.y, l = r.y, u = Math.min(i, a, o), d = Math.min(s, c, l), f = Math.max(i, a, o), p = Math.max(s, c, l), m = r.next;
for (; m !== t;) {
if (m.x >= u && m.x <= f && m.y >= d && m.y <= p && Tc(i, s, a, c, o, l, m.x, m.y) && Dc(m.prev, m, m.next) >= 0) return !1;
m = m.next;
}
return !0;
}
function fc(e, t, n, r) {
let i = e.prev, a = e, o = e.next;
if (Dc(i, a, o) >= 0) return !1;
let s = i.x, c = a.x, l = o.x, u = i.y, d = a.y, f = o.y, p = Math.min(s, c, l), m = Math.min(u, d, f), h = Math.max(s, c, l), g = Math.max(u, d, f), _ = Sc(p, m, t, n, r), v = Sc(h, g, t, n, r), y = e.prevZ, b = e.nextZ;
for (; y && y.z >= _ && b && b.z <= v;) {
if (y.x >= p && y.x <= h && y.y >= m && y.y <= g && y !== i && y !== o && Tc(s, u, c, d, l, f, y.x, y.y) && Dc(y.prev, y, y.next) >= 0 || (y = y.prevZ, b.x >= p && b.x <= h && b.y >= m && b.y <= g && b !== i && b !== o && Tc(s, u, c, d, l, f, b.x, b.y) && Dc(b.prev, b, b.next) >= 0)) return !1;
b = b.nextZ;
}
for (; y && y.z >= _;) {
if (y.x >= p && y.x <= h && y.y >= m && y.y <= g && y !== i && y !== o && Tc(s, u, c, d, l, f, y.x, y.y) && Dc(y.prev, y, y.next) >= 0) return !1;
y = y.prevZ;
}
for (; b && b.z <= v;) {
if (b.x >= p && b.x <= h && b.y >= m && b.y <= g && b !== i && b !== o && Tc(s, u, c, d, l, f, b.x, b.y) && Dc(b.prev, b, b.next) >= 0) return !1;
b = b.nextZ;
}
return !0;
}
function pc(e, t) {
let n = e;
do {
let r = n.prev, i = n.next.next;
!Oc(r, i) && kc(r, n, n.next, i) && Nc(r, i) && Nc(i, r) && (t.push(r.i, n.i, i.i), Lc(n), Lc(n.next), n = e = i), n = n.next;
} while (n !== e);
return lc(n);
}
function mc(e, t, n, r, i, a) {
let o = e;
do {
let e = o.next.next;
for (; e !== o.prev;) {
if (o.i !== e.i && Ec(o, e)) {
let s = Fc(o, e);
o = lc(o, o.next), s = lc(s, s.next), uc(o, t, n, r, i, a, 0), uc(s, t, n, r, i, a, 0);
return;
}
e = e.next;
}
o = o.next;
} while (o !== e);
}
function hc(e, t, n, r) {
let i = [];
for (let n = 0, a = t.length; n < a; n++) {
let o = cc(e, t[n] * r, n < a - 1 ? t[n + 1] * r : e.length, r, !1);
o === o.next && (o.steiner = !0), i.push(Cc(o));
}
i.sort(gc);
for (let e = 0; e < i.length; e++) n = _c(i[e], n);
return n;
}
function gc(e, t) {
let n = e.x - t.x;
return n === 0 && (n = e.y - t.y, n === 0 && (n = (e.next.y - e.y) / (e.next.x - e.x) - (t.next.y - t.y) / (t.next.x - t.x))), n;
}
function _c(e, t) {
let n = vc(e, t);
if (!n) return t;
let r = Fc(n, e);
return lc(r, r.next), lc(n, n.next);
}
function vc(e, t) {
let n = t, r = e.x, i = e.y, a = -Infinity, o;
if (Oc(e, n)) return n;
do {
if (Oc(e, n.next)) return n.next;
if (i <= n.y && i >= n.next.y && n.next.y !== n.y) {
let e = n.x + (i - n.y) * (n.next.x - n.x) / (n.next.y - n.y);
if (e <= r && e > a && (a = e, o = n.x < n.next.x ? n : n.next, e === r)) return o;
}
n = n.next;
} while (n !== t);
if (!o) return null;
let s = o, c = o.x, l = o.y, u = Infinity;
n = o;
do {
if (r >= n.x && n.x >= c && r !== n.x && wc(i < l ? r : a, i, c, l, i < l ? a : r, i, n.x, n.y)) {
let t = Math.abs(i - n.y) / (r - n.x);
Nc(n, e) && (t < u || t === u && (n.x > o.x || n.x === o.x && yc(o, n))) && (o = n, u = t);
}
n = n.next;
} while (n !== s);
return o;
}
function yc(e, t) {
return Dc(e.prev, e, t.prev) < 0 && Dc(t.next, e, e.next) < 0;
}
function bc(e, t, n, r) {
let i = e;
do
i.z === 0 && (i.z = Sc(i.x, i.y, t, n, r)), i.prevZ = i.prev, i.nextZ = i.next, i = i.next;
while (i !== e);
i.prevZ.nextZ = null, i.prevZ = null, xc(i);
}
function xc(e) {
let t, n = 1;
do {
let r = e, i;
e = null;
let a = null;
for (t = 0; r;) {
t++;
let o = r, s = 0;
for (let e = 0; e < n && (s++, o = o.nextZ, o); e++);
let c = n;
for (; s > 0 || c > 0 && o;) s !== 0 && (c === 0 || !o || r.z <= o.z) ? (i = r, r = r.nextZ, s--) : (i = o, o = o.nextZ, c--), a ? a.nextZ = i : e = i, i.prevZ = a, a = i;
r = o;
}
a.nextZ = null, n *= 2;
} while (t > 1);
return e;
}
function Sc(e, t, n, r, i) {
return e = (e - n) * i | 0, t = (t - r) * i | 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 Cc(e) {
let t = e, n = e;
do
(t.x < n.x || t.x === n.x && t.y < n.y) && (n = t), t = t.next;
while (t !== e);
return n;
}
function wc(e, t, n, r, i, a, o, s) {
return (i - o) * (t - s) >= (e - o) * (a - s) && (e - o) * (r - s) >= (n - o) * (t - s) && (n - o) * (a - s) >= (i - o) * (r - s);
}
function Tc(e, t, n, r, i, a, o, s) {
return !(e === o && t === s) && wc(e, t, n, r, i, a, o, s);
}
function Ec(e, t) {
return e.next.i !== t.i && e.prev.i !== t.i && !Mc(e, t) && (Nc(e, t) && Nc(t, e) && Pc(e, t) && (Dc(e.prev, e, t.prev) || Dc(e, t.prev, t)) || Oc(e, t) && Dc(e.prev, e, e.next) > 0 && Dc(t.prev, t, t.next) > 0);
}
function Dc(e, t, n) {
return (t.y - e.y) * (n.x - t.x) - (t.x - e.x) * (n.y - t.y);
}
function Oc(e, t) {
return e.x === t.x && e.y === t.y;
}
function kc(e, t, n, r) {
let i = jc(Dc(e, t, n)), a = jc(Dc(e, t, r)), o = jc(Dc(n, r, e)), s = jc(Dc(n, r, t));
return !!(i !== a && o !== s || i === 0 && Ac(e, n, t) || a === 0 && Ac(e, r, t) || o === 0 && Ac(n, e, r) || s === 0 && Ac(n, t, r));
}
function Ac(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 jc(e) {
return e > 0 ? 1 : e < 0 ? -1 : 0;
}
function Mc(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 && kc(n, n.next, e, t)) return !0;
n = n.next;
} while (n !== e);
return !1;
}
function Nc(e, t) {
return Dc(e.prev, e, e.next) < 0 ? Dc(e, t, e.next) >= 0 && Dc(e, e.prev, t) >= 0 : Dc(e, t, e.prev) < 0 || Dc(e, e.next, t) < 0;
}
function Pc(e, t) {
let n = e, r = !1, i = (e.x + t.x) / 2, a = (e.y + t.y) / 2;
do
n.y > a != n.next.y > a && n.next.y !== n.y && i < (n.next.x - n.x) * (a - n.y) / (n.next.y - n.y) + n.x && (r = !r), n = n.next;
while (n !== e);
return r;
}
function Fc(e, t) {
let n = Rc(e.i, e.x, e.y), r = Rc(t.i, t.x, t.y), i = e.next, a = t.prev;
return e.next = t, t.prev = e, n.next = i, i.prev = n, r.next = n, n.prev = r, a.next = r, r.prev = a, r;
}
function Ic(e, t, n, r) {
let i = Rc(e, t, n);
return r ? (i.next = r.next, i.prev = r, r.next.prev = i, r.next = i) : (i.prev = i, i.next = i), i;
}
function Lc(e) {
e.next.prev = e.prev, e.prev.next = e.next, e.prevZ && (e.prevZ.nextZ = e.nextZ), e.nextZ && (e.nextZ.prevZ = e.prevZ);
}
function Rc(e, t, n) {
return {
i: e,
x: t,
y: n,
prev: null,
next: null,
z: 0,
prevZ: null,
nextZ: null,
steiner: !1
};
}
function zc(e, t, n, r) {
let i = 0;
for (let a = t, o = n - r; a < n; a += r) i += (e[o] - e[a]) * (e[a + 1] + e[o + 1]), o = a;
return i;
}
var Bc = class {
static triangulate(e, t, n = 2) {
return sc(e, t, n);
}
}, Vc = class e {
static area(e) {
let t = e.length, n = 0;
for (let r = t - 1, i = 0; i < t; r = i++) n += e[r].x * e[i].y - e[i].x * e[r].y;
return n * .5;
}
static isClockWise(t) {
return e.area(t) < 0;
}
static triangulateShape(e, t) {
let n = [], r = [], i = [];
Hc(e), Uc(n, e);
let a = e.length;
t.forEach(Hc);
for (let e = 0; e < t.length; e++) r.push(a), a += t[e].length, Uc(n, t[e]);
let o = Bc.triangulate(n, r);
for (let e = 0; e < o.length; e += 3) i.push(o.slice(e, e + 3));
return i;
}
};
function Hc(e) {
let t = e.length;
t > 2 && e[t - 1].equals(e[0]) && e.pop();
}
function Uc(e, t) {
for (let n = 0; n < t.length; n++) e.push(t[n].x), e.push(t[n].y);
}
var Wc = class e extends q {
constructor(e = new oc([
new V(.5, .5),
new V(-.5, .5),
new V(-.5, -.5),
new V(.5, -.5)
]), t = {}) {
super(), this.type = "ExtrudeGeometry", this.parameters = {
shapes: e,
options: t
}, e = Array.isArray(e) ? e : [e];
let n = this, r = [], i = [];
for (let t = 0, n = e.length; t < n; t++) {
let n = e[t];
a(n);
}
this.setAttribute("position", new K(r, 3)), this.setAttribute("uv", new K(i, 2)), this.computeVertexNormals();
function a(e) {
let a = [], o = t.curveSegments === void 0 ? 12 : t.curveSegments, s = t.steps === void 0 ? 1 : t.steps, c = t.depth === void 0 ? 1 : t.depth, l = t.bevelEnabled === void 0 || t.bevelEnabled, u = t.bevelThickness === void 0 ? .2 : t.bevelThickness, d = t.bevelSize === void 0 ? u - .1 : t.bevelSize, f = t.bevelOffset === void 0 ? 0 : t.bevelOffset, p = t.bevelSegments === void 0 ? 3 : t.bevelSegments, m = t.extrudePath, h = t.UVGenerator === void 0 ? Gc : t.UVGenerator, g, _ = !1, v, y, b, x;
if (m) {
g = m.getSpacedPoints(s), _ = !0, l = !1;
let e = m.isCatmullRomCurve3 ? m.closed : !1;
v = m.computeFrenetFrames(s, e), y = new H(), b = new H(), x = new H();
}
l || (p = 0, u = 0, d = 0, f = 0);
let S = e.extractPoints(o), C = S.shape, w = S.holes;
if (!Vc.isClockWise(C)) {
C = C.reverse();
for (let e = 0, t = w.length; e < t; e++) {
let t = w[e];
Vc.isClockWise(t) && (w[e] = t.reverse());
}
}
function T(e) {
let t = e[0];
for (let n = 1; n <= e.length; n++) {
let r = n % e.length, i = e[r], a = i.x - t.x, o = i.y - t.y, s = a * a + o * o, c = Math.max(Math.abs(i.x), Math.abs(i.y), Math.abs(t.x), Math.abs(t.y));
if (s <= 10000000000000001e-36 * c * c) {
e.splice(r, 1), n--;
continue;
}
t = i;
}
}
T(C), w.forEach(T);
let E = w.length, D = C;
for (let e = 0; e < E; e++) {
let t = w[e];
C = C.concat(t);
}
function O(e, t, n) {
return t || R("ExtrudeGeometry: vec does not exist"), e.clone().addScaledVector(t, n);
}
let k = C.length;
function A(e, t, n) {
let r, i, a, o = e.x - t.x, s = e.y - t.y, c = n.x - e.x, l = n.y - e.y, u = o * o + s * s, d = o * l - s * c;
if (Math.abs(d) > 2 ** -52) {
let d = Math.sqrt(u), f = Math.sqrt(c * c + l * l), p = t.x - s / d, m = t.y + o / d, h = n.x - l / f, g = n.y + c / f, _ = ((h - p) * l - (g - m) * c) / (o * l - s * c);
r = p + o * _ - e.x, i = m + s * _ - e.y;
let v = r * r + i * i;
if (v <= 2) return new V(r, i);
a = Math.sqrt(v / 2);
} else {
let e = !1;
o > 2 ** -52 ? c > 2 ** -52 && (e = !0) : o < -(2 ** -52) ? c < -(2 ** -52) && (e = !0) : Math.sign(s) === Math.sign(l) && (e = !0), e ? (r = -s, i = o, a = Math.sqrt(u)) : (r = o, i = s, a = Math.sqrt(u / 2));
}
return new V(r / a, i / a);
}
let ee = [];
for (let e = 0, t = D.length, n = t - 1, r = e + 1; e < t; e++, n++, r++) n === t && (n = 0), r === t && (r = 0), ee[e] = A(D[e], D[n], D[r]);
let te = [], ne, j = ee.concat();
for (let e = 0, t = E; e < t; e++) {
let t = w[e];
ne = [];
for (let e = 0, n = t.length, r = n - 1, i = e + 1; e < n; e++, r++, i++) r === n && (r = 0), i === n && (i = 0), ne[e] = A(t[e], t[r], t[i]);
te.push(ne), j = j.concat(ne);
}
let M;
if (p === 0) M = Vc.triangulateShape(D, w);
else {
let e = [], t = [];
for (let n = 0; n < p; n++) {
let r = n / p, i = u * Math.cos(r * Math.PI / 2), a = d * Math.sin(r * Math.PI / 2) + f;
for (let t = 0, n = D.length; t < n; t++) {
let n = O(D[t], ee[t], a);
N(n.x, n.y, -i), r === 0 && e.push(n);
}
for (let e = 0, n = E; e < n; e++) {
let n = w[e];
ne = te[e];
let o = [];
for (let e = 0, t = n.length; e < t; e++) {
let t = O(n[e], ne[e], a);
N(t.x, t.y, -i), r === 0 && o.push(t);
}
r === 0 && t.push(o);
}
}
M = Vc.triangulateShape(e, t);
}
let re = M.length, ie = d + f;
for (let e = 0; e < k; e++) {
let t = l ? O(C[e], j[e], ie) : C[e];
_ ? (b.copy(v.normals[0]).multiplyScalar(t.x), y.copy(v.binormals[0]).multiplyScalar(t.y), x.copy(g[0]).add(b).add(y), N(x.x, x.y, x.z)) : N(t.x, t.y, 0);
}
for (let e = 1; e <= s; e++) for (let t = 0; t < k; t++) {
let n = l ? O(C[t], j[t], ie) : C[t];
_ ? (b.copy(v.normals[e]).multiplyScalar(n.x), y.copy(v.binormals[e]).multiplyScalar(n.y), x.copy(g[e]).add(b).add(y), N(x.x, x.y, x.z)) : N(n.x, n.y, c / s * e);
}
for (let e = p - 1; e >= 0; e--) {
let t = e / p, n = u * Math.cos(t * Math.PI / 2), r = d * Math.sin(t * Math.PI / 2) + f;
for (let e = 0, t = D.length; e < t; e++) {
let t = O(D[e], ee[e], r);
N(t.x, t.y, c + n);
}
for (let e = 0, t = w.length; e < t; e++) {
let t = w[e];
ne = te[e];
for (let e = 0, i = t.length; e < i; e++) {
let i = O(t[e], ne[e], r);
_ ? N(i.x, i.y + g[s - 1].y, g[s - 1].x + n) : N(i.x, i.y, c + n);
}
}
}
ae(), oe();
function ae() {
let e = r.length / 3;
if (l) {
let e = 0, t = k * e;
for (let e = 0; e < re; e++) {
let n = M[e];
ce(n[2] + t, n[1] + t, n[0] + t);
}
e = s + p * 2, t = k * e;
for (let e = 0; e < re; e++) {
let n = M[e];
ce(n[0] + t, n[1] + t, n[2] + t);
}
} else {
for (let e = 0; e < re; e++) {
let t = M[e];
ce(t[2], t[1], t[0]);
}
for (let e = 0; e < re; e++) {
let t = M[e];
ce(t[0] + k * s, t[1] + k * s, t[2] + k * s);
}
}
n.addGroup(e, r.length / 3 - e, 0);
}
function oe() {
let e = r.length / 3, t = 0;
se(D, t), t += D.length;
for (let e = 0, n = w.length; e < n; e++) {
let n = w[e];
se(n, t), t += n.length;
}
n.addGroup(e, r.length / 3 - e, 1);
}
function se(e, t) {
let n = e.length;
for (; --n >= 0;) {
let r = n, i = n - 1;
i < 0 && (i = e.length - 1);
for (let e = 0, n = s + p * 2; e < n; e++) {
let n = k * e, a = k * (e + 1);
le(t + r + n, t + i + n, t + i + a, t + r + a);
}
}
}
function N(e, t, n) {
a.push(e), a.push(t), a.push(n);
}
function ce(e, t, i) {
ue(e), ue(t), ue(i);
let a = r.length / 3, o = h.generateTopUV(n, r, a - 3, a - 2, a - 1);
de(o[0]), de(o[1]), de(o[2]);
}
function le(e, t, i, a) {
ue(e), ue(t), ue(a), ue(t), ue(i), ue(a);
let o = r.length / 3, s = h.generateSideWallUV(n, r, o - 6, o - 3, o - 2, o - 1);
de(s[0]), de(s[1]), de(s[3]), de(s[1]), de(s[2]), de(s[3]);
}
function ue(e) {
r.push(a[e * 3 + 0]), r.push(a[e * 3 + 1]), r.push(a[e * 3 + 2]);
}
function de(e) {
i.push(e.x), i.push(e.y);
}
}
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
toJSON() {
let e = super.toJSON(), t = this.parameters.shapes, n = this.parameters.options;
return Kc(t, n, e);
}
static fromJSON(t, n) {
let r = [];
for (let e = 0, i = t.shapes.length; e < i; e++) {
let i = n[t.shapes[e]];
r.push(i);
}
let i = t.options.extrudePath;
return i !== void 0 && (t.options.extrudePath = new rc[i.type]().fromJSON(i)), new e(r, t.options);
}
}, Gc = {
generateTopUV: function(e, t, n, r, i) {
let a = t[n * 3], o = t[n * 3 + 1], s = t[r * 3], c = t[r * 3 + 1], l = t[i * 3], u = t[i * 3 + 1];
return [
new V(a, o),
new V(s, c),
new V(l, u)
];
},
generateSideWallUV: function(e, t, n, r, i, a) {
let o = t[n * 3], s = t[n * 3 + 1], c = t[n * 3 + 2], l = t[r * 3], u = t[r * 3 + 1], d = t[r * 3 + 2], f = t[i * 3], p = t[i * 3 + 1], m = t[i * 3 + 2], h = t[a * 3], g = t[a * 3 + 1], _ = t[a * 3 + 2];
return Math.abs(s - u) < Math.abs(o - l) ? [
new V(o, 1 - c),
new V(l, 1 - d),
new V(f, 1 - m),
new V(h, 1 - _)
] : [
new V(s, 1 - c),
new V(u, 1 - d),
new V(p, 1 - m),
new V(g, 1 - _)
];
}
};
function Kc(e, t, n) {
if (n.shapes = [], Array.isArray(e)) for (let t = 0, r = e.length; t < r; t++) {
let r = e[t];
n.shapes.push(r.uuid);
}
else n.shapes.push(e.uuid);
return n.options = Object.assign({}, t), t.extrudePath !== void 0 && (n.options.extrudePath = t.extrudePath.toJSON()), n;
}
var qc = class e extends Cs {
constructor(e = 1, t = 0) {
let n = (1 + Math.sqrt(5)) / 2, r = [
-1,
n,
0,
1,
n,
0,
-1,
-n,
0,
1,
-n,
0,
0,
-1,
n,
0,
1,
n,
0,
-1,
-n,
0,
1,
-n,
n,
0,
-1,
n,
0,
1,
-n,
0,
-1,
-n,
0,
1
];
super(r, [
0,
11,
5,
0,
5,
1,
0,
1,
7,
0,
7,
10,
0,
10,
11,
1,
5,
9,
5,
11,
4,
11,
10,
2,
10,
7,
6,
7,
1,
8,
3,
9,
4,
3,
4,
2,
3,
2,
6,
3,
6,
8,
3,
8,
9,
4,
9,
5,
2,
4,
11,
6,
2,
10,
8,
6,
7,
9,
8,
1
], e, t), this.type = "IcosahedronGeometry", this.parameters = {
radius: e,
detail: t
};
}
static fromJSON(t) {
return new e(t.radius, t.detail);
}
}, Jc = class e extends q {
constructor(e = [
new V(0, -.5),
new V(.5, 0),
new V(0, .5)
], t = 12, n = 0, r = Math.PI * 2) {
super(), this.type = "LatheGeometry", this.parameters = {
points: e,
segments: t,
phiStart: n,
phiLength: r
}, t = Math.floor(t), r = z(r, 0, Math.PI * 2);
let i = [], a = [], o = [], s = [], c = [], l = 1 / t, u = new H(), d = new V(), f = new H(), p = new H(), m = new H(), h = 0, g = 0;
for (let t = 0; t <= e.length - 1; t++) switch (t) {
case 0:
h = e[t + 1].x - e[t].x, g = e[t + 1].y - e[t].y, f.x = g * 1, f.y = -h, f.z = g * 0, m.copy(f), f.normalize(), s.push(f.x, f.y, f.z);
break;
case e.length - 1:
s.push(m.x, m.y, m.z);
break;
default: h = e[t + 1].x - e[t].x, g = e[t + 1].y - e[t].y, f.x = g * 1, f.y = -h, f.z = g * 0, p.copy(f), f.x += m.x, f.y += m.y, f.z += m.z, f.normalize(), s.push(f.x, f.y, f.z), m.copy(p);
}
for (let i = 0; i <= t; i++) {
let f = n + i * l * r, p = Math.sin(f), m = Math.cos(f);
for (let n = 0; n <= e.length - 1; n++) {
u.x = e[n].x * p, u.y = e[n].y, u.z = e[n].x * m, a.push(u.x, u.y, u.z), d.x = i / t, d.y = n / (e.length - 1), o.push(d.x, d.y);
let r = s[3 * n + 0] * p, l = s[3 * n + 1], f = s[3 * n + 0] * m;
c.push(r, l, f);
}
}
for (let n = 0; n < t; n++) for (let t = 0; t < e.length - 1; t++) {
let r = t + n * e.length, a = r, o = r + e.length, s = r + e.length + 1, c = r + 1;
i.push(a, o, c), i.push(s, c, o);
}
this.setIndex(i), this.setAttribute("position", new K(a, 3)), this.setAttribute("uv", new K(o, 2)), this.setAttribute("normal", new K(c, 3));
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.points, t.segments, t.phiStart, t.phiLength);
}
}, Yc = class e extends Cs {
constructor(e = 1, t = 0) {
super([
1,
0,
0,
-1,
0,
0,
0,
1,
0,
0,
-1,
0,
0,
0,
1,
0,
0,
-1
], [
0,
2,
4,
0,
4,
3,
0,
3,
5,
0,
5,
2,
1,
2,
5,
1,
5,
3,
1,
3,
4,
1,
4,
2
], e, t), this.type = "OctahedronGeometry", this.parameters = {
radius: e,
detail: t
};
}
static fromJSON(t) {
return new e(t.radius, t.detail);
}
}, Xc = class e extends q {
constructor(e = 1, t = 1, n = 1, r = 1) {
super(), this.type = "PlaneGeometry", this.parameters = {
width: e,
height: t,
widthSegments: n,
heightSegments: r
};
let i = e / 2, a = t / 2, o = Math.floor(n), s = Math.floor(r), c = o + 1, l = s + 1, u = e / o, d = t / s, f = [], p = [], m = [], h = [];
for (let e = 0; e < l; e++) {
let t = e * d - a;
for (let n = 0; n < c; n++) {
let r = n * u - i;
p.push(r, -t, 0), m.push(0, 0, 1), h.push(n / o), h.push(1 - e / s);
}
}
for (let e = 0; e < s; e++) for (let t = 0; t < o; t++) {
let n = t + c * e, r = t + c * (e + 1), i = t + 1 + c * (e + 1), a = t + 1 + c * e;
f.push(n, r, a), f.push(r, i, a);
}
this.setIndex(f), this.setAttribute("position", new K(p, 3)), this.setAttribute("normal", new K(m, 3)), this.setAttribute("uv", new K(h, 2));
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.width, t.height, t.widthSegments, t.heightSegments);
}
}, Zc = class e extends q {
constructor(e = .5, t = 1, n = 32, r = 1, i = 0, a = Math.PI * 2) {
super(), this.type = "RingGeometry", this.parameters = {
innerRadius: e,
outerRadius: t,
thetaSegments: n,
phiSegments: r,
thetaStart: i,
thetaLength: a
}, n = Math.max(3, n), r = Math.max(1, r);
let o = [], s = [], c = [], l = [], u = e, d = (t - e) / r, f = new H(), p = new V();
for (let e = 0; e <= r; e++) {
for (let e = 0; e <= n; e++) {
let r = i + e / n * a;
f.x = u * Math.cos(r), f.y = u * Math.sin(r), s.push(f.x, f.y, f.z), c.push(0, 0, 1), p.x = (f.x / t + 1) / 2, p.y = (f.y / t + 1) / 2, l.push(p.x, p.y);
}
u += d;
}
for (let e = 0; e < r; e++) {
let t = e * (n + 1);
for (let e = 0; e < n; e++) {
let r = e + t, i = r, a = r + n + 1, s = r + n + 2, c = r + 1;
o.push(i, a, c), o.push(a, s, c);
}
}
this.setIndex(o), this.setAttribute("position", new K(s, 3)), this.setAttribute("normal", new K(c, 3)), this.setAttribute("uv", new K(l, 2));
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.innerRadius, t.outerRadius, t.thetaSegments, t.phiSegments, t.thetaStart, t.thetaLength);
}
}, Qc = class e extends q {
constructor(e = new oc([
new V(0, .5),
new V(-.5, -.5),
new V(.5, -.5)
]), t = 12) {
super(), this.type = "ShapeGeometry", this.parameters = {
shapes: e,
curveSegments: t
};
let n = [], r = [], i = [], a = [], o = 0, s = 0;
if (Array.isArray(e) === !1) c(e);
else for (let t = 0; t < e.length; t++) c(e[t]), this.addGroup(o, s, t), o += s, s = 0;
this.setIndex(n), this.setAttribute("position", new K(r, 3)), this.setAttribute("normal", new K(i, 3)), this.setAttribute("uv", new K(a, 2));
function c(e) {
let o = r.length / 3, c = e.extractPoints(t), l = c.shape, u = c.holes;
Vc.isClockWise(l) === !1 && (l = l.reverse());
for (let e = 0, t = u.length; e < t; e++) {
let t = u[e];
Vc.isClockWise(t) === !0 && (u[e] = t.reverse());
}
let d = Vc.triangulateShape(l, u);
for (let e = 0, t = u.length; e < t; e++) {
let t = u[e];
l = l.concat(t);
}
for (let e = 0, t = l.length; e < t; e++) {
let t = l[e];
r.push(t.x, t.y, 0), i.push(0, 0, 1), a.push(t.x, t.y);
}
for (let e = 0, t = d.length; e < t; e++) {
let t = d[e], r = t[0] + o, i = t[1] + o, a = t[2] + o;
n.push(r, i, a), s += 3;
}
}
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
toJSON() {
let e = super.toJSON(), t = this.parameters.shapes;
return $c(t, e);
}
static fromJSON(t, n) {
let r = [];
for (let e = 0, i = t.shapes.length; e < i; e++) {
let i = n[t.shapes[e]];
r.push(i);
}
return new e(r, t.curveSegments);
}
};
function $c(e, t) {
if (t.shapes = [], Array.isArray(e)) for (let n = 0, r = e.length; n < r; n++) {
let r = e[n];
t.shapes.push(r.uuid);
}
else t.shapes.push(e.uuid);
return t;
}
var el = class e extends q {
constructor(e = 1, t = 32, n = 16, r = 0, i = Math.PI * 2, a = 0, o = Math.PI) {
super(), this.type = "SphereGeometry", this.parameters = {
radius: e,
widthSegments: t,
heightSegments: n,
phiStart: r,
phiLength: i,
thetaStart: a,
thetaLength: o
}, t = Math.max(3, Math.floor(t)), n = Math.max(2, Math.floor(n));
let s = Math.min(a + o, Math.PI), c = 0, l = [], u = new H(), d = new H(), f = [], p = [], m = [], h = [];
for (let f = 0; f <= n; f++) {
let g = [], _ = f / n, v = a + _ * o, y = e * Math.cos(v), b = Math.sqrt(e * e - y * y), x = 0;
f === 0 && a === 0 ? x = .5 / t : f === n && s === Math.PI && (x = -.5 / t);
for (let e = 0; e <= t; e++) {
let n = e / t, a = r + n * i;
u.x = -b * Math.cos(a), u.y = y, u.z = b * Math.sin(a), p.push(u.x, u.y, u.z), d.copy(u).normalize(), m.push(d.x, d.y, d.z), h.push(n + x, 1 - _), g.push(c++);
}
l.push(g);
}
for (let e = 0; e < n; e++) for (let r = 0; r < t; r++) {
let t = l[e][r + 1], i = l[e][r], o = l[e + 1][r], c = l[e + 1][r + 1];
(e !== 0 || a > 0) && f.push(t, i, c), (e !== n - 1 || s < Math.PI) && f.push(i, o, c);
}
this.setIndex(f), this.setAttribute("position", new K(p, 3)), this.setAttribute("normal", new K(m, 3)), this.setAttribute("uv", new K(h, 2));
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.radius, t.widthSegments, t.heightSegments, t.phiStart, t.phiLength, t.thetaStart, t.thetaLength);
}
}, tl = class e extends Cs {
constructor(e = 1, t = 0) {
super([
1,
1,
1,
-1,
-1,
1,
-1,
1,
-1,
1,
-1,
-1
], [
2,
1,
0,
0,
3,
2,
1,
3,
0,
2,
3,
1
], e, t), this.type = "TetrahedronGeometry", this.parameters = {
radius: e,
detail: t
};
}
static fromJSON(t) {
return new e(t.radius, t.detail);
}
}, nl = class e extends q {
constructor(e = 1, t = .4, n = 12, r = 48, i = Math.PI * 2, a = 0, o = Math.PI * 2) {
super(), this.type = "TorusGeometry", this.parameters = {
radius: e,
tube: t,
radialSegments: n,
tubularSegments: r,
arc: i,
thetaStart: a,
thetaLength: o
}, n = Math.floor(n), r = Math.floor(r);
let s = [], c = [], l = [], u = [], d = new H(), f = new H(), p = new H();
for (let s = 0; s <= n; s++) {
let m = a + s / n * o;
for (let a = 0; a <= r; a++) {
let o = a / r * i;
f.x = (e + t * Math.cos(m)) * Math.cos(o), f.y = (e + t * Math.cos(m)) * Math.sin(o), f.z = t * Math.sin(m), c.push(f.x, f.y, f.z), d.x = e * Math.cos(o), d.y = e * Math.sin(o), p.subVectors(f, d).normalize(), l.push(p.x, p.y, p.z), u.push(a / r), u.push(s / n);
}
}
for (let e = 1; e <= n; e++) for (let t = 1; t <= r; t++) {
let n = (r + 1) * e + t - 1, i = (r + 1) * (e - 1) + t - 1, a = (r + 1) * (e - 1) + t, o = (r + 1) * e + t;
s.push(n, i, o), s.push(i, a, o);
}
this.setIndex(s), this.setAttribute("position", new K(c, 3)), this.setAttribute("normal", new K(l, 3)), this.setAttribute("uv", new K(u, 2));
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.radius, t.tube, t.radialSegments, t.tubularSegments, t.arc);
}
}, rl = class e extends q {
constructor(e = 1, t = .4, n = 64, r = 8, i = 2, a = 3) {
super(), this.type = "TorusKnotGeometry", this.parameters = {
radius: e,
tube: t,
tubularSegments: n,
radialSegments: r,
p: i,
q: a
}, n = Math.floor(n), r = Math.floor(r);
let o = [], s = [], c = [], l = [], u = new H(), d = new H(), f = new H(), p = new H(), m = new H(), h = new H(), g = new H();
for (let o = 0; o <= n; ++o) {
let v = o / n * i * Math.PI * 2;
_(v, i, a, e, f), _(v + .01, i, a, e, p), h.subVectors(p, f), g.addVectors(p, f), m.crossVectors(h, g), g.crossVectors(m, h), m.normalize(), g.normalize();
for (let e = 0; e <= r; ++e) {
let i = e / r * Math.PI * 2, a = -t * Math.cos(i), p = t * Math.sin(i);
u.x = f.x + (a * g.x + p * m.x), u.y = f.y + (a * g.y + p * m.y), u.z = f.z + (a * g.z + p * m.z), s.push(u.x, u.y, u.z), d.subVectors(u, f).normalize(), c.push(d.x, d.y, d.z), l.push(o / n), l.push(e / r);
}
}
for (let e = 1; e <= n; e++) for (let t = 1; t <= r; t++) {
let n = (r + 1) * (e - 1) + (t - 1), i = (r + 1) * e + (t - 1), a = (r + 1) * e + t, s = (r + 1) * (e - 1) + t;
o.push(n, i, s), o.push(i, a, s);
}
this.setIndex(o), this.setAttribute("position", new K(s, 3)), this.setAttribute("normal", new K(c, 3)), this.setAttribute("uv", new K(l, 2));
function _(e, t, n, r, i) {
let a = Math.cos(e), o = Math.sin(e), s = n / t * e, c = Math.cos(s);
i.x = r * (2 + c) * .5 * a, i.y = r * (2 + c) * o * .5, i.z = r * Math.sin(s) * .5;
}
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
static fromJSON(t) {
return new e(t.radius, t.tube, t.tubularSegments, t.radialSegments, t.p, t.q);
}
}, il = class e extends q {
constructor(e = new tc(new H(-1, -1, 0), new H(-1, 1, 0), new H(1, 1, 0)), t = 64, n = 1, r = 8, i = !1) {
super(), this.type = "TubeGeometry", this.parameters = {
path: e,
tubularSegments: t,
radius: n,
radialSegments: r,
closed: i
};
let a = e.computeFrenetFrames(t, i);
this.tangents = a.tangents, this.normals = a.normals, this.binormals = a.binormals;
let o = new H(), s = new H(), c = new V(), l = new H(), u = [], d = [], f = [], p = [];
m(), this.setIndex(p), this.setAttribute("position", new K(u, 3)), this.setAttribute("normal", new K(d, 3)), this.setAttribute("uv", new K(f, 2));
function m() {
for (let e = 0; e < t; e++) h(e);
h(i === !1 ? t : 0), _(), g();
}
function h(i) {
l = e.getPointAt(i / t, l);
let c = a.normals[i], f = a.binormals[i];
for (let e = 0; e <= r; e++) {
let t = e / r * Math.PI * 2, i = Math.sin(t), a = -Math.cos(t);
s.x = a * c.x + i * f.x, s.y = a * c.y + i * f.y, s.z = a * c.z + i * f.z, s.normalize(), d.push(s.x, s.y, s.z), o.x = l.x + n * s.x, o.y = l.y + n * s.y, o.z = l.z + n * s.z, u.push(o.x, o.y, o.z);
}
}
function g() {
for (let e = 1; e <= t; e++) for (let t = 1; t <= r; t++) {
let n = (r + 1) * (e - 1) + (t - 1), i = (r + 1) * e + (t - 1), a = (r + 1) * e + t, o = (r + 1) * (e - 1) + t;
p.push(n, i, o), p.push(i, a, o);
}
}
function _() {
for (let e = 0; e <= t; e++) for (let n = 0; n <= r; n++) c.x = e / t, c.y = n / r, f.push(c.x, c.y);
}
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
toJSON() {
let e = super.toJSON();
return e.path = this.parameters.path.toJSON(), e;
}
static fromJSON(t) {
return new e(new rc[t.path.type]().fromJSON(t.path), t.tubularSegments, t.radius, t.radialSegments, t.closed);
}
}, al = class extends q {
constructor(e = null) {
if (super(), this.type = "WireframeGeometry", this.parameters = { geometry: e }, e !== null) {
let t = [], n = /* @__PURE__ */ new Set(), r = new H(), i = new H();
if (e.index !== null) {
let a = e.attributes.position, o = e.index, s = e.groups;
s.length === 0 && (s = [{
start: 0,
count: o.count,
materialIndex: 0
}]);
for (let e = 0, c = s.length; e < c; ++e) {
let c = s[e], l = c.start, u = c.count;
for (let e = l, s = l + u; e < s; e += 3) for (let s = 0; s < 3; s++) {
let c = o.getX(e + s), l = o.getX(e + (s + 1) % 3);
r.fromBufferAttribute(a, c), i.fromBufferAttribute(a, l), ol(r, i, n) === !0 && (t.push(r.x, r.y, r.z), t.push(i.x, i.y, i.z));
}
}
} else {
let a = e.attributes.position;
for (let e = 0, o = a.count / 3; e < o; e++) for (let o = 0; o < 3; o++) {
let s = 3 * e + o, c = 3 * e + (o + 1) % 3;
r.fromBufferAttribute(a, s), i.fromBufferAttribute(a, c), ol(r, i, n) === !0 && (t.push(r.x, r.y, r.z), t.push(i.x, i.y, i.z));
}
}
this.setAttribute("position", new K(t, 3));
}
}
copy(e) {
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
}
};
function ol(e, t, n) {
let r = `${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`, i = `${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;
return n.has(r) === !0 || n.has(i) === !0 ? !1 : (n.add(r), n.add(i), !0);
}
var sl = /*#__PURE__*/ Object.freeze({
__proto__: null,
BoxGeometry: vs,
CapsuleGeometry: ys,
CircleGeometry: bs,
ConeGeometry: Ss,
CylinderGeometry: xs,
DodecahedronGeometry: ws,
EdgesGeometry: ks,
ExtrudeGeometry: Wc,
IcosahedronGeometry: qc,
LatheGeometry: Jc,
OctahedronGeometry: Yc,
PlaneGeometry: Xc,
PolyhedronGeometry: Cs,
RingGeometry: Zc,
ShapeGeometry: Qc,
SphereGeometry: el,
TetrahedronGeometry: tl,
TorusGeometry: nl,
TorusKnotGeometry: rl,
TubeGeometry: il,
WireframeGeometry: al
}), cl = class extends Zi {
constructor(e) {
super(), this.isShadowMaterial = !0, this.type = "ShadowMaterial", this.color = new G(0), this.transparent = !0, this.fog = !0, this.setValues(e);
}
copy(e) {
return super.copy(e), this.color.copy(e.color), this.fog = e.fog, this;
}
};
function ll(e) {
let t = {};
for (let n in e) {
t[n] = {};
for (let r in e[n]) {
let i = e[n][r];
if (dl(i)) i.isRenderTargetTexture ? (L("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), t[n][r] = null) : t[n][r] = i.clone();
else if (Array.isArray(i)) if (dl(i[0])) {
let e = [];
for (let t = 0, n = i.length; t < n; t++) e[t] = i[t].clone();
t[n][r] = e;
} else t[n][r] = i.slice();
else t[n][r] = i;
}
}
return t;
}
function ul(e) {
let t = {};
for (let n = 0; n < e.length; n++) {
let r = ll(e[n]);
for (let e in r) t[e] = r[e];
}
return t;
}
function dl(e) {
return e && (e.isColor || e.isMatrix3 || e.isMatrix4 || e.isVector2 || e.isVector3 || e.isVector4 || e.isTexture || e.isQuaternion);
}
function fl(e) {
let t = [];
for (let n = 0; n < e.length; n++) t.push(e[n].clone());
return t;
}
function pl(e) {
let t = e.getRenderTarget();
return t === null ? e.outputColorSpace : t.isXRRenderTarget === !0 ? t.texture.colorSpace : Hn.workingColorSpace;
}
var ml = {
clone: ll,
merge: ul
}, hl = "void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", gl = "void main() {\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}", _l = class extends Zi {
constructor(e) {
super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = hl, this.fragmentShader = gl, 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 = ll(e.uniforms), this.uniformsGroups = fl(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.defaultAttributeValues = Object.assign({}, e.defaultAttributeValues), this.index0AttributeName = e.index0AttributeName, this.uniformsNeedUpdate = e.uniformsNeedUpdate, this;
}
toJSON(e) {
let t = super.toJSON(e);
t.glslVersion = this.glslVersion, t.uniforms = {};
for (let n in this.uniforms) {
let r = this.uniforms[n].value;
r && r.isTexture ? t.uniforms[n] = {
type: "t",
value: r.toJSON(e).uuid
} : r && r.isColor ? t.uniforms[n] = {
type: "c",
value: r.getHex()
} : r && r.isVector2 ? t.uniforms[n] = {
type: "v2",
value: r.toArray()
} : r && r.isVector3 ? t.uniforms[n] = {
type: "v3",
value: r.toArray()
} : r && r.isVector4 ? t.uniforms[n] = {
type: "v4",
value: r.toArray()
} : r && r.isMatrix3 ? t.uniforms[n] = {
type: "m3",
value: r.toArray()
} : r && r.isMatrix4 ? t.uniforms[n] = {
type: "m4",
value: r.toArray()
} : t.uniforms[n] = { value: r };
}
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 e in this.extensions) this.extensions[e] === !0 && (n[e] = !0);
return Object.keys(n).length > 0 && (t.extensions = n), t;
}
fromJSON(e, t) {
if (super.fromJSON(e, t), e.uniforms !== void 0) for (let n in e.uniforms) {
let r = e.uniforms[n];
switch (this.uniforms[n] = {}, r.type) {
case "t":
this.uniforms[n].value = t[r.value] || null;
break;
case "c":
this.uniforms[n].value = new G().setHex(r.value);
break;
case "v2":
this.uniforms[n].value = new V().fromArray(r.value);
break;
case "v3":
this.uniforms[n].value = new H().fromArray(r.value);
break;
case "v4":
this.uniforms[n].value = new $n().fromArray(r.value);
break;
case "m3":
this.uniforms[n].value = new U().fromArray(r.value);
break;
case "m4":
this.uniforms[n].value = new W().fromArray(r.value);
break;
default: this.uniforms[n].value = r.value;
}
}
if (e.defines !== void 0 && (this.defines = e.defines), e.vertexShader !== void 0 && (this.vertexShader = e.vertexShader), e.fragmentShader !== void 0 && (this.fragmentShader = e.fragmentShader), e.glslVersion !== void 0 && (this.glslVersion = e.glslVersion), e.extensions !== void 0) for (let t in e.extensions) this.extensions[t] = e.extensions[t];
return e.lights !== void 0 && (this.lights = e.lights), e.clipping !== void 0 && (this.clipping = e.clipping), this;
}
}, vl = class extends _l {
constructor(e) {
super(e), this.isRawShaderMaterial = !0, this.type = "RawShaderMaterial";
}
}, yl = class extends Zi {
constructor(e) {
super(), this.isMeshStandardMaterial = !0, this.type = "MeshStandardMaterial", this.defines = { STANDARD: "" }, this.color = new G(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 G(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = 0, this.normalScale = new V(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 hr(), 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;
}
}, bl = class extends yl {
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 V(1, 1), this.clearcoatNormalMap = null, this.ior = 1.5, Object.defineProperty(this, "reflectivity", {
get: function() {
return z(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1);
},
set: function(e) {
this.ior = (1 + .4 * e) / (1 - .4 * e);
}
}), this.iridescenceMap = null, this.iridescenceIOR = 1.3, this.iridescenceThicknessRange = [100, 400], this.iridescenceThicknessMap = null, this.sheenColor = new G(0), this.sheenColorMap = null, this.sheenRoughness = 1, this.sheenRoughnessMap = null, this.transmissionMap = null, this.thickness = 0, this.thicknessMap = null, this.attenuationDistance = Infinity, this.attenuationColor = new G(1, 1, 1), this.specularIntensity = 1, this.specularIntensityMap = null, this.specularColor = new G(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) {
this._anisotropy > 0 != e > 0 && this.version++, this._anisotropy = e;
}
get clearcoat() {
return this._clearcoat;
}
set clearcoat(e) {
this._clearcoat > 0 != e > 0 && this.version++, this._clearcoat = e;
}
get iridescence() {
return this._iridescence;
}
set iridescence(e) {
this._iridescence > 0 != e > 0 && this.version++, this._iridescence = e;
}
get dispersion() {
return this._dispersion;
}
set dispersion(e) {
this._dispersion > 0 != e > 0 && this.version++, this._dispersion = e;
}
get sheen() {
return this._sheen;
}
set sheen(e) {
this._sheen > 0 != e > 0 && this.version++, this._sheen = e;
}
get transmission() {
return this._transmission;
}
set transmission(e) {
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;
}
}, xl = class extends Zi {
constructor(e) {
super(), this.isMeshPhongMaterial = !0, this.type = "MeshPhongMaterial", this.color = new G(16777215), this.specular = new G(1118481), this.shininess = 30, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new G(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = 0, this.normalScale = new V(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new hr(), this.combine = 0, this.reflectivity = 1, this.envMapIntensity = 1, this.refractionRatio = .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.envMapIntensity = e.envMapIntensity, 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;
}
}, Sl = class extends Zi {
constructor(e) {
super(), this.isMeshToonMaterial = !0, this.defines = { TOON: "" }, this.type = "MeshToonMaterial", this.color = new G(16777215), this.map = null, this.gradientMap = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new G(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = 0, this.normalScale = new V(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, 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.gradientMap = e.gradientMap, 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.alphaMap = e.alphaMap, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.fog = e.fog, this;
}
}, Cl = class extends Zi {
constructor(e) {
super(), this.isMeshNormalMaterial = !0, this.type = "MeshNormalMaterial", this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = 0, this.normalScale = new V(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.flatShading = !1, this.setValues(e);
}
copy(e) {
return super.copy(e), 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.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.flatShading = e.flatShading, this;
}
}, wl = class extends Zi {
constructor(e) {
super(), this.isMeshLambertMaterial = !0, this.type = "MeshLambertMaterial", this.color = new G(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new G(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = 0, this.normalScale = new V(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new hr(), this.combine = 0, this.reflectivity = 1, this.envMapIntensity = 1, this.refractionRatio = .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.envMapIntensity = e.envMapIntensity, 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;
}
}, Tl = class extends Zi {
constructor(e) {
super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = gt, 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;
}
}, El = class extends Zi {
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;
}
}, Dl = class extends Zi {
constructor(e) {
super(), this.isMeshMatcapMaterial = !0, this.defines = { MATCAP: "" }, this.type = "MeshMatcapMaterial", this.color = new G(16777215), this.matcap = null, this.map = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = 0, this.normalScale = new V(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, this.wireframe = !1, this.wireframeLinewidth = 1, this.flatShading = !1, this.fog = !0, this.setValues(e);
}
copy(e) {
return super.copy(e), this.defines = { MATCAP: "" }, this.color.copy(e.color), this.matcap = e.matcap, this.map = e.map, 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.alphaMap = e.alphaMap, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.flatShading = e.flatShading, this.fog = e.fog, this;
}
}, Ol = class extends zo {
constructor(e) {
super(), this.isLineDashedMaterial = !0, this.type = "LineDashedMaterial", this.scale = 1, this.dashSize = 3, this.gapSize = 1, this.setValues(e);
}
copy(e) {
return super.copy(e), this.scale = e.scale, this.dashSize = e.dashSize, this.gapSize = e.gapSize, this;
}
};
function kl(e, t) {
return !e || e.constructor === t ? e : typeof t.BYTES_PER_ELEMENT == "number" ? new t(e) : Array.prototype.slice.call(e);
}
function Al(e) {
function t(t, n) {
return e[t] - e[n];
}
let n = e.length, r = Array(n);
for (let e = 0; e !== n; ++e) r[e] = e;
return r.sort(t), r;
}
function jl(e, t, n) {
let r = e.length, i = new e.constructor(r);
for (let a = 0, o = 0; o !== r; ++a) {
let r = n[a] * t;
for (let n = 0; n !== t; ++n) i[o++] = e[r + n];
}
return i;
}
function Ml(e, t, n, r) {
let i = 1, a = e[0];
for (; a !== void 0 && a[r] === void 0;) a = e[i++];
if (a === void 0) return;
let o = a[r];
if (o !== void 0) if (Array.isArray(o)) do
o = a[r], o !== void 0 && (t.push(a.time), n.push(...o)), a = e[i++];
while (a !== void 0);
else if (o.toArray !== void 0) do
o = a[r], o !== void 0 && (t.push(a.time), o.toArray(n, n.length)), a = e[i++];
while (a !== void 0);
else do
o = a[r], o !== void 0 && (t.push(a.time), n.push(o)), a = e[i++];
while (a !== void 0);
}
function Nl(e, t, n, r, i = 30) {
let a = e.clone();
a.name = t;
let o = [];
for (let e = 0; e < a.tracks.length; ++e) {
let t = a.tracks[e], s = t.getValueSize(), c = [], l = [];
for (let e = 0; e < t.times.length; ++e) {
let a = t.times[e] * i;
if (!(a < n || a >= r)) {
c.push(t.times[e]);
for (let n = 0; n < s; ++n) l.push(t.values[e * s + n]);
}
}
c.length !== 0 && (t.times = kl(c, t.times.constructor), t.values = kl(l, t.values.constructor), o.push(t));
}
a.tracks = o;
let s = Infinity;
for (let e = 0; e < a.tracks.length; ++e) s > a.tracks[e].times[0] && (s = a.tracks[e].times[0]);
for (let e = 0; e < a.tracks.length; ++e) a.tracks[e].shift(-1 * s);
return a.resetDuration(), a;
}
function Pl(e, t = 0, n = e, r = 30) {
r <= 0 && (r = 30);
let i = n.tracks.length, a = t / r;
for (let t = 0; t < i; ++t) {
let r = n.tracks[t], i = r.ValueTypeName;
if (i === "bool" || i === "string") continue;
let o = e.tracks.find(function(e) {
return e.name === r.name && e.ValueTypeName === i;
});
if (o === void 0) continue;
let s = 0, c = r.getValueSize();
r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (s = c / 3);
let l = 0, u = o.getValueSize();
o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (l = u / 3);
let d = r.times.length - 1, f;
if (a <= r.times[0]) {
let e = s, t = c - s;
f = r.values.slice(e, t);
} else if (a >= r.times[d]) {
let e = d * c + s, t = e + c - s;
f = r.values.slice(e, t);
} else {
let e = r.createInterpolant(), t = s, n = c - s;
e.evaluate(a), f = e.resultBuffer.slice(t, n);
}
i === "quaternion" && new Fn().fromArray(f).normalize().conjugate().toArray(f);
let p = o.times.length;
for (let e = 0; e < p; ++e) {
let t = e * u + l;
if (i === "quaternion") Fn.multiplyQuaternionsFlat(o.values, t, f, 0, o.values, t);
else {
let e = u - l * 2;
for (let n = 0; n < e; ++n) o.values[t + n] -= f[n];
}
}
}
return e.blendMode = ht, e;
}
var Fl = class {
static convertArray(e, t) {
return kl(e, t);
}
static isTypedArray(e) {
return Xt(e);
}
static getKeyframeOrder(e) {
return Al(e);
}
static sortedArray(e, t, n) {
return jl(e, t, n);
}
static flattenJSON(e, t, n, r) {
Ml(e, t, n, r);
}
static subclip(e, t, n, r, i = 30) {
return Nl(e, t, n, r, i);
}
static makeClipAdditive(e, t = 0, n = e, r = 30) {
return Pl(e, t, n, r);
}
}, Il = class {
constructor(e, t, n, r) {
this.parameterPositions = e, this._cachedIndex = 0, this.resultBuffer = r === void 0 ? new t.constructor(n) : r, this.sampleValues = t, this.valueSize = n, this.settings = null, this.DefaultSettings_ = {};
}
evaluate(e) {
let t = this.parameterPositions, n = this._cachedIndex, r = t[n], i = t[n - 1];
validate_interval: {
seek: {
let a;
linear_scan: {
forward_scan: if (!(e < r)) {
for (let a = n + 2;;) {
if (r === void 0) {
if (e < i) break forward_scan;
return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1);
}
if (n === a) break;
if (i = r, r = t[++n], e < r) break seek;
}
a = t.length;
break linear_scan;
}
if (!(e >= i)) {
let o = t[1];
e < o && (n = 2, i = o);
for (let a = n - 2;;) {
if (i === void 0) return this._cachedIndex = 0, this.copySampleValue_(0);
if (n === a) break;
if (r = i, i = t[--n - 1], e >= i) break seek;
}
a = n, n = 0;
break linear_scan;
}
break validate_interval;
}
for (; n < a;) {
let r = n + a >>> 1;
e < t[r] ? a = r : n = r + 1;
}
if (r = t[n], i = t[n - 1], i === void 0) return this._cachedIndex = 0, this.copySampleValue_(0);
if (r === void 0) return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1);
}
this._cachedIndex = n, this.intervalChanged_(n, i, r);
}
return this.interpolate_(n, i, e, r);
}
getSettings_() {
return this.settings || this.DefaultSettings_;
}
copySampleValue_(e) {
let t = this.resultBuffer, n = this.sampleValues, r = this.valueSize, i = e * r;
for (let e = 0; e !== r; ++e) t[e] = n[i + e];
return t;
}
interpolate_() {
throw Error("THREE.Interpolant: Call to abstract method.");
}
intervalChanged_() {}
}, Ll = class extends Il {
constructor(e, t, n, r) {
super(e, t, n, r), this._weightPrev = -0, this._offsetPrev = -0, this._weightNext = -0, this._offsetNext = -0, this.DefaultSettings_ = {
endingStart: dt,
endingEnd: dt
};
}
intervalChanged_(e, t, n) {
let r = this.parameterPositions, i = e - 2, a = e + 1, o = r[i], s = r[a];
if (o === void 0) switch (this.getSettings_().endingStart) {
case ft:
i = e, o = 2 * t - n;
break;
case pt:
i = r.length - 2, o = t + r[i] - r[i + 1];
break;
default: i = e, o = n;
}
if (s === void 0) switch (this.getSettings_().endingEnd) {
case ft:
a = e, s = 2 * n - t;
break;
case pt:
a = 1, s = n + r[1] - r[0];
break;
default: a = e - 1, s = t;
}
let c = (n - t) * .5, l = this.valueSize;
this._weightPrev = c / (t - o), this._weightNext = c / (s - n), this._offsetPrev = i * l, this._offsetNext = a * l;
}
interpolate_(e, t, n, r) {
let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = e * o, c = s - o, l = this._offsetPrev, u = this._offsetNext, d = this._weightPrev, f = this._weightNext, p = (n - t) / (r - t), m = p * p, h = m * p, g = -d * h + 2 * d * m - d * p, _ = (1 + d) * h + (-1.5 - 2 * d) * m + (-.5 + d) * p + 1, v = (-1 - f) * h + (1.5 + f) * m + .5 * p, y = f * h - f * m;
for (let e = 0; e !== o; ++e) i[e] = g * a[l + e] + _ * a[c + e] + v * a[s + e] + y * a[u + e];
return i;
}
}, Rl = class extends Il {
constructor(e, t, n, r) {
super(e, t, n, r);
}
interpolate_(e, t, n, r) {
let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = e * o, c = s - o, l = (n - t) / (r - t), u = 1 - l;
for (let e = 0; e !== o; ++e) i[e] = a[c + e] * u + a[s + e] * l;
return i;
}
}, zl = class extends Il {
constructor(e, t, n, r) {
super(e, t, n, r);
}
interpolate_(e) {
return this.copySampleValue_(e - 1);
}
}, Bl = class extends Il {
interpolate_(e, t, n, r) {
let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = e * o, c = s - o, l = this.inTangents, u = this.outTangents;
if (!l || !u) {
let e = (n - t) / (r - t), l = 1 - e;
for (let t = 0; t !== o; ++t) i[t] = a[c + t] * l + a[s + t] * e;
return i;
}
let d = o * 2, f = e - 1;
for (let p = 0; p !== o; ++p) {
let o = a[c + p], m = a[s + p], h = f * d + p * 2, g = u[h], _ = u[h + 1], v = e * d + p * 2, y = l[v], b = l[v + 1], x = (n - t) / (r - t), S, C, w, T, E;
for (let e = 0; e < 8; e++) {
S = x * x, C = S * x, w = 1 - x, T = w * w, E = T * w;
let e = E * t + 3 * T * x * g + 3 * w * S * y + C * r - n;
if (Math.abs(e) < 1e-10) break;
let i = 3 * T * (g - t) + 6 * w * x * (y - g) + 3 * S * (r - y);
if (Math.abs(i) < 1e-10) break;
x -= e / i, x = Math.max(0, Math.min(1, x));
}
i[p] = E * o + 3 * T * x * _ + 3 * w * S * b + C * m;
}
return i;
}
}, Vl = class {
constructor(e, t, n, r) {
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 = kl(t, this.TimeBufferType), this.values = kl(n, this.ValueBufferType), this.setInterpolation(r || 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: kl(e.times, Array),
values: kl(e.values, Array)
};
let t = e.getInterpolation();
t !== e.DefaultInterpolation && (n.interpolation = t);
}
return n.type = e.ValueTypeName, n;
}
InterpolantFactoryMethodDiscrete(e) {
return new zl(this.times, this.values, this.getValueSize(), e);
}
InterpolantFactoryMethodLinear(e) {
return new Rl(this.times, this.values, this.getValueSize(), e);
}
InterpolantFactoryMethodSmooth(e) {
return new Ll(this.times, this.values, this.getValueSize(), e);
}
InterpolantFactoryMethodBezier(e) {
let t = new Bl(this.times, this.values, this.getValueSize(), e);
return this.settings && (t.inTangents = this.settings.inTangents, t.outTangents = this.settings.outTangents), t;
}
setInterpolation(e) {
let t;
switch (e) {
case st:
t = this.InterpolantFactoryMethodDiscrete;
break;
case ct:
t = this.InterpolantFactoryMethodLinear;
break;
case lt:
t = this.InterpolantFactoryMethodSmooth;
break;
case ut:
t = this.InterpolantFactoryMethodBezier;
break;
}
if (t === void 0) {
let t = "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(t);
return L("KeyframeTrack:", t), this;
}
return this.createInterpolant = t, this;
}
getInterpolation() {
switch (this.createInterpolant) {
case this.InterpolantFactoryMethodDiscrete: return st;
case this.InterpolantFactoryMethodLinear: return ct;
case this.InterpolantFactoryMethodSmooth: return lt;
case this.InterpolantFactoryMethodBezier: return ut;
}
}
getValueSize() {
return this.values.length / this.times.length;
}
shift(e) {
if (e !== 0) {
let t = this.times;
for (let n = 0, r = t.length; n !== r; ++n) t[n] += e;
}
return this;
}
scale(e) {
if (e !== 1) {
let t = this.times;
for (let n = 0, r = t.length; n !== r; ++n) t[n] *= e;
}
return this;
}
trim(e, t) {
let n = this.times, r = n.length, i = 0, a = r - 1;
for (; i !== r && n[i] < e;) ++i;
for (; a !== -1 && n[a] > t;) --a;
if (++a, i !== 0 || a !== r) {
i >= a && (a = Math.max(a, 1), i = a - 1);
let e = this.getValueSize();
this.times = n.slice(i, a), this.values = this.values.slice(i * e, a * e);
}
return this;
}
validate() {
let e = !0, t = this.getValueSize();
t - Math.floor(t) !== 0 && (R("KeyframeTrack: Invalid value size in track.", this), e = !1);
let n = this.times, r = this.values, i = n.length;
i === 0 && (R("KeyframeTrack: Track is empty.", this), e = !1);
let a = null;
for (let t = 0; t !== i; t++) {
let r = n[t];
if (typeof r == "number" && isNaN(r)) {
R("KeyframeTrack: Time is not a valid number.", this, t, r), e = !1;
break;
}
if (a !== null && a > r) {
R("KeyframeTrack: Out of order keys.", this, t, r, a), e = !1;
break;
}
a = r;
}
if (r !== void 0 && Xt(r)) for (let t = 0, n = r.length; t !== n; ++t) {
let n = r[t];
if (isNaN(n)) {
R("KeyframeTrack: Value is not a valid number.", this, t, n), e = !1;
break;
}
}
return e;
}
optimize() {
let e = this.times.slice(), t = this.values.slice(), n = this.getValueSize(), r = this.getInterpolation() === lt, i = e.length - 1, a = 1;
for (let o = 1; o < i; ++o) {
let i = !1, s = e[o];
if (s !== e[o + 1] && (o !== 1 || s !== e[0])) if (r) i = !0;
else {
let e = o * n, r = e - n, a = e + n;
for (let o = 0; o !== n; ++o) {
let n = t[e + o];
if (n !== t[r + o] || n !== t[a + o]) {
i = !0;
break;
}
}
}
if (i) {
if (o !== a) {
e[a] = e[o];
let r = o * n, i = a * n;
for (let e = 0; e !== n; ++e) t[i + e] = t[r + e];
}
++a;
}
}
if (i > 0) {
e[a] = e[i];
for (let e = i * n, r = a * n, o = 0; o !== n; ++o) t[r + o] = t[e + o];
++a;
}
return a === e.length ? (this.times = e, this.values = t) : (this.times = e.slice(0, a), this.values = t.slice(0, a * n)), this;
}
clone() {
let e = this.times.slice(), t = this.values.slice(), n = this.constructor, r = new n(this.name, e, t);
return r.createInterpolant = this.createInterpolant, r;
}
};
Vl.prototype.ValueTypeName = "", Vl.prototype.TimeBufferType = Float32Array, Vl.prototype.ValueBufferType = Float32Array, Vl.prototype.DefaultInterpolation = ct;
var Y = class extends Vl {
constructor(e, t, n) {
super(e, t, n);
}
};
Y.prototype.ValueTypeName = "bool", Y.prototype.ValueBufferType = Array, Y.prototype.DefaultInterpolation = st, Y.prototype.InterpolantFactoryMethodLinear = void 0, Y.prototype.InterpolantFactoryMethodSmooth = void 0;
var Hl = class extends Vl {
constructor(e, t, n, r) {
super(e, t, n, r);
}
};
Hl.prototype.ValueTypeName = "color";
var Ul = class extends Vl {
constructor(e, t, n, r) {
super(e, t, n, r);
}
};
Ul.prototype.ValueTypeName = "number";
var Wl = class extends Il {
constructor(e, t, n, r) {
super(e, t, n, r);
}
interpolate_(e, t, n, r) {
let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = (n - t) / (r - t), c = e * o;
for (let e = c + o; c !== e; c += 4) Fn.slerpFlat(i, 0, a, c - o, a, c, s);
return i;
}
}, Gl = class extends Vl {
constructor(e, t, n, r) {
super(e, t, n, r);
}
InterpolantFactoryMethodLinear(e) {
return new Wl(this.times, this.values, this.getValueSize(), e);
}
};
Gl.prototype.ValueTypeName = "quaternion", Gl.prototype.InterpolantFactoryMethodSmooth = void 0;
var Kl = class extends Vl {
constructor(e, t, n) {
super(e, t, n);
}
};
Kl.prototype.ValueTypeName = "string", Kl.prototype.ValueBufferType = Array, Kl.prototype.DefaultInterpolation = st, Kl.prototype.InterpolantFactoryMethodLinear = void 0, Kl.prototype.InterpolantFactoryMethodSmooth = void 0;
var ql = class extends Vl {
constructor(e, t, n, r) {
super(e, t, n, r);
}
};
ql.prototype.ValueTypeName = "vector";
var Jl = class {
constructor(e = "", t = -1, n = [], r = mt) {
this.name = e, this.tracks = n, this.duration = t, this.blendMode = r, this.uuid = mn(), this.userData = {}, this.duration < 0 && this.resetDuration();
}
static parse(e) {
let t = [], n = e.tracks, r = 1 / (e.fps || 1);
for (let e = 0, i = n.length; e !== i; ++e) t.push(Xl(n[e]).scale(r));
let i = new this(e.name, e.duration, t, e.blendMode);
return i.uuid = e.uuid, i.userData = JSON.parse(e.userData || "{}"), i;
}
static toJSON(e) {
let t = [], n = e.tracks, r = {
name: e.name,
duration: e.duration,
tracks: t,
uuid: e.uuid,
blendMode: e.blendMode,
userData: JSON.stringify(e.userData)
};
for (let e = 0, r = n.length; e !== r; ++e) t.push(Vl.toJSON(n[e]));
return r;
}
static CreateFromMorphTargetSequence(e, t, n, r) {
let i = t.length, a = [];
for (let e = 0; e < i; e++) {
let o = [], s = [];
o.push((e + i - 1) % i, e, (e + 1) % i), s.push(0, 1, 0);
let c = Al(o);
o = jl(o, 1, c), s = jl(s, 1, c), !r && o[0] === 0 && (o.push(i), s.push(s[0])), a.push(new Ul(".morphTargetInfluences[" + t[e].name + "]", o, s).scale(1 / n));
}
return new this(e, -1, a);
}
static findByName(e, t) {
let n = e;
if (!Array.isArray(e)) {
let t = e;
n = t.geometry && t.geometry.animations || t.animations;
}
for (let e = 0; e < n.length; e++) if (n[e].name === t) return n[e];
return null;
}
static CreateClipsFromMorphTargetSequences(e, t, n) {
let r = {}, i = /^([\w-]*?)([\d]+)$/;
for (let t = 0, n = e.length; t < n; t++) {
let n = e[t], a = n.name.match(i);
if (a && a.length > 1) {
let e = a[1], t = r[e];
t || (r[e] = t = []), t.push(n);
}
}
let a = [];
for (let e in r) a.push(this.CreateFromMorphTargetSequence(e, r[e], t, n));
return a;
}
resetDuration() {
let e = this.tracks, t = 0;
for (let n = 0, r = e.length; n !== r; ++n) {
let e = this.tracks[n];
t = Math.max(t, e.times[e.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 t = 0; t < this.tracks.length; t++) e.push(this.tracks[t].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 Yl(e) {
switch (e.toLowerCase()) {
case "scalar":
case "double":
case "float":
case "number":
case "integer": return Ul;
case "vector":
case "vector2":
case "vector3":
case "vector4": return ql;
case "color": return Hl;
case "quaternion": return Gl;
case "bool":
case "boolean": return Y;
case "string": return Kl;
}
throw Error("THREE.KeyframeTrack: Unsupported typeName: " + e);
}
function Xl(e) {
if (e.type === void 0) throw Error("THREE.KeyframeTrack: track type undefined, can not parse");
let t = Yl(e.type);
if (e.times === void 0) {
let t = [], n = [];
Ml(e.keys, t, n, "value"), e.times = t, e.values = n;
}
return t.parse === void 0 ? new t(e.name, e.times, e.values, e.interpolation) : t.parse(e);
}
var Zl = {
enabled: !1,
files: {},
add: function(e, t) {
this.enabled !== !1 && (Ql(e) || (this.files[e] = t));
},
get: function(e) {
if (this.enabled !== !1 && !Ql(e)) return this.files[e];
},
remove: function(e) {
delete this.files[e];
},
clear: function() {
this.files = {};
}
};
function Ql(e) {
try {
let t = e.slice(e.indexOf(":") + 1);
return new URL(t).protocol === "blob:";
} catch {
return !1;
}
}
var $l = class {
constructor(e, t, n) {
let r = this, i = !1, a = 0, o = 0, s, c = [];
this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = n, this._abortController = null, this.itemStart = function(e) {
o++, i === !1 && r.onStart !== void 0 && r.onStart(e, a, o), i = !0;
}, this.itemEnd = function(e) {
a++, r.onProgress !== void 0 && r.onProgress(e, a, o), a === o && (i = !1, r.onLoad !== void 0 && r.onLoad());
}, this.itemError = function(e) {
r.onError !== void 0 && r.onError(e);
}, this.resolveURL = function(e) {
return e = e.normalize("NFC"), s ? s(e) : e;
}, this.setURLModifier = function(e) {
return s = e, this;
}, this.addHandler = function(e, t) {
return c.push(e, t), this;
}, this.removeHandler = function(e) {
let t = c.indexOf(e);
return t !== -1 && c.splice(t, 2), this;
}, this.getHandler = function(e) {
for (let t = 0, n = c.length; t < n; t += 2) {
let n = c[t], r = c[t + 1];
if (n.global && (n.lastIndex = 0), n.test(e)) return r;
}
return null;
}, this.abort = function() {
return this.abortController.abort(), this._abortController = null, this;
};
}
get abortController() {
return this._abortController || (this._abortController = new AbortController()), this._abortController;
}
}, eu = /*@__PURE__*/ new $l(), tu = class {
constructor(e) {
this.manager = e === void 0 ? eu : e, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {}, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
}
load() {}
loadAsync(e, t) {
let n = this;
return new Promise(function(r, i) {
n.load(e, r, t, i);
});
}
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;
}
};
tu.DEFAULT_MATERIAL_NAME = "__DEFAULT";
var nu = {}, ru = class extends Error {
constructor(e, t) {
super(e), this.response = t;
}
}, iu = class extends tu {
constructor(e) {
super(e), this.mimeType = "", this.responseType = "", this._abortController = new AbortController();
}
load(e, t, n, r) {
e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);
let i = Zl.get(`file:${e}`);
if (i !== void 0) {
this.manager.itemStart(e), setTimeout(() => {
t && t(i), this.manager.itemEnd(e);
}, 0);
return;
}
if (nu[e] !== void 0) {
nu[e].push({
onLoad: t,
onProgress: n,
onError: r
});
return;
}
nu[e] = [], nu[e].push({
onLoad: t,
onProgress: n,
onError: r
});
let a = 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, s = this.responseType;
fetch(a).then((t) => {
if (t.status === 200 || t.status === 0) {
if (t.status === 0 && L("FileLoader: HTTP Status 0 received."), typeof ReadableStream > "u" || t.body === void 0 || t.body.getReader === void 0) return t;
let n = nu[e], r = t.body.getReader(), i = t.headers.get("X-File-Size") || t.headers.get("Content-Length"), a = i ? parseInt(i) : 0, o = a !== 0, s = 0, c = new ReadableStream({ start(e) {
t();
function t() {
r.read().then(({ done: r, value: i }) => {
if (r) e.close();
else {
s += i.byteLength;
let r = new ProgressEvent("progress", {
lengthComputable: o,
loaded: s,
total: a
});
for (let e = 0, t = n.length; e < t; e++) {
let t = n[e];
t.onProgress && t.onProgress(r);
}
e.enqueue(i), t();
}
}, (t) => {
e.error(t);
});
}
} });
return new Response(c);
} else throw new ru(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`, t);
}).then((e) => {
switch (s) {
case "arraybuffer": return e.arrayBuffer();
case "blob": return e.blob();
case "document": return e.text().then((e) => new DOMParser().parseFromString(e, o));
case "json": return e.json();
default:
if (o === "") return e.text();
{
let t = /charset="?([^;"\s]*)"?/i.exec(o), n = t && t[1] ? t[1].toLowerCase() : void 0, r = new TextDecoder(n);
return e.arrayBuffer().then((e) => r.decode(e));
}
}
}).then((t) => {
Zl.add(`file:${e}`, t);
let n = nu[e];
delete nu[e];
for (let e = 0, r = n.length; e < r; e++) {
let r = n[e];
r.onLoad && r.onLoad(t);
}
}).catch((t) => {
let n = nu[e];
if (n === void 0) throw this.manager.itemError(e), t;
delete nu[e];
for (let e = 0, r = n.length; e < r; e++) {
let r = n[e];
r.onError && r.onError(t);
}
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;
}
}, au = class extends tu {
constructor(e) {
super(e);
}
load(e, t, n, r) {
let i = this, a = new iu(this.manager);
a.setPath(this.path), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(n) {
try {
t(i.parse(JSON.parse(n)));
} catch (t) {
r ? r(t) : R(t), i.manager.itemError(e);
}
}, n, r);
}
parse(e) {
let t = [];
for (let n = 0; n < e.length; n++) {
let r = Jl.parse(e[n]);
t.push(r);
}
return t;
}
}, ou = class extends tu {
constructor(e) {
super(e);
}
load(e, t, n, r) {
let i = this, a = [], o = new ls(), s = new iu(this.manager);
s.setPath(this.path), s.setResponseType("arraybuffer"), s.setRequestHeader(this.requestHeader), s.setWithCredentials(i.withCredentials);
let c = 0;
function l(l) {
s.load(e[l], function(e) {
let n = i.parse(e, !0);
a[l] = {
width: n.width,
height: n.height,
format: n.format,
mipmaps: n.mipmaps
}, c += 1, c === 6 && (n.mipmapCount === 1 && (o.minFilter = A), o.image = a, o.format = n.format, o.needsUpdate = !0, t && t(o));
}, n, r);
}
if (Array.isArray(e)) for (let t = 0, n = e.length; t < n; ++t) l(t);
else s.load(e, function(e) {
let n = i.parse(e, !0);
if (n.isCubemap) {
let e = n.mipmaps.length / n.mipmapCount;
for (let t = 0; t < e; t++) {
a[t] = { mipmaps: [] };
for (let e = 0; e < n.mipmapCount; e++) a[t].mipmaps.push(n.mipmaps[t * n.mipmapCount + e]), a[t].format = n.format, a[t].width = n.width, a[t].height = n.height;
}
o.image = a;
} else o.image.width = n.width, o.image.height = n.height, o.mipmaps = n.mipmaps;
n.mipmapCount === 1 && (o.minFilter = A), o.format = n.format, o.needsUpdate = !0, t && t(o);
}, n, r);
return o;
}
}, su = /* @__PURE__ */ new WeakMap(), cu = class extends tu {
constructor(e) {
super(e);
}
load(e, t, n, r) {
this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);
let i = this, a = Zl.get(`image:${e}`);
if (a !== void 0) {
if (a.complete === !0) i.manager.itemStart(e), setTimeout(function() {
t && t(a), i.manager.itemEnd(e);
}, 0);
else {
let e = su.get(a);
e === void 0 && (e = [], su.set(a, e)), e.push({
onLoad: t,
onError: r
});
}
return a;
}
let o = Zt("img");
function s() {
l(), t && t(this);
let n = su.get(this) || [];
for (let e = 0; e < n.length; e++) {
let t = n[e];
t.onLoad && t.onLoad(this);
}
su.delete(this), i.manager.itemEnd(e);
}
function c(t) {
l(), r && r(t), Zl.remove(`image:${e}`);
let n = su.get(this) || [];
for (let e = 0; e < n.length; e++) {
let r = n[e];
r.onError && r.onError(t);
}
su.delete(this), i.manager.itemError(e), i.manager.itemEnd(e);
}
function l() {
o.removeEventListener("load", s, !1), o.removeEventListener("error", c, !1);
}
return o.addEventListener("load", s, !1), o.addEventListener("error", c, !1), e.slice(0, 5) !== "data:" && this.crossOrigin !== void 0 && (o.crossOrigin = this.crossOrigin), Zl.add(`image:${e}`, o), i.manager.itemStart(e), o.src = e, o;
}
}, lu = class extends tu {
constructor(e) {
super(e);
}
load(e, t, n, r) {
let i = new fs();
i.colorSpace = bt;
let a = new cu(this.manager);
a.setCrossOrigin(this.crossOrigin), a.setPath(this.path);
let o = 0;
function s(n) {
a.load(e[n], function(e) {
i.images[n] = e, o++, o === 6 && (i.needsUpdate = !0, t && t(i));
}, void 0, r);
}
for (let t = 0; t < e.length; ++t) s(t);
return i;
}
}, uu = class extends tu {
constructor(e) {
super(e);
}
load(e, t, n, r) {
let i = this, a = new Xa(), o = new iu(this.manager);
return o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(i.withCredentials), o.load(e, function(e) {
let n;
try {
n = i.parse(e);
} catch (e) {
r === void 0 ? R(e) : r(e);
return;
}
i._applyTexData(a, n), t && t(a, n);
}, n, r), a;
}
createDataTexture(e) {
let t = new Xa();
return this._applyTexData(t, this.parse(e)), t;
}
_applyTexData(e, t) {
t.image === void 0 ? t.data !== void 0 && (e.image.width = t.width, e.image.height = t.height, e.image.data = t.data) : e.image = t.image, e.wrapS = t.wrapS === void 0 ? C : t.wrapS, e.wrapT = t.wrapT === void 0 ? C : t.wrapT, e.magFilter = t.magFilter === void 0 ? A : t.magFilter, e.minFilter = t.minFilter === void 0 ? A : t.minFilter, e.anisotropy = t.anisotropy === void 0 ? 1 : t.anisotropy, t.colorSpace !== void 0 && (e.colorSpace = t.colorSpace), t.flipY !== void 0 && (e.flipY = t.flipY), t.format !== void 0 && (e.format = t.format), t.type !== void 0 && (e.type = t.type), t.mipmaps !== void 0 && (e.mipmaps = t.mipmaps, e.minFilter = ne), t.mipmapCount === 1 && (e.minFilter = A), t.generateMipmaps !== void 0 && (e.generateMipmaps = t.generateMipmaps), e.needsUpdate = !0;
}
}, du = class extends tu {
constructor(e) {
super(e);
}
load(e, t, n, r) {
let i = new Qn(), a = new cu(this.manager);
return a.setCrossOrigin(this.crossOrigin), a.setPath(this.path), a.load(e, function(e) {
i.image = e, i.needsUpdate = !0, t !== void 0 && t(i);
}, n, r), i;
}
}, fu = class extends Mr {
constructor(e, t = 1) {
super(), this.isLight = !0, this.type = "Light", this.color = new G(e), this.intensity = t;
}
dispose() {
this.dispatchEvent({ type: "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);
return t.object.color = this.color.getHex(), t.object.intensity = this.intensity, t;
}
}, pu = class extends fu {
constructor(e, t, n) {
super(e, n), this.isHemisphereLight = !0, this.type = "HemisphereLight", this.position.copy(Mr.DEFAULT_UP), this.updateMatrix(), this.groundColor = new G(t);
}
copy(e, t) {
return super.copy(e, t), this.groundColor.copy(e.groundColor), this;
}
toJSON(e) {
let t = super.toJSON(e);
return t.object.groundColor = this.groundColor.getHex(), t;
}
}, mu = /*@__PURE__*/ new W(), hu = /*@__PURE__*/ new H(), gu = /*@__PURE__*/ new H(), _u = class {
constructor(e) {
this.camera = e, this.intensity = 1, this.bias = 0, this.biasNode = null, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new V(512, 512), this.mapType = M, this.map = null, this.mapPass = null, this.matrix = new W(), this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new _o(), this._frameExtents = new V(1, 1), this._viewportCount = 1, this._viewports = [new $n(0, 0, 1, 1)];
}
getViewportCount() {
return this._viewportCount;
}
getFrustum() {
return this._frustum;
}
updateMatrices(e) {
let t = this.camera, n = this.matrix;
hu.setFromMatrixPosition(e.matrixWorld), t.position.copy(hu), gu.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(gu), t.updateMatrixWorld(), mu.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(mu, t.coordinateSystem, t.reversedDepth), t.coordinateSystem === 2001 || t.reversedDepth ? n.set(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, 1, 0, 0, 0, 0, 1) : n.set(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1), n.multiply(mu);
}
getViewport(e) {
return this._viewports[e];
}
getFrameExtents() {
return this._frameExtents;
}
dispose() {
this.map && this.map.dispose(), 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.biasNode = e.biasNode, this;
}
clone() {
return new this.constructor().copy(this);
}
toJSON() {
let e = {};
return this.intensity !== 1 && (e.intensity = this.intensity), this.bias !== 0 && (e.bias = this.bias), this.normalBias !== 0 && (e.normalBias = this.normalBias), this.radius !== 1 && (e.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (e.mapSize = this.mapSize.toArray()), e.camera = this.camera.toJSON(!1).object, delete e.camera.matrix, e;
}
}, vu = /*@__PURE__*/ new H(), yu = /*@__PURE__*/ new Fn(), bu = /*@__PURE__*/ new H(), xu = class extends Mr {
constructor() {
super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new W(), this.projectionMatrix = new W(), this.projectionMatrixInverse = new W(), this.coordinateSystem = Vt, 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.matrixWorld.decompose(vu, yu, bu), bu.x === 1 && bu.y === 1 && bu.z === 1 ? this.matrixWorldInverse.copy(this.matrixWorld).invert() : this.matrixWorldInverse.compose(vu, yu, bu.set(1, 1, 1)).invert();
}
updateWorldMatrix(e, t, n = !1) {
super.updateWorldMatrix(e, t, n), this.matrixWorld.decompose(vu, yu, bu), bu.x === 1 && bu.y === 1 && bu.z === 1 ? this.matrixWorldInverse.copy(this.matrixWorld).invert() : this.matrixWorldInverse.compose(vu, yu, bu.set(1, 1, 1)).invert();
}
clone() {
return new this.constructor().copy(this);
}
}, X = /*@__PURE__*/ new H(), Su = /*@__PURE__*/ new V(), Cu = /*@__PURE__*/ new V(), Z = class extends xu {
constructor(e = 50, t = 1, n = .1, r = 2e3) {
super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = n, this.far = r, 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 = .5 * this.getFilmHeight() / e;
this.fov = pn * 2 * Math.atan(t), this.updateProjectionMatrix();
}
getFocalLength() {
let e = Math.tan(fn * .5 * this.fov);
return .5 * this.getFilmHeight() / e;
}
getEffectiveFOV() {
return pn * 2 * Math.atan(Math.tan(fn * .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) {
X.set(-1, -1, .5).applyMatrix4(this.projectionMatrixInverse), t.set(X.x, X.y).multiplyScalar(-e / X.z), X.set(1, 1, .5).applyMatrix4(this.projectionMatrixInverse), n.set(X.x, X.y).multiplyScalar(-e / X.z);
}
getViewSize(e, t) {
return this.getViewBounds(e, Su, Cu), t.subVectors(Cu, Su);
}
setViewOffset(e, t, n, r, i, a) {
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 = r, this.view.width = i, this.view.height = a, this.updateProjectionMatrix();
}
clearViewOffset() {
this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
}
updateProjectionMatrix() {
let e = this.near, t = e * Math.tan(fn * .5 * this.fov) / this.zoom, n = 2 * t, r = this.aspect * n, i = -.5 * r, a = this.view;
if (this.view !== null && this.view.enabled) {
let e = a.fullWidth, o = a.fullHeight;
i += a.offsetX * r / e, t -= a.offsetY * n / o, r *= a.width / e, n *= a.height / o;
}
let o = this.filmOffset;
o !== 0 && (i += e * o / this.getFilmWidth()), this.projectionMatrix.makePerspective(i, i + r, t, t - n, e, this.far, this.coordinateSystem, this.reversedDepth), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
}
toJSON(e) {
let t = super.toJSON(e);
return 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)), t.object.filmGauge = this.filmGauge, t.object.filmOffset = this.filmOffset, t;
}
}, wu = class extends _u {
constructor() {
super(new Z(50, 1, .5, 500)), this.isSpotLightShadow = !0, this.focus = 1, this.aspect = 1;
}
updateMatrices(e) {
let t = this.camera, n = pn * 2 * e.angle * this.focus, r = this.mapSize.width / this.mapSize.height * this.aspect, i = e.distance || t.far;
(n !== t.fov || r !== t.aspect || i !== t.far) && (t.fov = n, t.aspect = r, t.far = i, t.updateProjectionMatrix()), super.updateMatrices(e);
}
copy(e) {
return super.copy(e), this.focus = e.focus, this;
}
}, Tu = class extends fu {
constructor(e, t, n = 0, r = Math.PI / 3, i = 0, a = 2) {
super(e, t), this.isSpotLight = !0, this.type = "SpotLight", this.position.copy(Mr.DEFAULT_UP), this.updateMatrix(), this.target = new Mr(), this.distance = n, this.angle = r, this.penumbra = i, this.decay = a, this.map = null, this.shadow = new wu();
}
get power() {
return this.intensity * Math.PI;
}
set power(e) {
this.intensity = e / Math.PI;
}
dispose() {
super.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.map = e.map, this.shadow = e.shadow.clone(), this;
}
toJSON(e) {
let t = super.toJSON(e);
return t.object.distance = this.distance, t.object.angle = this.angle, t.object.decay = this.decay, t.object.penumbra = this.penumbra, t.object.target = this.target.uuid, this.map && this.map.isTexture && (t.object.map = this.map.toJSON(e).uuid), t.object.shadow = this.shadow.toJSON(), t;
}
}, Eu = class extends _u {
constructor() {
super(new Z(90, 1, .5, 500)), this.isPointLightShadow = !0;
}
}, Du = class extends fu {
constructor(e, t, n = 0, r = 2) {
super(e, t), this.isPointLight = !0, this.type = "PointLight", this.distance = n, this.decay = r, this.shadow = new Eu();
}
get power() {
return this.intensity * 4 * Math.PI;
}
set power(e) {
this.intensity = e / (4 * Math.PI);
}
dispose() {
super.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;
}
toJSON(e) {
let t = super.toJSON(e);
return t.object.distance = this.distance, t.object.decay = this.decay, t.object.shadow = this.shadow.toJSON(), t;
}
}, Ou = class extends xu {
constructor(e = -1, t = 1, n = 1, r = -1, i = .1, a = 2e3) {
super(), this.isOrthographicCamera = !0, this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = e, this.right = t, this.top = n, this.bottom = r, this.near = i, this.far = a, 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, r, i, a) {
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 = r, this.view.width = i, this.view.height = a, this.updateProjectionMatrix();
}
clearViewOffset() {
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, r = (this.top + this.bottom) / 2, i = n - e, a = n + e, o = r + t, s = r - t;
if (this.view !== null && this.view.enabled) {
let e = (this.right - this.left) / this.view.fullWidth / this.zoom, t = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
i += e * this.view.offsetX, a = i + e * this.view.width, o -= t * this.view.offsetY, s = o - t * this.view.height;
}
this.projectionMatrix.makeOrthographic(i, a, o, s, this.near, this.far, this.coordinateSystem, this.reversedDepth), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
}
toJSON(e) {
let t = super.toJSON(e);
return 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)), t;
}
}, ku = class extends _u {
constructor() {
super(new Ou(-5, 5, 5, -5, .5, 500)), this.isDirectionalLightShadow = !0;
}
}, Au = class extends fu {
constructor(e, t) {
super(e, t), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(Mr.DEFAULT_UP), this.updateMatrix(), this.target = new Mr(), this.shadow = new ku();
}
dispose() {
super.dispose(), this.shadow.dispose();
}
copy(e) {
return super.copy(e), this.target = e.target.clone(), this.shadow = e.shadow.clone(), this;
}
toJSON(e) {
let t = super.toJSON(e);
return t.object.shadow = this.shadow.toJSON(), t.object.target = this.target.uuid, t;
}
}, ju = class extends fu {
constructor(e, t) {
super(e, t), this.isAmbientLight = !0, this.type = "AmbientLight";
}
}, Mu = class extends fu {
constructor(e, t, n = 10, r = 10) {
super(e, t), this.isRectAreaLight = !0, this.type = "RectAreaLight", this.width = n, this.height = r;
}
get power() {
return this.intensity * this.width * this.height * Math.PI;
}
set power(e) {
this.intensity = e / (this.width * this.height * Math.PI);
}
copy(e) {
return super.copy(e), this.width = e.width, this.height = e.height, this;
}
toJSON(e) {
let t = super.toJSON(e);
return t.object.width = this.width, t.object.height = this.height, t;
}
}, Nu = class {
constructor() {
this.isSphericalHarmonics3 = !0, this.coefficients = [];
for (let e = 0; e < 9; e++) this.coefficients.push(new H());
}
set(e) {
for (let t = 0; t < 9; t++) this.coefficients[t].copy(e[t]);
return this;
}
zero() {
for (let e = 0; e < 9; e++) this.coefficients[e].set(0, 0, 0);
return this;
}
getAt(e, t) {
let n = e.x, r = e.y, i = e.z, a = this.coefficients;
return t.copy(a[0]).multiplyScalar(.282095), t.addScaledVector(a[1], .488603 * r), t.addScaledVector(a[2], .488603 * i), t.addScaledVector(a[3], .488603 * n), t.addScaledVector(a[4], n * r * 1.092548), t.addScaledVector(a[5], r * i * 1.092548), t.addScaledVector(a[6], .315392 * (3 * i * i - 1)), t.addScaledVector(a[7], n * i * 1.092548), t.addScaledVector(a[8], .546274 * (n * n - r * r)), t;
}
getIrradianceAt(e, t) {
let n = e.x, r = e.y, i = e.z, a = this.coefficients;
return t.copy(a[0]).multiplyScalar(.886227), t.addScaledVector(a[1], 2 * .511664 * r), t.addScaledVector(a[2], 2 * .511664 * i), t.addScaledVector(a[3], 2 * .511664 * n), t.addScaledVector(a[4], 2 * .429043 * n * r), t.addScaledVector(a[5], 2 * .429043 * r * i), t.addScaledVector(a[6], .743125 * i * i - .247708), t.addScaledVector(a[7], 2 * .429043 * n * i), t.addScaledVector(a[8], .429043 * (n * n - r * r)), t;
}
add(e) {
for (let t = 0; t < 9; t++) this.coefficients[t].add(e.coefficients[t]);
return this;
}
addScaledSH(e, t) {
for (let n = 0; n < 9; n++) this.coefficients[n].addScaledVector(e.coefficients[n], t);
return this;
}
scale(e) {
for (let t = 0; t < 9; t++) this.coefficients[t].multiplyScalar(e);
return this;
}
lerp(e, t) {
for (let n = 0; n < 9; n++) this.coefficients[n].lerp(e.coefficients[n], t);
return this;
}
equals(e) {
for (let t = 0; t < 9; t++) if (!this.coefficients[t].equals(e.coefficients[t])) return !1;
return !0;
}
copy(e) {
return this.set(e.coefficients);
}
clone() {
return new this.constructor().copy(this);
}
fromArray(e, t = 0) {
let n = this.coefficients;
for (let r = 0; r < 9; r++) n[r].fromArray(e, t + r * 3);
return this;
}
toArray(e = [], t = 0) {
let n = this.coefficients;
for (let r = 0; r < 9; r++) n[r].toArray(e, t + r * 3);
return e;
}
static getBasisAt(e, t) {
let n = e.x, r = e.y, i = e.z;
t[0] = .282095, t[1] = .488603 * r, t[2] = .488603 * i, t[3] = .488603 * n, t[4] = 1.092548 * n * r, t[5] = 1.092548 * r * i, t[6] = .315392 * (3 * i * i - 1), t[7] = 1.092548 * n * i, t[8] = .546274 * (n * n - r * r);
}
}, Pu = class extends fu {
constructor(e = new Nu(), t = 1) {
super(void 0, t), this.isLightProbe = !0, this.sh = e;
}
copy(e) {
return super.copy(e), this.sh.copy(e.sh), this;
}
toJSON(e) {
let t = super.toJSON(e);
return t.object.sh = this.sh.toArray(), t;
}
}, Fu = {}, Iu = class e extends tu {
constructor(e) {
super(e), this.textures = {};
}
load(e, t, n, r) {
let i = this, a = new iu(i.manager);
a.setPath(i.path), a.setRequestHeader(i.requestHeader), a.setWithCredentials(i.withCredentials), a.load(e, function(n) {
try {
t(i.parse(JSON.parse(n)));
} catch (t) {
r ? r(t) : R(t), i.manager.itemError(e);
}
}, n, r);
}
parse(e) {
let t = this.createMaterialFromType(e.type);
return t.fromJSON(e, this.textures), t;
}
setTextures(e) {
return this.textures = e, this;
}
createMaterialFromType(t) {
return e.createMaterialFromType(t);
}
static createMaterialFromType(e) {
let t = {
ShadowMaterial: cl,
SpriteMaterial: Qi,
RawShaderMaterial: vl,
ShaderMaterial: _l,
PointsMaterial: $o,
MeshPhysicalMaterial: bl,
MeshStandardMaterial: yl,
MeshPhongMaterial: xl,
MeshToonMaterial: Sl,
MeshNormalMaterial: Cl,
MeshLambertMaterial: wl,
MeshDepthMaterial: Tl,
MeshDistanceMaterial: El,
MeshBasicMaterial: Ta,
MeshMatcapMaterial: Dl,
LineDashedMaterial: Ol,
LineBasicMaterial: zo,
Material: Zi,
...Fu
}[e], n;
return t === void 0 ? (on(`MaterialLoader: Unknown material type "${e}". Use .registerMaterial() before starting the deserialization process.`), n = new Zi()) : n = new t(), n;
}
static registerMaterial(e, t) {
Fu[e] = t;
}
}, Lu = class {
static extractUrlBase(e) {
let t = e.lastIndexOf("/");
return t === -1 ? "./" : e.slice(0, t + 1);
}
static resolveURL(e, t) {
return typeof e != "string" || e === "" ? "" : (/^https?:\/\//i.test(t) && /^\//.test(e) && (t = t.replace(/(^https?:\/\/[^\/]+).*/i, "$1")), /^(https?:)?\/\//i.test(e) || /^data:.*,.*$/i.test(e) || /^blob:.*$/i.test(e) ? e : t + e);
}
}, Ru = class extends q {
constructor() {
super(), this.isInstancedBufferGeometry = !0, this.type = "InstancedBufferGeometry", this.instanceCount = Infinity;
}
copy(e) {
return super.copy(e), this.instanceCount = e.instanceCount, this;
}
toJSON() {
let e = super.toJSON();
return e.instanceCount = this.instanceCount, e.isInstancedBufferGeometry = !0, e;
}
}, zu = class extends tu {
constructor(e) {
super(e);
}
load(e, t, n, r) {
let i = this, a = new iu(i.manager);
a.setPath(i.path), a.setRequestHeader(i.requestHeader), a.setWithCredentials(i.withCredentials), a.load(e, function(n) {
try {
t(i.parse(JSON.parse(n)));
} catch (t) {
r ? r(t) : R(t), i.manager.itemError(e);
}
}, n, r);
}
parse(e) {
let t = {}, n = {};
function r(e, n) {
if (t[n] !== void 0) return t[n];
let r = e.interleavedBuffers[n], a = i(e, r.buffer), o = new qi(Yt(r.type, a), r.stride);
return o.uuid = r.uuid, t[n] = o, o;
}
function i(e, t) {
if (n[t] !== void 0) return n[t];
let r = e.arrayBuffers[t], i = new Uint32Array(r).buffer;
return n[t] = i, i;
}
let a = e.isInstancedBufferGeometry ? new Ru() : new q(), o = e.data.index;
if (o !== void 0) {
let e = Yt(o.type, o.array);
a.setIndex(new Di(e, 1));
}
let s = e.data.attributes;
for (let t in s) {
let n = s[t], i;
if (n.isInterleavedBufferAttribute) i = new Yi(r(e.data, n.data), n.itemSize, n.offset, n.normalized);
else {
let e = Yt(n.type, n.array);
i = new (n.isInstancedBufferAttribute ? eo : Di)(e, n.itemSize, n.normalized);
}
n.name !== void 0 && (i.name = n.name), n.usage !== void 0 && i.setUsage(n.usage), a.setAttribute(t, i);
}
let c = e.data.morphAttributes;
if (c) for (let t in c) {
let n = c[t], i = [];
for (let t = 0, a = n.length; t < a; t++) {
let a = n[t], o;
o = a.isInterleavedBufferAttribute ? new Yi(r(e.data, a.data), a.itemSize, a.offset, a.normalized) : new Di(Yt(a.type, a.array), a.itemSize, a.normalized), a.name !== void 0 && (o.name = a.name), i.push(o);
}
a.morphAttributes[t] = i;
}
e.data.morphTargetsRelative && (a.morphTargetsRelative = !0);
let l = e.data.groups || e.data.drawcalls || e.data.offsets;
if (l !== void 0) for (let e = 0, t = l.length; e !== t; ++e) {
let t = l[e];
a.addGroup(t.start, t.count, t.materialIndex);
}
let u = e.data.boundingSphere;
return u !== void 0 && (a.boundingSphere = new zi().fromJSON(u)), e.name && (a.name = e.name), e.userData && (a.userData = e.userData), a;
}
}, Bu = {}, Vu = class extends tu {
constructor(e) {
super(e);
}
load(e, t, n, r) {
let i = this, a = this.path === "" ? Lu.extractUrlBase(e) : this.path;
this.resourcePath = this.resourcePath || a;
let o = new iu(this.manager);
o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(n) {
let a = null;
try {
a = JSON.parse(n);
} catch (t) {
r !== void 0 && r(t), R("ObjectLoader: Can't parse " + e + ".", t.message);
return;
}
let o = a.metadata;
if (o === void 0 || o.type === void 0 || o.type.toLowerCase() === "geometry") {
r !== void 0 && r(/* @__PURE__ */ Error("THREE.ObjectLoader: Can't load " + e)), R("ObjectLoader: Can't load " + e);
return;
}
i.parse(a, t);
}, n, r);
}
async loadAsync(e, t) {
let n = this, r = this.path === "" ? Lu.extractUrlBase(e) : this.path;
this.resourcePath = this.resourcePath || r;
let i = new iu(this.manager);
i.setPath(this.path), i.setRequestHeader(this.requestHeader), i.setWithCredentials(this.withCredentials);
let a = await i.loadAsync(e, t), o;
try {
o = JSON.parse(a);
} catch (t) {
throw Error("THREE.ObjectLoader: Can't parse " + e + ". " + t.message);
}
let s = o.metadata;
if (s === void 0 || s.type === void 0 || s.type.toLowerCase() === "geometry") throw Error("THREE.ObjectLoader: Can't load " + e);
return await n.parseAsync(o);
}
parse(e, t) {
let n = this.parseAnimations(e.animations), r = this.parseShapes(e.shapes), i = this.parseGeometries(e.geometries, r), a = this.parseImages(e.images, function() {
t !== void 0 && t(c);
}), o = this.parseTextures(e.textures, a), s = this.parseMaterials(e.materials, o), c = this.parseObject(e.object, i, s, o, n), l = this.parseSkeletons(e.skeletons, c);
if (this.bindSkeletons(c, l), this.bindLightTargets(c), t !== void 0) {
let e = !1;
for (let t in a) if (a[t].data instanceof HTMLImageElement) {
e = !0;
break;
}
e === !1 && t(c);
}
return c;
}
async parseAsync(e) {
let t = this.parseAnimations(e.animations), n = this.parseShapes(e.shapes), r = this.parseGeometries(e.geometries, n), i = await this.parseImagesAsync(e.images), a = this.parseTextures(e.textures, i), o = this.parseMaterials(e.materials, a), s = this.parseObject(e.object, r, o, a, t), c = this.parseSkeletons(e.skeletons, s);
return this.bindSkeletons(s, c), this.bindLightTargets(s), s;
}
static registerGeometry(e, t) {
Bu[e] = t;
}
parseShapes(e) {
let t = {};
if (e !== void 0) for (let n = 0, r = e.length; n < r; n++) {
let r = new oc().fromJSON(e[n]);
t[r.uuid] = r;
}
return t;
}
parseSkeletons(e, t) {
let n = {}, r = {};
if (t.traverse(function(e) {
e.isBone && (r[e.uuid] = e);
}), e !== void 0) for (let t = 0, i = e.length; t < i; t++) {
let i = new $a().fromJSON(e[t], r);
n[i.uuid] = i;
}
return n;
}
parseGeometries(e, t) {
let n = {};
if (e !== void 0) {
let r = new zu();
for (let i = 0, a = e.length; i < a; i++) {
let a, o = e[i];
switch (o.type) {
case "BufferGeometry":
case "InstancedBufferGeometry":
a = r.parse(o);
break;
default: o.type in sl ? a = sl[o.type].fromJSON(o, t) : o.type in Bu ? a = Bu[o.type].fromJSON(o, t) : L(`ObjectLoader: Unknown geometry type "${o.type}". Use .registerGeometry() before starting the deserialization process.`);
}
a.uuid = o.uuid, o.name !== void 0 && (a.name = o.name), o.userData !== void 0 && (a.userData = o.userData), n[o.uuid] = a;
}
}
return n;
}
parseMaterials(e, t) {
let n = {}, r = {};
if (e !== void 0) {
let i = new Iu();
i.setTextures(t);
for (let t = 0, a = e.length; t < a; t++) {
let a = e[t];
n[a.uuid] === void 0 && (n[a.uuid] = i.parse(a)), r[a.uuid] = n[a.uuid];
}
}
return r;
}
parseAnimations(e) {
let t = {};
if (e !== void 0) for (let n = 0; n < e.length; n++) {
let r = e[n], i = Jl.parse(r);
t[i.uuid] = i;
}
return t;
}
parseImages(e, t) {
let n = this, r = {}, i;
function a(e) {
return e = n.manager.resolveURL(e), n.manager.itemStart(e), i.load(e, function() {
n.manager.itemEnd(e);
}, void 0, function() {
n.manager.itemError(e), n.manager.itemEnd(e);
});
}
function o(e) {
if (typeof e == "string") {
let t = e;
return a(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t) ? t : n.resourcePath + t);
} else if (e.data) return {
data: Yt(e.type, e.data),
width: e.width,
height: e.height
};
else return null;
}
if (e !== void 0 && e.length > 0) {
i = new cu(new $l(t)), i.setCrossOrigin(this.crossOrigin);
for (let t = 0, n = e.length; t < n; t++) {
let n = e[t], i = n.url;
if (Array.isArray(i)) {
let e = [];
for (let t = 0, n = i.length; t < n; t++) {
let n = i[t], r = o(n);
r !== null && (r instanceof HTMLImageElement ? e.push(r) : e.push(new Xa(r.data, r.width, r.height)));
}
r[n.uuid] = new Jn(e);
} else {
let e = o(n.url);
r[n.uuid] = new Jn(e);
}
}
}
return r;
}
async parseImagesAsync(e) {
let t = this, n = {}, r;
async function i(e) {
if (typeof e == "string") {
let n = e, i = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(n) ? n : t.resourcePath + n;
return await r.loadAsync(i);
} else if (e.data) return {
data: Yt(e.type, e.data),
width: e.width,
height: e.height
};
else return null;
}
if (e !== void 0 && e.length > 0) {
r = new cu(this.manager), r.setCrossOrigin(this.crossOrigin);
for (let t = 0, r = e.length; t < r; t++) {
let r = e[t], a = r.url;
if (Array.isArray(a)) {
let e = [];
for (let t = 0, n = a.length; t < n; t++) {
let n = a[t], r = await i(n);
r !== null && (r instanceof HTMLImageElement ? e.push(r) : e.push(new Xa(r.data, r.width, r.height)));
}
n[r.uuid] = new Jn(e);
} else {
let e = await i(r.url);
n[r.uuid] = new Jn(e);
}
}
}
return n;
}
parseTextures(e, t) {
function n(e, t) {
return typeof e == "number" ? e : (L("ObjectLoader.parseTexture: Constant should be in numeric form.", e), t[e]);
}
let r = {};
if (e !== void 0) for (let i = 0, a = e.length; i < a; i++) {
let a = e[i];
a.image === void 0 && L("ObjectLoader: No \"image\" specified for", a.uuid), t[a.image] === void 0 && L("ObjectLoader: Undefined image", a.image);
let o = t[a.image], s = o.data, c;
Array.isArray(s) ? (c = new fs(), s.length === 6 && (c.needsUpdate = !0)) : (c = s && s.data ? new Xa() : new Qn(), s && (c.needsUpdate = !0)), c.source = o, c.uuid = a.uuid, a.name !== void 0 && (c.name = a.name), a.mapping !== void 0 && (c.mapping = n(a.mapping, Hu)), a.channel !== void 0 && (c.channel = a.channel), a.offset !== void 0 && c.offset.fromArray(a.offset), a.repeat !== void 0 && c.repeat.fromArray(a.repeat), a.center !== void 0 && c.center.fromArray(a.center), a.rotation !== void 0 && (c.rotation = a.rotation), a.wrap !== void 0 && (c.wrapS = n(a.wrap[0], Uu), c.wrapT = n(a.wrap[1], Uu)), a.format !== void 0 && (c.format = a.format), a.internalFormat !== void 0 && (c.internalFormat = a.internalFormat), a.type !== void 0 && (c.type = a.type), a.colorSpace !== void 0 && (c.colorSpace = a.colorSpace), a.minFilter !== void 0 && (c.minFilter = n(a.minFilter, Wu)), a.magFilter !== void 0 && (c.magFilter = n(a.magFilter, Wu)), a.anisotropy !== void 0 && (c.anisotropy = a.anisotropy), a.flipY !== void 0 && (c.flipY = a.flipY), a.generateMipmaps !== void 0 && (c.generateMipmaps = a.generateMipmaps), a.premultiplyAlpha !== void 0 && (c.premultiplyAlpha = a.premultiplyAlpha), a.unpackAlignment !== void 0 && (c.unpackAlignment = a.unpackAlignment), a.compareFunction !== void 0 && (c.compareFunction = a.compareFunction), a.normalized !== void 0 && (c.normalized = a.normalized), a.userData !== void 0 && (c.userData = a.userData), r[a.uuid] = c;
}
return r;
}
parseObject(e, t, n, r, i) {
let a;
function o(e) {
return t[e] === void 0 && L("ObjectLoader: Undefined geometry", e), t[e];
}
function s(e) {
if (e !== void 0) {
if (Array.isArray(e)) {
let t = [];
for (let r = 0, i = e.length; r < i; r++) {
let i = e[r];
n[i] === void 0 && L("ObjectLoader: Undefined material", i), t.push(n[i]);
}
return t;
}
return n[e] === void 0 && L("ObjectLoader: Undefined material", e), n[e];
}
}
function c(e) {
return r[e] === void 0 && L("ObjectLoader: Undefined texture", e), r[e];
}
let l, u;
switch (e.type) {
case "Scene":
a = new Ur(), e.background !== void 0 && (Number.isInteger(e.background) ? a.background = new G(e.background) : a.background = c(e.background)), e.environment !== void 0 && (a.environment = c(e.environment)), e.fog !== void 0 && (e.fog.type === "Fog" ? a.fog = new Hr(e.fog.color, e.fog.near, e.fog.far) : e.fog.type === "FogExp2" && (a.fog = new Vr(e.fog.color, e.fog.density)), e.fog.name !== "" && (a.fog.name = e.fog.name)), e.backgroundBlurriness !== void 0 && (a.backgroundBlurriness = e.backgroundBlurriness), e.backgroundIntensity !== void 0 && (a.backgroundIntensity = e.backgroundIntensity), e.backgroundRotation !== void 0 && a.backgroundRotation.fromArray(e.backgroundRotation), e.environmentIntensity !== void 0 && (a.environmentIntensity = e.environmentIntensity), e.environmentRotation !== void 0 && a.environmentRotation.fromArray(e.environmentRotation);
break;
case "PerspectiveCamera":
a = new Z(e.fov, e.aspect, e.near, e.far), e.focus !== void 0 && (a.focus = e.focus), e.zoom !== void 0 && (a.zoom = e.zoom), e.filmGauge !== void 0 && (a.filmGauge = e.filmGauge), e.filmOffset !== void 0 && (a.filmOffset = e.filmOffset), e.view !== void 0 && (a.view = Object.assign({}, e.view));
break;
case "OrthographicCamera":
a = new Ou(e.left, e.right, e.top, e.bottom, e.near, e.far), e.zoom !== void 0 && (a.zoom = e.zoom), e.view !== void 0 && (a.view = Object.assign({}, e.view));
break;
case "AmbientLight":
a = new ju(e.color, e.intensity);
break;
case "DirectionalLight":
a = new Au(e.color, e.intensity), a.target = e.target || "";
break;
case "PointLight":
a = new Du(e.color, e.intensity, e.distance, e.decay);
break;
case "RectAreaLight":
a = new Mu(e.color, e.intensity, e.width, e.height);
break;
case "SpotLight":
a = new Tu(e.color, e.intensity, e.distance, e.angle, e.penumbra, e.decay), a.target = e.target || "";
break;
case "HemisphereLight":
a = new pu(e.color, e.groundColor, e.intensity);
break;
case "LightProbe":
a = new Pu(new Nu().fromArray(e.sh), e.intensity);
break;
case "SkinnedMesh":
l = o(e.geometry), u = s(e.material), a = new Ja(l, u), e.bindMode !== void 0 && (a.bindMode = e.bindMode), e.bindMatrix !== void 0 && a.bindMatrix.fromArray(e.bindMatrix), e.skeleton !== void 0 && (a.skeleton = e.skeleton);
break;
case "Mesh":
l = o(e.geometry), u = s(e.material), a = new La(l, u);
break;
case "InstancedMesh":
l = o(e.geometry), u = s(e.material);
let t = e.count, n = e.instanceMatrix, r = e.instanceColor;
a = new co(l, u, t), a.instanceMatrix = new eo(new Float32Array(n.array), 16), r !== void 0 && (a.instanceColor = new eo(new Float32Array(r.array), r.itemSize));
break;
case "BatchedMesh":
l = o(e.geometry), u = s(e.material), a = new Ro(e.maxInstanceCount, e.maxVertexCount, e.maxIndexCount, u), a.geometry = l, a.perObjectFrustumCulled = e.perObjectFrustumCulled, a.sortObjects = e.sortObjects, a._drawRanges = e.drawRanges, a._reservedRanges = e.reservedRanges, a._geometryInfo = e.geometryInfo.map((e) => {
let t = null, n = null;
return e.boundingBox !== void 0 && (t = new ii().fromJSON(e.boundingBox)), e.boundingSphere !== void 0 && (n = new zi().fromJSON(e.boundingSphere)), {
...e,
boundingBox: t,
boundingSphere: n
};
}), a._instanceInfo = e.instanceInfo, a._availableInstanceIds = e._availableInstanceIds, a._availableGeometryIds = e._availableGeometryIds, a._nextIndexStart = e.nextIndexStart, a._nextVertexStart = e.nextVertexStart, a._geometryCount = e.geometryCount, a._maxInstanceCount = e.maxInstanceCount, a._maxVertexCount = e.maxVertexCount, a._maxIndexCount = e.maxIndexCount, a._geometryInitialized = e.geometryInitialized, a._matricesTexture = c(e.matricesTexture.uuid), a._indirectTexture = c(e.indirectTexture.uuid), e.colorsTexture !== void 0 && (a._colorsTexture = c(e.colorsTexture.uuid)), e.boundingSphere !== void 0 && (a.boundingSphere = new zi().fromJSON(e.boundingSphere)), e.boundingBox !== void 0 && (a.boundingBox = new ii().fromJSON(e.boundingBox));
break;
case "LOD":
a = new ga();
break;
case "Line":
a = new qo(o(e.geometry), s(e.material));
break;
case "LineLoop":
a = new Qo(o(e.geometry), s(e.material));
break;
case "LineSegments":
a = new Zo(o(e.geometry), s(e.material));
break;
case "PointCloud":
case "Points":
a = new is(o(e.geometry), s(e.material));
break;
case "Sprite":
a = new fa(s(e.material));
break;
case "Group":
a = new Nr();
break;
case "Bone":
a = new Ya();
break;
default: a = new Mr();
}
if (a.uuid = e.uuid, e.name !== void 0 && (a.name = e.name), e.matrix === void 0 ? (e.position !== void 0 && a.position.fromArray(e.position), e.rotation !== void 0 && a.rotation.fromArray(e.rotation), e.quaternion !== void 0 && a.quaternion.fromArray(e.quaternion), e.scale !== void 0 && a.scale.fromArray(e.scale)) : (a.matrix.fromArray(e.matrix), e.matrixAutoUpdate !== void 0 && (a.matrixAutoUpdate = e.matrixAutoUpdate), a.matrixAutoUpdate && a.matrix.decompose(a.position, a.quaternion, a.scale)), e.up !== void 0 && a.up.fromArray(e.up), e.pivot !== void 0 && (a.pivot = new H().fromArray(e.pivot)), e.morphTargetDictionary !== void 0 && (a.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), e.morphTargetInfluences !== void 0 && (a.morphTargetInfluences = e.morphTargetInfluences.slice()), e.castShadow !== void 0 && (a.castShadow = e.castShadow), e.receiveShadow !== void 0 && (a.receiveShadow = e.receiveShadow), e.shadow && (e.shadow.intensity !== void 0 && (a.shadow.intensity = e.shadow.intensity), e.shadow.bias !== void 0 && (a.shadow.bias = e.shadow.bias), e.shadow.normalBias !== void 0 && (a.shadow.normalBias = e.shadow.normalBias), e.shadow.radius !== void 0 && (a.shadow.radius = e.shadow.radius), e.shadow.mapSize !== void 0 && a.shadow.mapSize.fromArray(e.shadow.mapSize), e.shadow.camera !== void 0 && (a.shadow.camera = this.parseObject(e.shadow.camera))), e.visible !== void 0 && (a.visible = e.visible), e.frustumCulled !== void 0 && (a.frustumCulled = e.frustumCulled), e.renderOrder !== void 0 && (a.renderOrder = e.renderOrder), e.static !== void 0 && (a.static = e.static), e.userData !== void 0 && (a.userData = e.userData), e.layers !== void 0 && (a.layers.mask = e.layers), e.children !== void 0) {
let o = e.children;
for (let e = 0; e < o.length; e++) a.add(this.parseObject(o[e], t, n, r, i));
}
if (e.animations !== void 0) {
let t = e.animations;
for (let e = 0; e < t.length; e++) {
let n = t[e];
a.animations.push(i[n]);
}
}
if (e.type === "LOD") {
e.autoUpdate !== void 0 && (a.autoUpdate = e.autoUpdate);
let t = e.levels;
for (let e = 0; e < t.length; e++) {
let n = t[e], r = a.getObjectByProperty("uuid", n.object);
r !== void 0 && a.addLevel(r, n.distance, n.hysteresis);
}
}
return a;
}
bindSkeletons(e, t) {
Object.keys(t).length !== 0 && e.traverse(function(e) {
if (e.isSkinnedMesh === !0 && e.skeleton !== void 0) {
let n = t[e.skeleton];
n === void 0 ? L("ObjectLoader: No skeleton found with UUID:", e.skeleton) : e.bind(n, e.bindMatrix);
}
});
}
bindLightTargets(e) {
e.traverse(function(t) {
if (t.isDirectionalLight || t.isSpotLight) {
let n = t.target, r = e.getObjectByProperty("uuid", n);
r === void 0 ? t.target = new Mr() : t.target = r;
}
});
}
}, Hu = {
UVMapping: 300,
CubeReflectionMapping: 301,
CubeRefractionMapping: 302,
EquirectangularReflectionMapping: 303,
EquirectangularRefractionMapping: 304,
CubeUVReflectionMapping: 306
}, Uu = {
RepeatWrapping: S,
ClampToEdgeWrapping: C,
MirroredRepeatWrapping: w
}, Wu = {
NearestFilter: T,
NearestMipmapNearestFilter: E,
NearestMipmapLinearFilter: O,
LinearFilter: A,
LinearMipmapNearestFilter: ee,
LinearMipmapLinearFilter: ne
}, Gu = /* @__PURE__ */ new WeakMap(), Ku = class extends tu {
constructor(e) {
super(e), this.isImageBitmapLoader = !0, typeof createImageBitmap > "u" && L("ImageBitmapLoader: createImageBitmap() not supported."), typeof fetch > "u" && L("ImageBitmapLoader: fetch() not supported."), this.options = { premultiplyAlpha: "none" }, this._abortController = new AbortController();
}
setOptions(e) {
return this.options = e, this;
}
load(e, t, n, r) {
e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);
let i = this, a = Zl.get(`image-bitmap:${e}`);
if (a !== void 0) {
if (i.manager.itemStart(e), a.then) {
a.then((n) => {
Gu.has(a) === !0 ? (r && r(Gu.get(a)), i.manager.itemError(e), i.manager.itemEnd(e)) : (t && t(n), i.manager.itemEnd(e));
});
return;
}
setTimeout(function() {
t && t(a), i.manager.itemEnd(e);
}, 0);
return;
}
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 s = fetch(e, o).then(function(e) {
return e.blob();
}).then(function(e) {
return createImageBitmap(e, Object.assign(i.options, { colorSpaceConversion: "none" }));
}).then(function(n) {
Zl.add(`image-bitmap:${e}`, n), t && t(n), i.manager.itemEnd(e);
}).catch(function(t) {
r && r(t), Gu.set(s, t), Zl.remove(`image-bitmap:${e}`), i.manager.itemError(e), i.manager.itemEnd(e);
});
Zl.add(`image-bitmap:${e}`, s), i.manager.itemStart(e);
}
abort() {
return this._abortController.abort(), this._abortController = new AbortController(), this;
}
}, qu, Ju = class {
static getContext() {
return qu === void 0 && (qu = new (window.AudioContext || window.webkitAudioContext)()), qu;
}
static setContext(e) {
qu = e;
}
}, Yu = class extends tu {
constructor(e) {
super(e);
}
load(e, t, n, r) {
let i = this, a = new iu(this.manager);
a.setResponseType("arraybuffer"), a.setPath(this.path), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(n) {
try {
let r = n.slice(0), a = Ju.getContext(), s = e + "#decode";
i.manager.itemStart(s), a.decodeAudioData(r, function(e) {
t(e), i.manager.itemEnd(s);
}).catch(function(e) {
o(e), i.manager.itemEnd(s);
});
} catch (e) {
o(e);
}
}, n, r);
function o(t) {
r ? r(t) : R(t), i.manager.itemError(e);
}
}
}, Xu = /*@__PURE__*/ new W(), Zu = /*@__PURE__*/ new W(), Qu = /*@__PURE__*/ new W(), $u = class {
constructor() {
this.type = "StereoCamera", this.aspect = 1, this.eyeSep = .064, this.cameraL = new Z(), this.cameraL.layers.enable(1), this.cameraL.matrixAutoUpdate = !1, this.cameraR = new Z(), this.cameraR.layers.enable(2), this.cameraR.matrixAutoUpdate = !1, this._cache = {
focus: null,
fov: null,
aspect: null,
near: null,
far: null,
zoom: null,
eyeSep: null
};
}
update(e) {
let t = this._cache;
if (t.focus !== e.focus || t.fov !== e.fov || t.aspect !== e.aspect * this.aspect || t.near !== e.near || t.far !== e.far || t.zoom !== e.zoom || t.eyeSep !== this.eyeSep) {
t.focus = e.focus, t.fov = e.fov, t.aspect = e.aspect * this.aspect, t.near = e.near, t.far = e.far, t.zoom = e.zoom, t.eyeSep = this.eyeSep, Qu.copy(e.projectionMatrix);
let n = t.eyeSep / 2, r = n * t.near / t.focus, i = t.near * Math.tan(fn * t.fov * .5) / t.zoom, a, o;
Zu.elements[12] = -n, Xu.elements[12] = n, a = -i * t.aspect + r, o = i * t.aspect + r, Qu.elements[0] = 2 * t.near / (o - a), Qu.elements[8] = (o + a) / (o - a), this.cameraL.projectionMatrix.copy(Qu), a = -i * t.aspect - r, o = i * t.aspect - r, Qu.elements[0] = 2 * t.near / (o - a), Qu.elements[8] = (o + a) / (o - a), this.cameraR.projectionMatrix.copy(Qu);
}
this.cameraL.matrix.copy(e.matrixWorld).multiply(Zu), this.cameraL.matrixWorldNeedsUpdate = !0, this.cameraR.matrix.copy(e.matrixWorld).multiply(Xu), this.cameraR.matrixWorldNeedsUpdate = !0;
}
}, ed = -90, td = 1, nd = class extends Mr {
constructor(e, t, n) {
super(), this.type = "CubeCamera", this.renderTarget = n, this.coordinateSystem = null, this.activeMipmapLevel = 0;
let r = new Z(ed, td, e, t);
r.layers = this.layers, this.add(r);
let i = new Z(ed, td, e, t);
i.layers = this.layers, this.add(i);
let a = new Z(ed, td, e, t);
a.layers = this.layers, this.add(a);
let o = new Z(ed, td, e, t);
o.layers = this.layers, this.add(o);
let s = new Z(ed, td, e, t);
s.layers = this.layers, this.add(s);
let c = new Z(ed, td, e, t);
c.layers = this.layers, this.add(c);
}
updateCoordinateSystem() {
let e = this.coordinateSystem, t = this.children.concat(), [n, r, i, a, o, s] = t;
for (let e of t) this.remove(e);
if (e === 2e3) n.up.set(0, 1, 0), n.lookAt(1, 0, 0), r.up.set(0, 1, 0), r.lookAt(-1, 0, 0), i.up.set(0, 0, -1), i.lookAt(0, 1, 0), a.up.set(0, 0, 1), a.lookAt(0, -1, 0), o.up.set(0, 1, 0), o.lookAt(0, 0, 1), s.up.set(0, 1, 0), s.lookAt(0, 0, -1);
else if (e === 2001) n.up.set(0, -1, 0), n.lookAt(-1, 0, 0), r.up.set(0, -1, 0), r.lookAt(1, 0, 0), i.up.set(0, 0, 1), i.lookAt(0, 1, 0), a.up.set(0, 0, -1), a.lookAt(0, -1, 0), o.up.set(0, -1, 0), o.lookAt(0, 0, 1), s.up.set(0, -1, 0), s.lookAt(0, 0, -1);
else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + e);
for (let e of t) this.add(e), e.updateMatrixWorld();
}
update(e, t) {
this.parent === null && this.updateMatrixWorld();
let { renderTarget: n, activeMipmapLevel: r } = this;
this.coordinateSystem !== e.coordinateSystem && (this.coordinateSystem = e.coordinateSystem, this.updateCoordinateSystem());
let [i, a, o, s, c, l] = this.children, u = e.getRenderTarget(), d = e.getActiveCubeFace(), f = e.getActiveMipmapLevel(), p = e.xr.enabled;
e.xr.enabled = !1;
let m = n.texture.generateMipmaps;
n.texture.generateMipmaps = !1;
let h = !1;
h = e.isWebGLRenderer === !0 ? e.state.buffers.depth.getReversed() : e.reversedDepthBuffer, e.setRenderTarget(n, 0, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, i), e.setRenderTarget(n, 1, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, a), e.setRenderTarget(n, 2, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, o), e.setRenderTarget(n, 3, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, s), e.setRenderTarget(n, 4, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, c), n.texture.generateMipmaps = m, e.setRenderTarget(n, 5, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, l), e.setRenderTarget(u, d, f), e.xr.enabled = p, n.texture.needsPMREMUpdate = !0;
}
}, rd = class extends Z {
constructor(e = []) {
super(), this.isArrayCamera = !0, this.isMultiViewCamera = !1, this.cameras = e;
}
}, id = class {
constructor() {
this._previousTime = 0, this._currentTime = 0, this._startTime = performance.now(), this._delta = 0, this._elapsed = 0, this._timescale = 1, this._document = null, this._pageVisibilityHandler = null;
}
connect(e) {
this._document = e, e.hidden !== void 0 && (this._pageVisibilityHandler = ad.bind(this), e.addEventListener("visibilitychange", this._pageVisibilityHandler, !1));
}
disconnect() {
this._pageVisibilityHandler !== null && (this._document.removeEventListener("visibilitychange", this._pageVisibilityHandler), this._pageVisibilityHandler = null), this._document = null;
}
getDelta() {
return this._delta / 1e3;
}
getElapsed() {
return this._elapsed / 1e3;
}
getTimescale() {
return this._timescale;
}
setTimescale(e) {
return this._timescale = e, this;
}
reset() {
return this._currentTime = performance.now() - this._startTime, this;
}
dispose() {
this.disconnect();
}
update(e) {
return this._pageVisibilityHandler !== null && this._document.hidden === !0 ? this._delta = 0 : (this._previousTime = this._currentTime, this._currentTime = (e === void 0 ? performance.now() : e) - this._startTime, this._delta = (this._currentTime - this._previousTime) * this._timescale, this._elapsed += this._delta), this;
}
};
function ad() {
this._document.hidden === !1 && this.reset();
}
var od = /*@__PURE__*/ new H(), sd = /*@__PURE__*/ new Fn(), cd = /*@__PURE__*/ new H(), ld = /*@__PURE__*/ new H(), ud = /*@__PURE__*/ new H(), dd = class extends Mr {
constructor() {
super(), this.type = "AudioListener", this.context = Ju.getContext(), this.gain = this.context.createGain(), this.gain.connect(this.context.destination), this.filter = null, this.timeDelta = 0, this._timer = new id();
}
getInput() {
return this.gain;
}
removeFilter() {
return this.filter !== null && (this.gain.disconnect(this.filter), this.filter.disconnect(this.context.destination), this.gain.connect(this.context.destination), this.filter = null), this;
}
getFilter() {
return this.filter;
}
setFilter(e) {
return this.filter === null ? this.gain.disconnect(this.context.destination) : (this.gain.disconnect(this.filter), this.filter.disconnect(this.context.destination)), this.filter = e, this.gain.connect(this.filter), this.filter.connect(this.context.destination), this;
}
getMasterVolume() {
return this.gain.gain.value;
}
setMasterVolume(e) {
return this.gain.gain.setTargetAtTime(e, this.context.currentTime, .01), this;
}
updateMatrixWorld(e) {
super.updateMatrixWorld(e), this._timer.update();
let t = this.context.listener;
if (this.timeDelta = this._timer.getDelta(), this.matrixWorld.decompose(od, sd, cd), ld.set(0, 0, -1).applyQuaternion(sd), ud.set(0, 1, 0).applyQuaternion(sd), t.positionX) {
let e = this.context.currentTime + this.timeDelta;
t.positionX.linearRampToValueAtTime(od.x, e), t.positionY.linearRampToValueAtTime(od.y, e), t.positionZ.linearRampToValueAtTime(od.z, e), t.forwardX.linearRampToValueAtTime(ld.x, e), t.forwardY.linearRampToValueAtTime(ld.y, e), t.forwardZ.linearRampToValueAtTime(ld.z, e), t.upX.linearRampToValueAtTime(ud.x, e), t.upY.linearRampToValueAtTime(ud.y, e), t.upZ.linearRampToValueAtTime(ud.z, e);
} else t.setPosition(od.x, od.y, od.z), t.setOrientation(ld.x, ld.y, ld.z, ud.x, ud.y, ud.z);
}
}, fd = class extends Mr {
constructor(e) {
super(), this.type = "Audio", this.listener = e, this.context = e.context, this.gain = this.context.createGain(), this.gain.connect(e.getInput()), this.autoplay = !1, this.buffer = null, this.detune = 0, this.loop = !1, this.loopStart = 0, this.loopEnd = 0, this.offset = 0, this.duration = void 0, this.playbackRate = 1, this.isPlaying = !1, this.hasPlaybackControl = !0, this.source = null, this.sourceType = "empty", this._startedAt = 0, this._progress = 0, this._connected = !1, this.filters = [];
}
getOutput() {
return this.gain;
}
setNodeSource(e) {
return this.hasPlaybackControl = !1, this.sourceType = "audioNode", this.source = e, this.connect(), this;
}
setMediaElementSource(e) {
return this.hasPlaybackControl = !1, this.sourceType = "mediaNode", this.source = this.context.createMediaElementSource(e), this.connect(), this;
}
setMediaStreamSource(e) {
return this.hasPlaybackControl = !1, this.sourceType = "mediaStreamNode", this.source = this.context.createMediaStreamSource(e), this.connect(), this;
}
setBuffer(e) {
return this.buffer = e, this.sourceType = "buffer", this.autoplay && this.play(), this;
}
play(e = 0) {
if (this.isPlaying === !0) {
L("Audio: Audio is already playing.");
return;
}
if (this.hasPlaybackControl === !1) {
L("Audio: this Audio has no playback control.");
return;
}
this._startedAt = this.context.currentTime + e;
let t = this.context.createBufferSource();
return t.buffer = this.buffer, t.loop = this.loop, t.loopStart = this.loopStart, t.loopEnd = this.loopEnd, t.onended = this.onEnded.bind(this), t.start(this._startedAt, this._progress + this.offset, this.duration), this.isPlaying = !0, this.source = t, this.setDetune(this.detune), this.setPlaybackRate(this.playbackRate), this.connect();
}
pause() {
if (this.hasPlaybackControl === !1) {
L("Audio: this Audio has no playback control.");
return;
}
return this.isPlaying === !0 && (this._progress += Math.max(this.context.currentTime - this._startedAt, 0) * this.playbackRate, this.loop === !0 && (this._progress %= this.duration || this.buffer.duration), this.source.stop(), this.source.onended = null, this.isPlaying = !1), this;
}
stop(e = 0) {
if (this.hasPlaybackControl === !1) {
L("Audio: this Audio has no playback control.");
return;
}
return this._progress = 0, this.source !== null && (this.source.stop(this.context.currentTime + e), this.source.onended = null), this.isPlaying = !1, this;
}
connect() {
if (this.filters.length > 0) {
this.source.connect(this.filters[0]);
for (let e = 1, t = this.filters.length; e < t; e++) this.filters[e - 1].connect(this.filters[e]);
this.filters[this.filters.length - 1].connect(this.getOutput());
} else this.source.connect(this.getOutput());
return this._connected = !0, this;
}
disconnect() {
if (this._connected !== !1) {
if (this.filters.length > 0) {
this.source.disconnect(this.filters[0]);
for (let e = 1, t = this.filters.length; e < t; e++) this.filters[e - 1].disconnect(this.filters[e]);
this.filters[this.filters.length - 1].disconnect(this.getOutput());
} else this.source.disconnect(this.getOutput());
return this._connected = !1, this;
}
}
getFilters() {
return this.filters;
}
setFilters(e) {
return e || (e = []), this._connected === !0 ? (this.disconnect(), this.filters = e.slice(), this.connect()) : this.filters = e.slice(), this;
}
setDetune(e) {
return this.detune = e, this.isPlaying === !0 && this.source.detune !== void 0 && this.source.detune.setTargetAtTime(this.detune, this.context.currentTime, .01), this;
}
getDetune() {
return this.detune;
}
getFilter() {
return this.getFilters()[0];
}
setFilter(e) {
return this.setFilters(e ? [e] : []);
}
setPlaybackRate(e) {
if (this.hasPlaybackControl === !1) {
L("Audio: this Audio has no playback control.");
return;
}
return this.playbackRate = e, this.isPlaying === !0 && this.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, .01), this;
}
getPlaybackRate() {
return this.playbackRate;
}
onEnded() {
this.isPlaying = !1, this._progress = 0;
}
getLoop() {
return this.hasPlaybackControl === !1 ? (L("Audio: this Audio has no playback control."), !1) : this.loop;
}
setLoop(e) {
if (this.hasPlaybackControl === !1) {
L("Audio: this Audio has no playback control.");
return;
}
return this.loop = e, this.isPlaying === !0 && (this.source.loop = this.loop), this;
}
setLoopStart(e) {
return this.loopStart = e, this;
}
setLoopEnd(e) {
return this.loopEnd = e, this;
}
getVolume() {
return this.gain.gain.value;
}
setVolume(e) {
return this.gain.gain.setTargetAtTime(e, this.context.currentTime, .01), this;
}
copy(e, t) {
return super.copy(e, t), e.sourceType === "buffer" ? (this.autoplay = e.autoplay, this.buffer = e.buffer, this.detune = e.detune, this.loop = e.loop, this.loopStart = e.loopStart, this.loopEnd = e.loopEnd, this.offset = e.offset, this.duration = e.duration, this.playbackRate = e.playbackRate, this.hasPlaybackControl = e.hasPlaybackControl, this.sourceType = e.sourceType, this.filters = e.filters.slice(), this) : (L("Audio: Audio source type cannot be copied."), this);
}
clone(e) {
return new this.constructor(this.listener).copy(this, e);
}
}, pd = /*@__PURE__*/ new H(), md = /*@__PURE__*/ new Fn(), hd = /*@__PURE__*/ new H(), gd = /*@__PURE__*/ new H(), _d = class extends fd {
constructor(e) {
super(e), this.panner = this.context.createPanner(), this.panner.panningModel = "HRTF", this.panner.connect(this.gain);
}
connect() {
return super.connect(), this.panner.connect(this.gain), this;
}
disconnect() {
return super.disconnect(), this.panner.disconnect(this.gain), this;
}
getOutput() {
return this.panner;
}
getRefDistance() {
return this.panner.refDistance;
}
setRefDistance(e) {
return this.panner.refDistance = e, this;
}
getRolloffFactor() {
return this.panner.rolloffFactor;
}
setRolloffFactor(e) {
return this.panner.rolloffFactor = e, this;
}
getDistanceModel() {
return this.panner.distanceModel;
}
setDistanceModel(e) {
return this.panner.distanceModel = e, this;
}
getMaxDistance() {
return this.panner.maxDistance;
}
setMaxDistance(e) {
return this.panner.maxDistance = e, this;
}
setDirectionalCone(e, t, n) {
return this.panner.coneInnerAngle = e, this.panner.coneOuterAngle = t, this.panner.coneOuterGain = n, this;
}
updateMatrixWorld(e) {
if (super.updateMatrixWorld(e), this.hasPlaybackControl === !0 && this.isPlaying === !1) return;
this.matrixWorld.decompose(pd, md, hd), gd.set(0, 0, 1).applyQuaternion(md);
let t = this.panner;
if (t.positionX) {
let e = this.context.currentTime + this.listener.timeDelta;
t.positionX.linearRampToValueAtTime(pd.x, e), t.positionY.linearRampToValueAtTime(pd.y, e), t.positionZ.linearRampToValueAtTime(pd.z, e), t.orientationX.linearRampToValueAtTime(gd.x, e), t.orientationY.linearRampToValueAtTime(gd.y, e), t.orientationZ.linearRampToValueAtTime(gd.z, e);
} else t.setPosition(pd.x, pd.y, pd.z), t.setOrientation(gd.x, gd.y, gd.z);
}
}, vd = class {
constructor(e, t = 2048) {
this.analyser = e.context.createAnalyser(), this.analyser.fftSize = t, this.data = new Uint8Array(this.analyser.frequencyBinCount), e.getOutput().connect(this.analyser);
}
getFrequencyData() {
return this.analyser.getByteFrequencyData(this.data), this.data;
}
getAverageFrequency() {
let e = 0, t = this.getFrequencyData();
for (let n = 0; n < t.length; n++) e += t[n];
return e / t.length;
}
}, yd = class {
constructor(e, t, n) {
this.binding = e, this.valueSize = n;
let r, i, a;
switch (t) {
case "quaternion":
r = this._slerp, i = this._slerpAdditive, a = this._setAdditiveIdentityQuaternion, this.buffer = new Float64Array(n * 6), this._workIndex = 5;
break;
case "string":
case "bool":
r = this._select, i = this._select, a = this._setAdditiveIdentityOther, this.buffer = Array(n * 5);
break;
default: r = this._lerp, i = this._lerpAdditive, a = this._setAdditiveIdentityNumeric, this.buffer = new Float64Array(n * 5);
}
this._mixBufferRegion = r, this._mixBufferRegionAdditive = i, this._setIdentity = a, 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, r = this.valueSize, i = e * r + r, a = this.cumulativeWeight;
if (a === 0) {
for (let e = 0; e !== r; ++e) n[i + e] = n[e];
a = t;
} else {
a += t;
let e = t / a;
this._mixBufferRegion(n, i, 0, e, r);
}
this.cumulativeWeight = a;
}
accumulateAdditive(e) {
let t = this.buffer, n = this.valueSize, r = n * this._addIndex;
this.cumulativeWeightAdditive === 0 && this._setIdentity(), this._mixBufferRegionAdditive(t, r, 0, e, n), this.cumulativeWeightAdditive += e;
}
apply(e) {
let t = this.valueSize, n = this.buffer, r = e * t + t, i = this.cumulativeWeight, a = this.cumulativeWeightAdditive, o = this.binding;
if (this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, i < 1) {
let e = t * this._origIndex;
this._mixBufferRegion(n, r, e, 1 - i, t);
}
a > 0 && this._mixBufferRegionAdditive(n, r, this._addIndex * t, 1, t);
for (let e = t, i = t + t; e !== i; ++e) if (n[e] !== n[e + t]) {
o.setValue(n, r);
break;
}
}
saveOriginalState() {
let e = this.binding, t = this.buffer, n = this.valueSize, r = n * this._origIndex;
e.getValue(t, r);
for (let e = n, i = r; e !== i; ++e) t[e] = t[r + e % 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, r, i) {
if (r >= .5) for (let r = 0; r !== i; ++r) e[t + r] = e[n + r];
}
_slerp(e, t, n, r) {
Fn.slerpFlat(e, t, e, t, e, n, r);
}
_slerpAdditive(e, t, n, r, i) {
let a = this._workIndex * i;
Fn.multiplyQuaternionsFlat(e, a, e, t, e, n), Fn.slerpFlat(e, t, e, t, e, a, r);
}
_lerp(e, t, n, r, i) {
let a = 1 - r;
for (let o = 0; o !== i; ++o) {
let i = t + o;
e[i] = e[i] * a + e[n + o] * r;
}
}
_lerpAdditive(e, t, n, r, i) {
for (let a = 0; a !== i; ++a) {
let i = t + a;
e[i] = e[i] + e[n + a] * r;
}
}
}, bd = "\\[\\]\\.:\\/", xd = /* @__PURE__ */ RegExp("[\\[\\]\\.:\\/]", "g"), Sd = "[^\\[\\]\\.:\\/]", Cd = "[^" + bd.replace("\\.", "") + "]", wd = /*@__PURE__*/ "((?:WC+[\\/:])*)".replace("WC", Sd), Td = /*@__PURE__*/ "(WCOD+)?".replace("WCOD", Cd), Ed = /*@__PURE__*/ "(?:\\.(WC+)(?:\\[(.+)\\])?)?".replace("WC", Sd), Dd = /*@__PURE__*/ "\\.(WC+)(?:\\[(.+)\\])?".replace("WC", Sd), Od = RegExp("^" + wd + Td + Ed + Dd + "$"), kd = [
"material",
"materials",
"bones",
"map"
], Ad = class {
constructor(e, t, n) {
let r = n || jd.parseTrackName(t);
this._targetGroup = e, this._bindings = e.subscribe_(t, r);
}
getValue(e, t) {
this.bind();
let n = this._targetGroup.nCachedObjects_, r = this._bindings[n];
r !== void 0 && r.getValue(e, t);
}
setValue(e, t) {
let n = this._bindings;
for (let r = this._targetGroup.nCachedObjects_, i = n.length; r !== i; ++r) n[r].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();
}
}, jd = class e {
constructor(t, n, r) {
this.path = n, this.parsedPath = r || e.parseTrackName(n), this.node = e.findNode(t, this.parsedPath.nodeName), this.rootNode = t, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound;
}
static create(t, n, r) {
return t && t.isAnimationObjectGroup ? new e.Composite(t, n, r) : new e(t, n, r);
}
static sanitizeNodeName(e) {
return e.replace(/\s/g, "_").replace(xd, "");
}
static parseTrackName(e) {
let t = Od.exec(e);
if (t === null) throw Error("THREE.PropertyBinding: Cannot parse trackName: " + e);
let n = {
nodeName: t[2],
objectName: t[3],
objectIndex: t[4],
propertyName: t[5],
propertyIndex: t[6]
}, r = n.nodeName && n.nodeName.lastIndexOf(".");
if (r !== void 0 && r !== -1) {
let e = n.nodeName.substring(r + 1);
kd.indexOf(e) !== -1 && (n.nodeName = n.nodeName.substring(0, r), n.objectName = e);
}
if (n.propertyName === null || n.propertyName.length === 0) throw Error("THREE.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(e) {
for (let r = 0; r < e.length; r++) {
let i = e[r];
if (i.name === t || i.uuid === t) return i;
let a = n(i.children);
if (a) return a;
}
return null;
}, r = n(e.children);
if (r) return r;
}
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 r = 0, i = n.length; r !== i; ++r) e[t++] = n[r];
}
_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 r = 0, i = n.length; r !== i; ++r) n[r] = e[t++];
}
_setValue_array_setNeedsUpdate(e, t) {
let n = this.resolvedProperty;
for (let r = 0, i = n.length; r !== i; ++r) n[r] = e[t++];
this.targetObject.needsUpdate = !0;
}
_setValue_array_setMatrixWorldNeedsUpdate(e, t) {
let n = this.resolvedProperty;
for (let r = 0, i = n.length; r !== i; ++r) n[r] = 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 t = this.node, n = this.parsedPath, r = n.objectName, i = n.propertyName, a = n.propertyIndex;
if (t || (t = e.findNode(this.rootNode, n.nodeName), this.node = t), this.getValue = this._getValue_unavailable, this.setValue = this._setValue_unavailable, !t) {
L("PropertyBinding: No target node found for track: " + this.path + ".");
return;
}
if (r) {
let e = n.objectIndex;
switch (r) {
case "materials":
if (!t.material) {
R("PropertyBinding: Can not bind to material as node does not have a material.", this);
return;
}
if (!t.material.materials) {
R("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this);
return;
}
t = t.material.materials;
break;
case "bones":
if (!t.skeleton) {
R("PropertyBinding: Can not bind to bones as node does not have a skeleton.", this);
return;
}
t = t.skeleton.bones;
for (let n = 0; n < t.length; n++) if (t[n].name === e) {
e = n;
break;
}
break;
case "map":
if ("map" in t) {
t = t.map;
break;
}
if (!t.material) {
R("PropertyBinding: Can not bind to material as node does not have a material.", this);
return;
}
if (!t.material.map) {
R("PropertyBinding: Can not bind to material.map as node.material does not have a map.", this);
return;
}
t = t.material.map;
break;
default:
if (t[r] === void 0) {
R("PropertyBinding: Can not bind to objectName of node undefined.", this);
return;
}
t = t[r];
}
if (e !== void 0) {
if (t[e] === void 0) {
R("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, t);
return;
}
t = t[e];
}
}
let o = t[i];
if (o === void 0) {
let e = n.nodeName;
R("PropertyBinding: Trying to update property for track: " + e + "." + i + " but it wasn't found.", t);
return;
}
let s = this.Versioning.None;
this.targetObject = t, t.isMaterial === !0 ? s = this.Versioning.NeedsUpdate : t.isObject3D === !0 && (s = this.Versioning.MatrixWorldNeedsUpdate);
let c = this.BindingType.Direct;
if (a !== void 0) {
if (i === "morphTargetInfluences") {
if (!t.geometry) {
R("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this);
return;
}
if (!t.geometry.morphAttributes) {
R("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this);
return;
}
t.morphTargetDictionary[a] !== void 0 && (a = t.morphTargetDictionary[a]);
}
c = this.BindingType.ArrayElement, this.resolvedProperty = o, this.propertyIndex = a;
} else o.fromArray !== void 0 && o.toArray !== void 0 ? (c = this.BindingType.HasFromToArray, this.resolvedProperty = o) : Array.isArray(o) ? (c = this.BindingType.EntireArray, this.resolvedProperty = o) : this.propertyName = i;
this.getValue = this.GetterByBindingType[c], this.setValue = this.SetterByBindingTypeAndVersioning[c][s];
}
unbind() {
this.node = null, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound;
}
};
jd.Composite = Ad, jd.prototype.BindingType = {
Direct: 0,
EntireArray: 1,
ArrayElement: 2,
HasFromToArray: 3
}, jd.prototype.Versioning = {
None: 0,
NeedsUpdate: 1,
MatrixWorldNeedsUpdate: 2
}, jd.prototype.GetterByBindingType = [
jd.prototype._getValue_direct,
jd.prototype._getValue_array,
jd.prototype._getValue_arrayElement,
jd.prototype._getValue_toArray
], jd.prototype.SetterByBindingTypeAndVersioning = [
[
jd.prototype._setValue_direct,
jd.prototype._setValue_direct_setNeedsUpdate,
jd.prototype._setValue_direct_setMatrixWorldNeedsUpdate
],
[
jd.prototype._setValue_array,
jd.prototype._setValue_array_setNeedsUpdate,
jd.prototype._setValue_array_setMatrixWorldNeedsUpdate
],
[
jd.prototype._setValue_arrayElement,
jd.prototype._setValue_arrayElement_setNeedsUpdate,
jd.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate
],
[
jd.prototype._setValue_fromArray,
jd.prototype._setValue_fromArray_setNeedsUpdate,
jd.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate
]
];
var Md = class {
constructor() {
this.isAnimationObjectGroup = !0, this.uuid = mn(), this._objects = Array.prototype.slice.call(arguments), this.nCachedObjects_ = 0;
let e = {};
this._indicesByUUID = e;
for (let t = 0, n = arguments.length; t !== n; ++t) e[arguments[t].uuid] = t;
this._paths = [], this._parsedPaths = [], this._bindings = [], this._bindingsIndicesByPath = {};
let t = this;
this.stats = {
objects: {
get total() {
return t._objects.length;
},
get inUse() {
return this.total - t.nCachedObjects_;
}
},
get bindingsPerObject() {
return t._bindings.length;
}
};
}
add() {
let e = this._objects, t = this._indicesByUUID, n = this._paths, r = this._parsedPaths, i = this._bindings, a = i.length, o, s = e.length, c = this.nCachedObjects_;
for (let l = 0, u = arguments.length; l !== u; ++l) {
let u = arguments[l], d = u.uuid, f = t[d];
if (f === void 0) {
f = s++, t[d] = f, e.push(u);
for (let e = 0, t = a; e !== t; ++e) i[e].push(new jd(u, n[e], r[e]));
} else if (f < c) {
o = e[f];
let s = --c, l = e[s];
t[l.uuid] = f, e[f] = l, t[d] = s, e[s] = u;
for (let e = 0, t = a; e !== t; ++e) {
let t = i[e], a = t[s], o = t[f];
t[f] = a, o === void 0 && (o = new jd(u, n[e], r[e])), t[s] = o;
}
} else e[f] !== o && R("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.");
}
this.nCachedObjects_ = c;
}
remove() {
let e = this._objects, t = this._indicesByUUID, n = this._bindings, r = n.length, i = this.nCachedObjects_;
for (let a = 0, o = arguments.length; a !== o; ++a) {
let o = arguments[a], s = o.uuid, c = t[s];
if (c !== void 0 && c >= i) {
let a = i++, l = e[a];
t[l.uuid] = c, e[c] = l, t[s] = a, e[a] = o;
for (let e = 0, t = r; e !== t; ++e) {
let t = n[e], r = t[a], i = t[c];
t[c] = r, t[a] = i;
}
}
}
this.nCachedObjects_ = i;
}
uncache() {
let e = this._objects, t = this._indicesByUUID, n = this._bindings, r = n.length, i = this.nCachedObjects_, a = e.length;
for (let o = 0, s = arguments.length; o !== s; ++o) {
let s = arguments[o].uuid, c = t[s];
if (c !== void 0) if (delete t[s], c < i) {
let o = --i, s = e[o], l = --a, u = e[l];
t[s.uuid] = c, e[c] = s, t[u.uuid] = o, e[o] = u, e.pop();
for (let e = 0, t = r; e !== t; ++e) {
let t = n[e], r = t[o], i = t[l];
t[c] = r, t[o] = i, t.pop();
}
} else {
let i = --a, o = e[i];
i > 0 && (t[o.uuid] = c), e[c] = o, e.pop();
for (let e = 0, t = r; e !== t; ++e) {
let t = n[e];
t[c] = t[i], t.pop();
}
}
}
this.nCachedObjects_ = i;
}
subscribe_(e, t) {
let n = this._bindingsIndicesByPath, r = n[e], i = this._bindings;
if (r !== void 0) return i[r];
let a = this._paths, o = this._parsedPaths, s = this._objects, c = s.length, l = this.nCachedObjects_, u = Array(c);
r = i.length, n[e] = r, a.push(e), o.push(t), i.push(u);
for (let n = l, r = s.length; n !== r; ++n) {
let r = s[n];
u[n] = new jd(r, e, t);
}
return u;
}
unsubscribe_(e) {
let t = this._bindingsIndicesByPath, n = t[e];
if (n !== void 0) {
let r = this._paths, i = this._parsedPaths, a = this._bindings, o = a.length - 1, s = a[o], c = e[o];
t[c] = n, a[n] = s, a.pop(), i[n] = i[o], i.pop(), r[n] = r[o], r.pop();
}
}
}, Nd = class {
constructor(e, t, n = null, r = t.blendMode) {
this._mixer = e, this._clip = t, this._localRoot = n, this.blendMode = r;
let i = t.tracks, a = i.length, o = Array(a), s = {
endingStart: dt,
endingEnd: dt
};
for (let e = 0; e !== a; ++e) {
let t = i[e].createInterpolant(null);
o[e] = t, t.settings = s;
}
this._interpolantSettings = s, this._interpolants = o, this._propertyBindings = Array(a), this._cacheIndex = null, this._byClipCacheIndex = null, this._timeScaleInterpolant = null, this._restoreTimeScale = null, this._weightInterpolant = null, this.loop = at, this._loopCount = -1, this._startTime = null, this.time = 0, this.timeScale = 1, this._effectiveTimeScale = 1, this.weight = 1, this._effectiveWeight = 1, this.repetitions = Infinity, 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 n = this._clip.duration, r = e._clip.duration, i = r / n, a = n / r;
e._restoreTimeScale = e.timeScale, this._restoreTimeScale = this.timeScale, e.warp(1, i, t), this.warp(a, 1, t);
}
return this;
}
crossFadeTo(e, t, n = !1) {
return e.crossFadeFrom(this, t, n);
}
stopFading() {
let e = this._weightInterpolant;
return e !== null && (this._weightInterpolant = null, this._mixer._takeBackControlInterpolant(e)), 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 r = this._mixer, i = r.time, a = this.timeScale, o = this._timeScaleInterpolant;
o === null && (o = r._lendControlInterpolant(), this._timeScaleInterpolant = o);
let s = o.parameterPositions, c = o.sampleValues;
return s[0] = i, s[1] = i + n, c[0] = e / a, c[1] = t / a, this;
}
stopWarping() {
let e = this._timeScaleInterpolant;
return e !== null && (this._timeScaleInterpolant = null, this._mixer._takeBackControlInterpolant(e)), this._restoreTimeScale = null, this;
}
getMixer() {
return this._mixer;
}
getClip() {
return this._clip;
}
getRoot() {
return this._localRoot || this._mixer._root;
}
_update(e, t, n, r) {
if (!this.enabled) {
this._updateWeight(e);
return;
}
let i = this._startTime;
if (i !== null) {
let r = (e - i) * n;
r < 0 || n === 0 ? t = 0 : (this._startTime = null, t = n * r);
}
t *= this._updateTimeScale(e);
let a = this._updateTime(t), o = this._updateWeight(e);
if (o > 0) {
let e = this._interpolants, t = this._propertyBindings;
switch (this.blendMode) {
case ht:
for (let n = 0, r = e.length; n !== r; ++n) e[n].evaluate(a), t[n].accumulateAdditive(o);
break;
case mt:
default: for (let n = 0, i = e.length; n !== i; ++n) e[n].evaluate(a), t[n].accumulate(r, o);
}
}
}
_updateWeight(e) {
let t = 0;
if (this.enabled) {
t = this.weight;
let n = this._weightInterpolant;
if (n !== null) {
let r = n.evaluate(e)[0];
t *= r, e > n.parameterPositions[1] && (this.stopFading(), r === 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 r = n.evaluate(e)[0];
t *= r, e > n.parameterPositions[1] && (t === 0 ? this.paused = !0 : (this._restoreTimeScale !== null && (t = this._restoreTimeScale), this.timeScale = t), this.stopWarping());
}
}
return this._effectiveTimeScale = t, t;
}
_updateTime(e) {
let t = this._clip.duration, n = this.loop, r = this.time + e, i = this._loopCount, a = n === ot;
if (e === 0) return i === -1 ? r : a && (i & 1) == 1 ? t - r : r;
if (n === 2200) {
i === -1 && (this._loopCount = 0, this._setEndings(!0, !0, !1));
handle_stop: {
if (r >= t) r = t;
else if (r < 0) r = 0;
else {
this.time = r;
break handle_stop;
}
this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, this.time = r, this._mixer.dispatchEvent({
type: "finished",
action: this,
direction: e < 0 ? -1 : 1
});
}
} else {
if (i === -1 && (e >= 0 ? (i = 0, this._setEndings(!0, this.repetitions === 0, a)) : this._setEndings(this.repetitions === 0, !0, a)), r >= t || r < 0) {
let n = Math.floor(r / t);
r -= t * n, i += Math.abs(n);
let o = this.repetitions - i;
if (o <= 0) this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, r = e > 0 ? t : 0, this.time = r, this._mixer.dispatchEvent({
type: "finished",
action: this,
direction: e > 0 ? 1 : -1
});
else {
if (o === 1) {
let t = e < 0;
this._setEndings(t, !t, a);
} else this._setEndings(!1, !1, a);
this._loopCount = i, this.time = r, this._mixer.dispatchEvent({
type: "loop",
action: this,
loopDelta: n
});
}
} else this._loopCount = i, this.time = r;
if (a && (i & 1) == 1) return t - r;
}
return r;
}
_setEndings(e, t, n) {
let r = this._interpolantSettings;
n ? (r.endingStart = ft, r.endingEnd = ft) : (e ? r.endingStart = this.zeroSlopeAtStart ? ft : dt : r.endingStart = pt, t ? r.endingEnd = this.zeroSlopeAtEnd ? ft : dt : r.endingEnd = pt);
}
_scheduleFading(e, t, n) {
let r = this._mixer, i = r.time, a = this._weightInterpolant;
a === null && (a = r._lendControlInterpolant(), this._weightInterpolant = a);
let o = a.parameterPositions, s = a.sampleValues;
return o[0] = i, s[0] = t, o[1] = i + e, s[1] = n, this;
}
}, Pd = /* @__PURE__ */ new Float32Array(1), Fd = class extends ln {
constructor(e) {
super(), this._root = e, this._initMemoryManager(), this._accuIndex = 0, this.time = 0, this.timeScale = 1, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
}
_bindAction(e, t) {
let n = e._localRoot || this._root, r = e._clip.tracks, i = r.length, a = e._propertyBindings, o = e._interpolants, s = n.uuid, c = this._bindingsByRootAndName, l = c[s];
l === void 0 && (l = {}, c[s] = l);
for (let e = 0; e !== i; ++e) {
let i = r[e], c = i.name, u = l[c];
if (u !== void 0) ++u.referenceCount, a[e] = u;
else {
if (u = a[e], u !== void 0) {
u._cacheIndex === null && (++u.referenceCount, this._addInactiveBinding(u, s, c));
continue;
}
let r = t && t._propertyBindings[e].binding.parsedPath;
u = new yd(jd.create(n, c, r), i.ValueTypeName, i.getValueSize()), ++u.referenceCount, this._addInactiveBinding(u, s, c), a[e] = u;
}
o[e].resultBuffer = u.buffer;
}
}
_activateAction(e) {
if (!this._isActiveAction(e)) {
if (e._cacheIndex === null) {
let t = (e._localRoot || this._root).uuid, n = e._clip.uuid, r = this._actionsByClip[n];
this._bindAction(e, r && r.knownActions[0]), this._addInactiveAction(e, n, t);
}
let t = e._propertyBindings;
for (let e = 0, n = t.length; e !== n; ++e) {
let n = t[e];
n.useCount++ === 0 && (this._lendBinding(n), n.saveOriginalState());
}
this._lendAction(e);
}
}
_deactivateAction(e) {
if (this._isActiveAction(e)) {
let t = e._propertyBindings;
for (let e = 0, n = t.length; e !== n; ++e) {
let n = t[e];
--n.useCount === 0 && (n.restoreOriginalState(), this._takeBackBinding(n));
}
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 r = this._actions, i = this._actionsByClip, a = i[t];
if (a === void 0) a = {
knownActions: [e],
actionByRoot: {}
}, e._byClipCacheIndex = 0, i[t] = a;
else {
let t = a.knownActions;
e._byClipCacheIndex = t.length, t.push(e);
}
e._cacheIndex = r.length, r.push(e), a.actionByRoot[n] = e;
}
_removeInactiveAction(e) {
let t = this._actions, n = t[t.length - 1], r = e._cacheIndex;
n._cacheIndex = r, t[r] = n, t.pop(), e._cacheIndex = null;
let i = e._clip.uuid, a = this._actionsByClip, o = a[i], s = o.knownActions, c = s[s.length - 1], l = e._byClipCacheIndex;
c._byClipCacheIndex = l, s[l] = c, s.pop(), e._byClipCacheIndex = null;
let u = o.actionByRoot, d = (e._localRoot || this._root).uuid;
delete u[d], s.length === 0 && delete a[i], this._removeInactiveBindingsForAction(e);
}
_removeInactiveBindingsForAction(e) {
let t = e._propertyBindings;
for (let e = 0, n = t.length; e !== n; ++e) {
let n = t[e];
--n.referenceCount === 0 && this._removeInactiveBinding(n);
}
}
_lendAction(e) {
let t = this._actions, n = e._cacheIndex, r = this._nActiveActions++, i = t[r];
e._cacheIndex = r, t[r] = e, i._cacheIndex = n, t[n] = i;
}
_takeBackAction(e) {
let t = this._actions, n = e._cacheIndex, r = --this._nActiveActions, i = t[r];
e._cacheIndex = r, t[r] = e, i._cacheIndex = n, t[n] = i;
}
_addInactiveBinding(e, t, n) {
let r = this._bindingsByRootAndName, i = this._bindings, a = r[t];
a === void 0 && (a = {}, r[t] = a), a[n] = e, e._cacheIndex = i.length, i.push(e);
}
_removeInactiveBinding(e) {
let t = this._bindings, n = e.binding, r = n.rootNode.uuid, i = n.path, a = this._bindingsByRootAndName, o = a[r], s = t[t.length - 1], c = e._cacheIndex;
s._cacheIndex = c, t[c] = s, t.pop(), delete o[i], Object.keys(o).length === 0 && delete a[r];
}
_lendBinding(e) {
let t = this._bindings, n = e._cacheIndex, r = this._nActiveBindings++, i = t[r];
e._cacheIndex = r, t[r] = e, i._cacheIndex = n, t[n] = i;
}
_takeBackBinding(e) {
let t = this._bindings, n = e._cacheIndex, r = --this._nActiveBindings, i = t[r];
e._cacheIndex = r, t[r] = e, i._cacheIndex = n, t[n] = i;
}
_lendControlInterpolant() {
let e = this._controlInterpolants, t = this._nActiveControlInterpolants++, n = e[t];
return n === void 0 && (n = new Rl(/* @__PURE__ */ new Float32Array(2), /* @__PURE__ */ new Float32Array(2), 1, Pd), n.__cacheIndex = t, e[t] = n), n;
}
_takeBackControlInterpolant(e) {
let t = this._controlInterpolants, n = e.__cacheIndex, r = --this._nActiveControlInterpolants, i = t[r];
e.__cacheIndex = r, t[r] = e, i.__cacheIndex = n, t[n] = i;
}
clipAction(e, t, n) {
let r = t || this._root, i = r.uuid, a = typeof e == "string" ? Jl.findByName(r, e) : e, o = a === null ? e : a.uuid, s = this._actionsByClip[o], c = null;
if (n === void 0 && (n = a === null ? mt : a.blendMode), s !== void 0) {
let e = s.actionByRoot[i];
if (e !== void 0 && e.blendMode === n) return e;
c = s.knownActions[0], a === null && (a = c._clip);
}
if (a === null) return null;
let l = new Nd(this, a, t, n);
return this._bindAction(l, c), this._addInactiveAction(l, o, i), l;
}
existingAction(e, t) {
let n = t || this._root, r = n.uuid, i = typeof e == "string" ? Jl.findByName(n, e) : e, a = i ? i.uuid : e, o = this._actionsByClip[a];
return o === void 0 ? null : o.actionByRoot[r] || 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, r = this.time += e, i = Math.sign(e), a = this._accuIndex ^= 1;
for (let o = 0; o !== n; ++o) t[o]._update(r, e, i, a);
let o = this._bindings, s = this._nActiveBindings;
for (let e = 0; e !== s; ++e) o[e].apply(a);
return this;
}
setTime(e) {
this.time = 0;
for (let e = 0; e < this._actions.length; e++) this._actions[e].time = 0;
return this.update(e);
}
getRoot() {
return this._root;
}
uncacheClip(e) {
let t = this._actions, n = e.uuid, r = this._actionsByClip, i = r[n];
if (i !== void 0) {
let e = i.knownActions;
for (let n = 0, r = e.length; n !== r; ++n) {
let r = e[n];
this._deactivateAction(r);
let i = r._cacheIndex, a = t[t.length - 1];
r._cacheIndex = null, r._byClipCacheIndex = null, a._cacheIndex = i, t[i] = a, t.pop(), this._removeInactiveBindingsForAction(r);
}
delete r[n];
}
}
uncacheRoot(e) {
let t = e.uuid, n = this._actionsByClip;
for (let e in n) {
let r = n[e].actionByRoot[t];
r !== void 0 && (this._deactivateAction(r), this._removeInactiveAction(r));
}
let r = this._bindingsByRootAndName[t];
if (r !== void 0) for (let e in r) {
let t = r[e];
t.restoreOriginalState(), this._removeInactiveBinding(t);
}
}
uncacheAction(e, t) {
let n = this.existingAction(e, t);
n !== null && (this._deactivateAction(n), this._removeInactiveAction(n));
}
}, Id = class extends er {
constructor(e = 1, t = 1, n = 1, r = {}) {
super(e, t, r), this.isRenderTarget3D = !0, this.depth = n, this.texture = new ir(null, e, t, n), this._setTextureOptions(r), this.texture.isRenderTargetTexture = !0;
}
}, Ld = class e {
constructor(e) {
this.value = e;
}
clone() {
return new e(this.value.clone === void 0 ? this.value : this.value.clone());
}
}, Rd = 0, zd = class extends ln {
constructor() {
super(), this.isUniformsGroup = !0, Object.defineProperty(this, "id", { value: Rd++ }), this.name = "", this.usage = jt, this.uniforms = [];
}
add(e) {
return this.uniforms.push(e), this;
}
remove(e) {
let t = this.uniforms.indexOf(e);
return t !== -1 && this.uniforms.splice(t, 1), this;
}
setName(e) {
return this.name = e, this;
}
setUsage(e) {
return this.usage = e, this;
}
dispose() {
this.dispatchEvent({ type: "dispose" });
}
copy(e) {
this.name = e.name, this.usage = e.usage;
let t = e.uniforms;
this.uniforms.length = 0;
for (let e = 0, n = t.length; e < n; e++) {
let n = Array.isArray(t[e]) ? t[e] : [t[e]];
for (let e = 0; e < n.length; e++) this.uniforms.push(n[e].clone());
}
return this;
}
clone() {
return new this.constructor().copy(this);
}
}, Bd = class extends qi {
constructor(e, t, n = 1) {
super(e, t), this.isInstancedInterleavedBuffer = !0, this.meshPerAttribute = n;
}
copy(e) {
return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this;
}
clone(e) {
let t = super.clone(e);
return t.meshPerAttribute = this.meshPerAttribute, t;
}
toJSON(e) {
let t = super.toJSON(e);
return t.isInstancedInterleavedBuffer = !0, t.meshPerAttribute = this.meshPerAttribute, t;
}
}, Vd = class {
constructor(e, t, n, r, i, a = !1) {
this.isGLBufferAttribute = !0, this.name = "", this.buffer = e, this.type = t, this.itemSize = n, this.elementSize = r, this.count = i, this.normalized = a, this.version = 0;
}
set needsUpdate(e) {
e === !0 && this.version++;
}
setBuffer(e) {
return this.buffer = e, this;
}
setType(e, t) {
return this.type = e, this.elementSize = t, this;
}
setItemSize(e) {
return this.itemSize = e, this;
}
setCount(e) {
return this.count = e, this;
}
}, Hd = /*@__PURE__*/ new W(), Ud = class {
constructor(e, t, n = 0, r = Infinity) {
this.ray = new wa(e, t), this.near = n, this.far = r, this.camera = null, this.layers = new gr(), this.params = {
Mesh: {},
Line: { threshold: 1 },
LOD: {},
Points: { threshold: 1 },
Sprite: {}
};
}
set(e, t) {
this.ray.set(e, t);
}
setFromCamera(e, t) {
t.isPerspectiveCamera ? (this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(e.x, e.y, .5).unproject(t).sub(this.ray.origin).normalize(), this.camera = t) : t.isOrthographicCamera ? (this.ray.origin.set(e.x, e.y, t.projectionMatrix.elements[14]).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld), this.camera = t) : R("Raycaster: Unsupported camera type: " + t.type);
}
setFromXRController(e) {
return Hd.identity().extractRotation(e.matrixWorld), this.ray.origin.setFromMatrixPosition(e.matrixWorld), this.ray.direction.set(0, 0, -1).applyMatrix4(Hd), this;
}
intersectObject(e, t = !0, n = []) {
return Gd(e, this, n, t), n.sort(Wd), n;
}
intersectObjects(e, t = !0, n = []) {
for (let r = 0, i = e.length; r < i; r++) Gd(e[r], this, n, t);
return n.sort(Wd), n;
}
};
function Wd(e, t) {
return e.distance - t.distance;
}
function Gd(e, t, n, r) {
let i = !0;
if (e.layers.test(t.layers) && e.raycast(t, n) === !1 && (i = !1), i === !0 && r === !0) {
let r = e.children;
for (let e = 0, i = r.length; e < i; e++) Gd(r[e], t, n, !0);
}
}
var Kd = class {
constructor(e = !0) {
this.autoStart = e, this.startTime = 0, this.oldTime = 0, this.elapsedTime = 0, this.running = !1, L("Clock: This module has been deprecated. Please use THREE.Timer instead.");
}
start() {
this.startTime = performance.now(), this.oldTime = this.startTime, this.elapsedTime = 0, this.running = !0;
}
stop() {
this.getElapsedTime(), this.running = !1, this.autoStart = !1;
}
getElapsedTime() {
return this.getDelta(), this.elapsedTime;
}
getDelta() {
let e = 0;
if (this.autoStart && !this.running) return this.start(), 0;
if (this.running) {
let t = performance.now();
e = (t - this.oldTime) / 1e3, this.oldTime = t, this.elapsedTime += e;
}
return e;
}
}, qd = class {
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() {
let e = 1e-6;
return this.phi = z(this.phi, e, Math.PI - e), this;
}
setFromVector3(e) {
return this.setFromCartesianCoords(e.x, e.y, e.z);
}
setFromCartesianCoords(e, t, n) {
return this.radius = Math.sqrt(e * e + t * t + n * n), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(e, n), this.phi = Math.acos(z(t / this.radius, -1, 1))), this;
}
clone() {
return new this.constructor().copy(this);
}
}, Jd = class {
constructor(e = 1, t = 0, n = 0) {
this.radius = e, this.theta = t, this.y = n;
}
set(e, t, n) {
return this.radius = e, this.theta = t, this.y = n, this;
}
copy(e) {
return this.radius = e.radius, this.theta = e.theta, this.y = e.y, this;
}
setFromVector3(e) {
return this.setFromCartesianCoords(e.x, e.y, e.z);
}
setFromCartesianCoords(e, t, n) {
return this.radius = Math.sqrt(e * e + n * n), this.theta = Math.atan2(e, n), this.y = t, this;
}
clone() {
return new this.constructor().copy(this);
}
}, Yd = class {
constructor(e, t, n, r) {
this.elements = [
1,
0,
0,
1
], e !== void 0 && this.set(e, t, n, r);
}
identity() {
return this.set(1, 0, 0, 1), this;
}
fromArray(e, t = 0) {
for (let n = 0; n < 4; n++) this.elements[n] = e[n + t];
return this;
}
set(e, t, n, r) {
let i = this.elements;
return i[0] = e, i[2] = t, i[1] = n, i[3] = r, this;
}
};
m = Yd, m.prototype.isMatrix2 = !0;
var Xd = /*@__PURE__*/ new V(), Zd = class {
constructor(e = new V(Infinity, Infinity), t = new V(-Infinity, -Infinity)) {
this.isBox2 = !0, this.min = e, this.max = t;
}
set(e, t) {
return this.min.copy(e), this.max.copy(t), 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 = Xd.copy(t).multiplyScalar(.5);
return this.min.copy(e).sub(n), this.max.copy(e).add(n), this;
}
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 = Infinity, this.max.x = this.max.y = -Infinity, this;
}
isEmpty() {
return this.max.x < this.min.x || this.max.y < this.min.y;
}
getCenter(e) {
return this.isEmpty() ? e.set(0, 0) : e.addVectors(this.min, this.max).multiplyScalar(.5);
}
getSize(e) {
return this.isEmpty() ? e.set(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;
}
containsPoint(e) {
return e.x >= this.min.x && e.x <= this.max.x && e.y >= this.min.y && e.y <= this.max.y;
}
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;
}
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));
}
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;
}
clampPoint(e, t) {
return t.copy(e).clamp(this.min, this.max);
}
distanceToPoint(e) {
return this.clampPoint(e, Xd).distanceTo(e);
}
intersect(e) {
return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this;
}
union(e) {
return this.min.min(e.min), this.max.max(e.max), 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);
}
}, Qd = /*@__PURE__*/ new H(), $d = /*@__PURE__*/ new H(), ef = /*@__PURE__*/ new H(), tf = /*@__PURE__*/ new H(), nf = /*@__PURE__*/ new H(), rf = /*@__PURE__*/ new H(), af = /*@__PURE__*/ new H(), of = class {
constructor(e = new H(), t = new H()) {
this.start = e, this.end = t;
}
set(e, t) {
return this.start.copy(e), this.end.copy(t), this;
}
copy(e) {
return this.start.copy(e.start), this.end.copy(e.end), this;
}
getCenter(e) {
return e.addVectors(this.start, this.end).multiplyScalar(.5);
}
delta(e) {
return e.subVectors(this.end, this.start);
}
distanceSq() {
return this.start.distanceToSquared(this.end);
}
distance() {
return this.start.distanceTo(this.end);
}
at(e, t) {
return this.delta(t).multiplyScalar(e).add(this.start);
}
closestPointToPointParameter(e, t) {
Qd.subVectors(e, this.start), $d.subVectors(this.end, this.start);
let n = $d.dot($d);
if (n === 0) return 0;
let r = $d.dot(Qd) / n;
return t && (r = z(r, 0, 1)), r;
}
closestPointToPoint(e, t, n) {
let r = this.closestPointToPointParameter(e, t);
return this.delta(n).multiplyScalar(r).add(this.start);
}
distanceSqToLine3(e, t = rf, n = af) {
let r = 1e-8 * 1e-8, i, a, o = this.start, s = e.start, c = this.end, l = e.end;
ef.subVectors(c, o), tf.subVectors(l, s), nf.subVectors(o, s);
let u = ef.dot(ef), d = tf.dot(tf), f = tf.dot(nf);
if (u <= r && d <= r) return t.copy(o), n.copy(s), t.sub(n), t.dot(t);
if (u <= r) i = 0, a = f / d, a = z(a, 0, 1);
else {
let e = ef.dot(nf);
if (d <= r) a = 0, i = z(-e / u, 0, 1);
else {
let t = ef.dot(tf), n = u * d - t * t;
i = n === 0 ? 0 : z((t * f - e * d) / n, 0, 1), a = (t * i + f) / d, a < 0 ? (a = 0, i = z(-e / u, 0, 1)) : a > 1 && (a = 1, i = z((t - e) / u, 0, 1));
}
}
return t.copy(o).addScaledVector(ef, i), n.copy(s).addScaledVector(tf, a), t.distanceToSquared(n);
}
applyMatrix4(e) {
return this.start.applyMatrix4(e), this.end.applyMatrix4(e), this;
}
equals(e) {
return e.start.equals(this.start) && e.end.equals(this.end);
}
clone() {
return new this.constructor().copy(this);
}
}, sf = /*@__PURE__*/ new H(), cf = class extends Mr {
constructor(e, t) {
super(), this.light = e, this.matrixAutoUpdate = !1, this.color = t, this.type = "SpotLightHelper";
let n = new q(), r = [
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
1,
0,
0,
0,
-1,
0,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
-1,
1
];
for (let e = 0, t = 1; e < 32; e++, t++) {
let n = e / 32 * Math.PI * 2, i = t / 32 * Math.PI * 2;
r.push(Math.cos(n), Math.sin(n), 1, Math.cos(i), Math.sin(i), 1);
}
n.setAttribute("position", new K(r, 3));
let i = new zo({
fog: !1,
toneMapped: !1
});
this.cone = new Zo(n, i), this.add(this.cone), this.update();
}
dispose() {
this.cone.geometry.dispose(), this.cone.material.dispose();
}
update() {
this.light.updateWorldMatrix(!0, !1), this.light.target.updateWorldMatrix(!0, !1), this.parent ? (this.parent.updateWorldMatrix(!0), this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)) : this.matrix.copy(this.light.matrixWorld), this.matrixWorldNeedsUpdate = !0;
let e = this.light.distance ? this.light.distance : 1e3, t = e * Math.tan(this.light.angle);
this.cone.scale.set(t, t, e), sf.setFromMatrixPosition(this.light.target.matrixWorld), this.cone.lookAt(sf), this.color === void 0 ? this.cone.material.color.copy(this.light.color) : this.cone.material.color.set(this.color);
}
}, lf = /*@__PURE__*/ new H(), uf = /*@__PURE__*/ new W(), df = /*@__PURE__*/ new W(), ff = class extends Zo {
constructor(e) {
let t = pf(e), n = new q(), r = [], i = [];
for (let e = 0; e < t.length; e++) {
let n = t[e];
n.parent && n.parent.isBone && (r.push(0, 0, 0), r.push(0, 0, 0), i.push(0, 0, 0), i.push(0, 0, 0));
}
n.setAttribute("position", new K(r, 3)), n.setAttribute("color", new K(i, 3));
let a = new zo({
vertexColors: !0,
depthTest: !1,
depthWrite: !1,
toneMapped: !1,
transparent: !0
});
super(n, a), this.isSkeletonHelper = !0, this.type = "SkeletonHelper", this.root = e, this.bones = t, this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1;
let o = new G(255), s = new G(65280);
this.setColors(o, s);
}
updateMatrixWorld(e) {
let t = this.bones, n = this.geometry, r = n.getAttribute("position");
df.copy(this.root.matrixWorld).invert();
for (let e = 0, n = 0; e < t.length; e++) {
let i = t[e];
i.parent && i.parent.isBone && (uf.multiplyMatrices(df, i.matrixWorld), lf.setFromMatrixPosition(uf), r.setXYZ(n, lf.x, lf.y, lf.z), uf.multiplyMatrices(df, i.parent.matrixWorld), lf.setFromMatrixPosition(uf), r.setXYZ(n + 1, lf.x, lf.y, lf.z), n += 2);
}
n.getAttribute("position").needsUpdate = !0, super.updateMatrixWorld(e);
}
setColors(e, t) {
let n = this.geometry.getAttribute("color");
for (let r = 0; r < n.count; r += 2) n.setXYZ(r, e.r, e.g, e.b), n.setXYZ(r + 1, t.r, t.g, t.b);
return n.needsUpdate = !0, this;
}
dispose() {
this.geometry.dispose(), this.material.dispose();
}
};
function pf(e) {
let t = [];
e.isBone === !0 && t.push(e);
for (let n = 0; n < e.children.length; n++) t.push(...pf(e.children[n]));
return t;
}
var mf = class extends La {
constructor(e, t, n) {
let r = new el(t, 4, 2), i = new Ta({
wireframe: !0,
fog: !1,
toneMapped: !1
});
super(r, i), this.light = e, this.color = n, this.type = "PointLightHelper", this.matrix = this.light.matrixWorld, this.matrixAutoUpdate = !1, this.update();
}
dispose() {
this.geometry.dispose(), this.material.dispose();
}
update() {
this.matrixWorldNeedsUpdate = !0, this.light.updateWorldMatrix(!0, !1), this.color === void 0 ? this.material.color.copy(this.light.color) : this.material.color.set(this.color);
}
}, hf = /*@__PURE__*/ new H(), gf = /*@__PURE__*/ new G(), _f = /*@__PURE__*/ new G(), vf = class extends Mr {
constructor(e, t, n) {
super(), this.light = e, this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = n, this.type = "HemisphereLightHelper";
let r = new Yc(t);
r.rotateY(Math.PI * .5), this.material = new Ta({
wireframe: !0,
fog: !1,
toneMapped: !1
}), this.color === void 0 && (this.material.vertexColors = !0);
let i = r.getAttribute("position"), a = new Float32Array(i.count * 3);
r.setAttribute("color", new Di(a, 3)), this.add(new La(r, this.material)), this.update();
}
dispose() {
this.children[0].geometry.dispose(), this.children[0].material.dispose();
}
update() {
let e = this.children[0];
if (this.color !== void 0) this.material.color.set(this.color);
else {
let t = e.geometry.getAttribute("color");
gf.copy(this.light.color), _f.copy(this.light.groundColor);
for (let e = 0, n = t.count; e < n; e++) {
let r = e < n / 2 ? gf : _f;
t.setXYZ(e, r.r, r.g, r.b);
}
t.needsUpdate = !0;
}
this.matrixWorldNeedsUpdate = !0, this.light.updateWorldMatrix(!0, !1), e.lookAt(hf.setFromMatrixPosition(this.light.matrixWorld).negate());
}
}, yf = class extends Zo {
constructor(e = 10, t = 10, n = 4473924, r = 8947848) {
n = new G(n), r = new G(r);
let i = t / 2, a = e / t, o = e / 2, s = [], c = [];
for (let e = 0, l = 0, u = -o; e <= t; e++, u += a) {
s.push(-o, 0, u, o, 0, u), s.push(u, 0, -o, u, 0, o);
let t = e === i ? n : r;
t.toArray(c, l), l += 3, t.toArray(c, l), l += 3, t.toArray(c, l), l += 3, t.toArray(c, l), l += 3;
}
let l = new q();
l.setAttribute("position", new K(s, 3)), l.setAttribute("color", new K(c, 3));
let u = new zo({
vertexColors: !0,
toneMapped: !1
});
super(l, u), this.type = "GridHelper";
}
dispose() {
this.geometry.dispose(), this.material.dispose();
}
}, bf = class extends Zo {
constructor(e = 10, t = 16, n = 8, r = 64, i = 4473924, a = 8947848) {
i = new G(i), a = new G(a);
let o = [], s = [];
if (t > 1) for (let n = 0; n < t; n++) {
let r = n / t * (Math.PI * 2), c = Math.sin(r) * e, l = Math.cos(r) * e;
o.push(0, 0, 0), o.push(c, 0, l);
let u = n & 1 ? i : a;
s.push(u.r, u.g, u.b), s.push(u.r, u.g, u.b);
}
for (let t = 0; t < n; t++) {
let c = t & 1 ? i : a, l = e - e / n * t;
for (let e = 0; e < r; e++) {
let t = e / r * (Math.PI * 2), n = Math.sin(t) * l, i = Math.cos(t) * l;
o.push(n, 0, i), s.push(c.r, c.g, c.b), t = (e + 1) / r * (Math.PI * 2), n = Math.sin(t) * l, i = Math.cos(t) * l, o.push(n, 0, i), s.push(c.r, c.g, c.b);
}
}
let c = new q();
c.setAttribute("position", new K(o, 3)), c.setAttribute("color", new K(s, 3));
let l = new zo({
vertexColors: !0,
toneMapped: !1
});
super(c, l), this.type = "PolarGridHelper";
}
dispose() {
this.geometry.dispose(), this.material.dispose();
}
}, xf = /*@__PURE__*/ new H(), Sf = /*@__PURE__*/ new H(), Cf = /*@__PURE__*/ new H(), wf = class extends Mr {
constructor(e, t, n) {
super(), this.light = e, this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = n, this.type = "DirectionalLightHelper", t === void 0 && (t = 1);
let r = new q();
r.setAttribute("position", new K([
-t,
t,
0,
t,
t,
0,
t,
-t,
0,
-t,
-t,
0,
-t,
t,
0
], 3));
let i = new zo({
fog: !1,
toneMapped: !1
});
this.lightPlane = new qo(r, i), this.add(this.lightPlane), r = new q(), r.setAttribute("position", new K([
0,
0,
0,
0,
0,
1
], 3)), this.targetLine = new qo(r, i), this.add(this.targetLine), this.update();
}
dispose() {
this.lightPlane.geometry.dispose(), this.lightPlane.material.dispose(), this.targetLine.geometry.dispose(), this.targetLine.material.dispose();
}
update() {
this.matrixWorldNeedsUpdate = !0, this.light.updateWorldMatrix(!0, !1), this.light.target.updateWorldMatrix(!0, !1), xf.setFromMatrixPosition(this.light.matrixWorld), Sf.setFromMatrixPosition(this.light.target.matrixWorld), Cf.subVectors(Sf, xf), this.lightPlane.lookAt(Sf), this.color === void 0 ? (this.lightPlane.material.color.copy(this.light.color), this.targetLine.material.color.copy(this.light.color)) : (this.lightPlane.material.color.set(this.color), this.targetLine.material.color.set(this.color)), this.targetLine.lookAt(Sf), this.targetLine.scale.z = Cf.length();
}
}, Tf = /*@__PURE__*/ new H(), Ef = /*@__PURE__*/ new xu(), Df = class extends Zo {
constructor(e) {
let t = new q(), n = new zo({
color: 16777215,
vertexColors: !0,
toneMapped: !1
}), r = [], i = [], a = {};
o("n1", "n2"), o("n2", "n4"), o("n4", "n3"), o("n3", "n1"), o("f1", "f2"), o("f2", "f4"), o("f4", "f3"), o("f3", "f1"), o("n1", "f1"), o("n2", "f2"), o("n3", "f3"), o("n4", "f4"), o("p", "n1"), o("p", "n2"), o("p", "n3"), o("p", "n4"), o("u1", "u2"), o("u2", "u3"), o("u3", "u1"), o("c", "t"), o("p", "c"), o("cn1", "cn2"), o("cn3", "cn4"), o("cf1", "cf2"), o("cf3", "cf4");
function o(e, t) {
s(e), s(t);
}
function s(e) {
r.push(0, 0, 0), i.push(0, 0, 0), a[e] === void 0 && (a[e] = []), a[e].push(r.length / 3 - 1);
}
t.setAttribute("position", new K(r, 3)), t.setAttribute("color", new K(i, 3)), super(t, n), this.type = "CameraHelper", this.camera = e, this.camera.updateProjectionMatrix && this.camera.updateProjectionMatrix(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.pointMap = a, this.update();
let c = new G(16755200), l = new G(16711680), u = new G(43775), d = new G(16777215), f = new G(3355443);
this.setColors(c, l, u, d, f);
}
setColors(e, t, n, r, i) {
let a = this.geometry.getAttribute("color");
return a.setXYZ(0, e.r, e.g, e.b), a.setXYZ(1, e.r, e.g, e.b), a.setXYZ(2, e.r, e.g, e.b), a.setXYZ(3, e.r, e.g, e.b), a.setXYZ(4, e.r, e.g, e.b), a.setXYZ(5, e.r, e.g, e.b), a.setXYZ(6, e.r, e.g, e.b), a.setXYZ(7, e.r, e.g, e.b), a.setXYZ(8, e.r, e.g, e.b), a.setXYZ(9, e.r, e.g, e.b), a.setXYZ(10, e.r, e.g, e.b), a.setXYZ(11, e.r, e.g, e.b), a.setXYZ(12, e.r, e.g, e.b), a.setXYZ(13, e.r, e.g, e.b), a.setXYZ(14, e.r, e.g, e.b), a.setXYZ(15, e.r, e.g, e.b), a.setXYZ(16, e.r, e.g, e.b), a.setXYZ(17, e.r, e.g, e.b), a.setXYZ(18, e.r, e.g, e.b), a.setXYZ(19, e.r, e.g, e.b), a.setXYZ(20, e.r, e.g, e.b), a.setXYZ(21, e.r, e.g, e.b), a.setXYZ(22, e.r, e.g, e.b), a.setXYZ(23, e.r, e.g, e.b), a.setXYZ(24, t.r, t.g, t.b), a.setXYZ(25, t.r, t.g, t.b), a.setXYZ(26, t.r, t.g, t.b), a.setXYZ(27, t.r, t.g, t.b), a.setXYZ(28, t.r, t.g, t.b), a.setXYZ(29, t.r, t.g, t.b), a.setXYZ(30, t.r, t.g, t.b), a.setXYZ(31, t.r, t.g, t.b), a.setXYZ(32, n.r, n.g, n.b), a.setXYZ(33, n.r, n.g, n.b), a.setXYZ(34, n.r, n.g, n.b), a.setXYZ(35, n.r, n.g, n.b), a.setXYZ(36, n.r, n.g, n.b), a.setXYZ(37, n.r, n.g, n.b), a.setXYZ(38, r.r, r.g, r.b), a.setXYZ(39, r.r, r.g, r.b), a.setXYZ(40, i.r, i.g, i.b), a.setXYZ(41, i.r, i.g, i.b), a.setXYZ(42, i.r, i.g, i.b), a.setXYZ(43, i.r, i.g, i.b), a.setXYZ(44, i.r, i.g, i.b), a.setXYZ(45, i.r, i.g, i.b), a.setXYZ(46, i.r, i.g, i.b), a.setXYZ(47, i.r, i.g, i.b), a.setXYZ(48, i.r, i.g, i.b), a.setXYZ(49, i.r, i.g, i.b), a.needsUpdate = !0, this;
}
update() {
let e = this.geometry, t = this.pointMap, n, r;
if (Ef.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse), this.camera.reversedDepth === !0) n = 1, r = 0;
else if (this.camera.coordinateSystem === 2e3) n = -1, r = 1;
else if (this.camera.coordinateSystem === 2001) n = 0, r = 1;
else throw Error("THREE.CameraHelper.update(): Invalid coordinate system: " + this.camera.coordinateSystem);
Of("c", t, e, Ef, 0, 0, n), Of("t", t, e, Ef, 0, 0, r), Of("n1", t, e, Ef, -1, -1, n), Of("n2", t, e, Ef, 1, -1, n), Of("n3", t, e, Ef, -1, 1, n), Of("n4", t, e, Ef, 1, 1, n), Of("f1", t, e, Ef, -1, -1, r), Of("f2", t, e, Ef, 1, -1, r), Of("f3", t, e, Ef, -1, 1, r), Of("f4", t, e, Ef, 1, 1, r), Of("u1", t, e, Ef, 1 * .7, 1 * 1.1, n), Of("u2", t, e, Ef, -1 * .7, 1 * 1.1, n), Of("u3", t, e, Ef, 0, 2, n), Of("cf1", t, e, Ef, -1, 0, r), Of("cf2", t, e, Ef, 1, 0, r), Of("cf3", t, e, Ef, 0, -1, r), Of("cf4", t, e, Ef, 0, 1, r), Of("cn1", t, e, Ef, -1, 0, n), Of("cn2", t, e, Ef, 1, 0, n), Of("cn3", t, e, Ef, 0, -1, n), Of("cn4", t, e, Ef, 0, 1, n), e.getAttribute("position").needsUpdate = !0;
}
dispose() {
this.geometry.dispose(), this.material.dispose();
}
};
function Of(e, t, n, r, i, a, o) {
Tf.set(i, a, o).unproject(r);
let s = t[e];
if (s !== void 0) {
let e = n.getAttribute("position");
for (let t = 0, n = s.length; t < n; t++) e.setXYZ(s[t], Tf.x, Tf.y, Tf.z);
}
}
var kf = /*@__PURE__*/ new ii(), Af = class extends Zo {
constructor(e, t = 16776960) {
let n = new Uint16Array([
0,
1,
1,
2,
2,
3,
3,
0,
4,
5,
5,
6,
6,
7,
7,
4,
0,
4,
1,
5,
2,
6,
3,
7
]), r = /* @__PURE__ */ new Float32Array(24), i = new q();
i.setIndex(new Di(n, 1)), i.setAttribute("position", new Di(r, 3)), super(i, new zo({
color: t,
toneMapped: !1
})), this.object = e, this.type = "BoxHelper", this.matrixAutoUpdate = !1, this.update();
}
update() {
if (this.object !== void 0 && kf.setFromObject(this.object), kf.isEmpty()) return;
let e = kf.min, t = kf.max, n = this.geometry.attributes.position, r = n.array;
r[0] = t.x, r[1] = t.y, r[2] = t.z, r[3] = e.x, r[4] = t.y, r[5] = t.z, r[6] = e.x, r[7] = e.y, r[8] = t.z, r[9] = t.x, r[10] = e.y, r[11] = t.z, r[12] = t.x, r[13] = t.y, r[14] = e.z, r[15] = e.x, r[16] = t.y, r[17] = e.z, r[18] = e.x, r[19] = e.y, r[20] = e.z, r[21] = t.x, r[22] = e.y, r[23] = e.z, n.needsUpdate = !0, this.geometry.computeBoundingSphere();
}
setFromObject(e) {
return this.object = e, this.update(), this;
}
copy(e, t) {
return super.copy(e, t), this.object = e.object, this;
}
dispose() {
this.geometry.dispose(), this.material.dispose();
}
}, jf = class extends Zo {
constructor(e, t = 16776960) {
let n = new Uint16Array([
0,
1,
1,
2,
2,
3,
3,
0,
4,
5,
5,
6,
6,
7,
7,
4,
0,
4,
1,
5,
2,
6,
3,
7
]), r = [
1,
1,
1,
-1,
1,
1,
-1,
-1,
1,
1,
-1,
1,
1,
1,
-1,
-1,
1,
-1,
-1,
-1,
-1,
1,
-1,
-1
], i = new q();
i.setIndex(new Di(n, 1)), i.setAttribute("position", new K(r, 3)), super(i, new zo({
color: t,
toneMapped: !1
})), this.box = e, this.type = "Box3Helper", this.geometry.computeBoundingSphere();
}
updateMatrixWorld(e) {
let t = this.box;
t.isEmpty() || (t.getCenter(this.position), t.getSize(this.scale), this.scale.multiplyScalar(.5), super.updateMatrixWorld(e));
}
dispose() {
this.geometry.dispose(), this.material.dispose();
}
}, Mf = class extends qo {
constructor(e, t = 1, n = 16776960) {
let r = n, i = [
1,
-1,
0,
-1,
1,
0,
-1,
-1,
0,
1,
1,
0,
-1,
1,
0,
-1,
-1,
0,
1,
-1,
0,
1,
1,
0
], a = new q();
a.setAttribute("position", new K(i, 3)), a.computeBoundingSphere(), super(a, new zo({
color: r,
toneMapped: !1
})), this.type = "PlaneHelper", this.plane = e, this.size = t;
let o = [
1,
1,
0,
-1,
1,
0,
-1,
-1,
0,
1,
1,
0,
-1,
-1,
0,
1,
-1,
0
], s = new q();
s.setAttribute("position", new K(o, 3)), s.computeBoundingSphere(), this.add(new La(s, new Ta({
color: r,
opacity: .2,
transparent: !0,
depthWrite: !1,
toneMapped: !1
})));
}
updateMatrixWorld(e) {
this.position.set(0, 0, 0), this.scale.set(.5 * this.size, .5 * this.size, 1), this.lookAt(this.plane.normal), this.translateZ(-this.plane.constant), super.updateMatrixWorld(e);
}
dispose() {
this.geometry.dispose(), this.material.dispose(), this.children[0].geometry.dispose(), this.children[0].material.dispose();
}
}, Nf = /*@__PURE__*/ new H(), Pf, Ff, If = class extends Mr {
constructor(e = new H(0, 0, 1), t = new H(0, 0, 0), n = 1, r = 16776960, i = n * .2, a = i * .2) {
super(), this.type = "ArrowHelper", Pf === void 0 && (Pf = new q(), Pf.setAttribute("position", new K([
0,
0,
0,
0,
1,
0
], 3)), Ff = new Ss(.5, 1, 5, 1), Ff.translate(0, -.5, 0)), this.position.copy(t), this.line = new qo(Pf, new zo({
color: r,
toneMapped: !1
})), this.line.matrixAutoUpdate = !1, this.add(this.line), this.cone = new La(Ff, new Ta({
color: r,
toneMapped: !1
})), this.cone.matrixAutoUpdate = !1, this.add(this.cone), this.setDirection(e), this.setLength(n, i, a);
}
setDirection(e) {
if (e.y > .99999) this.quaternion.set(0, 0, 0, 1);
else if (e.y < -.99999) this.quaternion.set(1, 0, 0, 0);
else {
Nf.set(e.z, 0, -e.x).normalize();
let t = Math.acos(e.y);
this.quaternion.setFromAxisAngle(Nf, t);
}
}
setLength(e, t = e * .2, n = t * .2) {
this.line.scale.set(1, Math.max(1e-4, e - t), 1), this.line.updateMatrix(), this.cone.scale.set(n, t, n), this.cone.position.y = e, this.cone.updateMatrix();
}
setColor(e) {
this.line.material.color.set(e), this.cone.material.color.set(e);
}
copy(e) {
return super.copy(e, !1), this.line.copy(e.line), this.cone.copy(e.cone), this;
}
dispose() {
this.line.geometry.dispose(), this.line.material.dispose(), this.cone.geometry.dispose(), this.cone.material.dispose();
}
}, Lf = class extends Zo {
constructor(e = 1) {
let t = [
0,
0,
0,
e,
0,
0,
0,
0,
0,
0,
e,
0,
0,
0,
0,
0,
0,
e
], n = [
1,
0,
0,
1,
.6,
0,
0,
1,
0,
.6,
1,
0,
0,
0,
1,
0,
.6,
1
], r = new q();
r.setAttribute("position", new K(t, 3)), r.setAttribute("color", new K(n, 3));
let i = new zo({
vertexColors: !0,
toneMapped: !1
});
super(r, i), this.type = "AxesHelper";
}
setColors(e, t, n) {
let r = new G(), i = this.geometry.attributes.color.array;
return r.set(e), r.toArray(i, 0), r.toArray(i, 3), r.set(t), r.toArray(i, 6), r.toArray(i, 9), r.set(n), r.toArray(i, 12), r.toArray(i, 15), this.geometry.attributes.color.needsUpdate = !0, this;
}
dispose() {
this.geometry.dispose(), this.material.dispose();
}
}, Rf = class {
constructor() {
this.type = "ShapePath", this.color = new G(), this.subPaths = [], this.currentPath = null, this.userData = {};
}
moveTo(e, t) {
return this.currentPath = new ac(), this.subPaths.push(this.currentPath), this.currentPath.moveTo(e, t), this;
}
lineTo(e, t) {
return this.currentPath.lineTo(e, t), this;
}
quadraticCurveTo(e, t, n, r) {
return this.currentPath.quadraticCurveTo(e, t, n, r), this;
}
bezierCurveTo(e, t, n, r, i, a) {
return this.currentPath.bezierCurveTo(e, t, n, r, i, a), this;
}
splineThru(e) {
return this.currentPath.splineThru(e), this;
}
toShapes() {
function e(e, t) {
let n = !1, r = t.length;
for (let i = 0, a = r - 1; i < r; a = i++) {
let r = t[i], o = t[a];
r.y > e.y != o.y > e.y && e.x < (o.x - r.x) * (e.y - r.y) / (o.y - r.y) + r.x && (n = !n);
}
return n;
}
function t(t, n) {
let r = n.getCenter(new V());
if (e(r, t)) return r;
let i = r.y, a = [], o = t.length;
for (let e = 0; e < o; e++) {
let n = t[e], r = t[(e + 1) % o];
if (n.y > i != r.y > i) {
let e = n.x + (i - n.y) * (r.x - n.x) / (r.y - n.y);
a.push(e);
}
}
return a.length > 1 && (a.sort((e, t) => e - t), r.x = (a[0] + a[1]) / 2), r;
}
let n = this.userData.style && this.userData.style.fillRule || "nonzero";
n !== "nonzero" && n !== "evenodd" && (L("Fill-rule \"" + n + "\" is not supported, falling back to \"nonzero\"."), n = "nonzero");
let r = n === "nonzero" ? ((e) => e !== 0) : ((e) => (e & 1) != 0), i = [];
for (let e of this.subPaths) {
let n = e.getPoints();
if (n.length < 3) continue;
let r = Vc.area(n);
if (r === 0) continue;
let a = new Zd();
for (let e = 0; e < n.length; e++) a.expandByPoint(n[e]);
i.push({
subPath: e,
points: n,
boundingBox: a,
interiorPoint: t(n, a),
absArea: Math.abs(r),
winding: r < 0 ? -1 : 1,
container: null,
exclude: !1,
role: null
});
}
i.sort((e, t) => t.absArea - e.absArea);
for (let t = 0; t < i.length; t++) {
let n = i[t], a = 0;
for (let r = t - 1; r >= 0; r--) {
let t = i[r];
if (t.boundingBox.containsBox(n.boundingBox) && e(n.interiorPoint, t.points)) {
n.container = t.exclude ? t.container : t, a = t.winding, n.winding += a;
break;
}
}
r(n.winding) === r(a) && (n.exclude = !0);
}
for (let e of i) e.exclude || (e.role = e.container === null || e.container.role === "hole" ? "outer" : "hole");
let a = [], o = /* @__PURE__ */ new Map();
for (let e of i) {
if (e.exclude || e.role !== "outer") continue;
let t = new oc();
t.curves = e.subPath.curves, a.push(t), o.set(e, t);
}
for (let e of i) {
if (e.exclude || e.role !== "hole") continue;
let t = o.get(e.container);
if (!t) continue;
let n = new ac();
n.curves = e.subPath.curves, t.holes.push(n);
}
return a;
}
}, zf = class extends ln {
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) {
L("Controls: connect() now requires an element.");
return;
}
this.domElement !== null && this.disconnect(), this.domElement = e;
}
disconnect() {}
dispose() {}
update() {}
};
function Bf(e, t) {
let n = e.image && e.image.width ? e.image.width / e.image.height : 1;
return n > t ? (e.repeat.x = 1, e.repeat.y = n / t, e.offset.x = 0, e.offset.y = (1 - e.repeat.y) / 2) : (e.repeat.x = t / n, e.repeat.y = 1, e.offset.x = (1 - e.repeat.x) / 2, e.offset.y = 0), e;
}
function Vf(e, t) {
let n = e.image && e.image.width ? e.image.width / e.image.height : 1;
return n > t ? (e.repeat.x = t / n, e.repeat.y = 1, e.offset.x = (1 - e.repeat.x) / 2, e.offset.y = 0) : (e.repeat.x = 1, e.repeat.y = n / t, e.offset.x = 0, e.offset.y = (1 - e.repeat.y) / 2), e;
}
function Hf(e) {
return e.repeat.x = 1, e.repeat.y = 1, e.offset.x = 0, e.offset.y = 0, e;
}
function Uf(e, t, n, r) {
let i = Wf(r);
switch (n) {
case me: return e * t;
case ye: return e * t / i.components * i.byteLength;
case be: return e * t / i.components * i.byteLength;
case xe: return e * t * 2 / i.components * i.byteLength;
case Se: return e * t * 2 / i.components * i.byteLength;
case he: return e * t * 3 / i.components * i.byteLength;
case ge: return e * t * 4 / i.components * i.byteLength;
case we: return e * t * 4 / i.components * i.byteLength;
case Te:
case Ee: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 8;
case De:
case Oe: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 16;
case Ae:
case Me: return Math.max(e, 16) * Math.max(t, 8) / 4;
case ke:
case je: return Math.max(e, 8) * Math.max(t, 8) / 2;
case Ne:
case Pe:
case Fe:
case Ie: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 8;
case P:
case Le:
case F: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 16;
case Re: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 16;
case I: return Math.floor((e + 4) / 5) * Math.floor((t + 3) / 4) * 16;
case ze: return Math.floor((e + 4) / 5) * Math.floor((t + 4) / 5) * 16;
case Be: return Math.floor((e + 5) / 6) * Math.floor((t + 4) / 5) * 16;
case Ve: return Math.floor((e + 5) / 6) * Math.floor((t + 5) / 6) * 16;
case He: return Math.floor((e + 7) / 8) * Math.floor((t + 4) / 5) * 16;
case Ue: return Math.floor((e + 7) / 8) * Math.floor((t + 5) / 6) * 16;
case We: return Math.floor((e + 7) / 8) * Math.floor((t + 7) / 8) * 16;
case Ge: return Math.floor((e + 9) / 10) * Math.floor((t + 4) / 5) * 16;
case Ke: return Math.floor((e + 9) / 10) * Math.floor((t + 5) / 6) * 16;
case qe: return Math.floor((e + 9) / 10) * Math.floor((t + 7) / 8) * 16;
case Je: return Math.floor((e + 9) / 10) * Math.floor((t + 9) / 10) * 16;
case Ye: return Math.floor((e + 11) / 12) * Math.floor((t + 9) / 10) * 16;
case Xe: return Math.floor((e + 11) / 12) * Math.floor((t + 11) / 12) * 16;
case Ze:
case Qe:
case $e: return Math.ceil(e / 4) * Math.ceil(t / 4) * 16;
case et:
case tt: return Math.ceil(e / 4) * Math.ceil(t / 4) * 8;
case nt:
case rt: return Math.ceil(e / 4) * Math.ceil(t / 4) * 16;
}
throw Error(`Unable to determine texture byte length for ${n} format.`);
}
function Wf(e) {
switch (e) {
case M:
case re: return {
byteLength: 1,
components: 1
};
case ae:
case ie:
case ce: return {
byteLength: 2,
components: 1
};
case le:
case ue: return {
byteLength: 2,
components: 4
};
case se:
case oe:
case N: return {
byteLength: 4,
components: 1
};
case fe:
case pe: return {
byteLength: 4,
components: 3
};
}
throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`);
}
var Gf = class {
static contain(e, t) {
return Bf(e, t);
}
static cover(e, t) {
return Vf(e, t);
}
static fill(e) {
return Hf(e);
}
static getByteLength(e, t, n, r) {
return Uf(e, t, n, r);
}
};
typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: { revision: "185" } })), typeof window < "u" && (window.__THREE__ ? L("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = "185");
//#endregion
//#region ../../node_modules/.pnpm/three@0.185.1/node_modules/three/build/three.module.js
var Kf = /* @__PURE__ */ e({
ACESFilmicToneMapping: () => 4,
AddEquation: () => 100,
AddOperation: () => 2,
AdditiveAnimationBlendMode: () => ht,
AdditiveBlending: () => 2,
AgXToneMapping: () => 6,
AlphaFormat: () => me,
AlwaysCompare: () => 519,
AlwaysDepth: () => 1,
AlwaysStencilFunc: () => 519,
AmbientLight: () => ju,
AnimationAction: () => Nd,
AnimationClip: () => Jl,
AnimationLoader: () => au,
AnimationMixer: () => Fd,
AnimationObjectGroup: () => Md,
AnimationUtils: () => Fl,
ArcCurve: () => Ms,
ArrayCamera: () => rd,
ArrowHelper: () => If,
AttachedBindMode: () => b,
Audio: () => fd,
AudioAnalyser: () => vd,
AudioContext: () => Ju,
AudioListener: () => dd,
AudioLoader: () => Yu,
AxesHelper: () => Lf,
BackSide: () => 1,
BasicDepthPacking: () => gt,
BasicShadowMap: () => 0,
BatchedMesh: () => Ro,
BezierInterpolant: () => Bl,
Bone: () => Ya,
BooleanKeyframeTrack: () => Y,
Box2: () => Zd,
Box3: () => ii,
Box3Helper: () => jf,
BoxGeometry: () => vs,
BoxHelper: () => Af,
BufferAttribute: () => Di,
BufferGeometry: () => q,
BufferGeometryLoader: () => zu,
ByteType: () => re,
Cache: () => Zl,
Camera: () => xu,
CameraHelper: () => Df,
CanvasTexture: () => ps,
CapsuleGeometry: () => ys,
CatmullRomCurve3: () => zs,
CineonToneMapping: () => 3,
CircleGeometry: () => bs,
ClampToEdgeWrapping: () => C,
Clock: () => Kd,
Color: () => G,
ColorKeyframeTrack: () => Hl,
ColorManagement: () => Hn,
Compatibility: () => Kt,
CompressedArrayTexture: () => us,
CompressedCubeTexture: () => ds,
CompressedTexture: () => ls,
CompressedTextureLoader: () => ou,
ConeGeometry: () => Ss,
ConstantAlphaFactor: () => 213,
ConstantColorFactor: () => 211,
Controls: () => zf,
CubeCamera: () => nd,
CubeDepthTexture: () => gs,
CubeReflectionMapping: () => 301,
CubeRefractionMapping: () => 302,
CubeTexture: () => fs,
CubeTextureLoader: () => lu,
CubeUVReflectionMapping: () => 306,
CubicBezierCurve: () => Xs,
CubicBezierCurve3: () => Zs,
CubicInterpolant: () => Ll,
CullFaceBack: () => 1,
CullFaceFront: () => 2,
CullFaceFrontBack: () => 3,
CullFaceNone: () => 0,
Curve: () => As,
CurvePath: () => ic,
CustomBlending: () => 5,
CustomToneMapping: () => 5,
CylinderGeometry: () => xs,
Cylindrical: () => Jd,
Data3DTexture: () => ir,
DataArrayTexture: () => nr,
DataTexture: () => Xa,
DataTextureLoader: () => uu,
DataUtils: () => Ci,
DecrementStencilOp: () => Dt,
DecrementWrapStencilOp: () => kt,
DefaultLoadingManager: () => eu,
DepthFormat: () => _e,
DepthStencilFormat: () => ve,
DepthTexture: () => hs,
DetachedBindMode: () => x,
DirectionalLight: () => Au,
DirectionalLightHelper: () => wf,
DiscreteInterpolant: () => zl,
DodecahedronGeometry: () => ws,
DoubleSide: () => 2,
DstAlphaFactor: () => 206,
DstColorFactor: () => 208,
DynamicCopyUsage: () => Rt,
DynamicDrawUsage: () => Mt,
DynamicReadUsage: () => Ft,
EdgesGeometry: () => ks,
EllipseCurve: () => js,
EqualCompare: () => 514,
EqualDepth: () => 4,
EqualStencilFunc: () => 514,
EquirectangularReflectionMapping: () => 303,
EquirectangularRefractionMapping: () => 304,
Euler: () => hr,
EventDispatcher: () => ln,
ExternalTexture: () => _s,
ExtrudeGeometry: () => Wc,
FileLoader: () => iu,
Float16BufferAttribute: () => Fi,
Float32BufferAttribute: () => K,
FloatType: () => N,
Fog: () => Hr,
FogExp2: () => Vr,
FramebufferTexture: () => cs,
FrontSide: () => 0,
Frustum: () => _o,
FrustumArray: () => yo,
GLBufferAttribute: () => Vd,
GLSL1: () => "100",
GLSL3: () => Bt,
GreaterCompare: () => 516,
GreaterDepth: () => 6,
GreaterEqualCompare: () => 518,
GreaterEqualDepth: () => 5,
GreaterEqualStencilFunc: () => 518,
GreaterStencilFunc: () => 516,
GridHelper: () => yf,
Group: () => Nr,
HTMLTexture: () => ms,
HalfFloatType: () => ce,
HemisphereLight: () => pu,
HemisphereLightHelper: () => vf,
IcosahedronGeometry: () => qc,
ImageBitmapLoader: () => Ku,
ImageLoader: () => cu,
ImageUtils: () => Kn,
IncrementStencilOp: () => Et,
IncrementWrapStencilOp: () => Ot,
InstancedBufferAttribute: () => eo,
InstancedBufferGeometry: () => Ru,
InstancedInterleavedBuffer: () => Bd,
InstancedMesh: () => co,
Int16BufferAttribute: () => ji,
Int32BufferAttribute: () => Ni,
Int8BufferAttribute: () => Oi,
IntType: () => oe,
InterleavedBuffer: () => qi,
InterleavedBufferAttribute: () => Yi,
Interpolant: () => Il,
InterpolateBezier: () => ut,
InterpolateDiscrete: () => st,
InterpolateLinear: () => ct,
InterpolateSmooth: () => lt,
InterpolationSamplingMode: () => Gt,
InterpolationSamplingType: () => Wt,
InvertStencilOp: () => At,
KeepStencilOp: () => wt,
KeyframeTrack: () => Vl,
LOD: () => ga,
LatheGeometry: () => Jc,
Layers: () => gr,
LessCompare: () => 513,
LessDepth: () => 2,
LessEqualCompare: () => 515,
LessEqualDepth: () => 3,
LessEqualStencilFunc: () => 515,
LessStencilFunc: () => 513,
Light: () => fu,
LightProbe: () => Pu,
Line: () => qo,
Line3: () => of,
LineBasicMaterial: () => zo,
LineCurve: () => Qs,
LineCurve3: () => $s,
LineDashedMaterial: () => Ol,
LineLoop: () => Qo,
LineSegments: () => Zo,
LinearFilter: () => A,
LinearInterpolant: () => Rl,
LinearMipMapLinearFilter: () => j,
LinearMipMapNearestFilter: () => te,
LinearMipmapLinearFilter: () => ne,
LinearMipmapNearestFilter: () => ee,
LinearSRGBColorSpace: () => xt,
LinearToneMapping: () => 1,
LinearTransfer: () => St,
Loader: () => tu,
LoaderUtils: () => Lu,
LoadingManager: () => $l,
LoopOnce: () => it,
LoopPingPong: () => ot,
LoopRepeat: () => at,
MOUSE: () => v,
Material: () => Zi,
MaterialBlending: () => 6,
MaterialLoader: () => Iu,
MathUtils: () => Pn,
Matrix2: () => Yd,
Matrix3: () => U,
Matrix4: () => W,
MaxEquation: () => 104,
Mesh: () => La,
MeshBasicMaterial: () => Ta,
MeshDepthMaterial: () => Tl,
MeshDistanceMaterial: () => El,
MeshLambertMaterial: () => wl,
MeshMatcapMaterial: () => Dl,
MeshNormalMaterial: () => Cl,
MeshPhongMaterial: () => xl,
MeshPhysicalMaterial: () => bl,
MeshStandardMaterial: () => yl,
MeshToonMaterial: () => Sl,
MinEquation: () => 103,
MirroredRepeatWrapping: () => w,
MixOperation: () => 1,
MultiplyBlending: () => 4,
MultiplyOperation: () => 0,
NearestFilter: () => T,
NearestMipMapLinearFilter: () => k,
NearestMipMapNearestFilter: () => D,
NearestMipmapLinearFilter: () => O,
NearestMipmapNearestFilter: () => E,
NeutralToneMapping: () => 7,
NeverCompare: () => 512,
NeverDepth: () => 0,
NeverStencilFunc: () => 512,
NoBlending: () => 0,
NoColorSpace: () => "",
NoNormalPacking: () => "",
NoToneMapping: () => 0,
NormalAnimationBlendMode: () => mt,
NormalBlending: () => 1,
NormalGAPacking: () => "ga",
NormalRGPacking: () => "rg",
NotEqualCompare: () => 517,
NotEqualDepth: () => 7,
NotEqualStencilFunc: () => 517,
NumberKeyframeTrack: () => Ul,
Object3D: () => Mr,
ObjectLoader: () => Vu,
ObjectSpaceNormalMap: () => 1,
OctahedronGeometry: () => Yc,
OneFactor: () => 201,
OneMinusConstantAlphaFactor: () => 214,
OneMinusConstantColorFactor: () => 212,
OneMinusDstAlphaFactor: () => 207,
OneMinusDstColorFactor: () => 209,
OneMinusSrcAlphaFactor: () => 205,
OneMinusSrcColorFactor: () => 203,
OrthographicCamera: () => Ou,
PCFShadowMap: () => 1,
PCFSoftShadowMap: () => 2,
PMREMGenerator: () => hp,
Path: () => ac,
PerspectiveCamera: () => Z,
Plane: () => po,
PlaneGeometry: () => Xc,
PlaneHelper: () => Mf,
PointLight: () => Du,
PointLightHelper: () => mf,
Points: () => is,
PointsMaterial: () => $o,
PolarGridHelper: () => bf,
PolyhedronGeometry: () => Cs,
PositionalAudio: () => _d,
PropertyBinding: () => jd,
PropertyMixer: () => yd,
QuadraticBezierCurve: () => ec,
QuadraticBezierCurve3: () => tc,
Quaternion: () => Fn,
QuaternionKeyframeTrack: () => Gl,
QuaternionLinearInterpolant: () => Wl,
R11_EAC_Format: () => Fe,
RED_GREEN_RGTC2_Format: () => nt,
RED_RGTC1_Format: () => et,
REVISION: () => "185",
RG11_EAC_Format: () => Le,
RGBADepthPacking: () => _t,
RGBAFormat: () => ge,
RGBAIntegerFormat: () => we,
RGBA_ASTC_10x10_Format: () => Je,
RGBA_ASTC_10x5_Format: () => Ge,
RGBA_ASTC_10x6_Format: () => Ke,
RGBA_ASTC_10x8_Format: () => qe,
RGBA_ASTC_12x10_Format: () => Ye,
RGBA_ASTC_12x12_Format: () => Xe,
RGBA_ASTC_4x4_Format: () => Re,
RGBA_ASTC_5x4_Format: () => I,
RGBA_ASTC_5x5_Format: () => ze,
RGBA_ASTC_6x5_Format: () => Be,
RGBA_ASTC_6x6_Format: () => Ve,
RGBA_ASTC_8x5_Format: () => He,
RGBA_ASTC_8x6_Format: () => Ue,
RGBA_ASTC_8x8_Format: () => We,
RGBA_BPTC_Format: () => Ze,
RGBA_ETC2_EAC_Format: () => P,
RGBA_PVRTC_2BPPV1_Format: () => Me,
RGBA_PVRTC_4BPPV1_Format: () => je,
RGBA_S3TC_DXT1_Format: () => Ee,
RGBA_S3TC_DXT3_Format: () => De,
RGBA_S3TC_DXT5_Format: () => Oe,
RGBDepthPacking: () => vt,
RGBFormat: () => he,
RGBIntegerFormat: () => Ce,
RGB_BPTC_SIGNED_Format: () => Qe,
RGB_BPTC_UNSIGNED_Format: () => $e,
RGB_ETC1_Format: () => Ne,
RGB_ETC2_Format: () => Pe,
RGB_PVRTC_2BPPV1_Format: () => Ae,
RGB_PVRTC_4BPPV1_Format: () => ke,
RGB_S3TC_DXT1_Format: () => Te,
RGDepthPacking: () => yt,
RGFormat: () => xe,
RGIntegerFormat: () => Se,
RawShaderMaterial: () => vl,
Ray: () => wa,
Raycaster: () => Ud,
RectAreaLight: () => Mu,
RedFormat: () => ye,
RedIntegerFormat: () => be,
ReinhardToneMapping: () => 2,
RenderTarget: () => er,
RenderTarget3D: () => Id,
RepeatWrapping: () => S,
ReplaceStencilOp: () => Tt,
ReverseSubtractEquation: () => 102,
RingGeometry: () => Zc,
SIGNED_R11_EAC_Format: () => Ie,
SIGNED_RED_GREEN_RGTC2_Format: () => rt,
SIGNED_RED_RGTC1_Format: () => tt,
SIGNED_RG11_EAC_Format: () => F,
SRGBColorSpace: () => bt,
SRGBTransfer: () => Ct,
Scene: () => Ur,
ShaderChunk: () => Q,
ShaderLib: () => Yf,
ShaderMaterial: () => _l,
ShadowMaterial: () => cl,
Shape: () => oc,
ShapeGeometry: () => Qc,
ShapePath: () => Rf,
ShapeUtils: () => Vc,
ShortType: () => ie,
Skeleton: () => $a,
SkeletonHelper: () => ff,
SkinnedMesh: () => Ja,
Source: () => Jn,
Sphere: () => zi,
SphereGeometry: () => el,
Spherical: () => qd,
SphericalHarmonics3: () => Nu,
SplineCurve: () => nc,
SpotLight: () => Tu,
SpotLightHelper: () => cf,
Sprite: () => fa,
SpriteMaterial: () => Qi,
SrcAlphaFactor: () => 204,
SrcAlphaSaturateFactor: () => 210,
SrcColorFactor: () => 202,
StaticCopyUsage: () => Lt,
StaticDrawUsage: () => jt,
StaticReadUsage: () => Pt,
StereoCamera: () => $u,
StreamCopyUsage: () => zt,
StreamDrawUsage: () => Nt,
StreamReadUsage: () => It,
StringKeyframeTrack: () => Kl,
SubtractEquation: () => 101,
SubtractiveBlending: () => 3,
TOUCH: () => y,
TangentSpaceNormalMap: () => 0,
TetrahedronGeometry: () => tl,
Texture: () => Qn,
TextureLoader: () => du,
TextureUtils: () => Gf,
Timer: () => id,
TimestampQuery: () => Ut,
TorusGeometry: () => nl,
TorusKnotGeometry: () => rl,
Triangle: () => ri,
TriangleFanDrawMode: () => 2,
TriangleStripDrawMode: () => 1,
TrianglesDrawMode: () => 0,
TubeGeometry: () => il,
UVMapping: () => 300,
Uint16BufferAttribute: () => Mi,
Uint32BufferAttribute: () => Pi,
Uint8BufferAttribute: () => ki,
Uint8ClampedBufferAttribute: () => Ai,
Uniform: () => Ld,
UniformsGroup: () => zd,
UniformsLib: () => $,
UniformsUtils: () => ml,
UnsignedByteType: () => M,
UnsignedInt101111Type: () => pe,
UnsignedInt248Type: () => de,
UnsignedInt5999Type: () => fe,
UnsignedIntType: () => se,
UnsignedShort4444Type: () => le,
UnsignedShort5551Type: () => ue,
UnsignedShortType: () => ae,
VSMShadowMap: () => 3,
Vector2: () => V,
Vector3: () => H,
Vector4: () => $n,
VectorKeyframeTrack: () => ql,
VideoFrameTexture: () => ss,
VideoTexture: () => os,
WebGL3DRenderTarget: () => ar,
WebGLArrayRenderTarget: () => rr,
WebGLCoordinateSystem: () => Vt,
WebGLCubeRenderTarget: () => wp,
WebGLRenderTarget: () => tr,
WebGLRenderer: () => cg,
WebGLUtils: () => Xh,
WebGPUCoordinateSystem: () => Ht,
WebXRController: () => Fr,
WireframeGeometry: () => al,
WrapAroundEnding: () => pt,
ZeroCurvatureEnding: () => dt,
ZeroFactor: () => 200,
ZeroSlopeEnding: () => ft,
ZeroStencilOp: () => 0,
createCanvasElement: () => Qt,
error: () => R,
getConsoleFunction: () => nn,
log: () => rn,
setConsoleFunction: () => tn,
warn: () => L,
warnOnce: () => on
});
function qf() {
let e = null, t = !1, n = null, r = null;
function i(t, a) {
n(t, a), r = e.requestAnimationFrame(i);
}
return {
start: function() {
t !== !0 && n !== null && e !== null && (r = e.requestAnimationFrame(i), t = !0);
},
stop: function() {
e !== null && e.cancelAnimationFrame(r), t = !1;
},
setAnimationLoop: function(e) {
n = e;
},
setContext: function(t) {
e = t;
}
};
}
function Jf(e) {
let t = /* @__PURE__ */ new WeakMap();
function n(t, n) {
let r = t.array, i = t.usage, a = r.byteLength, o = e.createBuffer();
e.bindBuffer(n, o), e.bufferData(n, r, i), t.onUploadCallback();
let s;
if (r instanceof Float32Array) s = e.FLOAT;
else if (typeof Float16Array < "u" && r instanceof Float16Array) s = e.HALF_FLOAT;
else if (r instanceof Uint16Array) s = t.isFloat16BufferAttribute ? e.HALF_FLOAT : e.UNSIGNED_SHORT;
else if (r instanceof Int16Array) s = e.SHORT;
else if (r instanceof Uint32Array) s = e.UNSIGNED_INT;
else if (r instanceof Int32Array) s = e.INT;
else if (r instanceof Int8Array) s = e.BYTE;
else if (r instanceof Uint8Array) s = e.UNSIGNED_BYTE;
else if (r instanceof Uint8ClampedArray) s = e.UNSIGNED_BYTE;
else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: " + r);
return {
buffer: o,
type: s,
bytesPerElement: r.BYTES_PER_ELEMENT,
version: t.version,
size: a
};
}
function r(t, n, r) {
let i = n.array, a = n.updateRanges;
if (e.bindBuffer(r, t), a.length === 0) e.bufferSubData(r, 0, i);
else {
a.sort((e, t) => e.start - t.start);
let t = 0;
for (let e = 1; e < a.length; e++) {
let n = a[t], r = a[e];
r.start <= n.start + n.count + 1 ? n.count = Math.max(n.count, r.start + r.count - n.start) : (++t, a[t] = r);
}
a.length = t + 1;
for (let t = 0, n = a.length; t < n; t++) {
let n = a[t];
e.bufferSubData(r, n.start * i.BYTES_PER_ELEMENT, i, n.start, n.count);
}
n.clearUpdateRanges();
}
n.onUploadCallback();
}
function i(e) {
return e.isInterleavedBufferAttribute && (e = e.data), t.get(e);
}
function a(n) {
n.isInterleavedBufferAttribute && (n = n.data);
let r = t.get(n);
r && (e.deleteBuffer(r.buffer), t.delete(n));
}
function o(e, i) {
if (e.isInterleavedBufferAttribute && (e = e.data), e.isGLBufferAttribute) {
let n = t.get(e);
(!n || n.version < e.version) && t.set(e, {
buffer: e.buffer,
type: e.type,
bytesPerElement: e.elementSize,
version: e.version
});
return;
}
let a = t.get(e);
if (a === void 0) t.set(e, n(e, i));
else if (a.version < e.version) {
if (a.size !== e.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.");
r(a.buffer, e, i), a.version = e.version;
}
}
return {
get: i,
remove: a,
update: o
};
}
var Q = {
alphahash_fragment: "#ifdef USE_ALPHAHASH\n if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",
alphahash_pars_fragment: "#ifdef USE_ALPHAHASH\n const float ALPHA_HASH_SCALE = 0.05;\n float hash2D( vec2 value ) {\n return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n }\n float hash3D( vec3 value ) {\n return hash2D( vec2( hash2D( value.xy ), value.z ) );\n }\n float getAlphaHashThreshold( vec3 position ) {\n float maxDeriv = max(\n length( dFdx( position.xyz ) ),\n length( dFdy( position.xyz ) )\n );\n float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n vec2 pixScales = vec2(\n exp2( floor( log2( pixScale ) ) ),\n exp2( ceil( log2( pixScale ) ) )\n );\n vec2 alpha = vec2(\n hash3D( floor( pixScales.x * position.xyz ) ),\n hash3D( floor( pixScales.y * position.xyz ) )\n );\n float lerpFactor = fract( log2( pixScale ) );\n float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n float a = min( lerpFactor, 1.0 - lerpFactor );\n vec3 cases = vec3(\n x * x / ( 2.0 * a * ( 1.0 - a ) ),\n ( x - 0.5 * a ) / ( 1.0 - a ),\n 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n );\n float threshold = ( x < ( 1.0 - a ) )\n ? ( ( x < a ) ? cases.x : cases.y )\n : cases.z;\n return clamp( threshold , 1.0e-6, 1.0 );\n }\n#endif",
alphamap_fragment: "#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",
alphamap_pars_fragment: "#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",
alphatest_fragment: "#ifdef USE_ALPHATEST\n #ifdef ALPHA_TO_COVERAGE\n diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n if ( diffuseColor.a < alphaTest ) discard;\n #endif\n#endif",
alphatest_pars_fragment: "#ifdef USE_ALPHATEST\n uniform float alphaTest;\n#endif",
aomap_fragment: "#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_CLEARCOAT ) \n clearcoatSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_SHEEN ) \n sheenSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n #endif\n#endif",
aomap_pars_fragment: "#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif",
batching_pars_vertex: "#ifdef USE_BATCHING\n #if ! defined( GL_ANGLE_multi_draw )\n #define gl_DrawID _gl_DrawID\n uniform int _gl_DrawID;\n #endif\n uniform highp sampler2D batchingTexture;\n uniform highp usampler2D batchingIdTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n float getIndirectIndex( const in int i ) {\n int size = textureSize( batchingIdTexture, 0 ).x;\n int x = i % size;\n int y = i / size;\n return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n }\n#endif\n#ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec4 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n }\n#endif",
batching_vertex: "#ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",
begin_vertex: "vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n vPosition = vec3( position );\n#endif",
beginnormal_vertex: "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif",
bsdfs: "float G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( specularColor, 1.0, dotVH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n} // validated",
iridescence_fragment: "#ifdef USE_IRIDESCENCE\n const mat3 XYZ_TO_REC709 = mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n );\n vec3 Fresnel0ToIor( vec3 fresnel0 ) {\n vec3 sqrtF0 = sqrt( fresnel0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n }\n vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n }\n float IorToFresnel0( float transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n }\n vec3 evalSensitivity( float OPD, vec3 shift ) {\n float phase = 2.0 * PI * OPD * 1.0e-9;\n vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n 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 ) );\n xyz /= 1.0685e-7;\n vec3 rgb = XYZ_TO_REC709 * xyz;\n return rgb;\n }\n vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n vec3 I;\n float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n if ( cosTheta2Sq < 0.0 ) {\n return vec3( 1.0 );\n }\n float cosTheta2 = sqrt( cosTheta2Sq );\n float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n float R12 = F_Schlick( R0, 1.0, cosTheta1 );\n float T121 = 1.0 - R12;\n float phi12 = 0.0;\n if ( iridescenceIOR < outsideIOR ) phi12 = PI;\n float phi21 = PI - phi12;\n vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n vec3 phi23 = vec3( 0.0 );\n if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n vec3 phi = vec3( phi21 ) + phi23;\n vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n vec3 r123 = sqrt( R123 );\n vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n vec3 C0 = R12 + Rs;\n I = C0;\n vec3 Cm = Rs - T121;\n for ( int m = 1; m <= 2; ++ m ) {\n Cm *= r123;\n vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n I += Cm * Sm;\n }\n return max( I, vec3( 0.0 ) );\n }\n#endif",
bumpmap_pars_fragment: "#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vBumpMapUv );\n vec2 dSTdy = dFdy( vBumpMapUv );\n float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif",
clipping_planes_fragment: "#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #ifdef ALPHA_TO_COVERAGE\n float distanceToPlane, distanceGradient;\n float clipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n if ( clipOpacity == 0.0 ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n float unionClipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n }\n #pragma unroll_loop_end\n clipOpacity *= 1.0 - unionClipOpacity;\n #endif\n diffuseColor.a *= clipOpacity;\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n#endif",
clipping_planes_pars_fragment: "#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",
clipping_planes_pars_vertex: "#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif",
clipping_planes_vertex: "#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif",
color_fragment: "#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#endif",
color_pars_fragment: "#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#endif",
color_pars_vertex: "#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n varying vec4 vColor;\n#endif",
color_vertex: "#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n vColor *= color;\n#elif defined( USE_COLOR )\n vColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",
common: "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",
cube_uv_reflection_fragment: "#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif",
defaultnormal_vertex: "vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n vec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n mat3 bm = mat3( batchingMatrix );\n transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n transformedNormal = bm * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = bm * transformedTangent;\n #endif\n#endif\n#ifdef USE_INSTANCING\n mat3 im = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n transformedNormal = im * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = im * transformedTangent;\n #endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n#endif",
displacementmap_pars_vertex: "#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",
displacementmap_vertex: "#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",
emissivemap_fragment: "#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n emissiveColor = sRGBTransferEOTF( emissiveColor );\n #endif\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",
emissivemap_pars_fragment: "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",
colorspace_fragment: "gl_FragColor = linearToOutputTexel( gl_FragColor );",
colorspace_pars_fragment: "vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n 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 );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n 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 );\n}",
envmap_fragment: "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n #endif\n#endif",
envmap_common_pars_fragment: "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif",
envmap_pars_fragment: "#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",
envmap_pars_vertex: "#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",
envmap_physical_pars_fragment: "#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",
envmap_vertex: "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif",
fog_vertex: "#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif",
fog_pars_vertex: "#ifdef USE_FOG\n varying float vFogDepth;\n#endif",
fog_fragment: "#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",
fog_pars_fragment: "#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",
gradientmap_pars_fragment: "#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}",
lightmap_pars_fragment: "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",
lights_lambert_fragment: "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",
lights_lambert_pars_fragment: "varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid 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 ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",
lights_pars_begin: "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif\n#include <lightprobes_pars_fragment>",
lights_toon_fragment: "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",
lights_toon_pars_fragment: "varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid 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 ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon",
lights_phong_fragment: "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",
lights_phong_pars_fragment: "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid 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 ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid 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 ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong",
lights_physical_fragment: "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",
lights_physical_pars_fragment: "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n 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 ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n 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 ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid 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 ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid 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 ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid 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) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",
lights_fragment_begin: "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n #ifdef USE_LIGHT_PROBES_GRID\n vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",
lights_fragment_maps: "#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",
lights_fragment_end: "#if defined( RE_IndirectDiffuse )\n #if defined( LAMBERT ) || defined( PHONG )\n irradiance += iblIrradiance;\n #endif\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",
lightprobes_pars_fragment: "#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n vec3 res = probesResolution;\n vec3 gridRange = probesMax - probesMin;\n vec3 resMinusOne = res - 1.0;\n vec3 probeSpacing = gridRange / resMinusOne;\n vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n uvw = uvw * resMinusOne / res + 0.5 / res;\n float nz = res.z;\n float paddedSlices = nz + 2.0;\n float atlasDepth = 7.0 * paddedSlices;\n float uvZBase = uvw.z * nz + 1.0;\n vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n vec3 c0 = s0.xyz;\n vec3 c1 = vec3( s0.w, s1.xy );\n vec3 c2 = vec3( s1.zw, s2.x );\n vec3 c3 = s2.yzw;\n vec3 c4 = s3.xyz;\n vec3 c5 = vec3( s3.w, s4.xy );\n vec3 c6 = vec3( s4.zw, s5.x );\n vec3 c7 = s5.yzw;\n vec3 c8 = s6.xyz;\n float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n vec3 result = c0 * 0.886227;\n result += c1 * 2.0 * 0.511664 * y;\n result += c2 * 2.0 * 0.511664 * z;\n result += c3 * 2.0 * 0.511664 * x;\n result += c4 * 2.0 * 0.429043 * x * y;\n result += c5 * 2.0 * 0.429043 * y * z;\n result += c6 * ( 0.743125 * z * z - 0.247708 );\n result += c7 * 2.0 * 0.429043 * x * z;\n result += c8 * 0.429043 * ( x * x - y * y );\n return max( result, vec3( 0.0 ) );\n}\n#endif",
logdepthbuf_fragment: "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",
logdepthbuf_pars_fragment: "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",
logdepthbuf_pars_vertex: "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",
logdepthbuf_vertex: "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",
map_fragment: "#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif",
map_pars_fragment: "#ifdef USE_MAP\n uniform sampler2D map;\n#endif",
map_particle_fragment: "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",
map_particle_pars_fragment: "#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",
metalnessmap_fragment: "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif",
metalnessmap_pars_fragment: "#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",
morphinstance_vertex: "#ifdef USE_INSTANCING_MORPH\n float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n }\n#endif",
morphcolor_vertex: "#if defined( USE_MORPHCOLORS )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif",
morphnormal_vertex: "#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",
morphtarget_pars_vertex: "#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif",
morphtarget_vertex: "#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",
normal_fragment_begin: "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #ifdef DOUBLE_SIDED\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #ifdef DOUBLE_SIDED\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",
normal_fragment_maps: "#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #if defined( USE_PACKED_NORMALMAP )\n mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n #endif\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",
normal_pars_fragment: "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",
normal_pars_vertex: "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",
normal_vertex: "#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #ifdef FLIP_SIDED\n vBitangent = - vBitangent;\n #endif\n #endif\n#endif",
normalmap_pars_fragment: "#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif",
clearcoat_normal_fragment_begin: "#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif",
clearcoat_normal_fragment_maps: "#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",
clearcoat_pars_fragment: "#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif",
iridescence_pars_fragment: "#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform sampler2D iridescenceThicknessMap;\n#endif",
opaque_fragment: "#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",
packing: "vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n if( v <= 0.0 )\n return vec4( 0., 0., 0., 0. );\n if( v >= 1.0 )\n return vec4( 1., 1., 1., 1. );\n float vuf;\n float af = modf( v * PackFactors.a, vuf );\n float bf = modf( vuf * ShiftRight8, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n if( v <= 0.0 )\n return vec3( 0., 0., 0. );\n if( v >= 1.0 )\n return vec3( 1., 1., 1. );\n float vuf;\n float bf = modf( v * PackFactors.b, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n if( v <= 0.0 )\n return vec2( 0., 0. );\n if( v >= 1.0 )\n return vec2( 1., 1. );\n float vuf;\n float gf = modf( v * 256., vuf );\n return vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n return dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n \n return depth * ( far - near ) - far;\n #else\n return depth * ( near - far ) - near;\n #endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n \n #ifdef USE_REVERSED_DEPTH_BUFFER\n return ( near * far ) / ( ( near - far ) * depth - near );\n #else\n return ( near * far ) / ( ( far - near ) * depth - far );\n #endif\n}",
premultiplied_alpha_fragment: "#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",
project_vertex: "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n mvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",
dithering_fragment: "#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",
dithering_pars_fragment: "#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif",
roughnessmap_fragment: "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif",
roughnessmap_pars_fragment: "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",
shadowmap_pars_fragment: "#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n \n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp -= shadowBias;\n #else\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n #endif\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n vec2 sample0 = vogelDiskSample( 0, 5, phi );\n vec2 sample1 = vogelDiskSample( 1, 5, phi );\n vec2 sample2 = vogelDiskSample( 2, 5, phi );\n vec2 sample3 = vogelDiskSample( 3, 5, phi );\n vec2 sample4 = vogelDiskSample( 4, 5, phi );\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n depth = 1.0 - depth;\n #endif\n shadow = step( dp, depth );\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif",
shadowmap_pars_vertex: "#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif",
shadowmap_vertex: "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n #ifdef HAS_NORMAL\n vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #else\n vec3 shadowWorldNormal = vec3( 0.0 );\n #endif\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",
shadowmask_pars_fragment: "float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",
skinbase_vertex: "#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",
skinning_pars_vertex: "#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif",
skinning_vertex: "#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",
skinnormal_vertex: "#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif",
specularmap_fragment: "float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",
specularmap_pars_fragment: "#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",
tonemapping_fragment: "#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",
tonemapping_pars_fragment: "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n vec3( 1.6605, - 0.1246, - 0.0182 ),\n vec3( - 0.5876, 1.1329, - 0.1006 ),\n vec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n vec3( 0.6274, 0.0691, 0.0164 ),\n vec3( 0.3293, 0.9195, 0.0880 ),\n vec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n return + 15.5 * x4 * x2\n - 40.14 * x4 * x\n + 31.96 * x4\n - 6.868 * x2 * x\n + 0.4298 * x2\n + 0.1191 * x\n - 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n const mat3 AgXInsetMatrix = mat3(\n vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n );\n const mat3 AgXOutsetMatrix = mat3(\n vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n );\n const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;\n color *= toneMappingExposure;\n color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n color = AgXInsetMatrix * color;\n color = max( color, 1e-10 ); color = log2( color );\n color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n color = clamp( color, 0.0, 1.0 );\n color = agxDefaultContrastApprox( color );\n color = AgXOutsetMatrix * color;\n color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n color = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n color = clamp( color, 0.0, 1.0 );\n return color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n const float StartCompression = 0.8 - 0.04;\n const float Desaturation = 0.15;\n color *= toneMappingExposure;\n float x = min( color.r, min( color.g, color.b ) );\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max( color.r, max( color.g, color.b ) );\n if ( peak < StartCompression ) return color;\n float d = 1. - StartCompression;\n float newPeak = 1. - d * d / ( peak + d - StartCompression );\n color *= newPeak / peak;\n float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n return mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",
transmission_fragment: "#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",
transmission_pars_fragment: "#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec4 transmittedLight;\n vec3 transmittance;\n #ifdef USE_DISPERSION\n float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n for ( int i = 0; i < 3; i ++ ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n transmittedLight[ i ] = transmissionSample[ i ];\n transmittedLight.a += transmissionSample.a;\n transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n }\n transmittedLight.a /= 3.0;\n #else\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n #endif\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif",
uv_pars_fragment: "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",
uv_pars_vertex: "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",
uv_vertex: "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",
worldpos_vertex: "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_BATCHING\n worldPosition = batchingMatrix * worldPosition;\n #endif\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif",
background_vert: "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",
background_frag: "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n 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 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",
backgroundCube_vert: "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}",
backgroundCube_frag: "#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",
cube_vert: "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}",
cube_frag: "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",
depth_vert: "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vHighPrecisionZW = gl_Position.zw;\n}",
depth_frag: "#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <logdepthbuf_fragment>\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n #else\n float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #elif DEPTH_PACKING == 3202\n gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n #elif DEPTH_PACKING == 3203\n gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n #endif\n}",
distance_vert: "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n vWorldPosition = worldPosition.xyz;\n}",
distance_frag: "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",
equirect_vert: "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n}",
equirect_frag: "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",
linedashed_vert: "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n vLineDistance = scale * lineDistance;\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}",
linedashed_frag: "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}",
meshbasic_vert: "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <fog_vertex>\n}",
meshbasic_frag: "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include <aomap_fragment>\n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",
meshlambert_vert: "#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",
meshlambert_frag: "#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_lambert_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",
meshmatcap_vert: "#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n vViewPosition = - mvPosition.xyz;\n}",
meshmatcap_frag: "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",
meshnormal_vert: "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - mvPosition.xyz;\n#endif\n}",
meshnormal_frag: "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #endif\n}",
meshphong_vert: "#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",
meshphong_frag: "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_phong_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",
meshphysical_vert: "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}",
meshphysical_frag: "#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include <transmission_fragment>\n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",
meshtoon_vert: "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",
meshtoon_frag: "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_toon_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",
points_vert: "uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <fog_vertex>\n}",
points_frag: "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_particle_fragment>\n #include <color_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}",
shadow_vert: "#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",
shadow_frag: "uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n #include <logdepthbuf_fragment>\n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}",
sprite_vert: "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n vec4 mvPosition = modelViewMatrix[ 3 ];\n vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}",
sprite_frag: "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n}"
}, $ = {
common: {
diffuse: { value: /*@__PURE__*/ new G(16777215) },
opacity: { value: 1 },
map: { value: null },
mapTransform: { value: /*@__PURE__*/ new U() },
alphaMap: { value: null },
alphaMapTransform: { value: /*@__PURE__*/ new U() },
alphaTest: { value: 0 }
},
specularmap: {
specularMap: { value: null },
specularMapTransform: { value: /*@__PURE__*/ new U() }
},
envmap: {
envMap: { value: null },
envMapRotation: { value: /*@__PURE__*/ new U() },
reflectivity: { value: 1 },
ior: { value: 1.5 },
refractionRatio: { value: .98 },
dfgLUT: { value: null }
},
aomap: {
aoMap: { value: null },
aoMapIntensity: { value: 1 },
aoMapTransform: { value: /*@__PURE__*/ new U() }
},
lightmap: {
lightMap: { value: null },
lightMapIntensity: { value: 1 },
lightMapTransform: { value: /*@__PURE__*/ new U() }
},
bumpmap: {
bumpMap: { value: null },
bumpMapTransform: { value: /*@__PURE__*/ new U() },
bumpScale: { value: 1 }
},
normalmap: {
normalMap: { value: null },
normalMapTransform: { value: /*@__PURE__*/ new U() },
normalScale: { value: /*@__PURE__*/ new V(1, 1) }
},
displacementmap: {
displacementMap: { value: null },
displacementMapTransform: { value: /*@__PURE__*/ new U() },
displacementScale: { value: 1 },
displacementBias: { value: 0 }
},
emissivemap: {
emissiveMap: { value: null },
emissiveMapTransform: { value: /*@__PURE__*/ new U() }
},
metalnessmap: {
metalnessMap: { value: null },
metalnessMapTransform: { value: /*@__PURE__*/ new U() }
},
roughnessmap: {
roughnessMap: { value: null },
roughnessMapTransform: { value: /*@__PURE__*/ new U() }
},
gradientmap: { gradientMap: { value: null } },
fog: {
fogDensity: { value: 25e-5 },
fogNear: { value: 1 },
fogFar: { value: 2e3 },
fogColor: { value: /*@__PURE__*/ new G(16777215) }
},
lights: {
ambientLightColor: { value: [] },
lightProbe: { value: [] },
directionalLights: {
value: [],
properties: {
direction: {},
color: {}
}
},
directionalLightShadows: {
value: [],
properties: {
shadowIntensity: 1,
shadowBias: {},
shadowNormalBias: {},
shadowRadius: {},
shadowMapSize: {}
}
},
directionalShadowMatrix: { value: [] },
spotLights: {
value: [],
properties: {
color: {},
position: {},
direction: {},
distance: {},
coneCos: {},
penumbraCos: {},
decay: {}
}
},
spotLightShadows: {
value: [],
properties: {
shadowIntensity: 1,
shadowBias: {},
shadowNormalBias: {},
shadowRadius: {},
shadowMapSize: {}
}
},
spotLightMap: { value: [] },
spotLightMatrix: { value: [] },
pointLights: {
value: [],
properties: {
color: {},
position: {},
decay: {},
distance: {}
}
},
pointLightShadows: {
value: [],
properties: {
shadowIntensity: 1,
shadowBias: {},
shadowNormalBias: {},
shadowRadius: {},
shadowMapSize: {},
shadowCameraNear: {},
shadowCameraFar: {}
}
},
pointShadowMatrix: { value: [] },
hemisphereLights: {
value: [],
properties: {
direction: {},
skyColor: {},
groundColor: {}
}
},
rectAreaLights: {
value: [],
properties: {
color: {},
position: {},
width: {},
height: {}
}
},
ltc_1: { value: null },
ltc_2: { value: null },
probesSH: { value: null },
probesMin: { value: /*@__PURE__*/ new H() },
probesMax: { value: /*@__PURE__*/ new H() },
probesResolution: { value: /*@__PURE__*/ new H() }
},
points: {
diffuse: { value: /*@__PURE__*/ new G(16777215) },
opacity: { value: 1 },
size: { value: 1 },
scale: { value: 1 },
map: { value: null },
alphaMap: { value: null },
alphaMapTransform: { value: /*@__PURE__*/ new U() },
alphaTest: { value: 0 },
uvTransform: { value: /*@__PURE__*/ new U() }
},
sprite: {
diffuse: { value: /*@__PURE__*/ new G(16777215) },
opacity: { value: 1 },
center: { value: /*@__PURE__*/ new V(.5, .5) },
rotation: { value: 0 },
map: { value: null },
mapTransform: { value: /*@__PURE__*/ new U() },
alphaMap: { value: null },
alphaMapTransform: { value: /*@__PURE__*/ new U() },
alphaTest: { value: 0 }
}
}, Yf = {
basic: {
uniforms: /*@__PURE__*/ ul([
$.common,
$.specularmap,
$.envmap,
$.aomap,
$.lightmap,
$.fog
]),
vertexShader: Q.meshbasic_vert,
fragmentShader: Q.meshbasic_frag
},
lambert: {
uniforms: /*@__PURE__*/ ul([
$.common,
$.specularmap,
$.envmap,
$.aomap,
$.lightmap,
$.emissivemap,
$.bumpmap,
$.normalmap,
$.displacementmap,
$.fog,
$.lights,
{
emissive: { value: /*@__PURE__*/ new G(0) },
envMapIntensity: { value: 1 }
}
]),
vertexShader: Q.meshlambert_vert,
fragmentShader: Q.meshlambert_frag
},
phong: {
uniforms: /*@__PURE__*/ ul([
$.common,
$.specularmap,
$.envmap,
$.aomap,
$.lightmap,
$.emissivemap,
$.bumpmap,
$.normalmap,
$.displacementmap,
$.fog,
$.lights,
{
emissive: { value: /*@__PURE__*/ new G(0) },
specular: { value: /*@__PURE__*/ new G(1118481) },
shininess: { value: 30 },
envMapIntensity: { value: 1 }
}
]),
vertexShader: Q.meshphong_vert,
fragmentShader: Q.meshphong_frag
},
standard: {
uniforms: /*@__PURE__*/ ul([
$.common,
$.envmap,
$.aomap,
$.lightmap,
$.emissivemap,
$.bumpmap,
$.normalmap,
$.displacementmap,
$.roughnessmap,
$.metalnessmap,
$.fog,
$.lights,
{
emissive: { value: /*@__PURE__*/ new G(0) },
roughness: { value: 1 },
metalness: { value: 0 },
envMapIntensity: { value: 1 }
}
]),
vertexShader: Q.meshphysical_vert,
fragmentShader: Q.meshphysical_frag
},
toon: {
uniforms: /*@__PURE__*/ ul([
$.common,
$.aomap,
$.lightmap,
$.emissivemap,
$.bumpmap,
$.normalmap,
$.displacementmap,
$.gradientmap,
$.fog,
$.lights,
{ emissive: { value: /*@__PURE__*/ new G(0) } }
]),
vertexShader: Q.meshtoon_vert,
fragmentShader: Q.meshtoon_frag
},
matcap: {
uniforms: /*@__PURE__*/ ul([
$.common,
$.bumpmap,
$.normalmap,
$.displacementmap,
$.fog,
{ matcap: { value: null } }
]),
vertexShader: Q.meshmatcap_vert,
fragmentShader: Q.meshmatcap_frag
},
points: {
uniforms: /*@__PURE__*/ ul([$.points, $.fog]),
vertexShader: Q.points_vert,
fragmentShader: Q.points_frag
},
dashed: {
uniforms: /*@__PURE__*/ ul([
$.common,
$.fog,
{
scale: { value: 1 },
dashSize: { value: 1 },
totalSize: { value: 2 }
}
]),
vertexShader: Q.linedashed_vert,
fragmentShader: Q.linedashed_frag
},
depth: {
uniforms: /*@__PURE__*/ ul([$.common, $.displacementmap]),
vertexShader: Q.depth_vert,
fragmentShader: Q.depth_frag
},
normal: {
uniforms: /*@__PURE__*/ ul([
$.common,
$.bumpmap,
$.normalmap,
$.displacementmap,
{ opacity: { value: 1 } }
]),
vertexShader: Q.meshnormal_vert,
fragmentShader: Q.meshnormal_frag
},
sprite: {
uniforms: /*@__PURE__*/ ul([$.sprite, $.fog]),
vertexShader: Q.sprite_vert,
fragmentShader: Q.sprite_frag
},
background: {
uniforms: {
uvTransform: { value: /*@__PURE__*/ new U() },
t2D: { value: null },
backgroundIntensity: { value: 1 }
},
vertexShader: Q.background_vert,
fragmentShader: Q.background_frag
},
backgroundCube: {
uniforms: {
envMap: { value: null },
backgroundBlurriness: { value: 0 },
backgroundIntensity: { value: 1 },
backgroundRotation: { value: /*@__PURE__*/ new U() }
},
vertexShader: Q.backgroundCube_vert,
fragmentShader: Q.backgroundCube_frag
},
cube: {
uniforms: {
tCube: { value: null },
tFlip: { value: -1 },
opacity: { value: 1 }
},
vertexShader: Q.cube_vert,
fragmentShader: Q.cube_frag
},
equirect: {
uniforms: { tEquirect: { value: null } },
vertexShader: Q.equirect_vert,
fragmentShader: Q.equirect_frag
},
distance: {
uniforms: /*@__PURE__*/ ul([
$.common,
$.displacementmap,
{
referencePosition: { value: /*@__PURE__*/ new H() },
nearDistance: { value: 1 },
farDistance: { value: 1e3 }
}
]),
vertexShader: Q.distance_vert,
fragmentShader: Q.distance_frag
},
shadow: {
uniforms: /*@__PURE__*/ ul([
$.lights,
$.fog,
{
color: { value: /*@__PURE__*/ new G(0) },
opacity: { value: 1 }
}
]),
vertexShader: Q.shadow_vert,
fragmentShader: Q.shadow_frag
}
};
Yf.physical = {
uniforms: /*@__PURE__*/ ul([Yf.standard.uniforms, {
clearcoat: { value: 0 },
clearcoatMap: { value: null },
clearcoatMapTransform: { value: /*@__PURE__*/ new U() },
clearcoatNormalMap: { value: null },
clearcoatNormalMapTransform: { value: /*@__PURE__*/ new U() },
clearcoatNormalScale: { value: /*@__PURE__*/ new V(1, 1) },
clearcoatRoughness: { value: 0 },
clearcoatRoughnessMap: { value: null },
clearcoatRoughnessMapTransform: { value: /*@__PURE__*/ new U() },
dispersion: { value: 0 },
iridescence: { value: 0 },
iridescenceMap: { value: null },
iridescenceMapTransform: { value: /*@__PURE__*/ new U() },
iridescenceIOR: { value: 1.3 },
iridescenceThicknessMinimum: { value: 100 },
iridescenceThicknessMaximum: { value: 400 },
iridescenceThicknessMap: { value: null },
iridescenceThicknessMapTransform: { value: /*@__PURE__*/ new U() },
sheen: { value: 0 },
sheenColor: { value: /*@__PURE__*/ new G(0) },
sheenColorMap: { value: null },
sheenColorMapTransform: { value: /*@__PURE__*/ new U() },
sheenRoughness: { value: 1 },
sheenRoughnessMap: { value: null },
sheenRoughnessMapTransform: { value: /*@__PURE__*/ new U() },
transmission: { value: 0 },
transmissionMap: { value: null },
transmissionMapTransform: { value: /*@__PURE__*/ new U() },
transmissionSamplerSize: { value: /*@__PURE__*/ new V() },
transmissionSamplerMap: { value: null },
thickness: { value: 0 },
thicknessMap: { value: null },
thicknessMapTransform: { value: /*@__PURE__*/ new U() },
attenuationDistance: { value: 0 },
attenuationColor: { value: /*@__PURE__*/ new G(0) },
specularColor: { value: /*@__PURE__*/ new G(1, 1, 1) },
specularColorMap: { value: null },
specularColorMapTransform: { value: /*@__PURE__*/ new U() },
specularIntensity: { value: 1 },
specularIntensityMap: { value: null },
specularIntensityMapTransform: { value: /*@__PURE__*/ new U() },
anisotropyVector: { value: /*@__PURE__*/ new V() },
anisotropyMap: { value: null },
anisotropyMapTransform: { value: /*@__PURE__*/ new U() }
}]),
vertexShader: Q.meshphysical_vert,
fragmentShader: Q.meshphysical_frag
};
var Xf = {
r: 0,
b: 0,
g: 0
}, Zf = /*@__PURE__*/ new W(), Qf = /*@__PURE__*/ new U();
Qf.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
function $f(e, t, n, r, i, a) {
let o = new G(0), s = i === !0 ? 0 : 1, c, l, u = null, d = 0, f = null;
function p(e) {
let n = e.isScene === !0 ? e.background : null;
if (n && n.isTexture) {
let r = e.backgroundBlurriness > 0;
n = t.get(n, r);
}
return n;
}
function m(t) {
let r = !1, i = p(t);
i === null ? g(o, s) : i && i.isColor && (g(i, 1), r = !0);
let c = e.xr.getEnvironmentBlendMode();
c === "additive" ? n.buffers.color.setClear(0, 0, 0, 1, a) : c === "alpha-blend" && n.buffers.color.setClear(0, 0, 0, 0, a), (e.autoClear || r) && (n.buffers.depth.setTest(!0), n.buffers.depth.setMask(!0), n.buffers.color.setMask(!0), e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil));
}
function h(t, n) {
let i = p(n);
i && (i.isCubeTexture || i.mapping === 306) ? (l === void 0 && (l = new La(new vs(1, 1, 1), new _l({
name: "BackgroundCubeMaterial",
uniforms: ll(Yf.backgroundCube.uniforms),
vertexShader: Yf.backgroundCube.vertexShader,
fragmentShader: Yf.backgroundCube.fragmentShader,
side: 1,
depthTest: !1,
depthWrite: !1,
fog: !1,
allowOverride: !1
})), l.geometry.deleteAttribute("normal"), l.geometry.deleteAttribute("uv"), l.onBeforeRender = function(e, t, n) {
this.matrixWorld.copyPosition(n.matrixWorld);
}, Object.defineProperty(l.material, "envMap", { get: function() {
return this.uniforms.envMap.value;
} }), r.update(l)), l.material.uniforms.envMap.value = i, l.material.uniforms.backgroundBlurriness.value = n.backgroundBlurriness, l.material.uniforms.backgroundIntensity.value = n.backgroundIntensity, l.material.uniforms.backgroundRotation.value.setFromMatrix4(Zf.makeRotationFromEuler(n.backgroundRotation)).transpose(), i.isCubeTexture && i.isRenderTargetTexture === !1 && l.material.uniforms.backgroundRotation.value.premultiply(Qf), l.material.toneMapped = Hn.getTransfer(i.colorSpace) !== Ct, (u !== i || d !== i.version || f !== e.toneMapping) && (l.material.needsUpdate = !0, u = i, d = i.version, f = e.toneMapping), l.layers.enableAll(), t.unshift(l, l.geometry, l.material, 0, 0, null)) : i && i.isTexture && (c === void 0 && (c = new La(new Xc(2, 2), new _l({
name: "BackgroundMaterial",
uniforms: ll(Yf.background.uniforms),
vertexShader: Yf.background.vertexShader,
fragmentShader: Yf.background.fragmentShader,
side: 0,
depthTest: !1,
depthWrite: !1,
fog: !1,
allowOverride: !1
})), c.geometry.deleteAttribute("normal"), Object.defineProperty(c.material, "map", { get: function() {
return this.uniforms.t2D.value;
} }), r.update(c)), c.material.uniforms.t2D.value = i, c.material.uniforms.backgroundIntensity.value = n.backgroundIntensity, c.material.toneMapped = Hn.getTransfer(i.colorSpace) !== Ct, i.matrixAutoUpdate === !0 && i.updateMatrix(), c.material.uniforms.uvTransform.value.copy(i.matrix), (u !== i || d !== i.version || f !== e.toneMapping) && (c.material.needsUpdate = !0, u = i, d = i.version, f = e.toneMapping), c.layers.enableAll(), t.unshift(c, c.geometry, c.material, 0, 0, null));
}
function g(t, r) {
t.getRGB(Xf, pl(e)), n.buffers.color.setClear(Xf.r, Xf.g, Xf.b, r, a);
}
function _() {
l !== void 0 && (l.geometry.dispose(), l.material.dispose(), l = void 0), c !== void 0 && (c.geometry.dispose(), c.material.dispose(), c = void 0);
}
return {
getClearColor: function() {
return o;
},
setClearColor: function(e, t = 1) {
o.set(e), s = t, g(o, s);
},
getClearAlpha: function() {
return s;
},
setClearAlpha: function(e) {
s = e, g(o, s);
},
render: m,
addToRenderList: h,
dispose: _
};
}
function ep(e, t) {
let n = e.getParameter(e.MAX_VERTEX_ATTRIBS), r = {}, i = f(null), a = i, o = !1;
function s(n, r, i, s, c) {
let u = !1, f = d(n, s, i, r);
a !== f && (a = f, l(a.object)), u = p(n, s, i, c), u && m(n, s, i, c), c !== null && t.update(c, e.ELEMENT_ARRAY_BUFFER), (u || o) && (o = !1, b(n, r, i, s), c !== null && e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, t.get(c).buffer));
}
function c() {
return e.createVertexArray();
}
function l(t) {
return e.bindVertexArray(t);
}
function u(t) {
return e.deleteVertexArray(t);
}
function d(e, t, n, i) {
let a = i.wireframe === !0, o = r[t.id];
o === void 0 && (o = {}, r[t.id] = o);
let s = e.isInstancedMesh === !0 ? e.id : 0, l = o[s];
l === void 0 && (l = {}, o[s] = l);
let u = l[n.id];
u === void 0 && (u = {}, l[n.id] = u);
let d = u[a];
return d === void 0 && (d = f(c()), u[a] = d), d;
}
function f(e) {
let t = [], r = [], i = [];
for (let e = 0; e < n; e++) t[e] = 0, r[e] = 0, i[e] = 0;
return {
geometry: null,
program: null,
wireframe: !1,
newAttributes: t,
enabledAttributes: r,
attributeDivisors: i,
object: e,
attributes: {},
index: null
};
}
function p(e, t, n, r) {
let i = a.attributes, o = t.attributes, s = 0, c = n.getAttributes();
for (let t in c) if (c[t].location >= 0) {
let n = i[t], r = o[t];
if (r === void 0 && (t === "instanceMatrix" && e.instanceMatrix && (r = e.instanceMatrix), t === "instanceColor" && e.instanceColor && (r = e.instanceColor)), n === void 0 || n.attribute !== r || r && n.data !== r.data) return !0;
s++;
}
return a.attributesNum !== s || a.index !== r;
}
function m(e, t, n, r) {
let i = {}, o = t.attributes, s = 0, c = n.getAttributes();
for (let t in c) if (c[t].location >= 0) {
let n = o[t];
n === void 0 && (t === "instanceMatrix" && e.instanceMatrix && (n = e.instanceMatrix), t === "instanceColor" && e.instanceColor && (n = e.instanceColor));
let r = {};
r.attribute = n, n && n.data && (r.data = n.data), i[t] = r, s++;
}
a.attributes = i, a.attributesNum = s, a.index = r;
}
function h() {
let e = a.newAttributes;
for (let t = 0, n = e.length; t < n; t++) e[t] = 0;
}
function g(e) {
_(e, 0);
}
function _(t, n) {
let r = a.newAttributes, i = a.enabledAttributes, o = a.attributeDivisors;
r[t] = 1, i[t] === 0 && (e.enableVertexAttribArray(t), i[t] = 1), o[t] !== n && (e.vertexAttribDivisor(t, n), o[t] = n);
}
function v() {
let t = a.newAttributes, n = a.enabledAttributes;
for (let r = 0, i = n.length; r < i; r++) n[r] !== t[r] && (e.disableVertexAttribArray(r), n[r] = 0);
}
function y(t, n, r, i, a, o, s) {
s === !0 ? e.vertexAttribIPointer(t, n, r, a, o) : e.vertexAttribPointer(t, n, r, i, a, o);
}
function b(n, r, i, a) {
h();
let o = a.attributes, s = i.getAttributes(), c = r.defaultAttributeValues;
for (let r in s) {
let i = s[r];
if (i.location >= 0) {
let s = o[r];
if (s === void 0 && (r === "instanceMatrix" && n.instanceMatrix && (s = n.instanceMatrix), r === "instanceColor" && n.instanceColor && (s = n.instanceColor)), s !== void 0) {
let r = s.normalized, o = s.itemSize, c = t.get(s);
if (c === void 0) continue;
let l = c.buffer, u = c.type, d = c.bytesPerElement, f = u === e.INT || u === e.UNSIGNED_INT || s.gpuType === 1013;
if (s.isInterleavedBufferAttribute) {
let t = s.data, c = t.stride, p = s.offset;
if (t.isInstancedInterleavedBuffer) {
for (let e = 0; e < i.locationSize; e++) _(i.location + e, t.meshPerAttribute);
n.isInstancedMesh !== !0 && a._maxInstanceCount === void 0 && (a._maxInstanceCount = t.meshPerAttribute * t.count);
} else for (let e = 0; e < i.locationSize; e++) g(i.location + e);
e.bindBuffer(e.ARRAY_BUFFER, l);
for (let e = 0; e < i.locationSize; e++) y(i.location + e, o / i.locationSize, u, r, c * d, (p + o / i.locationSize * e) * d, f);
} else {
if (s.isInstancedBufferAttribute) {
for (let e = 0; e < i.locationSize; e++) _(i.location + e, s.meshPerAttribute);
n.isInstancedMesh !== !0 && a._maxInstanceCount === void 0 && (a._maxInstanceCount = s.meshPerAttribute * s.count);
} else for (let e = 0; e < i.locationSize; e++) g(i.location + e);
e.bindBuffer(e.ARRAY_BUFFER, l);
for (let e = 0; e < i.locationSize; e++) y(i.location + e, o / i.locationSize, u, r, o * d, o / i.locationSize * e * d, f);
}
} else if (c !== void 0) {
let t = c[r];
if (t !== void 0) switch (t.length) {
case 2:
e.vertexAttrib2fv(i.location, t);
break;
case 3:
e.vertexAttrib3fv(i.location, t);
break;
case 4:
e.vertexAttrib4fv(i.location, t);
break;
default: e.vertexAttrib1fv(i.location, t);
}
}
}
}
v();
}
function x() {
T();
for (let e in r) {
let t = r[e];
for (let e in t) {
let n = t[e];
for (let e in n) {
let t = n[e];
for (let e in t) u(t[e].object), delete t[e];
delete n[e];
}
}
delete r[e];
}
}
function S(e) {
if (r[e.id] === void 0) return;
let t = r[e.id];
for (let e in t) {
let n = t[e];
for (let e in n) {
let t = n[e];
for (let e in t) u(t[e].object), delete t[e];
delete n[e];
}
}
delete r[e.id];
}
function C(e) {
for (let t in r) {
let n = r[t];
for (let t in n) {
let r = n[t];
if (r[e.id] === void 0) continue;
let i = r[e.id];
for (let e in i) u(i[e].object), delete i[e];
delete r[e.id];
}
}
}
function w(e) {
for (let t in r) {
let n = r[t], i = e.isInstancedMesh === !0 ? e.id : 0, a = n[i];
if (a !== void 0) {
for (let e in a) {
let t = a[e];
for (let e in t) u(t[e].object), delete t[e];
delete a[e];
}
delete n[i], Object.keys(n).length === 0 && delete r[t];
}
}
}
function T() {
E(), o = !0, a !== i && (a = i, l(a.object));
}
function E() {
i.geometry = null, i.program = null, i.wireframe = !1;
}
return {
setup: s,
reset: T,
resetDefaultState: E,
dispose: x,
releaseStatesOfGeometry: S,
releaseStatesOfObject: w,
releaseStatesOfProgram: C,
initAttributes: h,
enableAttribute: g,
disableUnusedAttributes: v
};
}
function tp(e, t, n) {
let r;
function i(e) {
r = e;
}
function a(t, i) {
e.drawArrays(r, t, i), n.update(i, r, 1);
}
function o(t, i, a) {
a !== 0 && (e.drawArraysInstanced(r, t, i, a), n.update(i, r, a));
}
function s(e, i, a) {
if (a === 0) return;
t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r, e, 0, i, 0, a);
let o = 0;
for (let e = 0; e < a; e++) o += i[e];
n.update(o, r, 1);
}
this.setMode = i, this.render = a, this.renderInstances = o, this.renderMultiDraw = s;
}
function np(e, t, n, r) {
let i;
function a() {
if (i !== void 0) return i;
if (t.has("EXT_texture_filter_anisotropic") === !0) {
let n = t.get("EXT_texture_filter_anisotropic");
i = e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
} else i = 0;
return i;
}
function o(t) {
return !(t !== 1023 && r.convert(t) !== e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT));
}
function s(n) {
let i = n === 1016 && (t.has("EXT_color_buffer_half_float") || t.has("EXT_color_buffer_float"));
return !(n !== 1009 && r.convert(n) !== e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE) && n !== 1015 && !i);
}
function c(t) {
if (t === "highp") {
if (e.getShaderPrecisionFormat(e.VERTEX_SHADER, e.HIGH_FLOAT).precision > 0 && e.getShaderPrecisionFormat(e.FRAGMENT_SHADER, e.HIGH_FLOAT).precision > 0) return "highp";
t = "mediump";
}
return t === "mediump" && e.getShaderPrecisionFormat(e.VERTEX_SHADER, e.MEDIUM_FLOAT).precision > 0 && e.getShaderPrecisionFormat(e.FRAGMENT_SHADER, e.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp";
}
let l = n.precision === void 0 ? "highp" : n.precision, u = c(l);
u !== l && (L("WebGLRenderer:", l, "not supported, using", u, "instead."), l = u);
let d = n.logarithmicDepthBuffer === !0, f = n.reversedDepthBuffer === !0 && t.has("EXT_clip_control");
n.reversedDepthBuffer === !0 && f === !1 && L("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");
let p = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), m = e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS), h = e.getParameter(e.MAX_TEXTURE_SIZE), g = e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE), _ = e.getParameter(e.MAX_VERTEX_ATTRIBS), v = e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS), y = e.getParameter(e.MAX_VARYING_VECTORS), b = e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS), x = e.getParameter(e.MAX_SAMPLES), S = e.getParameter(e.SAMPLES);
return {
isWebGL2: !0,
getMaxAnisotropy: a,
getMaxPrecision: c,
textureFormatReadable: o,
textureTypeReadable: s,
precision: l,
logarithmicDepthBuffer: d,
reversedDepthBuffer: f,
maxTextures: p,
maxVertexTextures: m,
maxTextureSize: h,
maxCubemapSize: g,
maxAttributes: _,
maxVertexUniforms: v,
maxVaryings: y,
maxFragmentUniforms: b,
maxSamples: x,
samples: S
};
}
function rp(e) {
let t = this, n = null, r = 0, i = !1, a = !1, o = new po(), s = new U(), c = {
value: null,
needsUpdate: !1
};
this.uniform = c, this.numPlanes = 0, this.numIntersection = 0, this.init = function(e, t) {
let n = e.length !== 0 || t || r !== 0 || i;
return i = t, r = e.length, n;
}, this.beginShadows = function() {
a = !0, u(null);
}, this.endShadows = function() {
a = !1;
}, this.setGlobalState = function(e, t) {
n = u(e, t, 0);
}, this.setState = function(t, o, s) {
let d = t.clippingPlanes, f = t.clipIntersection, p = t.clipShadows, m = e.get(t);
if (!i || d === null || d.length === 0 || a && !p) a ? u(null) : l();
else {
let e = a ? 0 : r, t = e * 4, i = m.clippingState || null;
c.value = i, i = u(d, o, t, s);
for (let e = 0; e !== t; ++e) i[e] = n[e];
m.clippingState = i, this.numIntersection = f ? this.numPlanes : 0, this.numPlanes += e;
}
};
function l() {
c.value !== n && (c.value = n, c.needsUpdate = r > 0), t.numPlanes = r, t.numIntersection = 0;
}
function u(e, n, r, i) {
let a = e === null ? 0 : e.length, l = null;
if (a !== 0) {
if (l = c.value, i !== !0 || l === null) {
let t = r + a * 4, i = n.matrixWorldInverse;
s.getNormalMatrix(i), (l === null || l.length < t) && (l = new Float32Array(t));
for (let t = 0, n = r; t !== a; ++t, n += 4) o.copy(e[t]).applyMatrix4(i, s), o.normal.toArray(l, n), l[n + 3] = o.constant;
}
c.value = l, c.needsUpdate = !0;
}
return t.numPlanes = a, t.numIntersection = 0, l;
}
}
var ip = 4, ap = [
.125,
.215,
.35,
.446,
.526,
.582
], op = 20, sp = 256, cp = /*@__PURE__*/ new Ou(), lp = /*@__PURE__*/ new G(), up = null, dp = 0, fp = 0, pp = !1, mp = /*@__PURE__*/ new H(), hp = class {
constructor(e) {
this._renderer = e, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._sizeLods = [], this._sigmas = [], this._lodMeshes = [], this._backgroundBox = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._blurMaterial = null, this._ggxMaterial = null;
}
fromScene(e, t = 0, n = .1, r = 100, i = {}) {
let { size: a = 256, position: o = mp } = i;
up = this._renderer.getRenderTarget(), dp = this._renderer.getActiveCubeFace(), fp = this._renderer.getActiveMipmapLevel(), pp = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(a);
let s = this._allocateTargets();
return s.depthBuffer = !0, this._sceneToCubeUV(e, n, r, s, o), t > 0 && this._blur(s, 0, 0, t), this._applyPMREM(s), this._cleanup(s), s;
}
fromEquirectangular(e, t = null) {
return this._fromTexture(e, t);
}
fromCubemap(e, t = null) {
return this._fromTexture(e, t);
}
compileCubemapShader() {
this._cubemapMaterial === null && (this._cubemapMaterial = Sp(), this._compileMaterial(this._cubemapMaterial));
}
compileEquirectangularShader() {
this._equirectMaterial === null && (this._equirectMaterial = xp(), this._compileMaterial(this._equirectMaterial));
}
dispose() {
this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose(), this._backgroundBox !== null && (this._backgroundBox.geometry.dispose(), this._backgroundBox.material.dispose());
}
_setSize(e) {
this._lodMax = Math.floor(Math.log2(e)), this._cubeSize = 2 ** this._lodMax;
}
_dispose() {
this._blurMaterial !== null && this._blurMaterial.dispose(), this._ggxMaterial !== null && this._ggxMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose();
for (let e = 0; e < this._lodMeshes.length; e++) this._lodMeshes[e].geometry.dispose();
}
_cleanup(e) {
this._renderer.setRenderTarget(up, dp, fp), this._renderer.xr.enabled = pp, e.scissorTest = !1, vp(e, 0, 0, e.width, e.height);
}
_fromTexture(e, t) {
e.mapping === 301 || e.mapping === 302 ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), up = this._renderer.getRenderTarget(), dp = this._renderer.getActiveCubeFace(), fp = this._renderer.getActiveMipmapLevel(), pp = 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: A,
minFilter: A,
generateMipmaps: !1,
type: ce,
format: ge,
colorSpace: xt,
depthBuffer: !1
}, r = _p(e, t, n);
if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) {
this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = _p(e, t, n);
let { _lodMax: r } = this;
({lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas} = gp(r)), this._blurMaterial = bp(r, e, t), this._ggxMaterial = yp(r, e, t);
}
return r;
}
_compileMaterial(e) {
let t = new La(new q(), e);
this._renderer.compile(t, cp);
}
_sceneToCubeUV(e, t, n, r, i) {
let a = new Z(90, 1, t, n), o = [
1,
-1,
1,
1,
1,
1
], s = [
1,
1,
1,
-1,
-1,
-1
], c = this._renderer, l = c.autoClear, u = c.toneMapping;
c.getClearColor(lp), c.toneMapping = 0, c.autoClear = !1, c.state.buffers.depth.getReversed() && (c.setRenderTarget(r), c.clearDepth(), c.setRenderTarget(null)), this._backgroundBox === null && (this._backgroundBox = new La(new vs(), new Ta({
name: "PMREM.Background",
side: 1,
depthWrite: !1,
depthTest: !1
})));
let d = this._backgroundBox, f = d.material, p = !1, m = e.background;
m ? m.isColor && (f.color.copy(m), e.background = null, p = !0) : (f.color.copy(lp), p = !0);
for (let t = 0; t < 6; t++) {
let n = t % 3;
n === 0 ? (a.up.set(0, o[t], 0), a.position.set(i.x, i.y, i.z), a.lookAt(i.x + s[t], i.y, i.z)) : n === 1 ? (a.up.set(0, 0, o[t]), a.position.set(i.x, i.y, i.z), a.lookAt(i.x, i.y + s[t], i.z)) : (a.up.set(0, o[t], 0), a.position.set(i.x, i.y, i.z), a.lookAt(i.x, i.y, i.z + s[t]));
let l = this._cubeSize;
vp(r, n * l, t > 2 ? l : 0, l, l), c.setRenderTarget(r), p && c.render(d, a), c.render(e, a);
}
c.toneMapping = u, c.autoClear = l, e.background = m;
}
_textureToCubeUV(e, t) {
let n = this._renderer, r = e.mapping === 301 || e.mapping === 302;
r ? (this._cubemapMaterial === null && (this._cubemapMaterial = Sp()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = xp());
let i = r ? this._cubemapMaterial : this._equirectMaterial, a = this._lodMeshes[0];
a.material = i;
let o = i.uniforms;
o.envMap.value = e;
let s = this._cubeSize;
vp(t, 0, 0, 3 * s, 2 * s), n.setRenderTarget(t), n.render(a, cp);
}
_applyPMREM(e) {
let t = this._renderer, n = t.autoClear;
t.autoClear = !1;
let r = this._lodMeshes.length;
for (let t = 1; t < r; t++) this._applyGGXFilter(e, t - 1, t);
t.autoClear = n;
}
_applyGGXFilter(e, t, n) {
let r = this._renderer, i = this._pingPongRenderTarget, a = this._ggxMaterial, o = this._lodMeshes[n];
o.material = a;
let s = a.uniforms, c = n / (this._lodMeshes.length - 1), l = t / (this._lodMeshes.length - 1), u = Math.sqrt(c * c - l * l) * (0 + c * 1.25), { _lodMax: d } = this, f = this._sizeLods[n], p = 3 * f * (n > d - ip ? n - d + ip : 0), m = 4 * (this._cubeSize - f);
s.envMap.value = e.texture, s.roughness.value = u, s.mipInt.value = d - t, vp(i, p, m, 3 * f, 2 * f), r.setRenderTarget(i), r.render(o, cp), s.envMap.value = i.texture, s.roughness.value = 0, s.mipInt.value = d - n, vp(e, p, m, 3 * f, 2 * f), r.setRenderTarget(e), r.render(o, cp);
}
_blur(e, t, n, r, i) {
let a = this._pingPongRenderTarget;
this._halfBlur(e, a, t, n, r, "latitudinal", i), this._halfBlur(a, e, n, n, r, "longitudinal", i);
}
_halfBlur(e, t, n, r, i, a, o) {
let s = this._renderer, c = this._blurMaterial;
a !== "latitudinal" && a !== "longitudinal" && R("blur direction must be either latitudinal or longitudinal!");
let l = this._lodMeshes[r];
l.material = c;
let u = c.uniforms, d = this._sizeLods[n] - 1, f = isFinite(i) ? Math.PI / (2 * d) : 2 * Math.PI / (2 * op - 1), p = i / f, m = isFinite(i) ? 1 + Math.floor(3 * p) : op;
m > op && L(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${op}`);
let h = [], g = 0;
for (let e = 0; e < op; ++e) {
let t = e / p, n = Math.exp(-t * t / 2);
h.push(n), e === 0 ? g += n : e < m && (g += 2 * n);
}
for (let e = 0; e < h.length; e++) h[e] = h[e] / g;
u.envMap.value = e.texture, u.samples.value = m, u.weights.value = h, u.latitudinal.value = a === "latitudinal", o && (u.poleAxis.value = o);
let { _lodMax: _ } = this;
u.dTheta.value = f, u.mipInt.value = _ - n;
let v = this._sizeLods[r];
vp(t, 3 * v * (r > _ - ip ? r - _ + ip : 0), 4 * (this._cubeSize - v), 3 * v, 2 * v), s.setRenderTarget(t), s.render(l, cp);
}
};
function gp(e) {
let t = [], n = [], r = [], i = e, a = e - ip + 1 + ap.length;
for (let o = 0; o < a; o++) {
let a = 2 ** i;
t.push(a);
let s = 1 / a;
o > e - ip ? s = ap[o - e + ip - 1] : o === 0 && (s = 0), n.push(s);
let c = 1 / (a - 2), l = -c, u = 1 + c, d = [
l,
l,
u,
l,
u,
u,
l,
l,
u,
u,
l,
u
], f = /* @__PURE__ */ new Float32Array(108), p = /* @__PURE__ */ new Float32Array(72), m = /* @__PURE__ */ new Float32Array(36);
for (let e = 0; e < 6; e++) {
let t = e % 3 * 2 / 3 - 1, n = e > 2 ? 0 : -1, r = [
t,
n,
0,
t + 2 / 3,
n,
0,
t + 2 / 3,
n + 1,
0,
t,
n,
0,
t + 2 / 3,
n + 1,
0,
t,
n + 1,
0
];
f.set(r, 18 * e), p.set(d, 12 * e);
let i = [
e,
e,
e,
e,
e,
e
];
m.set(i, 6 * e);
}
let h = new q();
h.setAttribute("position", new Di(f, 3)), h.setAttribute("uv", new Di(p, 2)), h.setAttribute("faceIndex", new Di(m, 1)), r.push(new La(h, null)), i > ip && i--;
}
return {
lodMeshes: r,
sizeLods: t,
sigmas: n
};
}
function _p(e, t, n) {
let r = new tr(e, t, n);
return r.texture.mapping = 306, r.texture.name = "PMREM.cubeUv", r.scissorTest = !0, r;
}
function vp(e, t, n, r, i) {
e.viewport.set(t, n, r, i), e.scissor.set(t, n, r, i);
}
function yp(e, t, n) {
return new _l({
name: "PMREMGGXConvolution",
defines: {
GGX_SAMPLES: sp,
CUBEUV_TEXEL_WIDTH: 1 / t,
CUBEUV_TEXEL_HEIGHT: 1 / n,
CUBEUV_MAX_MIP: `${e}.0`
},
uniforms: {
envMap: { value: null },
roughness: { value: 0 },
mipInt: { value: 0 }
},
vertexShader: Cp(),
fragmentShader: "\n\n precision highp float;\n precision highp int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n uniform float roughness;\n uniform float mipInt;\n\n #define ENVMAP_TYPE_CUBE_UV\n #include <cube_uv_reflection_fragment>\n\n #define PI 3.14159265359\n\n // Van der Corput radical inverse\n float radicalInverse_VdC(uint bits) {\n bits = (bits << 16u) | (bits >> 16u);\n bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n return float(bits) * 2.3283064365386963e-10; // / 0x100000000\n }\n\n // Hammersley sequence\n vec2 hammersley(uint i, uint N) {\n return vec2(float(i) / float(N), radicalInverse_VdC(i));\n }\n\n // GGX VNDF importance sampling (Eric Heitz 2018)\n // \"Sampling the GGX Distribution of Visible Normals\"\n // https://jcgt.org/published/0007/04/01/\n vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n float alpha = roughness * roughness;\n\n // Section 4.1: Orthonormal basis\n vec3 T1 = vec3(1.0, 0.0, 0.0);\n vec3 T2 = cross(V, T1);\n\n // Section 4.2: Parameterization of projected area\n float r = sqrt(Xi.x);\n float phi = 2.0 * PI * Xi.y;\n float t1 = r * cos(phi);\n float t2 = r * sin(phi);\n float s = 0.5 * (1.0 + V.z);\n t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n // Section 4.3: Reprojection onto hemisphere\n vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n // Section 3.4: Transform back to ellipsoid configuration\n return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n }\n\n void main() {\n vec3 N = normalize(vOutputDirection);\n vec3 V = N; // Assume view direction equals normal for pre-filtering\n\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n\n // For very low roughness, just sample the environment directly\n if (roughness < 0.001) {\n gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n return;\n }\n\n // Tangent space basis for VNDF sampling\n vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n vec3 tangent = normalize(cross(up, N));\n vec3 bitangent = cross(N, tangent);\n\n for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n vec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n // For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n // Transform H back to world space\n vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n vec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n float NdotL = max(dot(N, L), 0.0);\n\n if(NdotL > 0.0) {\n // Sample environment at fixed mip level\n // VNDF importance sampling handles the distribution filtering\n vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n // Weight by NdotL for the split-sum approximation\n // VNDF PDF naturally accounts for the visible microfacet distribution\n prefilteredColor += sampleColor * NdotL;\n totalWeight += NdotL;\n }\n }\n\n if (totalWeight > 0.0) {\n prefilteredColor = prefilteredColor / totalWeight;\n }\n\n gl_FragColor = vec4(prefilteredColor, 1.0);\n }\n ",
blending: 0,
depthTest: !1,
depthWrite: !1
});
}
function bp(e, t, n) {
let r = new Float32Array(op), i = new H(0, 1, 0);
return new _l({
name: "SphericalGaussianBlur",
defines: {
n: op,
CUBEUV_TEXEL_WIDTH: 1 / t,
CUBEUV_TEXEL_HEIGHT: 1 / n,
CUBEUV_MAX_MIP: `${e}.0`
},
uniforms: {
envMap: { value: null },
samples: { value: 1 },
weights: { value: r },
latitudinal: { value: !1 },
dTheta: { value: 0 },
mipInt: { value: 0 },
poleAxis: { value: i }
},
vertexShader: Cp(),
fragmentShader: "\n\n precision mediump float;\n precision mediump int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n uniform int samples;\n uniform float weights[ n ];\n uniform bool latitudinal;\n uniform float dTheta;\n uniform float mipInt;\n uniform vec3 poleAxis;\n\n #define ENVMAP_TYPE_CUBE_UV\n #include <cube_uv_reflection_fragment>\n\n vec3 getSample( float theta, vec3 axis ) {\n\n float cosTheta = cos( theta );\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross( axis, vOutputDirection ) * sin( theta )\n + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n return bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n }\n\n void main() {\n\n vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n if ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n }\n\n axis = normalize( axis );\n\n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n for ( int i = 1; i < n; i++ ) {\n\n if ( i >= samples ) {\n\n break;\n\n }\n\n float theta = dTheta * float( i );\n gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n }\n\n }\n ",
blending: 0,
depthTest: !1,
depthWrite: !1
});
}
function xp() {
return new _l({
name: "EquirectangularToCubeUV",
uniforms: { envMap: { value: null } },
vertexShader: Cp(),
fragmentShader: "\n\n precision mediump float;\n precision mediump int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n\n #include <common>\n\n void main() {\n\n vec3 outputDirection = normalize( vOutputDirection );\n vec2 uv = equirectUv( outputDirection );\n\n gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n }\n ",
blending: 0,
depthTest: !1,
depthWrite: !1
});
}
function Sp() {
return new _l({
name: "CubemapToCubeUV",
uniforms: {
envMap: { value: null },
flipEnvMap: { value: -1 }
},
vertexShader: Cp(),
fragmentShader: "\n\n precision mediump float;\n precision mediump int;\n\n uniform float flipEnvMap;\n\n varying vec3 vOutputDirection;\n\n uniform samplerCube envMap;\n\n void main() {\n\n gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n }\n ",
blending: 0,
depthTest: !1,
depthWrite: !1
});
}
function Cp() {
return "\n\n precision mediump float;\n precision mediump int;\n\n attribute float faceIndex;\n\n varying vec3 vOutputDirection;\n\n // RH coordinate system; PMREM face-indexing convention\n vec3 getDirection( vec2 uv, float face ) {\n\n uv = 2.0 * uv - 1.0;\n\n vec3 direction = vec3( uv, 1.0 );\n\n if ( face == 0.0 ) {\n\n direction = direction.zyx; // ( 1, v, u ) pos x\n\n } else if ( face == 1.0 ) {\n\n direction = direction.xzy;\n direction.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n } else if ( face == 2.0 ) {\n\n direction.x *= -1.0; // ( -u, v, 1 ) pos z\n\n } else if ( face == 3.0 ) {\n\n direction = direction.zyx;\n direction.xz *= -1.0; // ( -1, v, -u ) neg x\n\n } else if ( face == 4.0 ) {\n\n direction = direction.xzy;\n direction.xy *= -1.0; // ( -u, -1, v ) neg y\n\n } else if ( face == 5.0 ) {\n\n direction.z *= -1.0; // ( u, v, -1 ) neg z\n\n }\n\n return direction;\n\n }\n\n void main() {\n\n vOutputDirection = getDirection( uv, faceIndex );\n gl_Position = vec4( position, 1.0 );\n\n }\n ";
}
var wp = class extends tr {
constructor(e = 1, t = {}) {
super(e, e, t), this.isWebGLCubeRenderTarget = !0;
let n = {
width: e,
height: e,
depth: 1
}, r = [
n,
n,
n,
n,
n,
n
];
this.texture = new fs(r), 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: "\n\n varying vec3 vWorldDirection;\n\n vec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n }\n\n void main() {\n\n vWorldDirection = transformDirection( position, modelMatrix );\n\n #include <begin_vertex>\n #include <project_vertex>\n\n }\n ",
fragmentShader: "\n\n uniform sampler2D tEquirect;\n\n varying vec3 vWorldDirection;\n\n #include <common>\n\n void main() {\n\n vec3 direction = normalize( vWorldDirection );\n\n vec2 sampleUV = equirectUv( direction );\n\n gl_FragColor = texture2D( tEquirect, sampleUV );\n\n }\n "
}, r = new vs(5, 5, 5), i = new _l({
name: "CubemapFromEquirect",
uniforms: ll(n.uniforms),
vertexShader: n.vertexShader,
fragmentShader: n.fragmentShader,
side: 1,
blending: 0
});
i.uniforms.tEquirect.value = t;
let a = new La(r, i), o = t.minFilter;
return t.minFilter === 1008 && (t.minFilter = A), new nd(1, 10, this).update(e, a), t.minFilter = o, a.geometry.dispose(), a.material.dispose(), this;
}
clear(e, t = !0, n = !0, r = !0) {
let i = e.getRenderTarget();
for (let i = 0; i < 6; i++) e.setRenderTarget(this, i), e.clear(t, n, r);
e.setRenderTarget(i);
}
};
function Tp(e) {
let t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = null;
function i(e, t = !1) {
return e == null ? null : t ? o(e) : a(e);
}
function a(n) {
if (n && n.isTexture) {
let r = n.mapping;
if (r === 303 || r === 304) if (t.has(n)) {
let e = t.get(n).texture;
return s(e, n.mapping);
} else {
let r = n.image;
if (r && r.height > 0) {
let i = new wp(r.height);
return i.fromEquirectangularTexture(e, n), t.set(n, i), n.addEventListener("dispose", l), s(i.texture, n.mapping);
} else return null;
}
}
return n;
}
function o(t) {
if (t && t.isTexture) {
let i = t.mapping, a = i === 303 || i === 304, o = i === 301 || i === 302;
if (a || o) {
let i = n.get(t), s = i === void 0 ? 0 : i.texture.pmremVersion;
if (t.isRenderTargetTexture && t.pmremVersion !== s) return r === null && (r = new hp(e)), i = a ? r.fromEquirectangular(t, i) : r.fromCubemap(t, i), i.texture.pmremVersion = t.pmremVersion, n.set(t, i), i.texture;
if (i !== void 0) return i.texture;
{
let s = t.image;
return a && s && s.height > 0 || o && s && c(s) ? (r === null && (r = new hp(e)), i = a ? r.fromEquirectangular(t) : r.fromCubemap(t), i.texture.pmremVersion = t.pmremVersion, n.set(t, i), t.addEventListener("dispose", u), i.texture) : null;
}
}
}
return t;
}
function s(e, t) {
return t === 303 ? e.mapping = 301 : t === 304 && (e.mapping = 302), e;
}
function c(e) {
let t = 0;
for (let n = 0; n < 6; n++) e[n] !== void 0 && t++;
return t === 6;
}
function l(e) {
let n = e.target;
n.removeEventListener("dispose", l);
let r = t.get(n);
r !== void 0 && (t.delete(n), r.dispose());
}
function u(e) {
let t = e.target;
t.removeEventListener("dispose", u);
let r = n.get(t);
r !== void 0 && (n.delete(t), r.dispose());
}
function d() {
t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r !== null && (r.dispose(), r = null);
}
return {
get: i,
dispose: d
};
}
function Ep(e) {
let t = {};
function n(n) {
if (t[n] !== void 0) return t[n];
let r = e.getExtension(n);
return t[n] = r, r;
}
return {
has: function(e) {
return n(e) !== 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(e) {
let t = n(e);
return t === null && on("WebGLRenderer: " + e + " extension not supported."), t;
}
};
}
function Dp(e, t, n, r) {
let i = {}, a = /* @__PURE__ */ new WeakMap();
function o(e) {
let s = e.target;
s.index !== null && t.remove(s.index);
for (let e in s.attributes) t.remove(s.attributes[e]);
s.removeEventListener("dispose", o), delete i[s.id];
let c = a.get(s);
c && (t.remove(c), a.delete(s)), r.releaseStatesOfGeometry(s), s.isInstancedBufferGeometry === !0 && delete s._maxInstanceCount, n.memory.geometries--;
}
function s(e, t) {
return i[t.id] === !0 ? t : (t.addEventListener("dispose", o), i[t.id] = !0, n.memory.geometries++, t);
}
function c(n) {
let r = n.attributes;
for (let n in r) t.update(r[n], e.ARRAY_BUFFER);
}
function l(e) {
let n = [], r = e.index, i = e.attributes.position, o = 0;
if (i === void 0) return;
if (r !== null) {
let e = r.array;
o = r.version;
for (let t = 0, r = e.length; t < r; t += 3) {
let r = e[t + 0], i = e[t + 1], a = e[t + 2];
n.push(r, i, i, a, a, r);
}
} else {
let e = i.array;
o = i.version;
for (let t = 0, r = e.length / 3 - 1; t < r; t += 3) {
let e = t + 0, r = t + 1, i = t + 2;
n.push(e, r, r, i, i, e);
}
}
let s = new (i.count >= 65535 ? Pi : Mi)(n, 1);
s.version = o;
let c = a.get(e);
c && t.remove(c), a.set(e, s);
}
function u(e) {
let t = a.get(e);
if (t) {
let n = e.index;
n !== null && t.version < n.version && l(e);
} else l(e);
return a.get(e);
}
return {
get: s,
update: c,
getWireframeAttribute: u
};
}
function Op(e, t, n) {
let r;
function i(e) {
r = e;
}
let a, o;
function s(e) {
a = e.type, o = e.bytesPerElement;
}
function c(t, i) {
e.drawElements(r, i, a, t * o), n.update(i, r, 1);
}
function l(t, i, s) {
s !== 0 && (e.drawElementsInstanced(r, i, a, t * o, s), n.update(i, r, s));
}
function u(e, i, o) {
if (o === 0) return;
t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r, i, 0, a, e, 0, o);
let s = 0;
for (let e = 0; e < o; e++) s += i[e];
n.update(s, r, 1);
}
this.setMode = i, this.setIndex = s, this.render = c, this.renderInstances = l, this.renderMultiDraw = u;
}
function kp(e) {
let t = {
geometries: 0,
textures: 0
}, n = {
frame: 0,
calls: 0,
triangles: 0,
points: 0,
lines: 0
};
function r(t, r, i) {
switch (n.calls++, r) {
case e.TRIANGLES:
n.triangles += t / 3 * i;
break;
case e.LINES:
n.lines += t / 2 * i;
break;
case e.LINE_STRIP:
n.lines += i * (t - 1);
break;
case e.LINE_LOOP:
n.lines += i * t;
break;
case e.POINTS:
n.points += i * t;
break;
default:
R("WebGLInfo: Unknown draw mode:", r);
break;
}
}
function i() {
n.calls = 0, n.triangles = 0, n.points = 0, n.lines = 0;
}
return {
memory: t,
render: n,
programs: null,
autoReset: !0,
reset: i,
update: r
};
}
function Ap(e, t, n) {
let r = /* @__PURE__ */ new WeakMap(), i = new $n();
function a(a, o, s) {
let c = a.morphTargetInfluences, l = o.morphAttributes.position || o.morphAttributes.normal || o.morphAttributes.color, u = l === void 0 ? 0 : l.length, d = r.get(o);
if (d === void 0 || d.count !== u) {
d !== void 0 && d.texture.dispose();
let e = o.morphAttributes.position !== void 0, n = o.morphAttributes.normal !== void 0, a = o.morphAttributes.color !== void 0, s = o.morphAttributes.position || [], c = o.morphAttributes.normal || [], l = o.morphAttributes.color || [], f = 0;
e === !0 && (f = 1), n === !0 && (f = 2), a === !0 && (f = 3);
let p = o.attributes.position.count * f, m = 1;
p > t.maxTextureSize && (m = Math.ceil(p / t.maxTextureSize), p = t.maxTextureSize);
let h = new Float32Array(p * m * 4 * u), g = new nr(h, p, m, u);
g.type = N, g.needsUpdate = !0;
let _ = f * 4;
for (let t = 0; t < u; t++) {
let r = s[t], o = c[t], u = l[t], d = p * m * 4 * t;
for (let t = 0; t < r.count; t++) {
let s = t * _;
e === !0 && (i.fromBufferAttribute(r, t), h[d + s + 0] = i.x, h[d + s + 1] = i.y, h[d + s + 2] = i.z, h[d + s + 3] = 0), n === !0 && (i.fromBufferAttribute(o, t), h[d + s + 4] = i.x, h[d + s + 5] = i.y, h[d + s + 6] = i.z, h[d + s + 7] = 0), a === !0 && (i.fromBufferAttribute(u, t), h[d + s + 8] = i.x, h[d + s + 9] = i.y, h[d + s + 10] = i.z, h[d + s + 11] = u.itemSize === 4 ? i.w : 1);
}
}
d = {
count: u,
texture: g,
size: new V(p, m)
}, r.set(o, d);
function v() {
g.dispose(), r.delete(o), o.removeEventListener("dispose", v);
}
o.addEventListener("dispose", v);
}
if (a.isInstancedMesh === !0 && a.morphTexture !== null) s.getUniforms().setValue(e, "morphTexture", a.morphTexture, n);
else {
let t = 0;
for (let e = 0; e < c.length; e++) t += c[e];
let n = o.morphTargetsRelative ? 1 : 1 - t;
s.getUniforms().setValue(e, "morphTargetBaseInfluence", n), s.getUniforms().setValue(e, "morphTargetInfluences", c);
}
s.getUniforms().setValue(e, "morphTargetsTexture", d.texture, n), s.getUniforms().setValue(e, "morphTargetsTextureSize", d.size);
}
return { update: a };
}
function jp(e, t, n, r, i) {
let a = /* @__PURE__ */ new WeakMap();
function o(r) {
let o = i.render.frame, s = r.geometry, l = t.get(r, s);
if (a.get(l) !== o && (t.update(l), a.set(l, o)), r.isInstancedMesh && (r.hasEventListener("dispose", c) === !1 && r.addEventListener("dispose", c), a.get(r) !== o && (n.update(r.instanceMatrix, e.ARRAY_BUFFER), r.instanceColor !== null && n.update(r.instanceColor, e.ARRAY_BUFFER), a.set(r, o))), r.isSkinnedMesh) {
let e = r.skeleton;
a.get(e) !== o && (e.update(), a.set(e, o));
}
return l;
}
function s() {
a = /* @__PURE__ */ new WeakMap();
}
function c(e) {
let t = e.target;
t.removeEventListener("dispose", c), r.releaseStatesOfObject(t), n.remove(t.instanceMatrix), t.instanceColor !== null && n.remove(t.instanceColor);
}
return {
update: o,
dispose: s
};
}
var Mp = {
1: "LINEAR_TONE_MAPPING",
2: "REINHARD_TONE_MAPPING",
3: "CINEON_TONE_MAPPING",
4: "ACES_FILMIC_TONE_MAPPING",
6: "AGX_TONE_MAPPING",
7: "NEUTRAL_TONE_MAPPING",
5: "CUSTOM_TONE_MAPPING"
};
function Np(e, t, n, r, i, a) {
let o = new tr(t, n, {
type: e,
depthBuffer: i,
stencilBuffer: a,
samples: r ? 4 : 0,
depthTexture: i ? new hs(t, n) : void 0
}), s = new tr(t, n, {
type: ce,
depthBuffer: !1,
stencilBuffer: !1
}), c = new q();
c.setAttribute("position", new K([
-1,
3,
0,
-1,
-1,
0,
3,
-1,
0
], 3)), c.setAttribute("uv", new K([
0,
2,
0,
0,
2,
0
], 2));
let l = new vl({
uniforms: { tDiffuse: { value: null } },
vertexShader: "\n precision highp float;\n\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
fragmentShader: "\n precision highp float;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n #include <tonemapping_pars_fragment>\n #include <colorspace_pars_fragment>\n\n void main() {\n gl_FragColor = texture2D( tDiffuse, vUv );\n\n #ifdef LINEAR_TONE_MAPPING\n gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n #elif defined( REINHARD_TONE_MAPPING )\n gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n #elif defined( CINEON_TONE_MAPPING )\n gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n #elif defined( ACES_FILMIC_TONE_MAPPING )\n gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n #elif defined( AGX_TONE_MAPPING )\n gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n #elif defined( NEUTRAL_TONE_MAPPING )\n gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n #elif defined( CUSTOM_TONE_MAPPING )\n gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n #endif\n\n #ifdef SRGB_TRANSFER\n gl_FragColor = sRGBTransferOETF( gl_FragColor );\n #endif\n }",
depthTest: !1,
depthWrite: !1
}), u = new La(c, l), d = new Ou(-1, 1, 1, -1, 0, 1), f = null, p = null, m = !1, h, g = null, _ = [], v = !1;
this.setSize = function(e, t) {
o.setSize(e, t), s.setSize(e, t);
for (let n = 0; n < _.length; n++) {
let r = _[n];
r.setSize && r.setSize(e, t);
}
}, this.setEffects = function(e) {
_ = e, v = _.length > 0 && _[0].isRenderPass === !0;
let t = o.width, n = o.height;
for (let e = 0; e < _.length; e++) {
let r = _[e];
r.setSize && r.setSize(t, n);
}
}, this.begin = function(e, t) {
if (m || e.toneMapping === 0 && _.length === 0) return !1;
if (g = t, t !== null) {
let e = t.width, n = t.height;
(o.width !== e || o.height !== n) && this.setSize(e, n);
}
return v === !1 && e.setRenderTarget(o), h = e.toneMapping, e.toneMapping = 0, !0;
}, this.hasRenderPass = function() {
return v;
}, this.end = function(e, t) {
e.toneMapping = h, m = !0;
let n = o, r = s;
for (let i = 0; i < _.length; i++) {
let a = _[i];
if (a.enabled !== !1 && (a.render(e, r, n, t), a.needsSwap !== !1)) {
let e = n;
n = r, r = e;
}
}
if (f !== e.outputColorSpace || p !== e.toneMapping) {
f = e.outputColorSpace, p = e.toneMapping, l.defines = {}, Hn.getTransfer(f) === "srgb" && (l.defines.SRGB_TRANSFER = "");
let t = Mp[p];
t && (l.defines[t] = ""), l.needsUpdate = !0;
}
l.uniforms.tDiffuse.value = n.texture, e.setRenderTarget(g), e.render(u, d), g = null, m = !1;
}, this.isCompositing = function() {
return m;
}, this.dispose = function() {
o.depthTexture && o.depthTexture.dispose(), o.dispose(), s.dispose(), c.dispose(), l.dispose();
};
}
var Pp = /*@__PURE__*/ new Qn(), Fp = /*@__PURE__*/ new hs(1, 1), Ip = /*@__PURE__*/ new nr(), Lp = /*@__PURE__*/ new ir(), Rp = /*@__PURE__*/ new fs(), zp = [], Bp = [], Vp = /* @__PURE__ */ new Float32Array(16), Hp = /* @__PURE__ */ new Float32Array(9), Up = /* @__PURE__ */ new Float32Array(4);
function Wp(e, t, n) {
let r = e[0];
if (r <= 0 || r > 0) return e;
let i = t * n, a = zp[i];
if (a === void 0 && (a = new Float32Array(i), zp[i] = a), t !== 0) {
r.toArray(a, 0);
for (let r = 1, i = 0; r !== t; ++r) i += n, e[r].toArray(a, i);
}
return a;
}
function Gp(e, t) {
if (e.length !== t.length) return !1;
for (let n = 0, r = e.length; n < r; n++) if (e[n] !== t[n]) return !1;
return !0;
}
function Kp(e, t) {
for (let n = 0, r = t.length; n < r; n++) e[n] = t[n];
}
function qp(e, t) {
let n = Bp[t];
n === void 0 && (n = new Int32Array(t), Bp[t] = n);
for (let r = 0; r !== t; ++r) n[r] = e.allocateTextureUnit();
return n;
}
function Jp(e, t) {
let n = this.cache;
n[0] !== t && (e.uniform1f(this.addr, t), n[0] = t);
}
function Yp(e, t) {
let n = this.cache;
if (t.x !== void 0) (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 (Gp(n, t)) return;
e.uniform2fv(this.addr, t), Kp(n, t);
}
}
function Xp(e, t) {
let n = this.cache;
if (t.x !== void 0) (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) (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 (Gp(n, t)) return;
e.uniform3fv(this.addr, t), Kp(n, t);
}
}
function Zp(e, t) {
let n = this.cache;
if (t.x !== void 0) (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 (Gp(n, t)) return;
e.uniform4fv(this.addr, t), Kp(n, t);
}
}
function Qp(e, t) {
let n = this.cache, r = t.elements;
if (r === void 0) {
if (Gp(n, t)) return;
e.uniformMatrix2fv(this.addr, !1, t), Kp(n, t);
} else {
if (Gp(n, r)) return;
Up.set(r), e.uniformMatrix2fv(this.addr, !1, Up), Kp(n, r);
}
}
function $p(e, t) {
let n = this.cache, r = t.elements;
if (r === void 0) {
if (Gp(n, t)) return;
e.uniformMatrix3fv(this.addr, !1, t), Kp(n, t);
} else {
if (Gp(n, r)) return;
Hp.set(r), e.uniformMatrix3fv(this.addr, !1, Hp), Kp(n, r);
}
}
function em(e, t) {
let n = this.cache, r = t.elements;
if (r === void 0) {
if (Gp(n, t)) return;
e.uniformMatrix4fv(this.addr, !1, t), Kp(n, t);
} else {
if (Gp(n, r)) return;
Vp.set(r), e.uniformMatrix4fv(this.addr, !1, Vp), Kp(n, r);
}
}
function tm(e, t) {
let n = this.cache;
n[0] !== t && (e.uniform1i(this.addr, t), n[0] = t);
}
function nm(e, t) {
let n = this.cache;
if (t.x !== void 0) (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 (Gp(n, t)) return;
e.uniform2iv(this.addr, t), Kp(n, t);
}
}
function rm(e, t) {
let n = this.cache;
if (t.x !== void 0) (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 (Gp(n, t)) return;
e.uniform3iv(this.addr, t), Kp(n, t);
}
}
function im(e, t) {
let n = this.cache;
if (t.x !== void 0) (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 (Gp(n, t)) return;
e.uniform4iv(this.addr, t), Kp(n, t);
}
}
function am(e, t) {
let n = this.cache;
n[0] !== t && (e.uniform1ui(this.addr, t), n[0] = t);
}
function om(e, t) {
let n = this.cache;
if (t.x !== void 0) (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 (Gp(n, t)) return;
e.uniform2uiv(this.addr, t), Kp(n, t);
}
}
function sm(e, t) {
let n = this.cache;
if (t.x !== void 0) (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 (Gp(n, t)) return;
e.uniform3uiv(this.addr, t), Kp(n, t);
}
}
function cm(e, t) {
let n = this.cache;
if (t.x !== void 0) (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 (Gp(n, t)) return;
e.uniform4uiv(this.addr, t), Kp(n, t);
}
}
function lm(e, t, n) {
let r = this.cache, i = n.allocateTextureUnit();
r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i);
let a;
this.type === e.SAMPLER_2D_SHADOW ? (Fp.compareFunction = n.isReversedDepthBuffer() ? 518 : 515, a = Fp) : a = Pp, n.setTexture2D(t || a, i);
}
function um(e, t, n) {
let r = this.cache, i = n.allocateTextureUnit();
r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTexture3D(t || Lp, i);
}
function dm(e, t, n) {
let r = this.cache, i = n.allocateTextureUnit();
r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTextureCube(t || Rp, i);
}
function fm(e, t, n) {
let r = this.cache, i = n.allocateTextureUnit();
r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTexture2DArray(t || Ip, i);
}
function pm(e) {
switch (e) {
case 5126: return Jp;
case 35664: return Yp;
case 35665: return Xp;
case 35666: return Zp;
case 35674: return Qp;
case 35675: return $p;
case 35676: return em;
case 5124:
case 35670: return tm;
case 35667:
case 35671: return nm;
case 35668:
case 35672: return rm;
case 35669:
case 35673: return im;
case 5125: return am;
case 36294: return om;
case 36295: return sm;
case 36296: return cm;
case 35678:
case 36198:
case 36298:
case 36306:
case 35682: return lm;
case 35679:
case 36299:
case 36307: return um;
case 35680:
case 36300:
case 36308:
case 36293: return dm;
case 36289:
case 36303:
case 36311:
case 36292: return fm;
}
}
function mm(e, t) {
e.uniform1fv(this.addr, t);
}
function hm(e, t) {
let n = Wp(t, this.size, 2);
e.uniform2fv(this.addr, n);
}
function gm(e, t) {
let n = Wp(t, this.size, 3);
e.uniform3fv(this.addr, n);
}
function _m(e, t) {
let n = Wp(t, this.size, 4);
e.uniform4fv(this.addr, n);
}
function vm(e, t) {
let n = Wp(t, this.size, 4);
e.uniformMatrix2fv(this.addr, !1, n);
}
function ym(e, t) {
let n = Wp(t, this.size, 9);
e.uniformMatrix3fv(this.addr, !1, n);
}
function bm(e, t) {
let n = Wp(t, this.size, 16);
e.uniformMatrix4fv(this.addr, !1, n);
}
function xm(e, t) {
e.uniform1iv(this.addr, t);
}
function Sm(e, t) {
e.uniform2iv(this.addr, t);
}
function Cm(e, t) {
e.uniform3iv(this.addr, t);
}
function wm(e, t) {
e.uniform4iv(this.addr, t);
}
function Tm(e, t) {
e.uniform1uiv(this.addr, t);
}
function Em(e, t) {
e.uniform2uiv(this.addr, t);
}
function Dm(e, t) {
e.uniform3uiv(this.addr, t);
}
function Om(e, t) {
e.uniform4uiv(this.addr, t);
}
function km(e, t, n) {
let r = this.cache, i = t.length, a = qp(n, i);
Gp(r, a) || (e.uniform1iv(this.addr, a), Kp(r, a));
let o;
o = this.type === e.SAMPLER_2D_SHADOW ? Fp : Pp;
for (let e = 0; e !== i; ++e) n.setTexture2D(t[e] || o, a[e]);
}
function Am(e, t, n) {
let r = this.cache, i = t.length, a = qp(n, i);
Gp(r, a) || (e.uniform1iv(this.addr, a), Kp(r, a));
for (let e = 0; e !== i; ++e) n.setTexture3D(t[e] || Lp, a[e]);
}
function jm(e, t, n) {
let r = this.cache, i = t.length, a = qp(n, i);
Gp(r, a) || (e.uniform1iv(this.addr, a), Kp(r, a));
for (let e = 0; e !== i; ++e) n.setTextureCube(t[e] || Rp, a[e]);
}
function Mm(e, t, n) {
let r = this.cache, i = t.length, a = qp(n, i);
Gp(r, a) || (e.uniform1iv(this.addr, a), Kp(r, a));
for (let e = 0; e !== i; ++e) n.setTexture2DArray(t[e] || Ip, a[e]);
}
function Nm(e) {
switch (e) {
case 5126: return mm;
case 35664: return hm;
case 35665: return gm;
case 35666: return _m;
case 35674: return vm;
case 35675: return ym;
case 35676: return bm;
case 5124:
case 35670: return xm;
case 35667:
case 35671: return Sm;
case 35668:
case 35672: return Cm;
case 35669:
case 35673: return wm;
case 5125: return Tm;
case 36294: return Em;
case 36295: return Dm;
case 36296: return Om;
case 35678:
case 36198:
case 36298:
case 36306:
case 35682: return km;
case 35679:
case 36299:
case 36307: return Am;
case 35680:
case 36300:
case 36308:
case 36293: return jm;
case 36289:
case 36303:
case 36311:
case 36292: return Mm;
}
}
var Pm = class {
constructor(e, t, n) {
this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.setValue = pm(t.type);
}
}, Fm = class {
constructor(e, t, n) {
this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = Nm(t.type);
}
}, Im = class {
constructor(e) {
this.id = e, this.seq = [], this.map = {};
}
setValue(e, t, n) {
let r = this.seq;
for (let i = 0, a = r.length; i !== a; ++i) {
let a = r[i];
a.setValue(e, t[a.id], n);
}
}
}, Lm = /(\w+)(\])?(\[|\.)?/g;
function Rm(e, t) {
e.seq.push(t), e.map[t.id] = t;
}
function zm(e, t, n) {
let r = e.name, i = r.length;
for (Lm.lastIndex = 0;;) {
let a = Lm.exec(r), o = Lm.lastIndex, s = a[1], c = a[2] === "]", l = a[3];
if (c && (s |= 0), l === void 0 || l === "[" && o + 2 === i) {
Rm(n, l === void 0 ? new Pm(s, e, t) : new Fm(s, e, t));
break;
} else {
let e = n.map[s];
e === void 0 && (e = new Im(s), Rm(n, e)), n = e;
}
}
}
var Bm = class {
constructor(e, t) {
this.seq = [], this.map = {};
let n = e.getProgramParameter(t, e.ACTIVE_UNIFORMS);
for (let r = 0; r < n; ++r) {
let n = e.getActiveUniform(t, r);
zm(n, e.getUniformLocation(t, n.name), this);
}
let r = [], i = [];
for (let t of this.seq) t.type === e.SAMPLER_2D_SHADOW || t.type === e.SAMPLER_CUBE_SHADOW || t.type === e.SAMPLER_2D_ARRAY_SHADOW ? r.push(t) : i.push(t);
r.length > 0 && (this.seq = r.concat(i));
}
setValue(e, t, n, r) {
let i = this.map[t];
i !== void 0 && i.setValue(e, n, r);
}
setOptional(e, t, n) {
let r = t[n];
r !== void 0 && this.setValue(e, n, r);
}
static upload(e, t, n, r) {
for (let i = 0, a = t.length; i !== a; ++i) {
let a = t[i], o = n[a.id];
o.needsUpdate !== !1 && a.setValue(e, o.value, r);
}
}
static seqWithValue(e, t) {
let n = [];
for (let r = 0, i = e.length; r !== i; ++r) {
let i = e[r];
i.id in t && n.push(i);
}
return n;
}
};
function Vm(e, t, n) {
let r = e.createShader(t);
return e.shaderSource(r, n), e.compileShader(r), r;
}
var Hm = 37297, Um = 0;
function Wm(e, t) {
let n = e.split("\n"), r = [], i = Math.max(t - 6, 0), a = Math.min(t + 6, n.length);
for (let e = i; e < a; e++) {
let i = e + 1;
r.push(`${i === t ? ">" : " "} ${i}: ${n[e]}`);
}
return r.join("\n");
}
var Gm = /*@__PURE__*/ new U();
function Km(e) {
Hn._getMatrix(Gm, Hn.workingColorSpace, e);
let t = `mat3( ${Gm.elements.map((e) => e.toFixed(4))} )`;
switch (Hn.getTransfer(e)) {
case St: return [t, "LinearTransferOETF"];
case Ct: return [t, "sRGBTransferOETF"];
default: return L("WebGLProgram: Unsupported color space: ", e), [t, "LinearTransferOETF"];
}
}
function qm(e, t, n) {
let r = e.getShaderParameter(t, e.COMPILE_STATUS), i = (e.getShaderInfoLog(t) || "").trim();
if (r && i === "") return "";
let a = /ERROR: 0:(\d+)/.exec(i);
if (a) {
let r = parseInt(a[1]);
return n.toUpperCase() + "\n\n" + i + "\n\n" + Wm(e.getShaderSource(t), r);
} else return i;
}
function Jm(e, t) {
let n = Km(t);
return [
`vec4 ${e}( vec4 value ) {`,
` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,
"}"
].join("\n");
}
var Ym = {
1: "Linear",
2: "Reinhard",
3: "Cineon",
4: "ACESFilmic",
6: "AgX",
7: "Neutral",
5: "Custom"
};
function Xm(e, t) {
let n = Ym[t];
return n === void 0 ? (L("WebGLProgram: Unsupported toneMapping:", t), "vec3 " + e + "( vec3 color ) { return LinearToneMapping( color ); }") : "vec3 " + e + "( vec3 color ) { return " + n + "ToneMapping( color ); }";
}
var Zm = /*@__PURE__*/ new H();
function Qm() {
return Hn.getLuminanceCoefficients(Zm), [
"float luminance( const in vec3 rgb ) {",
` const vec3 weights = vec3( ${Zm.x.toFixed(4)}, ${Zm.y.toFixed(4)}, ${Zm.z.toFixed(4)} );`,
" return dot( weights, rgb );",
"}"
].join("\n");
}
function $m(e) {
return [e.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "", e.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""].filter(nh).join("\n");
}
function eh(e) {
let t = [];
for (let n in e) {
let r = e[n];
r !== !1 && t.push("#define " + n + " " + r);
}
return t.join("\n");
}
function th(e, t) {
let n = {}, r = e.getProgramParameter(t, e.ACTIVE_ATTRIBUTES);
for (let i = 0; i < r; i++) {
let r = e.getActiveAttrib(t, i), a = r.name, o = 1;
r.type === e.FLOAT_MAT2 && (o = 2), r.type === e.FLOAT_MAT3 && (o = 3), r.type === e.FLOAT_MAT4 && (o = 4), n[a] = {
type: r.type,
location: e.getAttribLocation(t, a),
locationSize: o
};
}
return n;
}
function nh(e) {
return e !== "";
}
function rh(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 ih(e, t) {
return e.replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection);
}
var ah = /^[ \t]*#include +<([\w\d./]+)>/gm;
function oh(e) {
return e.replace(ah, ch);
}
var sh = /* @__PURE__ */ new Map();
function ch(e, t) {
let n = Q[t];
if (n === void 0) {
let e = sh.get(t);
if (e !== void 0) n = Q[e], L("WebGLRenderer: Shader chunk \"%s\" has been deprecated. Use \"%s\" instead.", t, e);
else throw Error("THREE.WebGLProgram: Can not resolve #include <" + t + ">");
}
return oh(n);
}
var lh = /#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 uh(e) {
return e.replace(lh, dh);
}
function dh(e, t, n, r) {
let i = "";
for (let e = parseInt(t); e < parseInt(n); e++) i += r.replace(/\[\s*i\s*\]/g, "[ " + e + " ]").replace(/UNROLLED_LOOP_INDEX/g, e);
return i;
}
function fh(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;
`;
return e.precision === "highp" ? t += "\n#define HIGH_PRECISION" : e.precision === "mediump" ? t += "\n#define MEDIUM_PRECISION" : e.precision === "lowp" && (t += "\n#define LOW_PRECISION"), t;
}
var ph = {
1: "SHADOWMAP_TYPE_PCF",
3: "SHADOWMAP_TYPE_VSM"
};
function mh(e) {
return ph[e.shadowMapType] || "SHADOWMAP_TYPE_BASIC";
}
var hh = {
301: "ENVMAP_TYPE_CUBE",
302: "ENVMAP_TYPE_CUBE",
306: "ENVMAP_TYPE_CUBE_UV"
};
function gh(e) {
return e.envMap === !1 ? "ENVMAP_TYPE_CUBE" : hh[e.envMapMode] || "ENVMAP_TYPE_CUBE";
}
var _h = { 302: "ENVMAP_MODE_REFRACTION" };
function vh(e) {
return e.envMap === !1 ? "ENVMAP_MODE_REFLECTION" : _h[e.envMapMode] || "ENVMAP_MODE_REFLECTION";
}
var yh = {
0: "ENVMAP_BLENDING_MULTIPLY",
1: "ENVMAP_BLENDING_MIX",
2: "ENVMAP_BLENDING_ADD"
};
function bh(e) {
return e.envMap === !1 ? "ENVMAP_BLENDING_NONE" : yh[e.combine] || "ENVMAP_BLENDING_NONE";
}
function xh(e) {
let t = e.envMapCubeUVHeight;
if (t === null) return null;
let n = Math.log2(t) - 2, r = 1 / t;
return {
texelWidth: 1 / (3 * Math.max(2 ** n, 112)),
texelHeight: r,
maxMip: n
};
}
function Sh(e, t, n, r) {
let i = e.getContext(), a = n.defines, o = n.vertexShader, s = n.fragmentShader, c = mh(n), l = gh(n), u = vh(n), d = bh(n), f = xh(n), p = $m(n), m = eh(a), h = i.createProgram(), g, _, v = n.glslVersion ? "#version " + n.glslVersion + "\n" : "";
n.isRawShaderMaterial ? (g = [
"#define SHADER_TYPE " + n.shaderType,
"#define SHADER_NAME " + n.shaderName,
m
].filter(nh).join("\n"), g.length > 0 && (g += "\n"), _ = [
"#define SHADER_TYPE " + n.shaderType,
"#define SHADER_NAME " + n.shaderName,
m
].filter(nh).join("\n"), _.length > 0 && (_ += "\n")) : (g = [
fh(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 " + u : "",
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.vertexNormals ? "#define HAS_NORMAL" : "",
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 " + c : "",
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",
" attribute mat4 instanceMatrix;",
"#endif",
"#ifdef USE_INSTANCING_COLOR",
" attribute vec3 instanceColor;",
"#endif",
"#ifdef USE_INSTANCING_MORPH",
" uniform sampler2D morphTexture;",
"#endif",
"attribute vec3 position;",
"attribute vec3 normal;",
"attribute vec2 uv;",
"#ifdef USE_UV1",
" attribute vec2 uv1;",
"#endif",
"#ifdef USE_UV2",
" attribute vec2 uv2;",
"#endif",
"#ifdef USE_UV3",
" attribute vec2 uv3;",
"#endif",
"#ifdef USE_TANGENT",
" attribute vec4 tangent;",
"#endif",
"#if defined( USE_COLOR_ALPHA )",
" attribute vec4 color;",
"#elif defined( USE_COLOR )",
" attribute vec3 color;",
"#endif",
"#ifdef USE_SKINNING",
" attribute vec4 skinIndex;",
" attribute vec4 skinWeight;",
"#endif",
"\n"
].filter(nh).join("\n"), _ = [
fh(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 " + l : "",
n.envMap ? "#define " + u : "",
n.envMap ? "#define " + d : "",
f ? "#define CUBEUV_TEXEL_WIDTH " + f.texelWidth : "",
f ? "#define CUBEUV_TEXEL_HEIGHT " + f.texelHeight : "",
f ? "#define CUBEUV_MAX_MIP " + f.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.packedNormalMap ? "#define USE_PACKED_NORMALMAP" : "",
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 ? "#define USE_COLOR" : "",
n.vertexAlphas || n.batchingColor ? "#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 " + c : "",
n.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
n.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
n.numLightProbeGrids > 0 ? "#define USE_LIGHT_PROBES_GRID" : "",
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 === 0 ? "" : "#define TONE_MAPPING",
n.toneMapping === 0 ? "" : Q.tonemapping_pars_fragment,
n.toneMapping === 0 ? "" : Xm("toneMapping", n.toneMapping),
n.dithering ? "#define DITHERING" : "",
n.opaque ? "#define OPAQUE" : "",
Q.colorspace_pars_fragment,
Jm("linearToOutputTexel", n.outputColorSpace),
Qm(),
n.useDepthPacking ? "#define DEPTH_PACKING " + n.depthPacking : "",
"\n"
].filter(nh).join("\n")), o = oh(o), o = rh(o, n), o = ih(o, n), s = oh(s), s = rh(s, n), s = ih(s, n), o = uh(o), s = uh(s), n.isRawShaderMaterial !== !0 && (v = "#version 300 es\n", g = [
p,
"#define attribute in",
"#define varying out",
"#define texture2D texture"
].join("\n") + "\n" + g, _ = [
"#define varying in",
n.glslVersion === "300 es" ? "" : "layout(location = 0) out highp vec4 pc_fragColor;",
n.glslVersion === "300 es" ? "" : "#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("\n") + "\n" + _);
let y = v + g + o, b = v + _ + s, x = Vm(i, i.VERTEX_SHADER, y), S = Vm(i, i.FRAGMENT_SHADER, b);
i.attachShader(h, x), i.attachShader(h, S), n.index0AttributeName === void 0 ? n.hasPositionAttribute === !0 && i.bindAttribLocation(h, 0, "position") : i.bindAttribLocation(h, 0, n.index0AttributeName), i.linkProgram(h);
function C(t) {
if (e.debug.checkShaderErrors) {
let n = i.getProgramInfoLog(h) || "", r = i.getShaderInfoLog(x) || "", a = i.getShaderInfoLog(S) || "", o = n.trim(), s = r.trim(), c = a.trim(), l = !0, u = !0;
if (i.getProgramParameter(h, i.LINK_STATUS) === !1) if (l = !1, typeof e.debug.onShaderError == "function") e.debug.onShaderError(i, h, x, S);
else {
let e = qm(i, x, "vertex"), n = qm(i, S, "fragment");
R("WebGLProgram: Shader Error " + i.getError() + " - VALIDATE_STATUS " + i.getProgramParameter(h, i.VALIDATE_STATUS) + "\n\nMaterial Name: " + t.name + "\nMaterial Type: " + t.type + "\n\nProgram Info Log: " + o + "\n" + e + "\n" + n);
}
else o === "" ? (s === "" || c === "") && (u = !1) : L("WebGLProgram: Program Info Log:", o);
u && (t.diagnostics = {
runnable: l,
programLog: o,
vertexShader: {
log: s,
prefix: g
},
fragmentShader: {
log: c,
prefix: _
}
});
}
i.deleteShader(x), i.deleteShader(S), w = new Bm(i, h), T = th(i, h);
}
let w;
this.getUniforms = function() {
return w === void 0 && C(this), w;
};
let T;
this.getAttributes = function() {
return T === void 0 && C(this), T;
};
let E = n.rendererExtensionParallelShaderCompile === !1;
return this.isReady = function() {
return E === !1 && (E = i.getProgramParameter(h, Hm)), E;
}, this.destroy = function() {
r.releaseStatesOfProgram(this), i.deleteProgram(h), this.program = void 0;
}, this.type = n.shaderType, this.name = n.shaderName, this.id = Um++, this.cacheKey = t, this.usedTimes = 1, this.program = h, this.vertexShader = x, this.fragmentShader = S, this;
}
var Ch = 0, wh = class {
constructor() {
this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map();
}
update(e, t, n) {
let r = this._getShaderCacheForMaterial(e);
return r.has(t) === !1 && (r.add(t), t.usedTimes++), r.has(n) === !1 && (r.add(n), n.usedTimes++), this;
}
remove(e) {
let t = this.materialCache.get(e);
for (let e of t) e.usedTimes--, e.usedTimes === 0 && this.shaderCache.delete(e.code);
return this.materialCache.delete(e), this;
}
getVertexShaderStage(e) {
return this._getShaderStage(e.vertexShader);
}
getFragmentShaderStage(e) {
return this._getShaderStage(e.fragmentShader);
}
dispose() {
this.shaderCache.clear(), this.materialCache.clear();
}
_getShaderCacheForMaterial(e) {
let t = this.materialCache, n = t.get(e);
return n === void 0 && (n = /* @__PURE__ */ new Set(), t.set(e, n)), n;
}
_getShaderStage(e) {
let t = this.shaderCache, n = t.get(e);
return n === void 0 && (n = new Th(e), t.set(e, n)), n;
}
}, Th = class {
constructor(e) {
this.id = Ch++, this.code = e, this.usedTimes = 0;
}
};
function Eh(e) {
return e === 1030 || e === 37490 || e === 36285;
}
function Dh(e, t, n, r, i, a) {
let o = new gr(), s = new wh(), c = /* @__PURE__ */ new Set(), l = [], u = /* @__PURE__ */ new Map(), d = r.logarithmicDepthBuffer, f = r.precision, p = {
MeshDepthMaterial: "depth",
MeshDistanceMaterial: "distance",
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 m(e) {
return c.add(e), e === 0 ? "uv" : `uv${e}`;
}
function h(i, o, l, u, h, g) {
let _ = u.fog, v = h.geometry, y = i.isMeshStandardMaterial || i.isMeshLambertMaterial || i.isMeshPhongMaterial ? u.environment : null, b = i.isMeshStandardMaterial || i.isMeshLambertMaterial && !i.envMap || i.isMeshPhongMaterial && !i.envMap, x = t.get(i.envMap || y, b), S = x && x.mapping === 306 ? x.image.height : null, C = p[i.type];
i.precision !== null && (f = r.getMaxPrecision(i.precision), f !== i.precision && L("WebGLProgram.getParameters:", i.precision, "not supported, using", f, "instead."));
let w = v.morphAttributes.position || v.morphAttributes.normal || v.morphAttributes.color, T = w === void 0 ? 0 : w.length, E = 0;
v.morphAttributes.position !== void 0 && (E = 1), v.morphAttributes.normal !== void 0 && (E = 2), v.morphAttributes.color !== void 0 && (E = 3);
let D, O, k, A;
if (C) {
let e = Yf[C];
D = e.vertexShader, O = e.fragmentShader;
} else {
D = i.vertexShader, O = i.fragmentShader;
let e = s.getVertexShaderStage(i), t = s.getFragmentShaderStage(i);
s.update(i, e, t), k = e.id, A = t.id;
}
let ee = e.getRenderTarget(), te = e.state.buffers.depth.getReversed(), ne = h.isInstancedMesh === !0, j = h.isBatchedMesh === !0, M = !!i.map, re = !!i.matcap, ie = !!x, ae = !!i.aoMap, oe = !!i.lightMap, se = !!i.bumpMap && i.wireframe === !1, N = !!i.normalMap, ce = !!i.displacementMap, le = !!i.emissiveMap, ue = !!i.metalnessMap, de = !!i.roughnessMap, fe = i.anisotropy > 0, pe = i.clearcoat > 0, me = i.dispersion > 0, he = i.iridescence > 0, ge = i.sheen > 0, _e = i.transmission > 0, ve = fe && !!i.anisotropyMap, ye = pe && !!i.clearcoatMap, be = pe && !!i.clearcoatNormalMap, xe = pe && !!i.clearcoatRoughnessMap, Se = he && !!i.iridescenceMap, Ce = he && !!i.iridescenceThicknessMap, we = ge && !!i.sheenColorMap, Te = ge && !!i.sheenRoughnessMap, Ee = !!i.specularMap, De = !!i.specularColorMap, Oe = !!i.specularIntensityMap, ke = _e && !!i.transmissionMap, Ae = _e && !!i.thicknessMap, je = !!i.gradientMap, Me = !!i.alphaMap, Ne = i.alphaTest > 0, Pe = !!i.alphaHash, P = !!i.extensions, Fe = 0;
i.toneMapped && (ee === null || ee.isXRRenderTarget === !0) && (Fe = e.toneMapping);
let Ie = {
shaderID: C,
shaderType: i.type,
shaderName: i.name,
vertexShader: D,
fragmentShader: O,
defines: i.defines,
customVertexShaderID: k,
customFragmentShaderID: A,
isRawShaderMaterial: i.isRawShaderMaterial === !0,
glslVersion: i.glslVersion,
precision: f,
batching: j,
batchingColor: j && h._colorsTexture !== null,
instancing: ne,
instancingColor: ne && h.instanceColor !== null,
instancingMorph: ne && h.morphTexture !== null,
outputColorSpace: ee === null ? e.outputColorSpace : ee.isXRRenderTarget === !0 ? ee.texture.colorSpace : Hn.workingColorSpace,
alphaToCoverage: !!i.alphaToCoverage,
map: M,
matcap: re,
envMap: ie,
envMapMode: ie && x.mapping,
envMapCubeUVHeight: S,
aoMap: ae,
lightMap: oe,
bumpMap: se,
normalMap: N,
displacementMap: ce,
emissiveMap: le,
normalMapObjectSpace: N && i.normalMapType === 1,
normalMapTangentSpace: N && i.normalMapType === 0,
packedNormalMap: N && i.normalMapType === 0 && Eh(i.normalMap.format),
metalnessMap: ue,
roughnessMap: de,
anisotropy: fe,
anisotropyMap: ve,
clearcoat: pe,
clearcoatMap: ye,
clearcoatNormalMap: be,
clearcoatRoughnessMap: xe,
dispersion: me,
iridescence: he,
iridescenceMap: Se,
iridescenceThicknessMap: Ce,
sheen: ge,
sheenColorMap: we,
sheenRoughnessMap: Te,
specularMap: Ee,
specularColorMap: De,
specularIntensityMap: Oe,
transmission: _e,
transmissionMap: ke,
thicknessMap: Ae,
gradientMap: je,
opaque: i.transparent === !1 && i.blending === 1 && i.alphaToCoverage === !1,
alphaMap: Me,
alphaTest: Ne,
alphaHash: Pe,
combine: i.combine,
mapUv: M && m(i.map.channel),
aoMapUv: ae && m(i.aoMap.channel),
lightMapUv: oe && m(i.lightMap.channel),
bumpMapUv: se && m(i.bumpMap.channel),
normalMapUv: N && m(i.normalMap.channel),
displacementMapUv: ce && m(i.displacementMap.channel),
emissiveMapUv: le && m(i.emissiveMap.channel),
metalnessMapUv: ue && m(i.metalnessMap.channel),
roughnessMapUv: de && m(i.roughnessMap.channel),
anisotropyMapUv: ve && m(i.anisotropyMap.channel),
clearcoatMapUv: ye && m(i.clearcoatMap.channel),
clearcoatNormalMapUv: be && m(i.clearcoatNormalMap.channel),
clearcoatRoughnessMapUv: xe && m(i.clearcoatRoughnessMap.channel),
iridescenceMapUv: Se && m(i.iridescenceMap.channel),
iridescenceThicknessMapUv: Ce && m(i.iridescenceThicknessMap.channel),
sheenColorMapUv: we && m(i.sheenColorMap.channel),
sheenRoughnessMapUv: Te && m(i.sheenRoughnessMap.channel),
specularMapUv: Ee && m(i.specularMap.channel),
specularColorMapUv: De && m(i.specularColorMap.channel),
specularIntensityMapUv: Oe && m(i.specularIntensityMap.channel),
transmissionMapUv: ke && m(i.transmissionMap.channel),
thicknessMapUv: Ae && m(i.thicknessMap.channel),
alphaMapUv: Me && m(i.alphaMap.channel),
vertexTangents: !!v.attributes.tangent && (N || fe),
vertexNormals: !!v.attributes.normal,
vertexColors: i.vertexColors,
vertexAlphas: i.vertexColors === !0 && !!v.attributes.color && v.attributes.color.itemSize === 4,
pointsUvs: h.isPoints === !0 && !!v.attributes.uv && (M || Me),
fog: !!_,
useFog: i.fog === !0,
fogExp2: !!_ && _.isFogExp2,
flatShading: i.wireframe === !1 && (i.flatShading === !0 || v.attributes.normal === void 0 && N === !1 && (i.isMeshLambertMaterial || i.isMeshPhongMaterial || i.isMeshStandardMaterial || i.isMeshPhysicalMaterial)),
sizeAttenuation: i.sizeAttenuation === !0,
logarithmicDepthBuffer: d,
reversedDepthBuffer: te,
skinning: h.isSkinnedMesh === !0,
hasPositionAttribute: v.attributes.position !== void 0,
morphTargets: v.morphAttributes.position !== void 0,
morphNormals: v.morphAttributes.normal !== void 0,
morphColors: v.morphAttributes.color !== void 0,
morphTargetsCount: T,
morphTextureStride: E,
numDirLights: o.directional.length,
numPointLights: o.point.length,
numSpotLights: o.spot.length,
numSpotLightMaps: o.spotLightMap.length,
numRectAreaLights: o.rectArea.length,
numHemiLights: o.hemi.length,
numDirLightShadows: o.directionalShadowMap.length,
numPointLightShadows: o.pointShadowMap.length,
numSpotLightShadows: o.spotShadowMap.length,
numSpotLightShadowsWithMaps: o.numSpotLightShadowsWithMaps,
numLightProbes: o.numLightProbes,
numLightProbeGrids: g.length,
numClippingPlanes: a.numPlanes,
numClipIntersection: a.numIntersection,
dithering: i.dithering,
shadowMapEnabled: e.shadowMap.enabled && l.length > 0,
shadowMapType: e.shadowMap.type,
toneMapping: Fe,
decodeVideoTexture: M && i.map.isVideoTexture === !0 && Hn.getTransfer(i.map.colorSpace) === "srgb",
decodeVideoTextureEmissive: le && i.emissiveMap.isVideoTexture === !0 && Hn.getTransfer(i.emissiveMap.colorSpace) === "srgb",
premultipliedAlpha: i.premultipliedAlpha,
doubleSided: i.side === 2,
flipSided: i.side === 1,
useDepthPacking: i.depthPacking >= 0,
depthPacking: i.depthPacking || 0,
index0AttributeName: i.index0AttributeName,
extensionClipCullDistance: P && i.extensions.clipCullDistance === !0 && n.has("WEBGL_clip_cull_distance"),
extensionMultiDraw: (P && i.extensions.multiDraw === !0 || j) && n.has("WEBGL_multi_draw"),
rendererExtensionParallelShaderCompile: n.has("KHR_parallel_shader_compile"),
customProgramCacheKey: i.customProgramCacheKey()
};
return Ie.vertexUv1s = c.has(1), Ie.vertexUv2s = c.has(2), Ie.vertexUv3s = c.has(3), c.clear(), Ie;
}
function g(t) {
let n = [];
if (t.shaderID ? n.push(t.shaderID) : (n.push(t.customVertexShaderID), n.push(t.customFragmentShaderID)), t.defines !== void 0) for (let e in t.defines) n.push(e), n.push(t.defines[e]);
return t.isRawShaderMaterial === !1 && (_(n, t), v(n, t), n.push(e.outputColorSpace)), n.push(t.customProgramCacheKey), n.join();
}
function _(e, t) {
e.push(t.precision), e.push(t.outputColorSpace), e.push(t.envMapMode), e.push(t.envMapCubeUVHeight), e.push(t.mapUv), e.push(t.alphaMapUv), e.push(t.lightMapUv), e.push(t.aoMapUv), e.push(t.bumpMapUv), e.push(t.normalMapUv), e.push(t.displacementMapUv), e.push(t.emissiveMapUv), e.push(t.metalnessMapUv), e.push(t.roughnessMapUv), e.push(t.anisotropyMapUv), e.push(t.clearcoatMapUv), e.push(t.clearcoatNormalMapUv), e.push(t.clearcoatRoughnessMapUv), e.push(t.iridescenceMapUv), e.push(t.iridescenceThicknessMapUv), e.push(t.sheenColorMapUv), e.push(t.sheenRoughnessMapUv), e.push(t.specularMapUv), e.push(t.specularColorMapUv), e.push(t.specularIntensityMapUv), e.push(t.transmissionMapUv), e.push(t.thicknessMapUv), e.push(t.combine), e.push(t.fogExp2), e.push(t.sizeAttenuation), e.push(t.morphTargetsCount), e.push(t.morphAttributeCount), e.push(t.numDirLights), e.push(t.numPointLights), e.push(t.numSpotLights), e.push(t.numSpotLightMaps), e.push(t.numHemiLights), e.push(t.numRectAreaLights), e.push(t.numDirLightShadows), e.push(t.numPointLightShadows), e.push(t.numSpotLightShadows), e.push(t.numSpotLightShadowsWithMaps), e.push(t.numLightProbes), e.push(t.shadowMapType), e.push(t.toneMapping), e.push(t.numClippingPlanes), e.push(t.numClipIntersection), e.push(t.depthPacking);
}
function v(e, t) {
o.disableAll(), t.instancing && o.enable(0), t.instancingColor && o.enable(1), t.instancingMorph && o.enable(2), t.matcap && o.enable(3), t.envMap && o.enable(4), t.normalMapObjectSpace && o.enable(5), t.normalMapTangentSpace && o.enable(6), t.clearcoat && o.enable(7), t.iridescence && o.enable(8), t.alphaTest && o.enable(9), t.vertexColors && o.enable(10), t.vertexAlphas && o.enable(11), t.vertexUv1s && o.enable(12), t.vertexUv2s && o.enable(13), t.vertexUv3s && o.enable(14), t.vertexTangents && o.enable(15), t.anisotropy && o.enable(16), t.alphaHash && o.enable(17), t.batching && o.enable(18), t.dispersion && o.enable(19), t.batchingColor && o.enable(20), t.gradientMap && o.enable(21), t.packedNormalMap && o.enable(22), t.vertexNormals && o.enable(23), e.push(o.mask), o.disableAll(), t.fog && o.enable(0), t.useFog && o.enable(1), t.flatShading && o.enable(2), t.logarithmicDepthBuffer && o.enable(3), t.reversedDepthBuffer && o.enable(4), t.skinning && o.enable(5), t.morphTargets && o.enable(6), t.morphNormals && o.enable(7), t.morphColors && o.enable(8), t.premultipliedAlpha && o.enable(9), t.shadowMapEnabled && o.enable(10), t.doubleSided && o.enable(11), t.flipSided && o.enable(12), t.useDepthPacking && o.enable(13), t.dithering && o.enable(14), t.transmission && o.enable(15), t.sheen && o.enable(16), t.opaque && o.enable(17), t.pointsUvs && o.enable(18), t.decodeVideoTexture && o.enable(19), t.decodeVideoTextureEmissive && o.enable(20), t.alphaToCoverage && o.enable(21), t.numLightProbeGrids > 0 && o.enable(22), t.hasPositionAttribute && o.enable(23), e.push(o.mask);
}
function y(e) {
let t = p[e.type], n;
if (t) {
let e = Yf[t];
n = ml.clone(e.uniforms);
} else n = e.uniforms;
return n;
}
function b(t, n) {
let r = u.get(n);
return r === void 0 ? (r = new Sh(e, n, t, i), l.push(r), u.set(n, r)) : ++r.usedTimes, r;
}
function x(e) {
if (--e.usedTimes === 0) {
let t = l.indexOf(e);
l[t] = l[l.length - 1], l.pop(), u.delete(e.cacheKey), e.destroy();
}
}
function S(e) {
s.remove(e);
}
function C() {
s.dispose();
}
return {
getParameters: h,
getProgramCacheKey: g,
getUniforms: y,
acquireProgram: b,
releaseProgram: x,
releaseShaderCache: S,
programs: l,
dispose: C
};
}
function Oh() {
let e = /* @__PURE__ */ new WeakMap();
function t(t) {
return e.has(t);
}
function n(t) {
let n = e.get(t);
return n === void 0 && (n = {}, e.set(t, n)), n;
}
function r(t) {
e.delete(t);
}
function i(t, n, r) {
e.get(t)[n] = r;
}
function a() {
e = /* @__PURE__ */ new WeakMap();
}
return {
has: t,
get: n,
remove: r,
update: i,
dispose: a
};
}
function kh(e, t) {
return e.groupOrder === t.groupOrder ? e.renderOrder === t.renderOrder ? e.material.id === t.material.id ? e.materialVariant === t.materialVariant ? e.z === t.z ? e.id - t.id : e.z - t.z : e.materialVariant - t.materialVariant : e.material.id - t.material.id : e.renderOrder - t.renderOrder : e.groupOrder - t.groupOrder;
}
function Ah(e, t) {
return e.groupOrder === t.groupOrder ? e.renderOrder === t.renderOrder ? e.z === t.z ? e.id - t.id : t.z - e.z : e.renderOrder - t.renderOrder : e.groupOrder - t.groupOrder;
}
function jh() {
let e = [], t = 0, n = [], r = [], i = [];
function a() {
t = 0, n.length = 0, r.length = 0, i.length = 0;
}
function o(e) {
let t = 0;
return e.isInstancedMesh && (t += 2), e.isSkinnedMesh && (t += 1), t;
}
function s(n, r, i, a, s, c) {
let l = e[t];
return l === void 0 ? (l = {
id: n.id,
object: n,
geometry: r,
material: i,
materialVariant: o(n),
groupOrder: a,
renderOrder: n.renderOrder,
z: s,
group: c
}, e[t] = l) : (l.id = n.id, l.object = n, l.geometry = r, l.material = i, l.materialVariant = o(n), l.groupOrder = a, l.renderOrder = n.renderOrder, l.z = s, l.group = c), t++, l;
}
function c(e, t, a, o, c, l) {
let u = s(e, t, a, o, c, l);
a.transmission > 0 ? r.push(u) : a.transparent === !0 ? i.push(u) : n.push(u);
}
function l(e, t, a, o, c, l) {
let u = s(e, t, a, o, c, l);
a.transmission > 0 ? r.unshift(u) : a.transparent === !0 ? i.unshift(u) : n.unshift(u);
}
function u(e, t, a) {
n.length > 1 && n.sort(e || kh), r.length > 1 && r.sort(t || Ah), i.length > 1 && i.sort(t || Ah), a && (n.reverse(), r.reverse(), i.reverse());
}
function d() {
for (let n = t, r = e.length; n < r; n++) {
let t = e[n];
if (t.id === null) break;
t.id = null, t.object = null, t.geometry = null, t.material = null, t.group = null;
}
}
return {
opaque: n,
transmissive: r,
transparent: i,
init: a,
push: c,
unshift: l,
finish: d,
sort: u
};
}
function Mh() {
let e = /* @__PURE__ */ new WeakMap();
function t(t, n) {
let r = e.get(t), i;
return r === void 0 ? (i = new jh(), e.set(t, [i])) : n >= r.length ? (i = new jh(), r.push(i)) : i = r[n], i;
}
function n() {
e = /* @__PURE__ */ new WeakMap();
}
return {
get: t,
dispose: n
};
}
function Nh() {
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 H(),
color: new G()
};
break;
case "SpotLight":
n = {
position: new H(),
direction: new H(),
color: new G(),
distance: 0,
coneCos: 0,
penumbraCos: 0,
decay: 0
};
break;
case "PointLight":
n = {
position: new H(),
color: new G(),
distance: 0,
decay: 0
};
break;
case "HemisphereLight":
n = {
direction: new H(),
skyColor: new G(),
groundColor: new G()
};
break;
case "RectAreaLight":
n = {
color: new G(),
position: new H(),
halfWidth: new H(),
halfHeight: new H()
};
break;
}
return e[t.id] = n, n;
} };
}
function Ph() {
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 V()
};
break;
case "SpotLight":
n = {
shadowIntensity: 1,
shadowBias: 0,
shadowNormalBias: 0,
shadowRadius: 1,
shadowMapSize: new V()
};
break;
case "PointLight":
n = {
shadowIntensity: 1,
shadowBias: 0,
shadowNormalBias: 0,
shadowRadius: 1,
shadowMapSize: new V(),
shadowCameraNear: 1,
shadowCameraFar: 1e3
};
break;
}
return e[t.id] = n, n;
} };
}
var Fh = 0;
function Ih(e, t) {
return (t.castShadow ? 2 : 0) - (e.castShadow ? 2 : 0) + +!!t.map - !!e.map;
}
function Lh(e) {
let t = new Nh(), n = Ph(), r = {
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 e = 0; e < 9; e++) r.probe.push(new H());
let i = new H(), a = new W(), o = new W();
function s(i) {
let a = 0, o = 0, s = 0;
for (let e = 0; e < 9; e++) r.probe[e].set(0, 0, 0);
let c = 0, l = 0, u = 0, d = 0, f = 0, p = 0, m = 0, h = 0, g = 0, _ = 0, v = 0;
i.sort(Ih);
for (let e = 0, y = i.length; e < y; e++) {
let y = i[e], b = y.color, x = y.intensity, S = y.distance, C = null;
if (y.shadow && y.shadow.map && (C = y.shadow.map.texture.format === 1030 ? y.shadow.map.texture : y.shadow.map.depthTexture || y.shadow.map.texture), y.isAmbientLight) a += b.r * x, o += b.g * x, s += b.b * x;
else if (y.isLightProbe) {
for (let e = 0; e < 9; e++) r.probe[e].addScaledVector(y.sh.coefficients[e], x);
v++;
} else if (y.isDirectionalLight) {
let e = t.get(y);
if (e.color.copy(y.color).multiplyScalar(y.intensity), y.castShadow) {
let e = y.shadow, t = n.get(y);
t.shadowIntensity = e.intensity, t.shadowBias = e.bias, t.shadowNormalBias = e.normalBias, t.shadowRadius = e.radius, t.shadowMapSize = e.mapSize, r.directionalShadow[c] = t, r.directionalShadowMap[c] = C, r.directionalShadowMatrix[c] = y.shadow.matrix, p++;
}
r.directional[c] = e, c++;
} else if (y.isSpotLight) {
let e = t.get(y);
e.position.setFromMatrixPosition(y.matrixWorld), e.color.copy(b).multiplyScalar(x), e.distance = S, e.coneCos = Math.cos(y.angle), e.penumbraCos = Math.cos(y.angle * (1 - y.penumbra)), e.decay = y.decay, r.spot[u] = e;
let i = y.shadow;
if (y.map && (r.spotLightMap[g] = y.map, g++, i.updateMatrices(y), y.castShadow && _++), r.spotLightMatrix[u] = i.matrix, y.castShadow) {
let e = n.get(y);
e.shadowIntensity = i.intensity, e.shadowBias = i.bias, e.shadowNormalBias = i.normalBias, e.shadowRadius = i.radius, e.shadowMapSize = i.mapSize, r.spotShadow[u] = e, r.spotShadowMap[u] = C, h++;
}
u++;
} else if (y.isRectAreaLight) {
let e = t.get(y);
e.color.copy(b).multiplyScalar(x), e.halfWidth.set(y.width * .5, 0, 0), e.halfHeight.set(0, y.height * .5, 0), r.rectArea[d] = e, d++;
} else if (y.isPointLight) {
let e = t.get(y);
if (e.color.copy(y.color).multiplyScalar(y.intensity), e.distance = y.distance, e.decay = y.decay, y.castShadow) {
let e = y.shadow, t = n.get(y);
t.shadowIntensity = e.intensity, t.shadowBias = e.bias, t.shadowNormalBias = e.normalBias, t.shadowRadius = e.radius, t.shadowMapSize = e.mapSize, t.shadowCameraNear = e.camera.near, t.shadowCameraFar = e.camera.far, r.pointShadow[l] = t, r.pointShadowMap[l] = C, r.pointShadowMatrix[l] = y.shadow.matrix, m++;
}
r.point[l] = e, l++;
} else if (y.isHemisphereLight) {
let e = t.get(y);
e.skyColor.copy(y.color).multiplyScalar(x), e.groundColor.copy(y.groundColor).multiplyScalar(x), r.hemi[f] = e, f++;
}
}
d > 0 && (e.has("OES_texture_float_linear") === !0 ? (r.rectAreaLTC1 = $.LTC_FLOAT_1, r.rectAreaLTC2 = $.LTC_FLOAT_2) : (r.rectAreaLTC1 = $.LTC_HALF_1, r.rectAreaLTC2 = $.LTC_HALF_2)), r.ambient[0] = a, r.ambient[1] = o, r.ambient[2] = s;
let y = r.hash;
(y.directionalLength !== c || y.pointLength !== l || y.spotLength !== u || y.rectAreaLength !== d || y.hemiLength !== f || y.numDirectionalShadows !== p || y.numPointShadows !== m || y.numSpotShadows !== h || y.numSpotMaps !== g || y.numLightProbes !== v) && (r.directional.length = c, r.spot.length = u, r.rectArea.length = d, r.point.length = l, r.hemi.length = f, r.directionalShadow.length = p, r.directionalShadowMap.length = p, r.pointShadow.length = m, r.pointShadowMap.length = m, r.spotShadow.length = h, r.spotShadowMap.length = h, r.directionalShadowMatrix.length = p, r.pointShadowMatrix.length = m, r.spotLightMatrix.length = h + g - _, r.spotLightMap.length = g, r.numSpotLightShadowsWithMaps = _, r.numLightProbes = v, y.directionalLength = c, y.pointLength = l, y.spotLength = u, y.rectAreaLength = d, y.hemiLength = f, y.numDirectionalShadows = p, y.numPointShadows = m, y.numSpotShadows = h, y.numSpotMaps = g, y.numLightProbes = v, r.version = Fh++);
}
function c(e, t) {
let n = 0, s = 0, c = 0, l = 0, u = 0, d = t.matrixWorldInverse;
for (let t = 0, f = e.length; t < f; t++) {
let f = e[t];
if (f.isDirectionalLight) {
let e = r.directional[n];
e.direction.setFromMatrixPosition(f.matrixWorld), i.setFromMatrixPosition(f.target.matrixWorld), e.direction.sub(i), e.direction.transformDirection(d), n++;
} else if (f.isSpotLight) {
let e = r.spot[c];
e.position.setFromMatrixPosition(f.matrixWorld), e.position.applyMatrix4(d), e.direction.setFromMatrixPosition(f.matrixWorld), i.setFromMatrixPosition(f.target.matrixWorld), e.direction.sub(i), e.direction.transformDirection(d), c++;
} else if (f.isRectAreaLight) {
let e = r.rectArea[l];
e.position.setFromMatrixPosition(f.matrixWorld), e.position.applyMatrix4(d), o.identity(), a.copy(f.matrixWorld), a.premultiply(d), o.extractRotation(a), e.halfWidth.set(f.width * .5, 0, 0), e.halfHeight.set(0, f.height * .5, 0), e.halfWidth.applyMatrix4(o), e.halfHeight.applyMatrix4(o), l++;
} else if (f.isPointLight) {
let e = r.point[s];
e.position.setFromMatrixPosition(f.matrixWorld), e.position.applyMatrix4(d), s++;
} else if (f.isHemisphereLight) {
let e = r.hemi[u];
e.direction.setFromMatrixPosition(f.matrixWorld), e.direction.transformDirection(d), u++;
}
}
}
return {
setup: s,
setupView: c,
state: r
};
}
function Rh(e) {
let t = new Lh(e), n = [], r = [], i = [];
function a(e) {
d.camera = e, n.length = 0, r.length = 0, i.length = 0;
}
function o(e) {
n.push(e);
}
function s(e) {
r.push(e);
}
function c(e) {
i.push(e);
}
function l() {
t.setup(n);
}
function u(e) {
t.setupView(n, e);
}
let d = {
lightsArray: n,
shadowsArray: r,
lightProbeGridArray: i,
camera: null,
lights: t,
transmissionRenderTarget: {},
textureUnits: 0
};
return {
init: a,
state: d,
setupLights: l,
setupLightsView: u,
pushLight: o,
pushShadow: s,
pushLightProbeGrid: c
};
}
function zh(e) {
let t = /* @__PURE__ */ new WeakMap();
function n(n, r = 0) {
let i = t.get(n), a;
return i === void 0 ? (a = new Rh(e), t.set(n, [a])) : r >= i.length ? (a = new Rh(e), i.push(a)) : a = i[r], a;
}
function r() {
t = /* @__PURE__ */ new WeakMap();
}
return {
get: n,
dispose: r
};
}
var Bh = "void main() {\n gl_Position = vec4( position, 1.0 );\n}", Vh = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}", Hh = [
/*@__PURE__*/ new H(1, 0, 0),
/*@__PURE__*/ new H(-1, 0, 0),
/*@__PURE__*/ new H(0, 1, 0),
/*@__PURE__*/ new H(0, -1, 0),
/*@__PURE__*/ new H(0, 0, 1),
/*@__PURE__*/ new H(0, 0, -1)
], Uh = [
/*@__PURE__*/ new H(0, -1, 0),
/*@__PURE__*/ new H(0, -1, 0),
/*@__PURE__*/ new H(0, 0, 1),
/*@__PURE__*/ new H(0, 0, -1),
/*@__PURE__*/ new H(0, -1, 0),
/*@__PURE__*/ new H(0, -1, 0)
], Wh = /*@__PURE__*/ new W(), Gh = /*@__PURE__*/ new H(), Kh = /*@__PURE__*/ new H();
function qh(e, t, n) {
let r = new _o(), i = new V(), a = new V(), o = new $n(), s = new Tl(), c = new El(), l = {}, u = n.maxTextureSize, d = {
0: 1,
1: 0,
2: 2
}, f = new _l({
defines: { VSM_SAMPLES: 8 },
uniforms: {
shadow_pass: { value: null },
resolution: { value: new V() },
radius: { value: 4 }
},
vertexShader: Bh,
fragmentShader: Vh
}), p = f.clone();
p.defines.HORIZONTAL_PASS = 1;
let m = new q();
m.setAttribute("position", new Di(new Float32Array([
-1,
-1,
.5,
3,
-1,
.5,
-1,
3,
.5
]), 3));
let h = new La(m, f), g = this;
this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = 1;
let _ = this.type;
this.render = function(t, n, s) {
if (g.enabled === !1 || g.autoUpdate === !1 && g.needsUpdate === !1 || t.length === 0) return;
this.type === 2 && (L("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."), this.type = 1);
let c = e.getRenderTarget(), l = e.getActiveCubeFace(), d = e.getActiveMipmapLevel(), f = e.state;
f.setBlending(0), f.buffers.depth.getReversed() === !0 ? f.buffers.color.setClear(0, 0, 0, 0) : f.buffers.color.setClear(1, 1, 1, 1), f.buffers.depth.setTest(!0), f.setScissorTest(!1);
let p = _ !== this.type;
p && n.traverse(function(e) {
e.material && (Array.isArray(e.material) ? e.material.forEach((e) => e.needsUpdate = !0) : e.material.needsUpdate = !0);
});
for (let c = 0, l = t.length; c < l; c++) {
let l = t[c], d = l.shadow;
if (d === void 0) {
L("WebGLShadowMap:", l, "has no shadow.");
continue;
}
if (d.autoUpdate === !1 && d.needsUpdate === !1) continue;
i.copy(d.mapSize);
let m = d.getFrameExtents();
i.multiply(m), a.copy(d.mapSize), (i.x > u || i.y > u) && (i.x > u && (a.x = Math.floor(u / m.x), i.x = a.x * m.x, d.mapSize.x = a.x), i.y > u && (a.y = Math.floor(u / m.y), i.y = a.y * m.y, d.mapSize.y = a.y));
let h = e.state.buffers.depth.getReversed();
if (d.camera._reversedDepth = h, d.map === null || p === !0) {
if (d.map !== null && (d.map.depthTexture !== null && (d.map.depthTexture.dispose(), d.map.depthTexture = null), d.map.dispose()), this.type === 3) {
if (l.isPointLight) {
L("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");
continue;
}
d.map = new tr(i.x, i.y, {
format: xe,
type: ce,
minFilter: A,
magFilter: A,
generateMipmaps: !1
}), d.map.texture.name = l.name + ".shadowMap", d.map.depthTexture = new hs(i.x, i.y, N), d.map.depthTexture.name = l.name + ".shadowMapDepth", d.map.depthTexture.format = _e, d.map.depthTexture.compareFunction = null, d.map.depthTexture.minFilter = T, d.map.depthTexture.magFilter = T;
} else l.isPointLight ? (d.map = new wp(i.x), d.map.depthTexture = new gs(i.x, se)) : (d.map = new tr(i.x, i.y), d.map.depthTexture = new hs(i.x, i.y, se)), d.map.depthTexture.name = l.name + ".shadowMap", d.map.depthTexture.format = _e, this.type === 1 ? (d.map.depthTexture.compareFunction = h ? 518 : 515, d.map.depthTexture.minFilter = A, d.map.depthTexture.magFilter = A) : (d.map.depthTexture.compareFunction = null, d.map.depthTexture.minFilter = T, d.map.depthTexture.magFilter = T);
d.camera.updateProjectionMatrix();
}
let g = d.map.isWebGLCubeRenderTarget ? 6 : 1;
for (let t = 0; t < g; t++) {
if (d.map.isWebGLCubeRenderTarget) e.setRenderTarget(d.map, t), e.clear();
else {
t === 0 && (e.setRenderTarget(d.map), e.clear());
let n = d.getViewport(t);
o.set(a.x * n.x, a.y * n.y, a.x * n.z, a.y * n.w), f.viewport(o);
}
if (l.isPointLight) {
let e = d.camera, n = d.matrix, r = l.distance || e.far;
r !== e.far && (e.far = r, e.updateProjectionMatrix()), Gh.setFromMatrixPosition(l.matrixWorld), e.position.copy(Gh), Kh.copy(e.position), Kh.add(Hh[t]), e.up.copy(Uh[t]), e.lookAt(Kh), e.updateMatrixWorld(), n.makeTranslation(-Gh.x, -Gh.y, -Gh.z), Wh.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), d._frustum.setFromProjectionMatrix(Wh, e.coordinateSystem, e.reversedDepth);
} else d.updateMatrices(l);
r = d.getFrustum(), b(n, s, d.camera, l, this.type);
}
d.isPointLightShadow !== !0 && this.type === 3 && v(d, s), d.needsUpdate = !1;
}
_ = this.type, g.needsUpdate = !1, e.setRenderTarget(c, l, d);
};
function v(n, r) {
let a = t.update(h);
f.defines.VSM_SAMPLES !== n.blurSamples && (f.defines.VSM_SAMPLES = n.blurSamples, p.defines.VSM_SAMPLES = n.blurSamples, f.needsUpdate = !0, p.needsUpdate = !0), n.mapPass === null && (n.mapPass = new tr(i.x, i.y, {
format: xe,
type: ce
})), f.uniforms.shadow_pass.value = n.map.depthTexture, f.uniforms.resolution.value = n.mapSize, f.uniforms.radius.value = n.radius, e.setRenderTarget(n.mapPass), e.clear(), e.renderBufferDirect(r, null, a, f, h, null), p.uniforms.shadow_pass.value = n.mapPass.texture, p.uniforms.resolution.value = n.mapSize, p.uniforms.radius.value = n.radius, e.setRenderTarget(n.map), e.clear(), e.renderBufferDirect(r, null, a, p, h, null);
}
function y(t, n, r, i) {
let a = null, o = r.isPointLight === !0 ? t.customDistanceMaterial : t.customDepthMaterial;
if (o !== void 0) a = o;
else if (a = r.isPointLight === !0 ? c : s, e.localClippingEnabled && n.clipShadows === !0 && Array.isArray(n.clippingPlanes) && n.clippingPlanes.length !== 0 || n.displacementMap && n.displacementScale !== 0 || n.alphaMap && n.alphaTest > 0 || n.map && n.alphaTest > 0 || n.alphaToCoverage === !0) {
let e = a.uuid, t = n.uuid, r = l[e];
r === void 0 && (r = {}, l[e] = r);
let i = r[t];
i === void 0 && (i = a.clone(), r[t] = i, n.addEventListener("dispose", x)), a = i;
}
if (a.visible = n.visible, a.wireframe = n.wireframe, i === 3 ? a.side = n.shadowSide === null ? n.side : n.shadowSide : a.side = n.shadowSide === null ? d[n.side] : n.shadowSide, a.alphaMap = n.alphaMap, a.alphaTest = n.alphaToCoverage === !0 ? .5 : n.alphaTest, a.map = n.map, a.clipShadows = n.clipShadows, a.clippingPlanes = n.clippingPlanes, a.clipIntersection = n.clipIntersection, a.displacementMap = n.displacementMap, a.displacementScale = n.displacementScale, a.displacementBias = n.displacementBias, a.wireframeLinewidth = n.wireframeLinewidth, a.linewidth = n.linewidth, r.isPointLight === !0 && a.isMeshDistanceMaterial === !0) {
let t = e.properties.get(a);
t.light = r;
}
return a;
}
function b(n, i, a, o, s) {
if (n.visible === !1) return;
if (n.layers.test(i.layers) && (n.isMesh || n.isLine || n.isPoints) && (n.castShadow || n.receiveShadow && s === 3) && (!n.frustumCulled || r.intersectsObject(n))) {
n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse, n.matrixWorld);
let r = t.update(n), c = n.material;
if (Array.isArray(c)) {
let t = r.groups;
for (let l = 0, u = t.length; l < u; l++) {
let u = t[l], d = c[u.materialIndex];
if (d && d.visible) {
let t = y(n, d, o, s);
n.onBeforeShadow(e, n, i, a, r, t, u), e.renderBufferDirect(a, null, r, t, n, u), n.onAfterShadow(e, n, i, a, r, t, u);
}
}
} else if (c.visible) {
let t = y(n, c, o, s);
n.onBeforeShadow(e, n, i, a, r, t, null), e.renderBufferDirect(a, null, r, t, n, null), n.onAfterShadow(e, n, i, a, r, t, null);
}
}
let c = n.children;
for (let e = 0, t = c.length; e < t; e++) b(c[e], i, a, o, s);
}
function x(e) {
e.target.removeEventListener("dispose", x);
for (let t in l) {
let n = l[t], r = e.target.uuid;
r in n && (n[r].dispose(), delete n[r]);
}
}
}
function Jh(e, t) {
function n() {
let t = !1, n = new $n(), r = null, i = new $n(0, 0, 0, 0);
return {
setMask: function(n) {
r !== n && !t && (e.colorMask(n, n, n, n), r = n);
},
setLocked: function(e) {
t = e;
},
setClear: function(t, r, a, o, s) {
s === !0 && (t *= o, r *= o, a *= o), n.set(t, r, a, o), i.equals(n) === !1 && (e.clearColor(t, r, a, o), i.copy(n));
},
reset: function() {
t = !1, r = null, i.set(-1, 0, 0, 0);
}
};
}
function r() {
let n = !1, r = !1, i = null, a = null, o = null;
return {
setReversed: function(e) {
if (r !== e) {
let n = t.get("EXT_clip_control");
e ? n.clipControlEXT(n.LOWER_LEFT_EXT, n.ZERO_TO_ONE_EXT) : n.clipControlEXT(n.LOWER_LEFT_EXT, n.NEGATIVE_ONE_TO_ONE_EXT), r = e;
let i = o;
o = null, this.setClear(i);
}
},
getReversed: function() {
return r;
},
setTest: function(t) {
t ? ue(e.DEPTH_TEST) : de(e.DEPTH_TEST);
},
setMask: function(t) {
i !== t && !n && (e.depthMask(t), i = t);
},
setFunc: function(t) {
if (r && (t = cn[t]), a !== t) {
switch (t) {
case 0:
e.depthFunc(e.NEVER);
break;
case 1:
e.depthFunc(e.ALWAYS);
break;
case 2:
e.depthFunc(e.LESS);
break;
case 3:
e.depthFunc(e.LEQUAL);
break;
case 4:
e.depthFunc(e.EQUAL);
break;
case 5:
e.depthFunc(e.GEQUAL);
break;
case 6:
e.depthFunc(e.GREATER);
break;
case 7:
e.depthFunc(e.NOTEQUAL);
break;
default: e.depthFunc(e.LEQUAL);
}
a = t;
}
},
setLocked: function(e) {
n = e;
},
setClear: function(t) {
o !== t && (o = t, r && (t = 1 - t), e.clearDepth(t));
},
reset: function() {
n = !1, i = null, a = null, o = null, r = !1;
}
};
}
function i() {
let t = !1, n = null, r = null, i = null, a = null, o = null, s = null, c = null, l = null;
return {
setTest: function(n) {
t || (n ? ue(e.STENCIL_TEST) : de(e.STENCIL_TEST));
},
setMask: function(r) {
n !== r && !t && (e.stencilMask(r), n = r);
},
setFunc: function(t, n, o) {
(r !== t || i !== n || a !== o) && (e.stencilFunc(t, n, o), r = t, i = n, a = o);
},
setOp: function(t, n, r) {
(o !== t || s !== n || c !== r) && (e.stencilOp(t, n, r), o = t, s = n, c = r);
},
setLocked: function(e) {
t = e;
},
setClear: function(t) {
l !== t && (e.clearStencil(t), l = t);
},
reset: function() {
t = !1, n = null, r = null, i = null, a = null, o = null, s = null, c = null, l = null;
}
};
}
let a = new n(), o = new r(), s = new i(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), u = {}, d = {}, f = {}, p = /* @__PURE__ */ new WeakMap(), m = [], h = null, g = !1, _ = null, v = null, y = null, b = null, x = null, S = null, C = null, w = new G(0, 0, 0), T = 0, E = !1, D = null, O = null, k = null, A = null, ee = null, te = e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS), ne = !1, j = 0, M = e.getParameter(e.VERSION);
M.indexOf("WebGL") === -1 ? M.indexOf("OpenGL ES") !== -1 && (j = parseFloat(/^OpenGL ES (\d)/.exec(M)[1]), ne = j >= 2) : (j = parseFloat(/^WebGL (\d)/.exec(M)[1]), ne = j >= 1);
let re = null, ie = {}, ae = e.getParameter(e.SCISSOR_BOX), oe = e.getParameter(e.VIEWPORT), se = new $n().fromArray(ae), N = new $n().fromArray(oe);
function ce(t, n, r, i) {
let a = /* @__PURE__ */ new Uint8Array(4), o = e.createTexture();
e.bindTexture(t, o), e.texParameteri(t, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(t, e.TEXTURE_MAG_FILTER, e.NEAREST);
for (let o = 0; o < r; o++) t === e.TEXTURE_3D || t === e.TEXTURE_2D_ARRAY ? e.texImage3D(n, 0, e.RGBA, 1, 1, i, 0, e.RGBA, e.UNSIGNED_BYTE, a) : e.texImage2D(n + o, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, a);
return o;
}
let le = {};
le[e.TEXTURE_2D] = ce(e.TEXTURE_2D, e.TEXTURE_2D, 1), le[e.TEXTURE_CUBE_MAP] = ce(e.TEXTURE_CUBE_MAP, e.TEXTURE_CUBE_MAP_POSITIVE_X, 6), le[e.TEXTURE_2D_ARRAY] = ce(e.TEXTURE_2D_ARRAY, e.TEXTURE_2D_ARRAY, 1, 1), le[e.TEXTURE_3D] = ce(e.TEXTURE_3D, e.TEXTURE_3D, 1, 1), a.setClear(0, 0, 0, 1), o.setClear(1), s.setClear(0), ue(e.DEPTH_TEST), o.setFunc(3), ye(!1), be(1), ue(e.CULL_FACE), _e(0);
function ue(t) {
u[t] !== !0 && (e.enable(t), u[t] = !0);
}
function de(t) {
u[t] !== !1 && (e.disable(t), u[t] = !1);
}
function fe(t, n) {
return f[t] === n ? !1 : (e.bindFramebuffer(t, n), f[t] = n, t === e.DRAW_FRAMEBUFFER && (f[e.FRAMEBUFFER] = n), t === e.FRAMEBUFFER && (f[e.DRAW_FRAMEBUFFER] = n), !0);
}
function pe(t, n) {
let r = m, i = !1;
if (t) {
r = p.get(n), r === void 0 && (r = [], p.set(n, r));
let a = t.textures;
if (r.length !== a.length || r[0] !== e.COLOR_ATTACHMENT0) {
for (let t = 0, n = a.length; t < n; t++) r[t] = e.COLOR_ATTACHMENT0 + t;
r.length = a.length, i = !0;
}
} else r[0] !== e.BACK && (r[0] = e.BACK, i = !0);
i && e.drawBuffers(r);
}
function me(t) {
return h === t ? !1 : (e.useProgram(t), h = t, !0);
}
let he = {
100: e.FUNC_ADD,
101: e.FUNC_SUBTRACT,
102: e.FUNC_REVERSE_SUBTRACT
};
he[103] = e.MIN, he[104] = e.MAX;
let ge = {
200: e.ZERO,
201: e.ONE,
202: e.SRC_COLOR,
204: e.SRC_ALPHA,
210: e.SRC_ALPHA_SATURATE,
208: e.DST_COLOR,
206: e.DST_ALPHA,
203: e.ONE_MINUS_SRC_COLOR,
205: e.ONE_MINUS_SRC_ALPHA,
209: e.ONE_MINUS_DST_COLOR,
207: e.ONE_MINUS_DST_ALPHA,
211: e.CONSTANT_COLOR,
212: e.ONE_MINUS_CONSTANT_COLOR,
213: e.CONSTANT_ALPHA,
214: e.ONE_MINUS_CONSTANT_ALPHA
};
function _e(t, n, r, i, a, o, s, c, l, u) {
if (t === 0) {
g === !0 && (de(e.BLEND), g = !1);
return;
}
if (g === !1 && (ue(e.BLEND), g = !0), t !== 5) {
if (t !== _ || u !== E) {
if ((v !== 100 || x !== 100) && (e.blendEquation(e.FUNC_ADD), v = 100, x = 100), u) switch (t) {
case 1:
e.blendFuncSeparate(e.ONE, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA);
break;
case 2:
e.blendFunc(e.ONE, e.ONE);
break;
case 3:
e.blendFuncSeparate(e.ZERO, e.ONE_MINUS_SRC_COLOR, e.ZERO, e.ONE);
break;
case 4:
e.blendFuncSeparate(e.DST_COLOR, e.ONE_MINUS_SRC_ALPHA, e.ZERO, e.ONE);
break;
default:
R("WebGLState: Invalid blending: ", t);
break;
}
else switch (t) {
case 1:
e.blendFuncSeparate(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA);
break;
case 2:
e.blendFuncSeparate(e.SRC_ALPHA, e.ONE, e.ONE, e.ONE);
break;
case 3:
R("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");
break;
case 4:
R("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");
break;
default:
R("WebGLState: Invalid blending: ", t);
break;
}
y = null, b = null, S = null, C = null, w.set(0, 0, 0), T = 0, _ = t, E = u;
}
return;
}
a = a || n, o = o || r, s = s || i, (n !== v || a !== x) && (e.blendEquationSeparate(he[n], he[a]), v = n, x = a), (r !== y || i !== b || o !== S || s !== C) && (e.blendFuncSeparate(ge[r], ge[i], ge[o], ge[s]), y = r, b = i, S = o, C = s), (c.equals(w) === !1 || l !== T) && (e.blendColor(c.r, c.g, c.b, l), w.copy(c), T = l), _ = t, E = !1;
}
function ve(t, n) {
t.side === 2 ? de(e.CULL_FACE) : ue(e.CULL_FACE);
let r = t.side === 1;
n && (r = !r), ye(r), t.blending === 1 && t.transparent === !1 ? _e(0) : _e(t.blending, t.blendEquation, t.blendSrc, t.blendDst, t.blendEquationAlpha, t.blendSrcAlpha, t.blendDstAlpha, t.blendColor, t.blendAlpha, t.premultipliedAlpha), o.setFunc(t.depthFunc), o.setTest(t.depthTest), o.setMask(t.depthWrite), a.setMask(t.colorWrite);
let i = t.stencilWrite;
s.setTest(i), i && (s.setMask(t.stencilWriteMask), s.setFunc(t.stencilFunc, t.stencilRef, t.stencilFuncMask), s.setOp(t.stencilFail, t.stencilZFail, t.stencilZPass)), Se(t.polygonOffset, t.polygonOffsetFactor, t.polygonOffsetUnits), t.alphaToCoverage === !0 ? ue(e.SAMPLE_ALPHA_TO_COVERAGE) : de(e.SAMPLE_ALPHA_TO_COVERAGE);
}
function ye(t) {
D !== t && (t ? e.frontFace(e.CW) : e.frontFace(e.CCW), D = t);
}
function be(t) {
t === 0 ? de(e.CULL_FACE) : (ue(e.CULL_FACE), t !== O && (t === 1 ? e.cullFace(e.BACK) : t === 2 ? e.cullFace(e.FRONT) : e.cullFace(e.FRONT_AND_BACK))), O = t;
}
function xe(t) {
t !== k && (ne && e.lineWidth(t), k = t);
}
function Se(t, n, r) {
t ? (ue(e.POLYGON_OFFSET_FILL), (A !== n || ee !== r) && (A = n, ee = r, o.getReversed() && (n = -n), e.polygonOffset(n, r))) : de(e.POLYGON_OFFSET_FILL);
}
function Ce(t) {
t ? ue(e.SCISSOR_TEST) : de(e.SCISSOR_TEST);
}
function we(t) {
t === void 0 && (t = e.TEXTURE0 + te - 1), re !== t && (e.activeTexture(t), re = t);
}
function Te(t, n, r) {
r === void 0 && (r = re === null ? e.TEXTURE0 + te - 1 : re);
let i = ie[r];
i === void 0 && (i = {
type: void 0,
texture: void 0
}, ie[r] = i), (i.type !== t || i.texture !== n) && (re !== r && (e.activeTexture(r), re = r), e.bindTexture(t, n || le[t]), i.type = t, i.texture = n);
}
function Ee() {
let t = ie[re];
t !== void 0 && t.type !== void 0 && (e.bindTexture(t.type, null), t.type = void 0, t.texture = void 0);
}
function De() {
try {
e.compressedTexImage2D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function Oe() {
try {
e.compressedTexImage3D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function ke() {
try {
e.texSubImage2D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function Ae() {
try {
e.texSubImage3D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function je() {
try {
e.compressedTexSubImage2D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function Me() {
try {
e.compressedTexSubImage3D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function Ne() {
try {
e.texStorage2D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function Pe() {
try {
e.texStorage3D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function P() {
try {
e.texImage2D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function Fe() {
try {
e.texImage3D(...arguments);
} catch (e) {
R("WebGLState:", e);
}
}
function Ie(t) {
return d[t] === void 0 ? e.getParameter(t) : d[t];
}
function Le(t, n) {
d[t] !== n && (e.pixelStorei(t, n), d[t] = n);
}
function F(t) {
se.equals(t) === !1 && (e.scissor(t.x, t.y, t.z, t.w), se.copy(t));
}
function Re(t) {
N.equals(t) === !1 && (e.viewport(t.x, t.y, t.z, t.w), N.copy(t));
}
function I(t, n) {
let r = l.get(n);
r === void 0 && (r = /* @__PURE__ */ new WeakMap(), l.set(n, r));
let i = r.get(t);
i === void 0 && (i = e.getUniformBlockIndex(n, t.name), r.set(t, i));
}
function ze(t, n) {
let r = l.get(n).get(t);
c.get(n) !== r && (e.uniformBlockBinding(n, r, t.__bindingPointIndex), c.set(n, r));
}
function Be() {
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), e.pixelStorei(e.PACK_ALIGNMENT, 4), e.pixelStorei(e.UNPACK_ALIGNMENT, 4), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, e.BROWSER_DEFAULT_WEBGL), e.pixelStorei(e.PACK_ROW_LENGTH, 0), e.pixelStorei(e.PACK_SKIP_PIXELS, 0), e.pixelStorei(e.PACK_SKIP_ROWS, 0), e.pixelStorei(e.UNPACK_ROW_LENGTH, 0), e.pixelStorei(e.UNPACK_IMAGE_HEIGHT, 0), e.pixelStorei(e.UNPACK_SKIP_PIXELS, 0), e.pixelStorei(e.UNPACK_SKIP_ROWS, 0), e.pixelStorei(e.UNPACK_SKIP_IMAGES, 0), u = {}, d = {}, re = null, ie = {}, f = {}, p = /* @__PURE__ */ new WeakMap(), m = [], h = null, g = !1, _ = null, v = null, y = null, b = null, x = null, S = null, C = null, w = new G(0, 0, 0), T = 0, E = !1, D = null, O = null, k = null, A = null, ee = null, se.set(0, 0, e.canvas.width, e.canvas.height), N.set(0, 0, e.canvas.width, e.canvas.height), a.reset(), o.reset(), s.reset();
}
return {
buffers: {
color: a,
depth: o,
stencil: s
},
enable: ue,
disable: de,
bindFramebuffer: fe,
drawBuffers: pe,
useProgram: me,
setBlending: _e,
setMaterial: ve,
setFlipSided: ye,
setCullFace: be,
setLineWidth: xe,
setPolygonOffset: Se,
setScissorTest: Ce,
activeTexture: we,
bindTexture: Te,
unbindTexture: Ee,
compressedTexImage2D: De,
compressedTexImage3D: Oe,
texImage2D: P,
texImage3D: Fe,
pixelStorei: Le,
getParameter: Ie,
updateUBOMapping: I,
uniformBlockBinding: ze,
texStorage2D: Ne,
texStorage3D: Pe,
texSubImage2D: ke,
texSubImage3D: Ae,
compressedTexSubImage2D: je,
compressedTexSubImage3D: Me,
scissor: F,
viewport: Re,
reset: Be
};
}
function Yh(e, t, n, r, i, a, o) {
let s = t.has("WEBGL_multisampled_render_to_texture") ? t.get("WEBGL_multisampled_render_to_texture") : null, c = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), l = new V(), u = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new Set(), f, p = /* @__PURE__ */ new WeakMap(), m = !1;
try {
m = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
} catch {}
function h(e, t) {
return m ? new OffscreenCanvas(e, t) : Zt("canvas");
}
function g(e, t, n) {
let r = 1, i = Ie(e);
if ((i.width > n || i.height > n) && (r = n / Math.max(i.width, i.height)), r < 1) if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap || typeof VideoFrame < "u" && e instanceof VideoFrame) {
let n = Math.floor(r * i.width), a = Math.floor(r * i.height);
f === void 0 && (f = h(n, a));
let o = t ? h(n, a) : f;
return o.width = n, o.height = a, o.getContext("2d").drawImage(e, 0, 0, n, a), L("WebGLRenderer: Texture has been resized from (" + i.width + "x" + i.height + ") to (" + n + "x" + a + ")."), o;
} else return "data" in e && L("WebGLRenderer: Image in DataTexture is too big (" + i.width + "x" + i.height + ")."), e;
return e;
}
function _(e) {
return e.generateMipmaps;
}
function v(t) {
e.generateMipmap(t);
}
function y(t) {
return t.isWebGLCubeRenderTarget ? e.TEXTURE_CUBE_MAP : t.isWebGL3DRenderTarget ? e.TEXTURE_3D : t.isWebGLArrayRenderTarget || t.isCompressedArrayTexture ? e.TEXTURE_2D_ARRAY : e.TEXTURE_2D;
}
function b(n, r, i, a, o, s = !1) {
if (n !== null) {
if (e[n] !== void 0) return e[n];
L("WebGLRenderer: Attempt to use non-existing WebGL internal format '" + n + "'");
}
let c;
a && (c = t.get("EXT_texture_norm16"), c || L("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));
let l = r;
if (r === e.RED && (i === e.FLOAT && (l = e.R32F), i === e.HALF_FLOAT && (l = e.R16F), i === e.UNSIGNED_BYTE && (l = e.R8), i === e.UNSIGNED_SHORT && c && (l = c.R16_EXT), i === e.SHORT && c && (l = c.R16_SNORM_EXT)), r === e.RED_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.R8UI), i === e.UNSIGNED_SHORT && (l = e.R16UI), i === e.UNSIGNED_INT && (l = e.R32UI), i === e.BYTE && (l = e.R8I), i === e.SHORT && (l = e.R16I), i === e.INT && (l = e.R32I)), r === e.RG && (i === e.FLOAT && (l = e.RG32F), i === e.HALF_FLOAT && (l = e.RG16F), i === e.UNSIGNED_BYTE && (l = e.RG8), i === e.UNSIGNED_SHORT && c && (l = c.RG16_EXT), i === e.SHORT && c && (l = c.RG16_SNORM_EXT)), r === e.RG_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.RG8UI), i === e.UNSIGNED_SHORT && (l = e.RG16UI), i === e.UNSIGNED_INT && (l = e.RG32UI), i === e.BYTE && (l = e.RG8I), i === e.SHORT && (l = e.RG16I), i === e.INT && (l = e.RG32I)), r === e.RGB_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.RGB8UI), i === e.UNSIGNED_SHORT && (l = e.RGB16UI), i === e.UNSIGNED_INT && (l = e.RGB32UI), i === e.BYTE && (l = e.RGB8I), i === e.SHORT && (l = e.RGB16I), i === e.INT && (l = e.RGB32I)), r === e.RGBA_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.RGBA8UI), i === e.UNSIGNED_SHORT && (l = e.RGBA16UI), i === e.UNSIGNED_INT && (l = e.RGBA32UI), i === e.BYTE && (l = e.RGBA8I), i === e.SHORT && (l = e.RGBA16I), i === e.INT && (l = e.RGBA32I)), r === e.RGB && (i === e.UNSIGNED_SHORT && c && (l = c.RGB16_EXT), i === e.SHORT && c && (l = c.RGB16_SNORM_EXT), i === e.UNSIGNED_INT_5_9_9_9_REV && (l = e.RGB9_E5), i === e.UNSIGNED_INT_10F_11F_11F_REV && (l = e.R11F_G11F_B10F)), r === e.RGBA) {
let t = s ? St : Hn.getTransfer(o);
i === e.FLOAT && (l = e.RGBA32F), i === e.HALF_FLOAT && (l = e.RGBA16F), i === e.UNSIGNED_BYTE && (l = t === "srgb" ? e.SRGB8_ALPHA8 : e.RGBA8), i === e.UNSIGNED_SHORT && c && (l = c.RGBA16_EXT), i === e.SHORT && c && (l = c.RGBA16_SNORM_EXT), i === e.UNSIGNED_SHORT_4_4_4_4 && (l = e.RGBA4), i === e.UNSIGNED_SHORT_5_5_5_1 && (l = e.RGB5_A1);
}
return (l === e.R16F || l === e.R32F || l === e.RG16F || l === e.RG32F || l === e.RGBA16F || l === e.RGBA32F) && t.get("EXT_color_buffer_float"), l;
}
function x(t, n) {
let r;
return t ? n === null || n === 1014 || n === 1020 ? r = e.DEPTH24_STENCIL8 : n === 1015 ? r = e.DEPTH32F_STENCIL8 : n === 1012 && (r = e.DEPTH24_STENCIL8, L("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")) : n === null || n === 1014 || n === 1020 ? r = e.DEPTH_COMPONENT24 : n === 1015 ? r = e.DEPTH_COMPONENT32F : n === 1012 && (r = e.DEPTH_COMPONENT16), r;
}
function D(e, t) {
return _(e) === !0 || e.isFramebufferTexture && e.minFilter !== 1003 && e.minFilter !== 1006 ? Math.log2(Math.max(t.width, t.height)) + 1 : e.mipmaps !== void 0 && e.mipmaps.length > 0 ? e.mipmaps.length : e.isCompressedTexture && Array.isArray(e.image) ? t.mipmaps.length : 1;
}
function k(e) {
let t = e.target;
t.removeEventListener("dispose", k), j(t), t.isVideoTexture && u.delete(t), t.isHTMLTexture && d.delete(t);
}
function te(e) {
let t = e.target;
t.removeEventListener("dispose", te), re(t);
}
function j(e) {
let t = r.get(e);
if (t.__webglInit === void 0) return;
let n = e.source, i = p.get(n);
if (i) {
let r = i[t.__cacheKey];
r.usedTimes--, r.usedTimes === 0 && M(e), Object.keys(i).length === 0 && p.delete(n);
}
r.remove(e);
}
function M(t) {
let n = r.get(t);
e.deleteTexture(n.__webglTexture);
let i = t.source, a = p.get(i);
delete a[n.__cacheKey], o.memory.textures--;
}
function re(t) {
let n = r.get(t);
if (t.depthTexture && (t.depthTexture.dispose(), r.remove(t.depthTexture)), t.isWebGLCubeRenderTarget) for (let t = 0; t < 6; t++) {
if (Array.isArray(n.__webglFramebuffer[t])) for (let r = 0; r < n.__webglFramebuffer[t].length; r++) e.deleteFramebuffer(n.__webglFramebuffer[t][r]);
else e.deleteFramebuffer(n.__webglFramebuffer[t]);
n.__webglDepthbuffer && e.deleteRenderbuffer(n.__webglDepthbuffer[t]);
}
else {
if (Array.isArray(n.__webglFramebuffer)) for (let t = 0; t < n.__webglFramebuffer.length; t++) e.deleteFramebuffer(n.__webglFramebuffer[t]);
else e.deleteFramebuffer(n.__webglFramebuffer);
if (n.__webglDepthbuffer && e.deleteRenderbuffer(n.__webglDepthbuffer), n.__webglMultisampledFramebuffer && e.deleteFramebuffer(n.__webglMultisampledFramebuffer), n.__webglColorRenderbuffer) for (let t = 0; t < n.__webglColorRenderbuffer.length; t++) n.__webglColorRenderbuffer[t] && e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);
n.__webglDepthRenderbuffer && e.deleteRenderbuffer(n.__webglDepthRenderbuffer);
}
let i = t.textures;
for (let t = 0, n = i.length; t < n; t++) {
let n = r.get(i[t]);
n.__webglTexture && (e.deleteTexture(n.__webglTexture), o.memory.textures--), r.remove(i[t]);
}
r.remove(t);
}
let ie = 0;
function ae() {
ie = 0;
}
function oe() {
return ie;
}
function se(e) {
ie = e;
}
function N() {
let e = ie;
return e >= i.maxTextures && L("WebGLTextures: Trying to use " + e + " texture units while this GPU supports only " + i.maxTextures), ie += 1, e;
}
function ce(e) {
let t = [];
return t.push(e.wrapS), t.push(e.wrapT), t.push(e.wrapR || 0), t.push(e.magFilter), t.push(e.minFilter), t.push(e.anisotropy), t.push(e.internalFormat), t.push(e.format), t.push(e.type), t.push(e.generateMipmaps), t.push(e.premultiplyAlpha), t.push(e.flipY), t.push(e.unpackAlignment), t.push(e.colorSpace), t.join();
}
function le(t, i) {
let a = r.get(t);
if (t.isVideoTexture && P(t), t.isRenderTargetTexture === !1 && t.isExternalTexture !== !0 && t.version > 0 && a.__version !== t.version) {
let e = t.image;
if (e === null) L("WebGLRenderer: Texture marked for update but no image data found.");
else if (e.complete === !1) L("WebGLRenderer: Texture marked for update but image is incomplete");
else {
xe(a, t, i);
return;
}
} else t.isExternalTexture && (a.__webglTexture = t.sourceTexture ? t.sourceTexture : null);
n.bindTexture(e.TEXTURE_2D, a.__webglTexture, e.TEXTURE0 + i);
}
function ue(t, i) {
let a = r.get(t);
if (t.isRenderTargetTexture === !1 && t.version > 0 && a.__version !== t.version) {
xe(a, t, i);
return;
} else t.isExternalTexture && (a.__webglTexture = t.sourceTexture ? t.sourceTexture : null);
n.bindTexture(e.TEXTURE_2D_ARRAY, a.__webglTexture, e.TEXTURE0 + i);
}
function de(t, i) {
let a = r.get(t);
if (t.isRenderTargetTexture === !1 && t.version > 0 && a.__version !== t.version) {
xe(a, t, i);
return;
}
n.bindTexture(e.TEXTURE_3D, a.__webglTexture, e.TEXTURE0 + i);
}
function fe(t, i) {
let a = r.get(t);
if (t.isCubeDepthTexture !== !0 && t.version > 0 && a.__version !== t.version) {
Se(a, t, i);
return;
}
n.bindTexture(e.TEXTURE_CUBE_MAP, a.__webglTexture, e.TEXTURE0 + i);
}
let pe = {
[S]: e.REPEAT,
[C]: e.CLAMP_TO_EDGE,
[w]: e.MIRRORED_REPEAT
}, me = {
[T]: e.NEAREST,
[E]: e.NEAREST_MIPMAP_NEAREST,
[O]: e.NEAREST_MIPMAP_LINEAR,
[A]: e.LINEAR,
[ee]: e.LINEAR_MIPMAP_NEAREST,
[ne]: e.LINEAR_MIPMAP_LINEAR
}, he = {
512: e.NEVER,
519: e.ALWAYS,
513: e.LESS,
515: e.LEQUAL,
514: e.EQUAL,
518: e.GEQUAL,
516: e.GREATER,
517: e.NOTEQUAL
};
function ge(n, a) {
if (a.type === 1015 && t.has("OES_texture_float_linear") === !1 && (a.magFilter === 1006 || a.magFilter === 1007 || a.magFilter === 1005 || a.magFilter === 1008 || a.minFilter === 1006 || a.minFilter === 1007 || a.minFilter === 1005 || a.minFilter === 1008) && L("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), e.texParameteri(n, e.TEXTURE_WRAP_S, pe[a.wrapS]), e.texParameteri(n, e.TEXTURE_WRAP_T, pe[a.wrapT]), (n === e.TEXTURE_3D || n === e.TEXTURE_2D_ARRAY) && e.texParameteri(n, e.TEXTURE_WRAP_R, pe[a.wrapR]), e.texParameteri(n, e.TEXTURE_MAG_FILTER, me[a.magFilter]), e.texParameteri(n, e.TEXTURE_MIN_FILTER, me[a.minFilter]), a.compareFunction && (e.texParameteri(n, e.TEXTURE_COMPARE_MODE, e.COMPARE_REF_TO_TEXTURE), e.texParameteri(n, e.TEXTURE_COMPARE_FUNC, he[a.compareFunction])), t.has("EXT_texture_filter_anisotropic") === !0) {
if (a.magFilter === 1003 || a.minFilter !== 1005 && a.minFilter !== 1008 || a.type === 1015 && t.has("OES_texture_float_linear") === !1) return;
if (a.anisotropy > 1 || r.get(a).__currentAnisotropy) {
let o = t.get("EXT_texture_filter_anisotropic");
e.texParameterf(n, o.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(a.anisotropy, i.getMaxAnisotropy())), r.get(a).__currentAnisotropy = a.anisotropy;
}
}
}
function _e(t, n) {
let r = !1;
t.__webglInit === void 0 && (t.__webglInit = !0, n.addEventListener("dispose", k));
let i = n.source, a = p.get(i);
a === void 0 && (a = {}, p.set(i, a));
let s = ce(n);
if (s !== t.__cacheKey) {
a[s] === void 0 && (a[s] = {
texture: e.createTexture(),
usedTimes: 0
}, o.memory.textures++, r = !0), a[s].usedTimes++;
let i = a[t.__cacheKey];
i !== void 0 && (a[t.__cacheKey].usedTimes--, i.usedTimes === 0 && M(n)), t.__cacheKey = s, t.__webglTexture = a[s].texture;
}
return r;
}
function ye(e, t, n) {
return Math.floor(Math.floor(e / n) / t);
}
function be(t, r, i, a) {
let o = t.updateRanges;
if (o.length === 0) n.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, r.width, r.height, i, a, r.data);
else {
o.sort((e, t) => e.start - t.start);
let s = 0;
for (let e = 1; e < o.length; e++) {
let t = o[s], n = o[e], i = t.start + t.count, a = ye(n.start, r.width, 4), c = ye(t.start, r.width, 4);
n.start <= i + 1 && a === c && ye(n.start + n.count - 1, r.width, 4) === a ? t.count = Math.max(t.count, n.start + n.count - t.start) : (++s, o[s] = n);
}
o.length = s + 1;
let c = n.getParameter(e.UNPACK_ROW_LENGTH), l = n.getParameter(e.UNPACK_SKIP_PIXELS), u = n.getParameter(e.UNPACK_SKIP_ROWS);
n.pixelStorei(e.UNPACK_ROW_LENGTH, r.width);
for (let t = 0, s = o.length; t < s; t++) {
let s = o[t], c = Math.floor(s.start / 4), l = Math.ceil(s.count / 4), u = c % r.width, d = Math.floor(c / r.width), f = l;
n.pixelStorei(e.UNPACK_SKIP_PIXELS, u), n.pixelStorei(e.UNPACK_SKIP_ROWS, d), n.texSubImage2D(e.TEXTURE_2D, 0, u, d, f, 1, i, a, r.data);
}
t.clearUpdateRanges(), n.pixelStorei(e.UNPACK_ROW_LENGTH, c), n.pixelStorei(e.UNPACK_SKIP_PIXELS, l), n.pixelStorei(e.UNPACK_SKIP_ROWS, u);
}
}
function xe(t, o, s) {
let c = e.TEXTURE_2D;
(o.isDataArrayTexture || o.isCompressedArrayTexture) && (c = e.TEXTURE_2D_ARRAY), o.isData3DTexture && (c = e.TEXTURE_3D);
let l = _e(t, o), u = o.source;
n.bindTexture(c, t.__webglTexture, e.TEXTURE0 + s);
let f = r.get(u);
if (u.version !== f.__version || l === !0) {
if (n.activeTexture(e.TEXTURE0 + s), !(typeof ImageBitmap < "u" && o.image instanceof ImageBitmap)) {
let t = Hn.getPrimaries(Hn.workingColorSpace), r = o.colorSpace === "" ? null : Hn.getPrimaries(o.colorSpace), i = o.colorSpace === "" || t === r ? e.NONE : e.BROWSER_DEFAULT_WEBGL;
n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, o.flipY), n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o.premultiplyAlpha), n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, i);
}
n.pixelStorei(e.UNPACK_ALIGNMENT, o.unpackAlignment);
let t = g(o.image, !1, i.maxTextureSize);
t = Fe(o, t);
let r = a.convert(o.format, o.colorSpace), p = a.convert(o.type), m = b(o.internalFormat, r, p, o.normalized, o.colorSpace, o.isVideoTexture);
ge(c, o);
let h, y = o.mipmaps, S = o.isVideoTexture !== !0, C = f.__version === void 0 || l === !0, w = u.dataReady, T = D(o, t);
if (o.isDepthTexture) m = x(o.format === ve, o.type), C && (S ? n.texStorage2D(e.TEXTURE_2D, 1, m, t.width, t.height) : n.texImage2D(e.TEXTURE_2D, 0, m, t.width, t.height, 0, r, p, null));
else if (o.isDataTexture) if (y.length > 0) {
S && C && n.texStorage2D(e.TEXTURE_2D, T, m, y[0].width, y[0].height);
for (let t = 0, i = y.length; t < i; t++) h = y[t], S ? w && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, h.width, h.height, r, p, h.data) : n.texImage2D(e.TEXTURE_2D, t, m, h.width, h.height, 0, r, p, h.data);
o.generateMipmaps = !1;
} else S ? (C && n.texStorage2D(e.TEXTURE_2D, T, m, t.width, t.height), w && be(o, t, r, p)) : n.texImage2D(e.TEXTURE_2D, 0, m, t.width, t.height, 0, r, p, t.data);
else if (o.isCompressedTexture) if (o.isCompressedArrayTexture) {
S && C && n.texStorage3D(e.TEXTURE_2D_ARRAY, T, m, y[0].width, y[0].height, t.depth);
for (let i = 0, a = y.length; i < a; i++) if (h = y[i], o.format !== 1023) if (r !== null) if (S) {
if (w) if (o.layerUpdates.size > 0) {
let t = Uf(h.width, h.height, o.format, o.type);
for (let a of o.layerUpdates) {
let o = h.data.subarray(a * t / h.data.BYTES_PER_ELEMENT, (a + 1) * t / h.data.BYTES_PER_ELEMENT);
n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY, i, 0, 0, a, h.width, h.height, 1, r, o);
}
o.clearLayerUpdates();
} else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY, i, 0, 0, 0, h.width, h.height, t.depth, r, h.data);
} else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY, i, m, h.width, h.height, t.depth, 0, h.data, 0, 0);
else L("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");
else S ? w && n.texSubImage3D(e.TEXTURE_2D_ARRAY, i, 0, 0, 0, h.width, h.height, t.depth, r, p, h.data) : n.texImage3D(e.TEXTURE_2D_ARRAY, i, m, h.width, h.height, t.depth, 0, r, p, h.data);
} else {
S && C && n.texStorage2D(e.TEXTURE_2D, T, m, y[0].width, y[0].height);
for (let t = 0, i = y.length; t < i; t++) h = y[t], o.format === 1023 ? S ? w && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, h.width, h.height, r, p, h.data) : n.texImage2D(e.TEXTURE_2D, t, m, h.width, h.height, 0, r, p, h.data) : r === null ? L("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : S ? w && n.compressedTexSubImage2D(e.TEXTURE_2D, t, 0, 0, h.width, h.height, r, h.data) : n.compressedTexImage2D(e.TEXTURE_2D, t, m, h.width, h.height, 0, h.data);
}
else if (o.isDataArrayTexture) if (S) {
if (C && n.texStorage3D(e.TEXTURE_2D_ARRAY, T, m, t.width, t.height, t.depth), w) if (o.layerUpdates.size > 0) {
let i = Uf(t.width, t.height, o.format, o.type);
for (let a of o.layerUpdates) {
let o = t.data.subarray(a * i / t.data.BYTES_PER_ELEMENT, (a + 1) * i / t.data.BYTES_PER_ELEMENT);
n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, a, t.width, t.height, 1, r, p, o);
}
o.clearLayerUpdates();
} else n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, 0, t.width, t.height, t.depth, r, p, t.data);
} else n.texImage3D(e.TEXTURE_2D_ARRAY, 0, m, t.width, t.height, t.depth, 0, r, p, t.data);
else if (o.isData3DTexture) S ? (C && n.texStorage3D(e.TEXTURE_3D, T, m, t.width, t.height, t.depth), w && n.texSubImage3D(e.TEXTURE_3D, 0, 0, 0, 0, t.width, t.height, t.depth, r, p, t.data)) : n.texImage3D(e.TEXTURE_3D, 0, m, t.width, t.height, t.depth, 0, r, p, t.data);
else if (o.isFramebufferTexture) {
if (C) if (S) n.texStorage2D(e.TEXTURE_2D, T, m, t.width, t.height);
else {
let i = t.width, a = t.height;
for (let t = 0; t < T; t++) n.texImage2D(e.TEXTURE_2D, t, m, i, a, 0, r, p, null), i >>= 1, a >>= 1;
}
} else if (o.isHTMLTexture) {
if ("texElementImage2D" in e) {
let n = e.canvas;
if (n.hasAttribute("layoutsubtree") || n.setAttribute("layoutsubtree", "true"), t.parentNode !== n) {
n.appendChild(t), d.add(o), n.onpaint = (e) => {
let t = e.changedElements;
for (let e of d) t.includes(e.image) && (e.needsUpdate = !0);
}, n.requestPaint();
return;
}
if (e.texElementImage2D.length === 3) e.texElementImage2D(e.TEXTURE_2D, e.RGBA8, t);
else {
let n = e.RGBA, r = e.RGBA, i = e.UNSIGNED_BYTE;
e.texElementImage2D(e.TEXTURE_2D, 0, n, r, i, t);
}
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE);
}
} else if (y.length > 0) {
if (S && C) {
let t = Ie(y[0]);
n.texStorage2D(e.TEXTURE_2D, T, m, t.width, t.height);
}
for (let t = 0, i = y.length; t < i; t++) h = y[t], S ? w && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, r, p, h) : n.texImage2D(e.TEXTURE_2D, t, m, r, p, h);
o.generateMipmaps = !1;
} else if (S) {
if (C) {
let r = Ie(t);
n.texStorage2D(e.TEXTURE_2D, T, m, r.width, r.height);
}
w && n.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, r, p, t);
} else n.texImage2D(e.TEXTURE_2D, 0, m, r, p, t);
_(o) && v(c), f.__version = u.version, o.onUpdate && o.onUpdate(o);
}
t.__version = o.version;
}
function Se(t, o, s) {
if (o.image.length !== 6) return;
let c = _e(t, o), l = o.source;
n.bindTexture(e.TEXTURE_CUBE_MAP, t.__webglTexture, e.TEXTURE0 + s);
let u = r.get(l);
if (l.version !== u.__version || c === !0) {
n.activeTexture(e.TEXTURE0 + s);
let t = Hn.getPrimaries(Hn.workingColorSpace), r = o.colorSpace === "" ? null : Hn.getPrimaries(o.colorSpace), d = o.colorSpace === "" || t === r ? e.NONE : e.BROWSER_DEFAULT_WEBGL;
n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, o.flipY), n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o.premultiplyAlpha), n.pixelStorei(e.UNPACK_ALIGNMENT, o.unpackAlignment), n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, d);
let f = o.isCompressedTexture || o.image[0].isCompressedTexture, p = o.image[0] && o.image[0].isDataTexture, m = [];
for (let e = 0; e < 6; e++) !f && !p ? m[e] = g(o.image[e], !0, i.maxCubemapSize) : m[e] = p ? o.image[e].image : o.image[e], m[e] = Fe(o, m[e]);
let h = m[0], y = a.convert(o.format, o.colorSpace), x = a.convert(o.type), S = b(o.internalFormat, y, x, o.normalized, o.colorSpace), C = o.isVideoTexture !== !0, w = u.__version === void 0 || c === !0, T = l.dataReady, E = D(o, h);
ge(e.TEXTURE_CUBE_MAP, o);
let O;
if (f) {
C && w && n.texStorage2D(e.TEXTURE_CUBE_MAP, E, S, h.width, h.height);
for (let t = 0; t < 6; t++) {
O = m[t].mipmaps;
for (let r = 0; r < O.length; r++) {
let i = O[r];
o.format === 1023 ? C ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, 0, 0, i.width, i.height, y, x, i.data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, S, i.width, i.height, 0, y, x, i.data) : y === null ? L("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : C ? T && n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, 0, 0, i.width, i.height, y, i.data) : n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, S, i.width, i.height, 0, i.data);
}
}
} else {
if (O = o.mipmaps, C && w) {
O.length > 0 && E++;
let t = Ie(m[0]);
n.texStorage2D(e.TEXTURE_CUBE_MAP, E, S, t.width, t.height);
}
for (let t = 0; t < 6; t++) if (p) {
C ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, 0, 0, m[t].width, m[t].height, y, x, m[t].data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, S, m[t].width, m[t].height, 0, y, x, m[t].data);
for (let r = 0; r < O.length; r++) {
let i = O[r].image[t].image;
C ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, 0, 0, i.width, i.height, y, x, i.data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, S, i.width, i.height, 0, y, x, i.data);
}
} else {
C ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, 0, 0, y, x, m[t]) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, S, y, x, m[t]);
for (let r = 0; r < O.length; r++) {
let i = O[r];
C ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, 0, 0, y, x, i.image[t]) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, S, y, x, i.image[t]);
}
}
}
_(o) && v(e.TEXTURE_CUBE_MAP), u.__version = l.version, o.onUpdate && o.onUpdate(o);
}
t.__version = o.version;
}
function Ce(t, i, o, c, l, u) {
let d = a.convert(o.format, o.colorSpace), f = a.convert(o.type), p = b(o.internalFormat, d, f, o.normalized, o.colorSpace), m = r.get(i), h = r.get(o);
if (h.__renderTarget = i, !m.__hasExternalTextures) {
let t = Math.max(1, i.width >> u), r = Math.max(1, i.height >> u);
l === e.TEXTURE_3D || l === e.TEXTURE_2D_ARRAY ? n.texImage3D(l, u, p, t, r, i.depth, 0, d, f, null) : n.texImage2D(l, u, p, t, r, 0, d, f, null);
}
n.bindFramebuffer(e.FRAMEBUFFER, t), Pe(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, c, l, h.__webglTexture, 0, Ne(i)) : (l === e.TEXTURE_2D || l >= e.TEXTURE_CUBE_MAP_POSITIVE_X && l <= e.TEXTURE_CUBE_MAP_NEGATIVE_Z) && e.framebufferTexture2D(e.FRAMEBUFFER, c, l, h.__webglTexture, u), n.bindFramebuffer(e.FRAMEBUFFER, null);
}
function we(t, n, r) {
if (e.bindRenderbuffer(e.RENDERBUFFER, t), n.depthBuffer) {
let i = n.depthTexture, a = i && i.isDepthTexture ? i.type : null, o = x(n.stencilBuffer, a), c = n.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT;
Pe(n) ? s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, Ne(n), o, n.width, n.height) : r ? e.renderbufferStorageMultisample(e.RENDERBUFFER, Ne(n), o, n.width, n.height) : e.renderbufferStorage(e.RENDERBUFFER, o, n.width, n.height), e.framebufferRenderbuffer(e.FRAMEBUFFER, c, e.RENDERBUFFER, t);
} else {
let t = n.textures;
for (let i = 0; i < t.length; i++) {
let o = t[i], c = a.convert(o.format, o.colorSpace), l = a.convert(o.type), u = b(o.internalFormat, c, l, o.normalized, o.colorSpace);
Pe(n) ? s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, Ne(n), u, n.width, n.height) : r ? e.renderbufferStorageMultisample(e.RENDERBUFFER, Ne(n), u, n.width, n.height) : e.renderbufferStorage(e.RENDERBUFFER, u, n.width, n.height);
}
}
e.bindRenderbuffer(e.RENDERBUFFER, null);
}
function Te(t, i, o) {
let c = i.isWebGLCubeRenderTarget === !0;
if (n.bindFramebuffer(e.FRAMEBUFFER, t), !(i.depthTexture && i.depthTexture.isDepthTexture)) throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");
let l = r.get(i.depthTexture);
if (l.__renderTarget = i, (!l.__webglTexture || i.depthTexture.image.width !== i.width || i.depthTexture.image.height !== i.height) && (i.depthTexture.image.width = i.width, i.depthTexture.image.height = i.height, i.depthTexture.needsUpdate = !0), c) {
if (l.__webglInit === void 0 && (l.__webglInit = !0, i.depthTexture.addEventListener("dispose", k)), l.__webglTexture === void 0) {
l.__webglTexture = e.createTexture(), n.bindTexture(e.TEXTURE_CUBE_MAP, l.__webglTexture), ge(e.TEXTURE_CUBE_MAP, i.depthTexture);
let t = a.convert(i.depthTexture.format), r = a.convert(i.depthTexture.type), o;
i.depthTexture.format === 1026 ? o = e.DEPTH_COMPONENT24 : i.depthTexture.format === 1027 && (o = e.DEPTH24_STENCIL8);
for (let n = 0; n < 6; n++) e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + n, 0, o, i.width, i.height, 0, t, r, null);
}
} else le(i.depthTexture, 0);
let u = l.__webglTexture, d = Ne(i), f = c ? e.TEXTURE_CUBE_MAP_POSITIVE_X + o : e.TEXTURE_2D, p = i.depthTexture.format === 1027 ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT;
if (i.depthTexture.format === 1026) Pe(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, p, f, u, 0, d) : e.framebufferTexture2D(e.FRAMEBUFFER, p, f, u, 0);
else if (i.depthTexture.format === 1027) Pe(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, p, f, u, 0, d) : e.framebufferTexture2D(e.FRAMEBUFFER, p, f, u, 0);
else throw Error("THREE.WebGLTextures: Unknown depthTexture format.");
}
function Ee(t) {
let i = r.get(t), a = t.isWebGLCubeRenderTarget === !0;
if (i.__boundDepthTexture !== t.depthTexture) {
let e = t.depthTexture;
if (i.__depthDisposeCallback && i.__depthDisposeCallback(), e) {
let t = () => {
delete i.__boundDepthTexture, delete i.__depthDisposeCallback, e.removeEventListener("dispose", t);
};
e.addEventListener("dispose", t), i.__depthDisposeCallback = t;
}
i.__boundDepthTexture = e;
}
if (t.depthTexture && !i.__autoAllocateDepthBuffer) if (a) for (let e = 0; e < 6; e++) Te(i.__webglFramebuffer[e], t, e);
else {
let e = t.texture.mipmaps;
e && e.length > 0 ? Te(i.__webglFramebuffer[0], t, 0) : Te(i.__webglFramebuffer, t, 0);
}
else if (a) {
i.__webglDepthbuffer = [];
for (let r = 0; r < 6; r++) if (n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer[r]), i.__webglDepthbuffer[r] === void 0) i.__webglDepthbuffer[r] = e.createRenderbuffer(), we(i.__webglDepthbuffer[r], t, !1);
else {
let n = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, a = i.__webglDepthbuffer[r];
e.bindRenderbuffer(e.RENDERBUFFER, a), e.framebufferRenderbuffer(e.FRAMEBUFFER, n, e.RENDERBUFFER, a);
}
} else {
let r = t.texture.mipmaps;
if (r && r.length > 0 ? n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer[0]) : n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer), i.__webglDepthbuffer === void 0) i.__webglDepthbuffer = e.createRenderbuffer(), we(i.__webglDepthbuffer, t, !1);
else {
let n = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, r = i.__webglDepthbuffer;
e.bindRenderbuffer(e.RENDERBUFFER, r), e.framebufferRenderbuffer(e.FRAMEBUFFER, n, e.RENDERBUFFER, r);
}
}
n.bindFramebuffer(e.FRAMEBUFFER, null);
}
function De(t, n, i) {
let a = r.get(t);
n !== void 0 && Ce(a.__webglFramebuffer, t, t.texture, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, 0), i !== void 0 && Ee(t);
}
function Oe(t) {
let i = t.texture, s = r.get(t), c = r.get(i);
t.addEventListener("dispose", te);
let l = t.textures, u = t.isWebGLCubeRenderTarget === !0, d = l.length > 1;
if (d || (c.__webglTexture === void 0 && (c.__webglTexture = e.createTexture()), c.__version = i.version, o.memory.textures++), u) {
s.__webglFramebuffer = [];
for (let t = 0; t < 6; t++) if (i.mipmaps && i.mipmaps.length > 0) {
s.__webglFramebuffer[t] = [];
for (let n = 0; n < i.mipmaps.length; n++) s.__webglFramebuffer[t][n] = e.createFramebuffer();
} else s.__webglFramebuffer[t] = e.createFramebuffer();
} else {
if (i.mipmaps && i.mipmaps.length > 0) {
s.__webglFramebuffer = [];
for (let t = 0; t < i.mipmaps.length; t++) s.__webglFramebuffer[t] = e.createFramebuffer();
} else s.__webglFramebuffer = e.createFramebuffer();
if (d) for (let t = 0, n = l.length; t < n; t++) {
let n = r.get(l[t]);
n.__webglTexture === void 0 && (n.__webglTexture = e.createTexture(), o.memory.textures++);
}
if (t.samples > 0 && Pe(t) === !1) {
s.__webglMultisampledFramebuffer = e.createFramebuffer(), s.__webglColorRenderbuffer = [], n.bindFramebuffer(e.FRAMEBUFFER, s.__webglMultisampledFramebuffer);
for (let n = 0; n < l.length; n++) {
let r = l[n];
s.__webglColorRenderbuffer[n] = e.createRenderbuffer(), e.bindRenderbuffer(e.RENDERBUFFER, s.__webglColorRenderbuffer[n]);
let i = a.convert(r.format, r.colorSpace), o = a.convert(r.type), c = b(r.internalFormat, i, o, r.normalized, r.colorSpace, t.isXRRenderTarget === !0), u = Ne(t);
e.renderbufferStorageMultisample(e.RENDERBUFFER, u, c, t.width, t.height), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + n, e.RENDERBUFFER, s.__webglColorRenderbuffer[n]);
}
e.bindRenderbuffer(e.RENDERBUFFER, null), t.depthBuffer && (s.__webglDepthRenderbuffer = e.createRenderbuffer(), we(s.__webglDepthRenderbuffer, t, !0)), n.bindFramebuffer(e.FRAMEBUFFER, null);
}
}
if (u) {
n.bindTexture(e.TEXTURE_CUBE_MAP, c.__webglTexture), ge(e.TEXTURE_CUBE_MAP, i);
for (let n = 0; n < 6; n++) if (i.mipmaps && i.mipmaps.length > 0) for (let r = 0; r < i.mipmaps.length; r++) Ce(s.__webglFramebuffer[n][r], t, i, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + n, r);
else Ce(s.__webglFramebuffer[n], t, i, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + n, 0);
_(i) && v(e.TEXTURE_CUBE_MAP), n.unbindTexture();
} else if (d) {
for (let i = 0, a = l.length; i < a; i++) {
let a = l[i], o = r.get(a), c = e.TEXTURE_2D;
(t.isWebGL3DRenderTarget || t.isWebGLArrayRenderTarget) && (c = t.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY), n.bindTexture(c, o.__webglTexture), ge(c, a), Ce(s.__webglFramebuffer, t, a, e.COLOR_ATTACHMENT0 + i, c, 0), _(a) && v(c);
}
n.unbindTexture();
} else {
let r = e.TEXTURE_2D;
if ((t.isWebGL3DRenderTarget || t.isWebGLArrayRenderTarget) && (r = t.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY), n.bindTexture(r, c.__webglTexture), ge(r, i), i.mipmaps && i.mipmaps.length > 0) for (let n = 0; n < i.mipmaps.length; n++) Ce(s.__webglFramebuffer[n], t, i, e.COLOR_ATTACHMENT0, r, n);
else Ce(s.__webglFramebuffer, t, i, e.COLOR_ATTACHMENT0, r, 0);
_(i) && v(r), n.unbindTexture();
}
t.depthBuffer && Ee(t);
}
function ke(e) {
let t = e.textures;
for (let i = 0, a = t.length; i < a; i++) {
let a = t[i];
if (_(a)) {
let t = y(e), i = r.get(a).__webglTexture;
n.bindTexture(t, i), v(t), n.unbindTexture();
}
}
}
let Ae = [], je = [];
function Me(t) {
if (t.samples > 0) {
if (Pe(t) === !1) {
let i = t.textures, a = t.width, o = t.height, s = e.COLOR_BUFFER_BIT, l = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, u = r.get(t), d = i.length > 1;
if (d) for (let t = 0; t < i.length; t++) n.bindFramebuffer(e.FRAMEBUFFER, u.__webglMultisampledFramebuffer), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.RENDERBUFFER, null), n.bindFramebuffer(e.FRAMEBUFFER, u.__webglFramebuffer), e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.TEXTURE_2D, null, 0);
n.bindFramebuffer(e.READ_FRAMEBUFFER, u.__webglMultisampledFramebuffer);
let f = t.texture.mipmaps;
f && f.length > 0 ? n.bindFramebuffer(e.DRAW_FRAMEBUFFER, u.__webglFramebuffer[0]) : n.bindFramebuffer(e.DRAW_FRAMEBUFFER, u.__webglFramebuffer);
for (let n = 0; n < i.length; n++) {
if (t.resolveDepthBuffer && (t.depthBuffer && (s |= e.DEPTH_BUFFER_BIT), t.stencilBuffer && t.resolveStencilBuffer && (s |= e.STENCIL_BUFFER_BIT)), d) {
e.framebufferRenderbuffer(e.READ_FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.RENDERBUFFER, u.__webglColorRenderbuffer[n]);
let t = r.get(i[n]).__webglTexture;
e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0);
}
e.blitFramebuffer(0, 0, a, o, 0, 0, a, o, s, e.NEAREST), c === !0 && (Ae.length = 0, je.length = 0, Ae.push(e.COLOR_ATTACHMENT0 + n), t.depthBuffer && t.resolveDepthBuffer === !1 && (Ae.push(l), je.push(l), e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER, je)), e.invalidateFramebuffer(e.READ_FRAMEBUFFER, Ae));
}
if (n.bindFramebuffer(e.READ_FRAMEBUFFER, null), n.bindFramebuffer(e.DRAW_FRAMEBUFFER, null), d) for (let t = 0; t < i.length; t++) {
n.bindFramebuffer(e.FRAMEBUFFER, u.__webglMultisampledFramebuffer), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.RENDERBUFFER, u.__webglColorRenderbuffer[t]);
let a = r.get(i[t]).__webglTexture;
n.bindFramebuffer(e.FRAMEBUFFER, u.__webglFramebuffer), e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.TEXTURE_2D, a, 0);
}
n.bindFramebuffer(e.DRAW_FRAMEBUFFER, u.__webglMultisampledFramebuffer);
} else if (t.depthBuffer && t.resolveDepthBuffer === !1 && c) {
let n = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT;
e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER, [n]);
}
}
}
function Ne(e) {
return Math.min(i.maxSamples, e.samples);
}
function Pe(e) {
let n = r.get(e);
return e.samples > 0 && t.has("WEBGL_multisampled_render_to_texture") === !0 && n.__useRenderToTexture !== !1;
}
function P(e) {
let t = o.render.frame;
u.get(e) !== t && (u.set(e, t), e.update());
}
function Fe(e, t) {
let n = e.colorSpace, r = e.format, i = e.type;
return e.isCompressedTexture === !0 || e.isVideoTexture === !0 || n !== "srgb-linear" && n !== "" && (Hn.getTransfer(n) === "srgb" ? (r !== 1023 || i !== 1009) && L("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : R("WebGLTextures: Unsupported texture color space:", n)), t;
}
function Ie(e) {
return typeof HTMLImageElement < "u" && e instanceof HTMLImageElement ? (l.width = e.naturalWidth || e.width, l.height = e.naturalHeight || e.height) : typeof VideoFrame < "u" && e instanceof VideoFrame ? (l.width = e.displayWidth, l.height = e.displayHeight) : (l.width = e.width, l.height = e.height), l;
}
this.allocateTextureUnit = N, this.resetTextureUnits = ae, this.getTextureUnits = oe, this.setTextureUnits = se, this.setTexture2D = le, this.setTexture2DArray = ue, this.setTexture3D = de, this.setTextureCube = fe, this.rebindTextures = De, this.setupRenderTarget = Oe, this.updateRenderTargetMipmap = ke, this.updateMultisampleRenderTarget = Me, this.setupDepthRenderbuffer = Ee, this.setupFrameBufferTexture = Ce, this.useMultisampledRTT = Pe, this.isReversedDepthBuffer = function() {
return n.buffers.depth.getReversed();
};
}
function Xh(e, t) {
function n(n, r = "") {
let i, a = Hn.getTransfer(r);
if (n === 1009) return e.UNSIGNED_BYTE;
if (n === 1017) return e.UNSIGNED_SHORT_4_4_4_4;
if (n === 1018) return e.UNSIGNED_SHORT_5_5_5_1;
if (n === 35902) return e.UNSIGNED_INT_5_9_9_9_REV;
if (n === 35899) return e.UNSIGNED_INT_10F_11F_11F_REV;
if (n === 1010) return e.BYTE;
if (n === 1011) return e.SHORT;
if (n === 1012) return e.UNSIGNED_SHORT;
if (n === 1013) return e.INT;
if (n === 1014) return e.UNSIGNED_INT;
if (n === 1015) return e.FLOAT;
if (n === 1016) return e.HALF_FLOAT;
if (n === 1021) return e.ALPHA;
if (n === 1022) return e.RGB;
if (n === 1023) return e.RGBA;
if (n === 1026) return e.DEPTH_COMPONENT;
if (n === 1027) return e.DEPTH_STENCIL;
if (n === 1028) return e.RED;
if (n === 1029) return e.RED_INTEGER;
if (n === 1030) return e.RG;
if (n === 1031) return e.RG_INTEGER;
if (n === 1033) return e.RGBA_INTEGER;
if (n === 33776 || n === 33777 || n === 33778 || n === 33779) if (a === "srgb") if (i = t.get("WEBGL_compressed_texture_s3tc_srgb"), i !== null) {
if (n === 33776) return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;
if (n === 33777) return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
if (n === 33778) return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
if (n === 33779) return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
} else return null;
else if (i = t.get("WEBGL_compressed_texture_s3tc"), i !== null) {
if (n === 33776) return i.COMPRESSED_RGB_S3TC_DXT1_EXT;
if (n === 33777) return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;
if (n === 33778) return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;
if (n === 33779) return i.COMPRESSED_RGBA_S3TC_DXT5_EXT;
} else return null;
if (n === 35840 || n === 35841 || n === 35842 || n === 35843) if (i = t.get("WEBGL_compressed_texture_pvrtc"), i !== null) {
if (n === 35840) return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
if (n === 35841) return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
if (n === 35842) return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
if (n === 35843) return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
} else return null;
if (n === 36196 || n === 37492 || n === 37496 || n === 37488 || n === 37489 || n === 37490 || n === 37491) if (i = t.get("WEBGL_compressed_texture_etc"), i !== null) {
if (n === 36196 || n === 37492) return a === "srgb" ? i.COMPRESSED_SRGB8_ETC2 : i.COMPRESSED_RGB8_ETC2;
if (n === 37496) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : i.COMPRESSED_RGBA8_ETC2_EAC;
if (n === 37488) return i.COMPRESSED_R11_EAC;
if (n === 37489) return i.COMPRESSED_SIGNED_R11_EAC;
if (n === 37490) return i.COMPRESSED_RG11_EAC;
if (n === 37491) return i.COMPRESSED_SIGNED_RG11_EAC;
} else return null;
if (n === 37808 || n === 37809 || n === 37810 || n === 37811 || n === 37812 || n === 37813 || n === 37814 || n === 37815 || n === 37816 || n === 37817 || n === 37818 || n === 37819 || n === 37820 || n === 37821) if (i = t.get("WEBGL_compressed_texture_astc"), i !== null) {
if (n === 37808) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : i.COMPRESSED_RGBA_ASTC_4x4_KHR;
if (n === 37809) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : i.COMPRESSED_RGBA_ASTC_5x4_KHR;
if (n === 37810) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : i.COMPRESSED_RGBA_ASTC_5x5_KHR;
if (n === 37811) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : i.COMPRESSED_RGBA_ASTC_6x5_KHR;
if (n === 37812) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : i.COMPRESSED_RGBA_ASTC_6x6_KHR;
if (n === 37813) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : i.COMPRESSED_RGBA_ASTC_8x5_KHR;
if (n === 37814) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : i.COMPRESSED_RGBA_ASTC_8x6_KHR;
if (n === 37815) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : i.COMPRESSED_RGBA_ASTC_8x8_KHR;
if (n === 37816) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : i.COMPRESSED_RGBA_ASTC_10x5_KHR;
if (n === 37817) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : i.COMPRESSED_RGBA_ASTC_10x6_KHR;
if (n === 37818) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : i.COMPRESSED_RGBA_ASTC_10x8_KHR;
if (n === 37819) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : i.COMPRESSED_RGBA_ASTC_10x10_KHR;
if (n === 37820) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : i.COMPRESSED_RGBA_ASTC_12x10_KHR;
if (n === 37821) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : i.COMPRESSED_RGBA_ASTC_12x12_KHR;
} else return null;
if (n === 36492 || n === 36494 || n === 36495) if (i = t.get("EXT_texture_compression_bptc"), i !== null) {
if (n === 36492) return a === "srgb" ? i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : i.COMPRESSED_RGBA_BPTC_UNORM_EXT;
if (n === 36494) return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
if (n === 36495) return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
} else return null;
if (n === 36283 || n === 36284 || n === 36285 || n === 36286) if (i = t.get("EXT_texture_compression_rgtc"), i !== null) {
if (n === 36283) return i.COMPRESSED_RED_RGTC1_EXT;
if (n === 36284) return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;
if (n === 36285) return i.COMPRESSED_RED_GREEN_RGTC2_EXT;
if (n === 36286) return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
} else return null;
return n === 1020 ? e.UNSIGNED_INT_24_8 : e[n] === void 0 ? null : e[n];
}
return { convert: n };
}
var Zh = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Qh = "\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n if ( coord.x >= 1.0 ) {\n\n gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n } else {\n\n gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n }\n\n}", $h = class {
constructor() {
this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0;
}
init(e, t) {
if (this.texture === null) {
let n = new _s(e.texture);
(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 && this.mesh === null) {
let t = e.cameras[0].viewport, n = new _l({
vertexShader: Zh,
fragmentShader: Qh,
uniforms: {
depthColor: { value: this.texture },
depthWidth: { value: t.z },
depthHeight: { value: t.w }
}
});
this.mesh = new La(new Xc(20, 20), n);
}
return this.mesh;
}
reset() {
this.texture = null, this.mesh = null;
}
getDepthTexture() {
return this.texture;
}
}, eg = class extends ln {
constructor(e, t) {
super();
let n = this, r = null, i = 1, a = null, o = "local-floor", s = 1, c = null, l = null, u = null, d = null, f = null, p = null, m = typeof XRWebGLBinding < "u", h = new $h(), g = {}, _ = t.getContextAttributes(), v = null, y = null, b = [], x = [], S = new V(), C = null, w = new Z();
w.viewport = new $n();
let T = new Z();
T.viewport = new $n();
let E = [w, T], D = new rd(), O = null, k = null;
this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(e) {
let t = b[e];
return t === void 0 && (t = new Fr(), b[e] = t), t.getTargetRaySpace();
}, this.getControllerGrip = function(e) {
let t = b[e];
return t === void 0 && (t = new Fr(), b[e] = t), t.getGripSpace();
}, this.getHand = function(e) {
let t = b[e];
return t === void 0 && (t = new Fr(), b[e] = t), t.getHandSpace();
};
function A(e) {
let t = x.indexOf(e.inputSource);
if (t === -1) return;
let n = b[t];
n !== void 0 && (n.update(e.inputSource, e.frame, c || a), n.dispatchEvent({
type: e.type,
data: e.inputSource
}));
}
function ee() {
r.removeEventListener("select", A), r.removeEventListener("selectstart", A), r.removeEventListener("selectend", A), r.removeEventListener("squeeze", A), r.removeEventListener("squeezestart", A), r.removeEventListener("squeezeend", A), r.removeEventListener("end", ee), r.removeEventListener("inputsourceschange", te);
for (let e = 0; e < b.length; e++) {
let t = x[e];
t !== null && (x[e] = null, b[e].disconnect(t));
}
O = null, k = null, h.reset();
for (let e in g) delete g[e];
e.setRenderTarget(v), f = null, d = null, u = null, r = null, y = null, ce.stop(), n.isPresenting = !1, e.setPixelRatio(C), e.setSize(S.width, S.height, !1), n.dispatchEvent({ type: "sessionend" });
}
this.setFramebufferScaleFactor = function(e) {
i = e, n.isPresenting === !0 && L("WebXRManager: Cannot change framebuffer scale while presenting.");
}, this.setReferenceSpaceType = function(e) {
o = e, n.isPresenting === !0 && L("WebXRManager: Cannot change reference space type while presenting.");
}, this.getReferenceSpace = function() {
return c || a;
}, this.setReferenceSpace = function(e) {
c = e;
}, this.getBaseLayer = function() {
return d === null ? f : d;
}, this.getBinding = function() {
return u === null && m && (u = new XRWebGLBinding(r, t)), u;
}, this.getFrame = function() {
return p;
}, this.getSession = function() {
return r;
}, this.setSession = async function(l) {
if (r = l, r !== null) {
if (v = e.getRenderTarget(), r.addEventListener("select", A), r.addEventListener("selectstart", A), r.addEventListener("selectend", A), r.addEventListener("squeeze", A), r.addEventListener("squeezestart", A), r.addEventListener("squeezeend", A), r.addEventListener("end", ee), r.addEventListener("inputsourceschange", te), _.xrCompatible !== !0 && await t.makeXRCompatible(), C = e.getPixelRatio(), e.getSize(S), m && "createProjectionLayer" in XRWebGLBinding.prototype) {
let n = null, a = null, o = null;
_.depth && (o = _.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, n = _.stencil ? ve : _e, a = _.stencil ? de : se);
let s = {
colorFormat: t.RGBA8,
depthFormat: o,
scaleFactor: i
};
u = this.getBinding(), d = u.createProjectionLayer(s), r.updateRenderState({ layers: [d] }), e.setPixelRatio(1), e.setSize(d.textureWidth, d.textureHeight, !1), y = new tr(d.textureWidth, d.textureHeight, {
format: ge,
type: M,
depthTexture: new hs(d.textureWidth, d.textureHeight, a, void 0, void 0, void 0, void 0, void 0, void 0, n),
stencilBuffer: _.stencil,
colorSpace: e.outputColorSpace,
samples: _.antialias ? 4 : 0,
resolveDepthBuffer: d.ignoreDepthValues === !1,
resolveStencilBuffer: d.ignoreDepthValues === !1
});
} else {
let n = {
antialias: _.antialias,
alpha: !0,
depth: _.depth,
stencil: _.stencil,
framebufferScaleFactor: i
};
f = new XRWebGLLayer(r, t, n), r.updateRenderState({ baseLayer: f }), e.setPixelRatio(1), e.setSize(f.framebufferWidth, f.framebufferHeight, !1), y = new tr(f.framebufferWidth, f.framebufferHeight, {
format: ge,
type: M,
colorSpace: e.outputColorSpace,
stencilBuffer: _.stencil,
resolveDepthBuffer: f.ignoreDepthValues === !1,
resolveStencilBuffer: f.ignoreDepthValues === !1
});
}
y.isXRRenderTarget = !0, this.setFoveation(s), c = null, a = await r.requestReferenceSpace(o), ce.setContext(r), ce.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" });
}
}, this.getEnvironmentBlendMode = function() {
if (r !== null) return r.environmentBlendMode;
}, this.getDepthTexture = function() {
return h.getDepthTexture();
};
function te(e) {
for (let t = 0; t < e.removed.length; t++) {
let n = e.removed[t], r = x.indexOf(n);
r >= 0 && (x[r] = null, b[r].disconnect(n));
}
for (let t = 0; t < e.added.length; t++) {
let n = e.added[t], r = x.indexOf(n);
if (r === -1) {
for (let e = 0; e < b.length; e++) if (e >= x.length) {
x.push(n), r = e;
break;
} else if (x[e] === null) {
x[e] = n, r = e;
break;
}
if (r === -1) break;
}
let i = b[r];
i && i.connect(n);
}
}
let ne = new H(), j = new H();
function re(e, t, n) {
ne.setFromMatrixPosition(t.matrixWorld), j.setFromMatrixPosition(n.matrixWorld);
let r = ne.distanceTo(j), i = t.projectionMatrix.elements, a = n.projectionMatrix.elements, o = i[14] / (i[10] - 1), s = i[14] / (i[10] + 1), c = (i[9] + 1) / i[5], l = (i[9] - 1) / i[5], u = (i[8] - 1) / i[0], d = (a[8] + 1) / a[0], f = o * u, p = o * d, m = r / (-u + d), h = m * -u;
if (t.matrixWorld.decompose(e.position, e.quaternion, e.scale), e.translateX(h), e.translateZ(m), e.matrixWorld.compose(e.position, e.quaternion, e.scale), e.matrixWorldInverse.copy(e.matrixWorld).invert(), i[10] === -1) e.projectionMatrix.copy(t.projectionMatrix), e.projectionMatrixInverse.copy(t.projectionMatrixInverse);
else {
let t = o + m, n = s + m, i = f - h, a = p + (r - h), u = c * s / n * t, d = l * s / n * t;
e.projectionMatrix.makePerspective(i, a, u, d, t, n), e.projectionMatrixInverse.copy(e.projectionMatrix).invert();
}
}
function ie(e, t) {
t === null ? e.matrixWorld.copy(e.matrix) : e.matrixWorld.multiplyMatrices(t.matrixWorld, e.matrix), e.matrixWorldInverse.copy(e.matrixWorld).invert();
}
this.updateCamera = function(e) {
if (r === null) return;
let t = e.near, n = e.far;
h.texture !== null && (h.depthNear > 0 && (t = h.depthNear), h.depthFar > 0 && (n = h.depthFar)), D.near = T.near = w.near = t, D.far = T.far = w.far = n, (O !== D.near || k !== D.far) && (r.updateRenderState({
depthNear: D.near,
depthFar: D.far
}), O = D.near, k = D.far), D.layers.mask = e.layers.mask | 6, w.layers.mask = D.layers.mask & -5, T.layers.mask = D.layers.mask & -3;
let i = e.parent, a = D.cameras;
ie(D, i);
for (let e = 0; e < a.length; e++) ie(a[e], i);
a.length === 2 ? re(D, w, T) : D.projectionMatrix.copy(w.projectionMatrix), ae(e, D, i);
};
function ae(e, t, n) {
n === null ? e.matrix.copy(t.matrixWorld) : (e.matrix.copy(n.matrixWorld), e.matrix.invert(), e.matrix.multiply(t.matrixWorld)), e.matrix.decompose(e.position, e.quaternion, e.scale), e.updateMatrixWorld(!0), e.projectionMatrix.copy(t.projectionMatrix), e.projectionMatrixInverse.copy(t.projectionMatrixInverse), e.isPerspectiveCamera && (e.fov = pn * 2 * Math.atan(1 / e.projectionMatrix.elements[5]), e.zoom = 1);
}
this.getCamera = function() {
return D;
}, this.getFoveation = function() {
if (!(d === null && f === null)) return s;
}, this.setFoveation = function(e) {
s = e, d !== null && (d.fixedFoveation = e), f !== null && f.fixedFoveation !== void 0 && (f.fixedFoveation = e);
}, this.hasDepthSensing = function() {
return h.texture !== null;
}, this.getDepthSensingMesh = function() {
return h.getMesh(D);
}, this.getCameraTexture = function(e) {
return g[e];
};
let oe = null;
function N(t, i) {
if (l = i.getViewerPose(c || a), p = i, l !== null) {
let t = l.views;
f !== null && (e.setRenderTargetFramebuffer(y, f.framebuffer), e.setRenderTarget(y));
let i = !1;
t.length !== D.cameras.length && (D.cameras.length = 0, i = !0);
for (let n = 0; n < t.length; n++) {
let r = t[n], a = null;
if (f !== null) a = f.getViewport(r);
else {
let t = u.getViewSubImage(d, r);
a = t.viewport, n === 0 && (e.setRenderTargetTextures(y, t.colorTexture, t.depthStencilTexture), e.setRenderTarget(y));
}
let o = E[n];
o === void 0 && (o = new Z(), o.layers.enable(n), o.viewport = new $n(), E[n] = o), o.matrix.fromArray(r.transform.matrix), o.matrix.decompose(o.position, o.quaternion, o.scale), o.projectionMatrix.fromArray(r.projectionMatrix), o.projectionMatrixInverse.copy(o.projectionMatrix).invert(), o.viewport.set(a.x, a.y, a.width, a.height), n === 0 && (D.matrix.copy(o.matrix), D.matrix.decompose(D.position, D.quaternion, D.scale)), i === !0 && D.cameras.push(o);
}
let a = r.enabledFeatures;
if (a && a.includes("depth-sensing") && r.depthUsage == "gpu-optimized" && m) {
u = n.getBinding();
let e = u.getDepthInformation(t[0]);
e && e.isValid && e.texture && h.init(e, r.renderState);
}
if (a && a.includes("camera-access") && m) {
e.state.unbindTexture(), u = n.getBinding();
for (let e = 0; e < t.length; e++) {
let n = t[e].camera;
if (n) {
let e = g[n];
e || (e = new _s(), g[n] = e);
let t = u.getCameraImage(n);
e.sourceTexture = t;
}
}
}
}
for (let e = 0; e < b.length; e++) {
let t = x[e], n = b[e];
t !== null && n !== void 0 && n.update(t, i, c || a);
}
oe && oe(t, i), i.detectedPlanes && n.dispatchEvent({
type: "planesdetected",
data: i
}), p = null;
}
let ce = new qf();
ce.setAnimationLoop(N), this.setAnimationLoop = function(e) {
oe = e;
}, this.dispose = function() {};
}
}, tg = /*@__PURE__*/ new W(), ng = /*@__PURE__*/ new U();
ng.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
function rg(e, t) {
function n(e, t) {
e.matrixAutoUpdate === !0 && e.updateMatrix(), t.value.copy(e.matrix);
}
function r(t, n) {
n.color.getRGB(t.fogColor.value, pl(e)), n.isFog ? (t.fogNear.value = n.near, t.fogFar.value = n.far) : n.isFogExp2 && (t.fogDensity.value = n.density);
}
function i(e, t, n, r, i) {
t.isNodeMaterial ? t.uniformsNeedUpdate = !1 : t.isMeshBasicMaterial ? a(e, t) : t.isMeshLambertMaterial ? (a(e, t), t.envMap && (e.envMapIntensity.value = t.envMapIntensity)) : t.isMeshToonMaterial ? (a(e, t), d(e, t)) : t.isMeshPhongMaterial ? (a(e, t), u(e, t), t.envMap && (e.envMapIntensity.value = t.envMapIntensity)) : t.isMeshStandardMaterial ? (a(e, t), f(e, t), t.isMeshPhysicalMaterial && p(e, t, i)) : t.isMeshMatcapMaterial ? (a(e, t), m(e, t)) : t.isMeshDepthMaterial ? a(e, t) : t.isMeshDistanceMaterial ? (a(e, t), h(e, t)) : t.isMeshNormalMaterial ? a(e, t) : t.isLineBasicMaterial ? (o(e, t), t.isLineDashedMaterial && s(e, t)) : t.isPointsMaterial ? c(e, t, n, r) : t.isSpriteMaterial ? l(e, t) : t.isShadowMaterial ? (e.color.value.copy(t.color), e.opacity.value = t.opacity) : t.isShaderMaterial && (t.uniformsNeedUpdate = !1);
}
function a(e, r) {
e.opacity.value = r.opacity, r.color && e.diffuse.value.copy(r.color), r.emissive && e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity), r.map && (e.map.value = r.map, n(r.map, e.mapTransform)), r.alphaMap && (e.alphaMap.value = r.alphaMap, n(r.alphaMap, e.alphaMapTransform)), r.bumpMap && (e.bumpMap.value = r.bumpMap, n(r.bumpMap, e.bumpMapTransform), e.bumpScale.value = r.bumpScale, r.side === 1 && (e.bumpScale.value *= -1)), r.normalMap && (e.normalMap.value = r.normalMap, n(r.normalMap, e.normalMapTransform), e.normalScale.value.copy(r.normalScale), r.side === 1 && e.normalScale.value.negate()), r.displacementMap && (e.displacementMap.value = r.displacementMap, n(r.displacementMap, e.displacementMapTransform), e.displacementScale.value = r.displacementScale, e.displacementBias.value = r.displacementBias), r.emissiveMap && (e.emissiveMap.value = r.emissiveMap, n(r.emissiveMap, e.emissiveMapTransform)), r.specularMap && (e.specularMap.value = r.specularMap, n(r.specularMap, e.specularMapTransform)), r.alphaTest > 0 && (e.alphaTest.value = r.alphaTest);
let i = t.get(r), a = i.envMap, o = i.envMapRotation;
a && (e.envMap.value = a, e.envMapRotation.value.setFromMatrix4(tg.makeRotationFromEuler(o)).transpose(), a.isCubeTexture && a.isRenderTargetTexture === !1 && e.envMapRotation.value.premultiply(ng), e.reflectivity.value = r.reflectivity, e.ior.value = r.ior, e.refractionRatio.value = r.refractionRatio), r.lightMap && (e.lightMap.value = r.lightMap, e.lightMapIntensity.value = r.lightMapIntensity, n(r.lightMap, e.lightMapTransform)), r.aoMap && (e.aoMap.value = r.aoMap, e.aoMapIntensity.value = r.aoMapIntensity, n(r.aoMap, e.aoMapTransform));
}
function o(e, t) {
e.diffuse.value.copy(t.color), e.opacity.value = t.opacity, t.map && (e.map.value = t.map, n(t.map, e.mapTransform));
}
function s(e, t) {
e.dashSize.value = t.dashSize, e.totalSize.value = t.dashSize + t.gapSize, e.scale.value = t.scale;
}
function c(e, t, r, i) {
e.diffuse.value.copy(t.color), e.opacity.value = t.opacity, e.size.value = t.size * r, e.scale.value = i * .5, t.map && (e.map.value = t.map, n(t.map, e.uvTransform)), t.alphaMap && (e.alphaMap.value = t.alphaMap, n(t.alphaMap, e.alphaMapTransform)), t.alphaTest > 0 && (e.alphaTest.value = t.alphaTest);
}
function l(e, t) {
e.diffuse.value.copy(t.color), e.opacity.value = t.opacity, e.rotation.value = t.rotation, t.map && (e.map.value = t.map, n(t.map, e.mapTransform)), t.alphaMap && (e.alphaMap.value = t.alphaMap, n(t.alphaMap, e.alphaMapTransform)), t.alphaTest > 0 && (e.alphaTest.value = t.alphaTest);
}
function u(e, t) {
e.specular.value.copy(t.specular), e.shininess.value = Math.max(t.shininess, 1e-4);
}
function d(e, t) {
t.gradientMap && (e.gradientMap.value = t.gradientMap);
}
function f(e, t) {
e.metalness.value = t.metalness, t.metalnessMap && (e.metalnessMap.value = t.metalnessMap, n(t.metalnessMap, e.metalnessMapTransform)), e.roughness.value = t.roughness, t.roughnessMap && (e.roughnessMap.value = t.roughnessMap, n(t.roughnessMap, e.roughnessMapTransform)), t.envMap && (e.envMapIntensity.value = t.envMapIntensity);
}
function p(e, t, r) {
e.ior.value = t.ior, t.sheen > 0 && (e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen), e.sheenRoughness.value = t.sheenRoughness, t.sheenColorMap && (e.sheenColorMap.value = t.sheenColorMap, n(t.sheenColorMap, e.sheenColorMapTransform)), t.sheenRoughnessMap && (e.sheenRoughnessMap.value = t.sheenRoughnessMap, n(t.sheenRoughnessMap, e.sheenRoughnessMapTransform))), t.clearcoat > 0 && (e.clearcoat.value = t.clearcoat, e.clearcoatRoughness.value = t.clearcoatRoughness, t.clearcoatMap && (e.clearcoatMap.value = t.clearcoatMap, n(t.clearcoatMap, e.clearcoatMapTransform)), t.clearcoatRoughnessMap && (e.clearcoatRoughnessMap.value = t.clearcoatRoughnessMap, n(t.clearcoatRoughnessMap, e.clearcoatRoughnessMapTransform)), t.clearcoatNormalMap && (e.clearcoatNormalMap.value = t.clearcoatNormalMap, n(t.clearcoatNormalMap, e.clearcoatNormalMapTransform), e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale), t.side === 1 && e.clearcoatNormalScale.value.negate())), t.dispersion > 0 && (e.dispersion.value = t.dispersion), t.iridescence > 0 && (e.iridescence.value = t.iridescence, e.iridescenceIOR.value = t.iridescenceIOR, e.iridescenceThicknessMinimum.value = t.iridescenceThicknessRange[0], e.iridescenceThicknessMaximum.value = t.iridescenceThicknessRange[1], t.iridescenceMap && (e.iridescenceMap.value = t.iridescenceMap, n(t.iridescenceMap, e.iridescenceMapTransform)), t.iridescenceThicknessMap && (e.iridescenceThicknessMap.value = t.iridescenceThicknessMap, n(t.iridescenceThicknessMap, e.iridescenceThicknessMapTransform))), t.transmission > 0 && (e.transmission.value = t.transmission, e.transmissionSamplerMap.value = r.texture, e.transmissionSamplerSize.value.set(r.width, r.height), t.transmissionMap && (e.transmissionMap.value = t.transmissionMap, n(t.transmissionMap, e.transmissionMapTransform)), e.thickness.value = t.thickness, t.thicknessMap && (e.thicknessMap.value = t.thicknessMap, n(t.thicknessMap, e.thicknessMapTransform)), e.attenuationDistance.value = t.attenuationDistance, e.attenuationColor.value.copy(t.attenuationColor)), t.anisotropy > 0 && (e.anisotropyVector.value.set(t.anisotropy * Math.cos(t.anisotropyRotation), t.anisotropy * Math.sin(t.anisotropyRotation)), t.anisotropyMap && (e.anisotropyMap.value = t.anisotropyMap, n(t.anisotropyMap, e.anisotropyMapTransform))), e.specularIntensity.value = t.specularIntensity, e.specularColor.value.copy(t.specularColor), t.specularColorMap && (e.specularColorMap.value = t.specularColorMap, n(t.specularColorMap, e.specularColorMapTransform)), t.specularIntensityMap && (e.specularIntensityMap.value = t.specularIntensityMap, n(t.specularIntensityMap, e.specularIntensityMapTransform));
}
function m(e, t) {
t.matcap && (e.matcap.value = t.matcap);
}
function h(e, n) {
let r = t.get(n).light;
e.referencePosition.value.setFromMatrixPosition(r.matrixWorld), e.nearDistance.value = r.shadow.camera.near, e.farDistance.value = r.shadow.camera.far;
}
return {
refreshFogUniforms: r,
refreshMaterialUniforms: i
};
}
function ig(e, t, n, r) {
let i = {}, a = {}, o = [], s = e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);
function c(e, t) {
let n = t.program;
r.uniformBlockBinding(e, n);
}
function l(e, n) {
let o = i[e.id];
o === void 0 && (g(e), o = u(e), i[e.id] = o, e.addEventListener("dispose", v));
let s = n.program;
r.updateUBOMapping(e, s);
let c = t.render.frame;
a[e.id] !== c && (f(e), a[e.id] = c);
}
function u(t) {
let n = d();
t.__bindingPointIndex = n;
let r = e.createBuffer(), i = t.__size, a = t.usage;
return e.bindBuffer(e.UNIFORM_BUFFER, r), e.bufferData(e.UNIFORM_BUFFER, i, a), e.bindBuffer(e.UNIFORM_BUFFER, null), e.bindBufferBase(e.UNIFORM_BUFFER, n, r), r;
}
function d() {
for (let e = 0; e < s; e++) if (o.indexOf(e) === -1) return o.push(e), e;
return R("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0;
}
function f(t) {
let n = i[t.id], r = t.uniforms, a = t.__cache;
e.bindBuffer(e.UNIFORM_BUFFER, n);
for (let e = 0, t = r.length; e < t; e++) {
let t = r[e];
if (Array.isArray(t)) for (let n = 0, r = t.length; n < r; n++) p(t[n], e, n, a);
else p(t, e, 0, a);
}
e.bindBuffer(e.UNIFORM_BUFFER, null);
}
function p(t, n, r, i) {
if (h(t, n, r, i) === !0) {
let n = t.__offset, r = t.value;
if (Array.isArray(r)) {
let e = 0;
for (let n = 0; n < r.length; n++) {
let i = r[n], a = _(i);
m(i, t.__data, e), typeof i != "number" && typeof i != "boolean" && !i.isMatrix3 && !ArrayBuffer.isView(i) && (e += a.storage / Float32Array.BYTES_PER_ELEMENT);
}
} else m(r, t.__data, 0);
e.bufferSubData(e.UNIFORM_BUFFER, n, t.__data);
}
}
function m(e, t, n) {
typeof e == "number" || typeof e == "boolean" ? t[0] = e : e.isMatrix3 ? (t[0] = e.elements[0], t[1] = e.elements[1], t[2] = e.elements[2], t[3] = 0, t[4] = e.elements[3], t[5] = e.elements[4], t[6] = e.elements[5], t[7] = 0, t[8] = e.elements[6], t[9] = e.elements[7], t[10] = e.elements[8], t[11] = 0) : ArrayBuffer.isView(e) ? t.set(new e.constructor(e.buffer, e.byteOffset, t.length)) : e.toArray(t, n);
}
function h(e, t, n, r) {
let i = e.value, a = t + "_" + n;
if (r[a] === void 0) return typeof i == "number" || typeof i == "boolean" ? r[a] = i : ArrayBuffer.isView(i) ? r[a] = i.slice() : r[a] = i.clone(), !0;
{
let e = r[a];
if (typeof i == "number" || typeof i == "boolean") {
if (e !== i) return r[a] = i, !0;
} else if (ArrayBuffer.isView(i)) return !0;
else if (e.equals(i) === !1) return e.copy(i), !0;
}
return !1;
}
function g(e) {
let t = e.uniforms, n = 0;
for (let e = 0, r = t.length; e < r; e++) {
let r = Array.isArray(t[e]) ? t[e] : [t[e]];
for (let e = 0, t = r.length; e < t; e++) {
let t = r[e], i = Array.isArray(t.value) ? t.value : [t.value];
for (let e = 0, r = i.length; e < r; e++) {
let r = i[e], a = _(r), o = n % 16, s = o % a.boundary, c = o + s;
n += s, c !== 0 && 16 - c < a.storage && (n += 16 - c), t.__data = new Float32Array(a.storage / Float32Array.BYTES_PER_ELEMENT), t.__offset = n, n += a.storage;
}
}
}
let r = n % 16;
return r > 0 && (n += 16 - r), e.__size = n, e.__cache = {}, this;
}
function _(e) {
let t = {
boundary: 0,
storage: 0
};
return typeof e == "number" || typeof e == "boolean" ? (t.boundary = 4, t.storage = 4) : e.isVector2 ? (t.boundary = 8, t.storage = 8) : e.isVector3 || e.isColor ? (t.boundary = 16, t.storage = 12) : e.isVector4 ? (t.boundary = 16, t.storage = 16) : e.isMatrix3 ? (t.boundary = 48, t.storage = 48) : e.isMatrix4 ? (t.boundary = 64, t.storage = 64) : e.isTexture ? L("WebGLRenderer: Texture samplers can not be part of an uniforms group.") : ArrayBuffer.isView(e) ? (t.boundary = 16, t.storage = e.byteLength) : L("WebGLRenderer: Unsupported uniform value type.", e), t;
}
function v(t) {
let n = t.target;
n.removeEventListener("dispose", v);
let r = o.indexOf(n.__bindingPointIndex);
o.splice(r, 1), e.deleteBuffer(i[n.id]), delete i[n.id], delete a[n.id];
}
function y() {
for (let t in i) e.deleteBuffer(i[t]);
o = [], i = {}, a = {};
}
return {
bind: c,
update: l,
dispose: y
};
}
var ag = new Uint16Array([
12469,
15057,
12620,
14925,
13266,
14620,
13807,
14376,
14323,
13990,
14545,
13625,
14713,
13328,
14840,
12882,
14931,
12528,
14996,
12233,
15039,
11829,
15066,
11525,
15080,
11295,
15085,
10976,
15082,
10705,
15073,
10495,
13880,
14564,
13898,
14542,
13977,
14430,
14158,
14124,
14393,
13732,
14556,
13410,
14702,
12996,
14814,
12596,
14891,
12291,
14937,
11834,
14957,
11489,
14958,
11194,
14943,
10803,
14921,
10506,
14893,
10278,
14858,
9960,
14484,
14039,
14487,
14025,
14499,
13941,
14524,
13740,
14574,
13468,
14654,
13106,
14743,
12678,
14818,
12344,
14867,
11893,
14889,
11509,
14893,
11180,
14881,
10751,
14852,
10428,
14812,
10128,
14765,
9754,
14712,
9466,
14764,
13480,
14764,
13475,
14766,
13440,
14766,
13347,
14769,
13070,
14786,
12713,
14816,
12387,
14844,
11957,
14860,
11549,
14868,
11215,
14855,
10751,
14825,
10403,
14782,
10044,
14729,
9651,
14666,
9352,
14599,
9029,
14967,
12835,
14966,
12831,
14963,
12804,
14954,
12723,
14936,
12564,
14917,
12347,
14900,
11958,
14886,
11569,
14878,
11247,
14859,
10765,
14828,
10401,
14784,
10011,
14727,
9600,
14660,
9289,
14586,
8893,
14508,
8533,
15111,
12234,
15110,
12234,
15104,
12216,
15092,
12156,
15067,
12010,
15028,
11776,
14981,
11500,
14942,
11205,
14902,
10752,
14861,
10393,
14812,
9991,
14752,
9570,
14682,
9252,
14603,
8808,
14519,
8445,
14431,
8145,
15209,
11449,
15208,
11451,
15202,
11451,
15190,
11438,
15163,
11384,
15117,
11274,
15055,
10979,
14994,
10648,
14932,
10343,
14871,
9936,
14803,
9532,
14729,
9218,
14645,
8742,
14556,
8381,
14461,
8020,
14365,
7603,
15273,
10603,
15272,
10607,
15267,
10619,
15256,
10631,
15231,
10614,
15182,
10535,
15118,
10389,
15042,
10167,
14963,
9787,
14883,
9447,
14800,
9115,
14710,
8665,
14615,
8318,
14514,
7911,
14411,
7507,
14279,
7198,
15314,
9675,
15313,
9683,
15309,
9712,
15298,
9759,
15277,
9797,
15229,
9773,
15166,
9668,
15084,
9487,
14995,
9274,
14898,
8910,
14800,
8539,
14697,
8234,
14590,
7790,
14479,
7409,
14367,
7067,
14178,
6621,
15337,
8619,
15337,
8631,
15333,
8677,
15325,
8769,
15305,
8871,
15264,
8940,
15202,
8909,
15119,
8775,
15022,
8565,
14916,
8328,
14804,
8009,
14688,
7614,
14569,
7287,
14448,
6888,
14321,
6483,
14088,
6171,
15350,
7402,
15350,
7419,
15347,
7480,
15340,
7613,
15322,
7804,
15287,
7973,
15229,
8057,
15148,
8012,
15046,
7846,
14933,
7611,
14810,
7357,
14682,
7069,
14552,
6656,
14421,
6316,
14251,
5948,
14007,
5528,
15356,
5942,
15356,
5977,
15353,
6119,
15348,
6294,
15332,
6551,
15302,
6824,
15249,
7044,
15171,
7122,
15070,
7050,
14949,
6861,
14818,
6611,
14679,
6349,
14538,
6067,
14398,
5651,
14189,
5311,
13935,
4958,
15359,
4123,
15359,
4153,
15356,
4296,
15353,
4646,
15338,
5160,
15311,
5508,
15263,
5829,
15188,
6042,
15088,
6094,
14966,
6001,
14826,
5796,
14678,
5543,
14527,
5287,
14377,
4985,
14133,
4586,
13869,
4257,
15360,
1563,
15360,
1642,
15358,
2076,
15354,
2636,
15341,
3350,
15317,
4019,
15273,
4429,
15203,
4732,
15105,
4911,
14981,
4932,
14836,
4818,
14679,
4621,
14517,
4386,
14359,
4156,
14083,
3795,
13808,
3437,
15360,
122,
15360,
137,
15358,
285,
15355,
636,
15344,
1274,
15322,
2177,
15281,
2765,
15215,
3223,
15120,
3451,
14995,
3569,
14846,
3567,
14681,
3466,
14511,
3305,
14344,
3121,
14037,
2800,
13753,
2467,
15360,
0,
15360,
1,
15359,
21,
15355,
89,
15346,
253,
15325,
479,
15287,
796,
15225,
1148,
15133,
1492,
15008,
1749,
14856,
1882,
14685,
1886,
14506,
1783,
14324,
1608,
13996,
1398,
13702,
1183
]), og = null;
function sg() {
return og === null && (og = new Xa(ag, 16, 16, xe, ce), og.name = "DFG_LUT", og.minFilter = A, og.magFilter = A, og.wrapS = C, og.wrapT = C, og.generateMipmaps = !1, og.needsUpdate = !0), og;
}
var cg = class {
constructor(e = {}) {
let { canvas: t = Qt(), context: n = null, depth: r = !0, stencil: i = !1, alpha: a = !1, antialias: o = !1, premultipliedAlpha: s = !0, preserveDrawingBuffer: c = !1, powerPreference: l = "default", failIfMajorPerformanceCaveat: u = !1, reversedDepthBuffer: d = !1, outputBufferType: f = M } = e;
this.isWebGLRenderer = !0;
let p;
if (n !== null) {
if (typeof WebGLRenderingContext < "u" && n instanceof WebGLRenderingContext) throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");
p = n.getContextAttributes().alpha;
} else p = a;
let m = f, h = /* @__PURE__ */ new Set([
we,
Se,
be
]), g = /* @__PURE__ */ new Set([
M,
se,
ae,
de,
le,
ue
]), _ = /* @__PURE__ */ new Uint32Array(4), v = /* @__PURE__ */ new Int32Array(4), y = new H(), b = null, x = null, S = [], C = [], w = null;
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 = 0, this.toneMappingExposure = 1, this.transmissionResolutionScale = 1;
let T = this, E = !1, D = null, O = null, k = null, A = null;
this._outputColorSpace = bt;
let ee = 0, te = 0, j = null, re = -1, ie = null, oe = new $n(), N = new $n(), fe = null, pe = new G(0), me = 0, he = t.width, ge = t.height, _e = 1, ve = null, ye = null, xe = new $n(0, 0, he, ge), Ce = new $n(0, 0, he, ge), Te = !1, Ee = new _o(), De = !1, Oe = !1, ke = new W(), Ae = new H(), je = new $n(), Me = {
background: null,
fog: null,
environment: null,
overrideMaterial: null,
isScene: !0
}, Ne = !1;
function Pe() {
return j === null ? _e : 1;
}
let P = n;
function Fe(e, n) {
return t.getContext(e, n);
}
try {
let e = {
alpha: !0,
depth: r,
stencil: i,
antialias: o,
premultipliedAlpha: s,
preserveDrawingBuffer: c,
powerPreference: l,
failIfMajorPerformanceCaveat: u
};
if ("setAttribute" in t && t.setAttribute("data-engine", "three.js r185"), t.addEventListener("webglcontextlost", at, !1), t.addEventListener("webglcontextrestored", ot, !1), t.addEventListener("webglcontextcreationerror", st, !1), P === null) {
let t = "webgl2";
if (P = Fe(t, e), P === null) throw Fe(t) ? Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.") : Error("THREE.WebGLRenderer: Error creating WebGL context.");
}
} catch (e) {
throw R("WebGLRenderer: " + e.message), e;
}
let Ie, Le, F, Re, I, ze, Be, Ve, He, Ue, We, Ge, Ke, qe, Je, Ye, Xe, Ze, Qe, $e, et, tt, nt;
function rt() {
Ie = new Ep(P), Ie.init(), et = new Xh(P, Ie), Le = new np(P, Ie, e, et), F = new Jh(P, Ie), Le.reversedDepthBuffer && d && F.buffers.depth.setReversed(!0), O = P.createFramebuffer(), k = P.createFramebuffer(), A = P.createFramebuffer(), Re = new kp(P), I = new Oh(), ze = new Yh(P, Ie, F, I, Le, et, Re), Be = new Tp(T), Ve = new Jf(P), tt = new ep(P, Ve), He = new Dp(P, Ve, Re, tt), Ue = new jp(P, He, Ve, tt, Re), Ze = new Ap(P, Le, ze), Je = new rp(I), We = new Dh(T, Be, Ie, Le, tt, Je), Ge = new rg(T, I), Ke = new Mh(), qe = new zh(Ie), Xe = new $f(T, Be, F, Ue, p, s), Ye = new qh(T, Ue, Le), nt = new ig(P, Re, Le, F), Qe = new tp(P, Ie, Re), $e = new Op(P, Ie, Re), Re.programs = We.programs, T.capabilities = Le, T.extensions = Ie, T.properties = I, T.renderLists = Ke, T.shadowMap = Ye, T.state = F, T.info = Re;
}
rt(), m !== 1009 && (w = new Np(m, t.width, t.height, o, r, i));
let it = new eg(T, P);
this.xr = it, this.getContext = function() {
return P;
}, this.getContextAttributes = function() {
return P.getContextAttributes();
}, this.forceContextLoss = function() {
let e = Ie.get("WEBGL_lose_context");
e && e.loseContext();
}, this.forceContextRestore = function() {
let e = Ie.get("WEBGL_lose_context");
e && e.restoreContext();
}, this.getPixelRatio = function() {
return _e;
}, this.setPixelRatio = function(e) {
e !== void 0 && (_e = e, this.setSize(he, ge, !1));
}, this.getSize = function(e) {
return e.set(he, ge);
}, this.setSize = function(e, n, r = !0) {
if (it.isPresenting) {
L("WebGLRenderer: Can't change size while VR device is presenting.");
return;
}
he = e, ge = n, t.width = Math.floor(e * _e), t.height = Math.floor(n * _e), r === !0 && (t.style.width = e + "px", t.style.height = n + "px"), w !== null && w.setSize(t.width, t.height), this.setViewport(0, 0, e, n);
}, this.getDrawingBufferSize = function(e) {
return e.set(he * _e, ge * _e).floor();
}, this.setDrawingBufferSize = function(e, n, r) {
he = e, ge = n, _e = r, t.width = Math.floor(e * r), t.height = Math.floor(n * r), this.setViewport(0, 0, e, n);
}, this.setEffects = function(e) {
if (m === 1009) {
R("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
return;
}
if (e) {
for (let t = 0; t < e.length; t++) if (e[t].isOutputPass === !0) {
L("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
break;
}
}
w.setEffects(e || []);
}, this.getCurrentViewport = function(e) {
return e.copy(oe);
}, this.getViewport = function(e) {
return e.copy(xe);
}, this.setViewport = function(e, t, n, r) {
e.isVector4 ? xe.set(e.x, e.y, e.z, e.w) : xe.set(e, t, n, r), F.viewport(oe.copy(xe).multiplyScalar(_e).round());
}, this.getScissor = function(e) {
return e.copy(Ce);
}, this.setScissor = function(e, t, n, r) {
e.isVector4 ? Ce.set(e.x, e.y, e.z, e.w) : Ce.set(e, t, n, r), F.scissor(N.copy(Ce).multiplyScalar(_e).round());
}, this.getScissorTest = function() {
return Te;
}, this.setScissorTest = function(e) {
F.setScissorTest(Te = e);
}, this.setOpaqueSort = function(e) {
ve = e;
}, this.setTransparentSort = function(e) {
ye = e;
}, this.getClearColor = function(e) {
return e.copy(Xe.getClearColor());
}, this.setClearColor = function() {
Xe.setClearColor(...arguments);
}, this.getClearAlpha = function() {
return Xe.getClearAlpha();
}, this.setClearAlpha = function() {
Xe.setClearAlpha(...arguments);
}, this.clear = function(e = !0, t = !0, n = !0) {
let r = 0;
if (e) {
let e = !1;
if (j !== null) {
let t = j.texture.format;
e = h.has(t);
}
if (e) {
let e = j.texture.type, t = g.has(e), n = Xe.getClearColor(), r = Xe.getClearAlpha(), i = n.r, a = n.g, o = n.b;
t ? (_[0] = i, _[1] = a, _[2] = o, _[3] = r, P.clearBufferuiv(P.COLOR, 0, _)) : (v[0] = i, v[1] = a, v[2] = o, v[3] = r, P.clearBufferiv(P.COLOR, 0, v));
} else r |= P.COLOR_BUFFER_BIT;
}
t && (r |= P.DEPTH_BUFFER_BIT, this.state.buffers.depth.setMask(!0)), n && (r |= P.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), r !== 0 && P.clear(r);
}, 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.setNodesHandler = function(e) {
e.setRenderer(this), D = e;
}, this.dispose = function() {
t.removeEventListener("webglcontextlost", at, !1), t.removeEventListener("webglcontextrestored", ot, !1), t.removeEventListener("webglcontextcreationerror", st, !1), Xe.dispose(), Ke.dispose(), qe.dispose(), I.dispose(), Be.dispose(), Ue.dispose(), tt.dispose(), nt.dispose(), We.dispose(), it.dispose(), it.removeEventListener("sessionstart", mt), it.removeEventListener("sessionend", ht), gt.stop();
};
function at(e) {
e.preventDefault(), rn("WebGLRenderer: Context Lost."), E = !0;
}
function ot() {
rn("WebGLRenderer: Context Restored."), E = !1;
let e = Re.autoReset, t = Ye.enabled, n = Ye.autoUpdate, r = Ye.needsUpdate, i = Ye.type;
rt(), Re.autoReset = e, Ye.enabled = t, Ye.autoUpdate = n, Ye.needsUpdate = r, Ye.type = i;
}
function st(e) {
R("WebGLRenderer: A WebGL context could not be created. Reason: ", e.statusMessage);
}
function ct(e) {
let t = e.target;
t.removeEventListener("dispose", ct), lt(t);
}
function lt(e) {
ut(e), I.remove(e);
}
function ut(e) {
let t = I.get(e).programs;
t !== void 0 && (t.forEach(function(e) {
We.releaseProgram(e);
}), e.isShaderMaterial && We.releaseShaderCache(e));
}
this.renderBufferDirect = function(e, t, n, r, i, a) {
t === null && (t = Me);
let o = i.isMesh && i.matrixWorld.determinantAffine() < 0, s = Dt(e, t, n, r, i);
F.setMaterial(r, o);
let c = n.index, l = 1;
if (r.wireframe === !0) {
if (c = He.getWireframeAttribute(n), c === void 0) return;
l = 2;
}
let u = n.drawRange, d = n.attributes.position, f = u.start * l, p = (u.start + u.count) * l;
a !== null && (f = Math.max(f, a.start * l), p = Math.min(p, (a.start + a.count) * l)), c === null ? d != null && (f = Math.max(f, 0), p = Math.min(p, d.count)) : (f = Math.max(f, 0), p = Math.min(p, c.count));
let m = p - f;
if (m < 0 || m === Infinity) return;
tt.setup(i, r, s, n, c);
let h, g = Qe;
if (c !== null && (h = Ve.get(c), g = $e, g.setIndex(h)), i.isMesh) r.wireframe === !0 ? (F.setLineWidth(r.wireframeLinewidth * Pe()), g.setMode(P.LINES)) : g.setMode(P.TRIANGLES);
else if (i.isLine) {
let e = r.linewidth;
e === void 0 && (e = 1), F.setLineWidth(e * Pe()), i.isLineSegments ? g.setMode(P.LINES) : i.isLineLoop ? g.setMode(P.LINE_LOOP) : g.setMode(P.LINE_STRIP);
} else i.isPoints ? g.setMode(P.POINTS) : i.isSprite && g.setMode(P.TRIANGLES);
if (i.isBatchedMesh) if (Ie.get("WEBGL_multi_draw")) g.renderMultiDraw(i._multiDrawStarts, i._multiDrawCounts, i._multiDrawCount);
else {
let e = i._multiDrawStarts, t = i._multiDrawCounts, n = i._multiDrawCount, a = c ? Ve.get(c).bytesPerElement : 1, o = I.get(r).currentProgram.getUniforms();
for (let r = 0; r < n; r++) o.setValue(P, "_gl_DrawID", r), g.render(e[r] / a, t[r]);
}
else if (i.isInstancedMesh) g.renderInstances(f, m, i.count);
else if (n.isInstancedBufferGeometry) {
let e = n._maxInstanceCount === void 0 ? Infinity : n._maxInstanceCount, t = Math.min(n.instanceCount, e);
g.renderInstances(f, m, t);
} else g.render(f, m);
};
function dt(e, t, n) {
e.transparent === !0 && e.side === 2 && e.forceSinglePass === !1 ? (e.side = 1, e.needsUpdate = !0, Ct(e, t, n), e.side = 0, e.needsUpdate = !0, Ct(e, t, n), e.side = 2) : Ct(e, t, n);
}
this.compile = function(e, t, n = null) {
n === null && (n = e), x = qe.get(n), x.init(t), C.push(x), n.traverseVisible(function(e) {
e.isLight && e.layers.test(t.layers) && (x.pushLight(e), e.castShadow && x.pushShadow(e));
}), e !== n && e.traverseVisible(function(e) {
e.isLight && e.layers.test(t.layers) && (x.pushLight(e), e.castShadow && x.pushShadow(e));
}), x.setupLights();
let r = /* @__PURE__ */ new Set();
return e.traverse(function(e) {
if (!(e.isMesh || e.isPoints || e.isLine || e.isSprite)) return;
let t = e.material;
if (t) if (Array.isArray(t)) for (let i = 0; i < t.length; i++) {
let a = t[i];
dt(a, n, e), r.add(a);
}
else dt(t, n, e), r.add(t);
}), x = C.pop(), r;
}, this.compileAsync = function(e, t, n = null) {
let r = this.compile(e, t, n);
return new Promise((t) => {
function n() {
if (r.forEach(function(e) {
I.get(e).currentProgram.isReady() && r.delete(e);
}), r.size === 0) {
t(e);
return;
}
setTimeout(n, 10);
}
Ie.get("KHR_parallel_shader_compile") === null ? setTimeout(n, 10) : n();
});
};
let ft = null;
function pt(e) {
ft && ft(e);
}
function mt() {
gt.stop();
}
function ht() {
gt.start();
}
let gt = new qf();
gt.setAnimationLoop(pt), typeof self < "u" && gt.setContext(self), this.setAnimationLoop = function(e) {
ft = e, it.setAnimationLoop(e), e === null ? gt.stop() : gt.start();
}, it.addEventListener("sessionstart", mt), it.addEventListener("sessionend", ht), this.render = function(e, t) {
if (t !== void 0 && t.isCamera !== !0) {
R("WebGLRenderer.render: camera is not an instance of THREE.Camera.");
return;
}
if (E === !0) return;
D !== null && D.renderStart(e, t);
let n = it.enabled === !0 && it.isPresenting === !0, r = w !== null && (j === null || n) && w.begin(T, j);
if (e.matrixWorldAutoUpdate === !0 && e.updateMatrixWorld(), t.parent === null && t.matrixWorldAutoUpdate === !0 && t.updateMatrixWorld(), it.enabled === !0 && it.isPresenting === !0 && (w === null || w.isCompositing() === !1) && (it.cameraAutoUpdate === !0 && it.updateCamera(t), t = it.getCamera()), e.isScene === !0 && e.onBeforeRender(T, e, t, j), x = qe.get(e, C.length), x.init(t), x.state.textureUnits = ze.getTextureUnits(), C.push(x), ke.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), Ee.setFromProjectionMatrix(ke, Vt, t.reversedDepth), Oe = this.localClippingEnabled, De = Je.init(this.clippingPlanes, Oe), b = Ke.get(e, S.length), b.init(), S.push(b), it.enabled === !0 && it.isPresenting === !0) {
let e = T.xr.getDepthSensingMesh();
e !== null && _t(e, t, -Infinity, T.sortObjects);
}
_t(e, t, 0, T.sortObjects), b.finish(), T.sortObjects === !0 && b.sort(ve, ye, t.reversedDepth), Ne = it.enabled === !1 || it.isPresenting === !1 || it.hasDepthSensing() === !1, Ne && Xe.addToRenderList(b, e), this.info.render.frame++, this.info.autoReset === !0 && this.info.reset(), De === !0 && Je.beginShadows();
let i = x.state.shadowsArray;
if (Ye.render(i, e, t), De === !0 && Je.endShadows(), (r && w.hasRenderPass()) === !1) {
let n = b.opaque, r = b.transmissive;
if (x.setupLights(), t.isArrayCamera) {
let i = t.cameras;
if (r.length > 0) for (let t = 0, a = i.length; t < a; t++) {
let a = i[t];
yt(n, r, e, a);
}
Ne && Xe.render(e);
for (let t = 0, n = i.length; t < n; t++) {
let n = i[t];
vt(b, e, n, n.viewport);
}
} else r.length > 0 && yt(n, r, e, t), Ne && Xe.render(e), vt(b, e, t);
}
j !== null && te === 0 && (ze.updateMultisampleRenderTarget(j), ze.updateRenderTargetMipmap(j)), r && w.end(T), e.isScene === !0 && e.onAfterRender(T, e, t), tt.resetDefaultState(), re = -1, ie = null, C.pop(), C.length > 0 ? (x = C[C.length - 1], ze.setTextureUnits(x.state.textureUnits), De === !0 && Je.setGlobalState(T.clippingPlanes, x.state.camera)) : x = null, S.pop(), b = S.length > 0 ? S[S.length - 1] : null, D !== null && D.renderEnd();
};
function _t(e, t, n, r) {
if (e.visible === !1) return;
if (e.layers.test(t.layers)) {
if (e.isGroup) n = e.renderOrder;
else if (e.isLOD) e.autoUpdate === !0 && e.update(t);
else if (e.isLightProbeGrid) x.pushLightProbeGrid(e);
else if (e.isLight) x.pushLight(e), e.castShadow && x.pushShadow(e);
else if (e.isSprite) {
if (!e.frustumCulled || Ee.intersectsSprite(e)) {
r && je.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ke);
let t = Ue.update(e), i = e.material;
i.visible && b.push(e, t, i, n, je.z, null);
}
} else if ((e.isMesh || e.isLine || e.isPoints) && (!e.frustumCulled || Ee.intersectsObject(e))) {
let t = Ue.update(e), i = e.material;
if (r && (e.boundingSphere === void 0 ? (t.boundingSphere === null && t.computeBoundingSphere(), je.copy(t.boundingSphere.center)) : (e.boundingSphere === null && e.computeBoundingSphere(), je.copy(e.boundingSphere.center)), je.applyMatrix4(e.matrixWorld).applyMatrix4(ke)), Array.isArray(i)) {
let r = t.groups;
for (let a = 0, o = r.length; a < o; a++) {
let o = r[a], s = i[o.materialIndex];
s && s.visible && b.push(e, t, s, n, je.z, o);
}
} else i.visible && b.push(e, t, i, n, je.z, null);
}
}
let i = e.children;
for (let e = 0, a = i.length; e < a; e++) _t(i[e], t, n, r);
}
function vt(e, t, n, r) {
let { opaque: i, transmissive: a, transparent: o } = e;
x.setupLightsView(n), De === !0 && Je.setGlobalState(T.clippingPlanes, n), r && F.viewport(oe.copy(r)), i.length > 0 && xt(i, t, n), a.length > 0 && xt(a, t, n), o.length > 0 && xt(o, t, n), F.buffers.depth.setTest(!0), F.buffers.depth.setMask(!0), F.buffers.color.setMask(!0), F.setPolygonOffset(!1);
}
function yt(e, t, n, r) {
if ((n.isScene === !0 ? n.overrideMaterial : null) !== null) return;
if (x.state.transmissionRenderTarget[r.id] === void 0) {
let e = Ie.has("EXT_color_buffer_half_float") || Ie.has("EXT_color_buffer_float");
x.state.transmissionRenderTarget[r.id] = new tr(1, 1, {
generateMipmaps: !0,
type: e ? ce : M,
minFilter: ne,
samples: Math.max(4, Le.samples),
stencilBuffer: i,
resolveDepthBuffer: !1,
resolveStencilBuffer: !1,
colorSpace: Hn.workingColorSpace
});
}
let a = x.state.transmissionRenderTarget[r.id], o = r.viewport || oe;
a.setSize(o.z * T.transmissionResolutionScale, o.w * T.transmissionResolutionScale);
let s = T.getRenderTarget(), c = T.getActiveCubeFace(), l = T.getActiveMipmapLevel();
T.setRenderTarget(a), T.getClearColor(pe), me = T.getClearAlpha(), me < 1 && T.setClearColor(16777215, .5), T.clear(), Ne && Xe.render(n);
let u = T.toneMapping;
T.toneMapping = 0;
let d = r.viewport;
if (r.viewport !== void 0 && (r.viewport = void 0), x.setupLightsView(r), De === !0 && Je.setGlobalState(T.clippingPlanes, r), xt(e, n, r), ze.updateMultisampleRenderTarget(a), ze.updateRenderTargetMipmap(a), Ie.has("WEBGL_multisampled_render_to_texture") === !1) {
let e = !1;
for (let i = 0, a = t.length; i < a; i++) {
let { object: a, geometry: o, material: s, group: c } = t[i];
if (s.side === 2 && a.layers.test(r.layers)) {
let t = s.side;
s.side = 1, s.needsUpdate = !0, St(a, n, r, o, s, c), s.side = t, s.needsUpdate = !0, e = !0;
}
}
e === !0 && (ze.updateMultisampleRenderTarget(a), ze.updateRenderTargetMipmap(a));
}
T.setRenderTarget(s, c, l), T.setClearColor(pe, me), d !== void 0 && (r.viewport = d), T.toneMapping = u;
}
function xt(e, t, n) {
let r = t.isScene === !0 ? t.overrideMaterial : null;
for (let i = 0, a = e.length; i < a; i++) {
let a = e[i], { object: o, geometry: s, group: c } = a, l = a.material;
l.allowOverride === !0 && r !== null && (l = r), o.layers.test(n.layers) && St(o, t, n, s, l, c);
}
}
function St(e, t, n, r, i, a) {
e.onBeforeRender(T, t, n, r, i, a), e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse, e.matrixWorld), e.normalMatrix.getNormalMatrix(e.modelViewMatrix), i.onBeforeRender(T, t, n, r, e, a), i.transparent === !0 && i.side === 2 && i.forceSinglePass === !1 ? (i.side = 1, i.needsUpdate = !0, T.renderBufferDirect(n, t, r, i, e, a), i.side = 0, i.needsUpdate = !0, T.renderBufferDirect(n, t, r, i, e, a), i.side = 2) : T.renderBufferDirect(n, t, r, i, e, a), e.onAfterRender(T, t, n, r, i, a);
}
function Ct(e, t, n) {
t.isScene !== !0 && (t = Me);
let r = I.get(e), i = x.state.lights, a = x.state.shadowsArray, o = i.state.version, s = We.getParameters(e, i.state, a, t, n, x.state.lightProbeGridArray), c = We.getProgramCacheKey(s), l = r.programs;
r.environment = e.isMeshStandardMaterial || e.isMeshLambertMaterial || e.isMeshPhongMaterial ? t.environment : null, r.fog = t.fog;
let u = e.isMeshStandardMaterial || e.isMeshLambertMaterial && !e.envMap || e.isMeshPhongMaterial && !e.envMap;
r.envMap = Be.get(e.envMap || r.environment, u), r.envMapRotation = r.environment !== null && e.envMap === null ? t.environmentRotation : e.envMapRotation, l === void 0 && (e.addEventListener("dispose", ct), l = /* @__PURE__ */ new Map(), r.programs = l);
let d = l.get(c);
if (d !== void 0) {
if (r.currentProgram === d && r.lightsStateVersion === o) return Tt(e, s), d;
} else s.uniforms = We.getUniforms(e), D !== null && e.isNodeMaterial && D.build(e, n, s), e.onBeforeCompile(s, T), d = We.acquireProgram(s, c), l.set(c, d), r.uniforms = s.uniforms;
let f = r.uniforms;
return (!e.isShaderMaterial && !e.isRawShaderMaterial || e.clipping === !0) && (f.clippingPlanes = Je.uniform), Tt(e, s), r.needsLights = kt(e), r.lightsStateVersion = o, r.needsLights && (f.ambientLightColor.value = i.state.ambient, f.lightProbe.value = i.state.probe, f.directionalLights.value = i.state.directional, f.directionalLightShadows.value = i.state.directionalShadow, f.spotLights.value = i.state.spot, f.spotLightShadows.value = i.state.spotShadow, f.rectAreaLights.value = i.state.rectArea, f.ltc_1.value = i.state.rectAreaLTC1, f.ltc_2.value = i.state.rectAreaLTC2, f.pointLights.value = i.state.point, f.pointLightShadows.value = i.state.pointShadow, f.hemisphereLights.value = i.state.hemi, f.directionalShadowMatrix.value = i.state.directionalShadowMatrix, f.spotLightMatrix.value = i.state.spotLightMatrix, f.spotLightMap.value = i.state.spotLightMap, f.pointShadowMatrix.value = i.state.pointShadowMatrix), r.lightProbeGrid = x.state.lightProbeGridArray.length > 0, r.currentProgram = d, r.uniformsList = null, d;
}
function wt(e) {
if (e.uniformsList === null) {
let t = e.currentProgram.getUniforms();
e.uniformsList = Bm.seqWithValue(t.seq, e.uniforms);
}
return e.uniformsList;
}
function Tt(e, t) {
let n = I.get(e);
n.outputColorSpace = t.outputColorSpace, n.batching = t.batching, n.batchingColor = t.batchingColor, n.instancing = t.instancing, n.instancingColor = t.instancingColor, n.instancingMorph = t.instancingMorph, n.skinning = t.skinning, n.morphTargets = t.morphTargets, n.morphNormals = t.morphNormals, n.morphColors = t.morphColors, n.morphTargetsCount = t.morphTargetsCount, n.numClippingPlanes = t.numClippingPlanes, n.numIntersection = t.numClipIntersection, n.vertexAlphas = t.vertexAlphas, n.vertexTangents = t.vertexTangents, n.toneMapping = t.toneMapping;
}
function Et(e, t) {
if (e.length === 0) return null;
if (e.length === 1) return e[0].texture === null ? null : e[0];
y.setFromMatrixPosition(t.matrixWorld);
for (let t = 0, n = e.length; t < n; t++) {
let n = e[t];
if (n.texture !== null && n.boundingBox.containsPoint(y)) return n;
}
return null;
}
function Dt(e, t, n, r, i) {
t.isScene !== !0 && (t = Me), ze.resetTextureUnits();
let a = t.fog, o = r.isMeshStandardMaterial || r.isMeshLambertMaterial || r.isMeshPhongMaterial ? t.environment : null, s = j === null ? T.outputColorSpace : j.isXRRenderTarget === !0 ? j.texture.colorSpace : Hn.workingColorSpace, c = r.isMeshStandardMaterial || r.isMeshLambertMaterial && !r.envMap || r.isMeshPhongMaterial && !r.envMap, l = Be.get(r.envMap || o, c), u = r.vertexColors === !0 && !!n.attributes.color && n.attributes.color.itemSize === 4, d = !!n.attributes.tangent && (!!r.normalMap || r.anisotropy > 0), f = !!n.morphAttributes.position, p = !!n.morphAttributes.normal, m = !!n.morphAttributes.color, h = 0;
r.toneMapped && (j === null || j.isXRRenderTarget === !0) && (h = T.toneMapping);
let g = n.morphAttributes.position || n.morphAttributes.normal || n.morphAttributes.color, _ = g === void 0 ? 0 : g.length, v = I.get(r), y = x.state.lights;
if (De === !0 && (Oe === !0 || e !== ie)) {
let t = e === ie && r.id === re;
Je.setState(r, e, t);
}
let b = !1;
r.version === v.__version ? v.needsLights && v.lightsStateVersion !== y.state.version ? b = !0 : v.outputColorSpace === s ? i.isBatchedMesh && v.batching === !1 || !i.isBatchedMesh && v.batching === !0 || i.isBatchedMesh && v.batchingColor === !0 && i.colorTexture === null || i.isBatchedMesh && v.batchingColor === !1 && i.colorTexture !== null || i.isInstancedMesh && v.instancing === !1 || !i.isInstancedMesh && v.instancing === !0 || i.isSkinnedMesh && v.skinning === !1 || !i.isSkinnedMesh && v.skinning === !0 || i.isInstancedMesh && v.instancingColor === !0 && i.instanceColor === null || i.isInstancedMesh && v.instancingColor === !1 && i.instanceColor !== null || i.isInstancedMesh && v.instancingMorph === !0 && i.morphTexture === null || i.isInstancedMesh && v.instancingMorph === !1 && i.morphTexture !== null ? b = !0 : v.envMap === l ? r.fog === !0 && v.fog !== a || v.numClippingPlanes !== void 0 && (v.numClippingPlanes !== Je.numPlanes || v.numIntersection !== Je.numIntersection) ? b = !0 : v.vertexAlphas === u && v.vertexTangents === d && v.morphTargets === f && v.morphNormals === p && v.morphColors === m && v.toneMapping === h && v.morphTargetsCount === _ ? !!v.lightProbeGrid != x.state.lightProbeGridArray.length > 0 && (b = !0) : b = !0 : b = !0 : b = !0 : (b = !0, v.__version = r.version);
let S = v.currentProgram;
b === !0 && (S = Ct(r, t, i), D && r.isNodeMaterial && D.onUpdateProgram(r, S, v));
let C = !1, w = !1, E = !1, O = S.getUniforms(), k = v.uniforms;
if (F.useProgram(S.program) && (C = !0, w = !0, E = !0), r.id !== re && (re = r.id, w = !0), v.needsLights) {
let e = Et(x.state.lightProbeGridArray, i);
v.lightProbeGrid !== e && (v.lightProbeGrid = e, w = !0);
}
if (C || ie !== e) {
F.buffers.depth.getReversed() && e.reversedDepth !== !0 && (e._reversedDepth = !0, e.updateProjectionMatrix()), O.setValue(P, "projectionMatrix", e.projectionMatrix), O.setValue(P, "viewMatrix", e.matrixWorldInverse);
let t = O.map.cameraPosition;
t !== void 0 && t.setValue(P, Ae.setFromMatrixPosition(e.matrixWorld)), Le.logarithmicDepthBuffer && O.setValue(P, "logDepthBufFC", 2 / (Math.log(e.far + 1) / Math.LN2)), (r.isMeshPhongMaterial || r.isMeshToonMaterial || r.isMeshLambertMaterial || r.isMeshBasicMaterial || r.isMeshStandardMaterial || r.isShaderMaterial) && O.setValue(P, "isOrthographic", e.isOrthographicCamera === !0), ie !== e && (ie = e, w = !0, E = !0);
}
if (v.needsLights && (y.state.directionalShadowMap.length > 0 && O.setValue(P, "directionalShadowMap", y.state.directionalShadowMap, ze), y.state.spotShadowMap.length > 0 && O.setValue(P, "spotShadowMap", y.state.spotShadowMap, ze), y.state.pointShadowMap.length > 0 && O.setValue(P, "pointShadowMap", y.state.pointShadowMap, ze)), i.isSkinnedMesh) {
O.setOptional(P, i, "bindMatrix"), O.setOptional(P, i, "bindMatrixInverse");
let e = i.skeleton;
e && (e.boneTexture === null && e.computeBoneTexture(), O.setValue(P, "boneTexture", e.boneTexture, ze));
}
i.isBatchedMesh && (O.setOptional(P, i, "batchingTexture"), O.setValue(P, "batchingTexture", i._matricesTexture, ze), O.setOptional(P, i, "batchingIdTexture"), O.setValue(P, "batchingIdTexture", i._indirectTexture, ze), O.setOptional(P, i, "batchingColorTexture"), i._colorsTexture !== null && O.setValue(P, "batchingColorTexture", i._colorsTexture, ze));
let A = n.morphAttributes;
if ((A.position !== void 0 || A.normal !== void 0 || A.color !== void 0) && Ze.update(i, n, S), (w || v.receiveShadow !== i.receiveShadow) && (v.receiveShadow = i.receiveShadow, O.setValue(P, "receiveShadow", i.receiveShadow)), (r.isMeshStandardMaterial || r.isMeshLambertMaterial || r.isMeshPhongMaterial) && r.envMap === null && t.environment !== null && (k.envMapIntensity.value = t.environmentIntensity), k.dfgLUT !== void 0 && (k.dfgLUT.value = sg()), w) {
if (O.setValue(P, "toneMappingExposure", T.toneMappingExposure), v.needsLights && Ot(k, E), a && r.fog === !0 && Ge.refreshFogUniforms(k, a), Ge.refreshMaterialUniforms(k, r, _e, ge, x.state.transmissionRenderTarget[e.id]), v.needsLights && v.lightProbeGrid) {
let e = v.lightProbeGrid;
k.probesSH.value = e.texture, k.probesMin.value.copy(e.boundingBox.min), k.probesMax.value.copy(e.boundingBox.max), k.probesResolution.value.copy(e.resolution);
}
Bm.upload(P, wt(v), k, ze);
}
if (r.isShaderMaterial && r.uniformsNeedUpdate === !0 && (Bm.upload(P, wt(v), k, ze), r.uniformsNeedUpdate = !1), r.isSpriteMaterial && O.setValue(P, "center", i.center), O.setValue(P, "modelViewMatrix", i.modelViewMatrix), O.setValue(P, "normalMatrix", i.normalMatrix), O.setValue(P, "modelMatrix", i.matrixWorld), r.uniformsGroups !== void 0) {
let e = r.uniformsGroups;
for (let t = 0, n = e.length; t < n; t++) {
let n = e[t];
nt.update(n, S), nt.bind(n, S);
}
}
return S;
}
function Ot(e, t) {
e.ambientLightColor.needsUpdate = t, e.lightProbe.needsUpdate = t, e.directionalLights.needsUpdate = t, e.directionalLightShadows.needsUpdate = t, e.pointLights.needsUpdate = t, e.pointLightShadows.needsUpdate = t, e.spotLights.needsUpdate = t, e.spotLightShadows.needsUpdate = t, e.rectAreaLights.needsUpdate = t, e.hemisphereLights.needsUpdate = t;
}
function kt(e) {
return e.isMeshLambertMaterial || e.isMeshToonMaterial || e.isMeshPhongMaterial || e.isMeshStandardMaterial || e.isShadowMaterial || e.isShaderMaterial && e.lights === !0;
}
this.getActiveCubeFace = function() {
return ee;
}, this.getActiveMipmapLevel = function() {
return te;
}, this.getRenderTarget = function() {
return j;
}, this.setRenderTargetTextures = function(e, t, n) {
let r = I.get(e);
r.__autoAllocateDepthBuffer = e.resolveDepthBuffer === !1, r.__autoAllocateDepthBuffer === !1 && (r.__useRenderToTexture = !1), I.get(e.texture).__webglTexture = t, I.get(e.depthTexture).__webglTexture = r.__autoAllocateDepthBuffer ? void 0 : n, r.__hasExternalTextures = !0;
}, this.setRenderTargetFramebuffer = function(e, t) {
let n = I.get(e);
n.__webglFramebuffer = t, n.__useDefaultFramebuffer = t === void 0;
}, this.setRenderTarget = function(e, t = 0, n = 0) {
j = e, ee = t, te = n;
let r = null, i = !1, a = !1;
if (e) {
let o = I.get(e);
if (o.__useDefaultFramebuffer !== void 0) {
F.bindFramebuffer(P.FRAMEBUFFER, o.__webglFramebuffer), oe.copy(e.viewport), N.copy(e.scissor), fe = e.scissorTest, F.viewport(oe), F.scissor(N), F.setScissorTest(fe), re = -1;
return;
} else if (o.__webglFramebuffer === void 0) ze.setupRenderTarget(e);
else if (o.__hasExternalTextures) ze.rebindTextures(e, I.get(e.texture).__webglTexture, I.get(e.depthTexture).__webglTexture);
else if (e.depthBuffer) {
let t = e.depthTexture;
if (o.__boundDepthTexture !== t) {
if (t !== null && I.has(t) && (e.width !== t.image.width || e.height !== t.image.height)) throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");
ze.setupDepthRenderbuffer(e);
}
}
let s = e.texture;
(s.isData3DTexture || s.isDataArrayTexture || s.isCompressedArrayTexture) && (a = !0);
let c = I.get(e).__webglFramebuffer;
e.isWebGLCubeRenderTarget ? (r = Array.isArray(c[t]) ? c[t][n] : c[t], i = !0) : r = e.samples > 0 && ze.useMultisampledRTT(e) === !1 ? I.get(e).__webglMultisampledFramebuffer : Array.isArray(c) ? c[n] : c, oe.copy(e.viewport), N.copy(e.scissor), fe = e.scissorTest;
} else oe.copy(xe).multiplyScalar(_e).floor(), N.copy(Ce).multiplyScalar(_e).floor(), fe = Te;
if (n !== 0 && (r = O), F.bindFramebuffer(P.FRAMEBUFFER, r) && F.drawBuffers(e, r), F.viewport(oe), F.scissor(N), F.setScissorTest(fe), i) {
let r = I.get(e.texture);
P.framebufferTexture2D(P.FRAMEBUFFER, P.COLOR_ATTACHMENT0, P.TEXTURE_CUBE_MAP_POSITIVE_X + t, r.__webglTexture, n);
} else if (a) {
let r = t;
for (let t = 0; t < e.textures.length; t++) {
let i = I.get(e.textures[t]);
P.framebufferTextureLayer(P.FRAMEBUFFER, P.COLOR_ATTACHMENT0 + t, i.__webglTexture, n, r);
}
} else if (e !== null && n !== 0) {
let t = I.get(e.texture);
P.framebufferTexture2D(P.FRAMEBUFFER, P.COLOR_ATTACHMENT0, P.TEXTURE_2D, t.__webglTexture, n);
}
re = -1;
}, this.readRenderTargetPixels = function(e, t, n, r, i, a, o, s = 0) {
if (!(e && e.isWebGLRenderTarget)) {
R("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
return;
}
let c = I.get(e).__webglFramebuffer;
if (e.isWebGLCubeRenderTarget && o !== void 0 && (c = c[o]), c) {
F.bindFramebuffer(P.FRAMEBUFFER, c);
try {
let o = e.textures[s], c = o.format, l = o.type;
if (e.textures.length > 1 && P.readBuffer(P.COLOR_ATTACHMENT0 + s), !Le.textureFormatReadable(c)) {
R("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
return;
}
if (!Le.textureTypeReadable(l)) {
R("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
return;
}
t >= 0 && t <= e.width - r && n >= 0 && n <= e.height - i && P.readPixels(t, n, r, i, et.convert(c), et.convert(l), a);
} finally {
let e = j === null ? null : I.get(j).__webglFramebuffer;
F.bindFramebuffer(P.FRAMEBUFFER, e);
}
}
}, this.readRenderTargetPixelsAsync = async function(e, t, n, r, i, a, o, s = 0) {
if (!(e && e.isWebGLRenderTarget)) throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
let c = I.get(e).__webglFramebuffer;
if (e.isWebGLCubeRenderTarget && o !== void 0 && (c = c[o]), c) if (t >= 0 && t <= e.width - r && n >= 0 && n <= e.height - i) {
F.bindFramebuffer(P.FRAMEBUFFER, c);
let o = e.textures[s], l = o.format, u = o.type;
if (e.textures.length > 1 && P.readBuffer(P.COLOR_ATTACHMENT0 + s), !Le.textureFormatReadable(l)) throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");
if (!Le.textureTypeReadable(u)) throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");
let d = P.createBuffer();
P.bindBuffer(P.PIXEL_PACK_BUFFER, d), P.bufferData(P.PIXEL_PACK_BUFFER, a.byteLength, P.STREAM_READ), P.readPixels(t, n, r, i, et.convert(l), et.convert(u), 0);
let f = j === null ? null : I.get(j).__webglFramebuffer;
F.bindFramebuffer(P.FRAMEBUFFER, f);
let p = P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE, 0);
return P.flush(), await sn(P, p, 4), P.bindBuffer(P.PIXEL_PACK_BUFFER, d), P.getBufferSubData(P.PIXEL_PACK_BUFFER, 0, a), P.deleteBuffer(d), P.deleteSync(p), a;
} else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.");
}, this.copyFramebufferToTexture = function(e, t = null, n = 0) {
let r = 2 ** -n, i = Math.floor(e.image.width * r), a = Math.floor(e.image.height * r), o = t === null ? 0 : t.x, s = t === null ? 0 : t.y;
ze.setTexture2D(e, 0), P.copyTexSubImage2D(P.TEXTURE_2D, n, 0, 0, o, s, i, a), F.unbindTexture();
}, this.copyTextureToTexture = function(e, t, n = null, r = null, i = 0, a = 0) {
let o, s, c, l, u, d, f, p, m, h = e.isCompressedTexture ? e.mipmaps[a] : e.image;
if (n !== null) o = n.max.x - n.min.x, s = n.max.y - n.min.y, c = n.isBox3 ? n.max.z - n.min.z : 1, l = n.min.x, u = n.min.y, d = n.isBox3 ? n.min.z : 0;
else {
let t = 2 ** -i;
o = Math.floor(h.width * t), s = Math.floor(h.height * t), c = e.isDataArrayTexture ? h.depth : e.isData3DTexture ? Math.floor(h.depth * t) : 1, l = 0, u = 0, d = 0;
}
r === null ? (f = 0, p = 0, m = 0) : (f = r.x, p = r.y, m = r.z);
let g = et.convert(t.format), _ = et.convert(t.type), v;
t.isData3DTexture ? (ze.setTexture3D(t, 0), v = P.TEXTURE_3D) : t.isDataArrayTexture || t.isCompressedArrayTexture ? (ze.setTexture2DArray(t, 0), v = P.TEXTURE_2D_ARRAY) : (ze.setTexture2D(t, 0), v = P.TEXTURE_2D), F.activeTexture(P.TEXTURE0), F.pixelStorei(P.UNPACK_FLIP_Y_WEBGL, t.flipY), F.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL, t.premultiplyAlpha), F.pixelStorei(P.UNPACK_ALIGNMENT, t.unpackAlignment);
let y = F.getParameter(P.UNPACK_ROW_LENGTH), b = F.getParameter(P.UNPACK_IMAGE_HEIGHT), x = F.getParameter(P.UNPACK_SKIP_PIXELS), S = F.getParameter(P.UNPACK_SKIP_ROWS), C = F.getParameter(P.UNPACK_SKIP_IMAGES);
F.pixelStorei(P.UNPACK_ROW_LENGTH, h.width), F.pixelStorei(P.UNPACK_IMAGE_HEIGHT, h.height), F.pixelStorei(P.UNPACK_SKIP_PIXELS, l), F.pixelStorei(P.UNPACK_SKIP_ROWS, u), F.pixelStorei(P.UNPACK_SKIP_IMAGES, d);
let w = e.isDataArrayTexture || e.isData3DTexture, T = t.isDataArrayTexture || t.isData3DTexture;
if (e.isDepthTexture) {
let n = I.get(e), r = I.get(t), h = I.get(n.__renderTarget), g = I.get(r.__renderTarget);
F.bindFramebuffer(P.READ_FRAMEBUFFER, h.__webglFramebuffer), F.bindFramebuffer(P.DRAW_FRAMEBUFFER, g.__webglFramebuffer);
for (let n = 0; n < c; n++) w && (P.framebufferTextureLayer(P.READ_FRAMEBUFFER, P.COLOR_ATTACHMENT0, I.get(e).__webglTexture, i, d + n), P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER, P.COLOR_ATTACHMENT0, I.get(t).__webglTexture, a, m + n)), P.blitFramebuffer(l, u, o, s, f, p, o, s, P.DEPTH_BUFFER_BIT, P.NEAREST);
F.bindFramebuffer(P.READ_FRAMEBUFFER, null), F.bindFramebuffer(P.DRAW_FRAMEBUFFER, null);
} else if (i !== 0 || e.isRenderTargetTexture || I.has(e)) {
let n = I.get(e), r = I.get(t);
F.bindFramebuffer(P.READ_FRAMEBUFFER, k), F.bindFramebuffer(P.DRAW_FRAMEBUFFER, A);
for (let e = 0; e < c; e++) w ? P.framebufferTextureLayer(P.READ_FRAMEBUFFER, P.COLOR_ATTACHMENT0, n.__webglTexture, i, d + e) : P.framebufferTexture2D(P.READ_FRAMEBUFFER, P.COLOR_ATTACHMENT0, P.TEXTURE_2D, n.__webglTexture, i), T ? P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER, P.COLOR_ATTACHMENT0, r.__webglTexture, a, m + e) : P.framebufferTexture2D(P.DRAW_FRAMEBUFFER, P.COLOR_ATTACHMENT0, P.TEXTURE_2D, r.__webglTexture, a), i === 0 ? T ? P.copyTexSubImage3D(v, a, f, p, m + e, l, u, o, s) : P.copyTexSubImage2D(v, a, f, p, l, u, o, s) : P.blitFramebuffer(l, u, o, s, f, p, o, s, P.COLOR_BUFFER_BIT, P.NEAREST);
F.bindFramebuffer(P.READ_FRAMEBUFFER, null), F.bindFramebuffer(P.DRAW_FRAMEBUFFER, null);
} else T ? e.isDataTexture || e.isData3DTexture ? P.texSubImage3D(v, a, f, p, m, o, s, c, g, _, h.data) : t.isCompressedArrayTexture ? P.compressedTexSubImage3D(v, a, f, p, m, o, s, c, g, h.data) : P.texSubImage3D(v, a, f, p, m, o, s, c, g, _, h) : e.isDataTexture ? P.texSubImage2D(P.TEXTURE_2D, a, f, p, o, s, g, _, h.data) : e.isCompressedTexture ? P.compressedTexSubImage2D(P.TEXTURE_2D, a, f, p, h.width, h.height, g, h.data) : P.texSubImage2D(P.TEXTURE_2D, a, f, p, o, s, g, _, h);
F.pixelStorei(P.UNPACK_ROW_LENGTH, y), F.pixelStorei(P.UNPACK_IMAGE_HEIGHT, b), F.pixelStorei(P.UNPACK_SKIP_PIXELS, x), F.pixelStorei(P.UNPACK_SKIP_ROWS, S), F.pixelStorei(P.UNPACK_SKIP_IMAGES, C), a === 0 && t.generateMipmaps && P.generateMipmap(v), F.unbindTexture();
}, this.initRenderTarget = function(e) {
I.get(e).__webglFramebuffer === void 0 && ze.setupRenderTarget(e);
}, this.initTexture = function(e) {
e.isCubeTexture ? ze.setTextureCube(e, 0) : e.isData3DTexture ? ze.setTexture3D(e, 0) : e.isDataArrayTexture || e.isCompressedArrayTexture ? ze.setTexture2DArray(e, 0) : ze.setTexture2D(e, 0), F.unbindTexture();
}, this.resetState = function() {
ee = 0, te = 0, j = null, F.reset(), tt.reset();
}, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
}
get coordinateSystem() {
return Vt;
}
get outputColorSpace() {
return this._outputColorSpace;
}
set outputColorSpace(e) {
this._outputColorSpace = e;
let t = this.getContext();
t.drawingBufferColorSpace = Hn._getDrawingBufferColorSpace(e), t.unpackColorSpace = Hn._getUnpackColorSpace();
}
}, lg = /* @__PURE__ */ n(((e) => {
var t = r().__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
e.c = function(e) {
return t.H.useMemoCache(e);
};
})), ug = /* @__PURE__ */ n(((e, t) => {
t.exports = lg();
})), dg = /* @__PURE__ */ n(((e) => {
var t = r(), n = s();
function i(e, t) {
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
}
var a = typeof Object.is == "function" ? Object.is : i, o = n.useSyncExternalStore, c = t.useRef, l = t.useEffect, u = t.useMemo, d = t.useDebugValue;
e.useSyncExternalStoreWithSelector = function(e, t, n, r, i) {
var s = c(null);
if (s.current === null) {
var f = {
hasValue: !1,
value: null
};
s.current = f;
} else f = s.current;
s = u(function() {
function e(e) {
if (!o) {
if (o = !0, s = e, e = r(e), i !== void 0 && f.hasValue) {
var t = f.value;
if (i(t, e)) return c = t;
}
return c = e;
}
if (t = c, a(s, e)) return t;
var n = r(e);
return i !== void 0 && i(t, n) ? (s = e, t) : (s = e, c = n);
}
var o = !1, s, c, l = n === void 0 ? null : n;
return [function() {
return e(t());
}, l === null ? void 0 : function() {
return e(l());
}];
}, [
t,
n,
r,
i
]);
var p = o(e, s[0], s[1]);
return l(function() {
f.hasValue = !0, f.value = p;
}, [p]), d(p), p;
};
})), fg = /* @__PURE__ */ t((/* @__PURE__ */ n(((e, t) => {
t.exports = dg();
})))(), 1), pg = (e) => {
let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
let i = typeof e == "function" ? e(t) : e;
if (!Object.is(i, t)) {
let e = t;
t = (r == null ? typeof i != "object" || !i : r) ? i : Object.assign({}, t, i), n.forEach((n) => n(t, e));
}
}, i = () => t, a = {
setState: r,
getState: i,
getInitialState: () => o,
subscribe: (e) => (n.add(e), () => n.delete(e))
}, o = t = e(r, i, a);
return a;
}, mg = ((e) => e ? pg(e) : pg), { useSyncExternalStoreWithSelector: hg } = fg.default, gg = (e) => e;
function _g(e, t = gg, n) {
let r = hg(e.subscribe, e.getState, e.getInitialState, t, n);
return c.useDebugValue(r), r;
}
var vg = (e, t) => {
let n = mg(e), r = (e, r = t) => _g(n, e, r);
return Object.assign(r, n), r;
}, yg = ((e, t) => e ? vg(e, t) : vg), bg = (e) => typeof e == "object" && typeof e.then == "function", xg = [];
function Sg(e, t, n = (e, t) => e === t) {
if (e === t) return !0;
if (!e || !t) return !1;
let r = e.length;
if (t.length !== r) return !1;
for (let i = 0; i < r; i++) if (!n(e[i], t[i])) return !1;
return !0;
}
function Cg(e, t = null, n = !1, r = {}) {
t === null && (t = [e]);
for (let e of xg) if (Sg(t, e.keys, e.equal)) {
if (n) return;
if (Object.prototype.hasOwnProperty.call(e, "error")) throw e.error;
if (Object.prototype.hasOwnProperty.call(e, "response")) return r.lifespan && r.lifespan > 0 && (e.timeout && clearTimeout(e.timeout), e.timeout = setTimeout(e.remove, r.lifespan)), e.response;
if (!n) throw e.promise;
}
let i = {
keys: t,
equal: r.equal,
remove: () => {
let e = xg.indexOf(i);
e !== -1 && xg.splice(e, 1);
},
promise: (bg(e) ? e : e(...t)).then((e) => {
i.response = e, r.lifespan && r.lifespan > 0 && (i.timeout = setTimeout(i.remove, r.lifespan));
}).catch((e) => i.error = e)
};
if (xg.push(i), !n) throw i.promise;
}
var wg = (e, t, n) => Cg(e, t, !1, n), Tg = (e, t, n) => void Cg(e, t, !0, n), Eg = (e) => {
if (e === void 0 || e.length === 0) xg.splice(0, xg.length);
else {
let t = xg.find((t) => Sg(e, t.keys, t.equal));
t && t.remove();
}
}, Dg = i(), Og = /* @__PURE__ */ t(a());
/* @__PURE__ */ (() => {
var e, t;
return typeof window < "u" && (((e = window.document) == null ? void 0 : e.createElement) || ((t = window.navigator) == null ? void 0 : t.product) === "ReactNative");
})() ? c.useLayoutEffect : c.useEffect;
function kg(e, t, n) {
if (!e) return;
if (n(e) === !0) return e;
let r = t ? e.return : e.child;
for (; r;) {
let e = kg(r, t, n);
if (e) return e;
r = t ? null : r.sibling;
}
}
function Ag(e) {
try {
return Object.defineProperties(e, {
_currentRenderer: {
get() {
return null;
},
set() {}
},
_currentRenderer2: {
get() {
return null;
},
set() {}
}
});
} catch {
return e;
}
}
var jg = /* @__PURE__ */ Ag(/* @__PURE__ */ c.createContext(null)), Mg = class extends c.Component {
render() {
return /* @__PURE__ */ c.createElement(jg.Provider, { value: this._reactInternals }, this.props.children);
}
};
function Ng() {
let e = c.useContext(jg);
if (e === null) throw Error("its-fine: useFiber must be called within a <FiberProvider />!");
let t = c.useId();
return c.useMemo(() => {
for (let n of [e, e == null ? void 0 : e.alternate]) {
if (!n) continue;
let e = kg(n, !1, (e) => {
let n = e.memoizedState;
for (; n;) {
if (n.memoizedState === t) return !0;
n = n.next;
}
});
if (e) return e;
}
}, [e, t]);
}
var Pg = Symbol.for("react.context"), Fg = (e) => typeof e == "object" && !!e && "$$typeof" in e && e.$$typeof === Pg;
function Ig() {
let e = Ng(), [t] = c.useState(() => /* @__PURE__ */ new Map());
t.clear();
let n = e;
for (; n;) {
let e = n.type;
Fg(e) && e !== jg && !t.has(e) && t.set(e, c.use(Ag(e))), n = n.return;
}
return t;
}
function Lg() {
let e = Ig();
return c.useMemo(() => Array.from(e.keys()).reduce((t, n) => (r) => /* @__PURE__ */ c.createElement(t, null, /* @__PURE__ */ c.createElement(n.Provider, {
...r,
value: e.get(n)
})), (e) => /* @__PURE__ */ c.createElement(Mg, { ...e })), [e]);
}
//#endregion
//#region ../../node_modules/.pnpm/@react-three+fiber@9.7.0_@types+react@19.2.17_react-dom@19.2.8_react@19.2.8__react@19.2.8_three@0.185.1/node_modules/@react-three/fiber/dist/events-156d8d12.esm.js
function Rg(e) {
let t = e.root;
for (; t.getState().previousRoot;) t = t.getState().previousRoot;
return t;
}
var zg = (e) => e && e.isOrthographicCamera, Bg = (e) => e && e.hasOwnProperty("current"), Vg = (e) => e != null && (typeof e == "string" || typeof e == "number" || e.isColor), Hg = /* @__PURE__ */ ((e, t) => typeof window < "u" && (((e = window.document) == null ? void 0 : e.createElement) || ((t = window.navigator) == null ? void 0 : t.product) === "ReactNative"))() ? c.useLayoutEffect : c.useEffect;
function Ug(e) {
let t = c.useRef(e);
return Hg(() => void (t.current = e), [e]), t;
}
function Wg() {
let e = Ng(), t = Lg();
return c.useMemo(() => ({ children: n }) => /*#__PURE__*/ (0, Dg.jsx)(kg(e, !0, (e) => e.type === c.StrictMode) ? c.StrictMode : c.Fragment, { children: /*#__PURE__*/ (0, Dg.jsx)(t, { children: n }) }), [e, t]);
}
function Gg({ set: e }) {
return Hg(() => (e(new Promise(() => null)), () => e(!1)), [e]), null;
}
var Kg = /* @__PURE__ */ ((e) => (e = class extends c.Component {
constructor(...e) {
super(...e), this.state = { error: !1 };
}
componentDidCatch(e) {
this.props.set(e);
}
render() {
return this.state.error ? null : this.props.children;
}
}, e.getDerivedStateFromError = () => ({ error: !0 }), e))();
function qg(e) {
var t;
let n = typeof window < "u" ? (t = window.devicePixelRatio) == null ? 2 : t : 1;
return Array.isArray(e) ? Math.min(Math.max(e[0], n), e[1]) : e;
}
function Jg(e) {
var t;
return (t = e.__r3f) == null ? void 0 : t.root.getState();
}
var Yg = {
obj: (e) => e === Object(e) && !Yg.arr(e) && typeof e != "function",
fun: (e) => typeof e == "function",
str: (e) => typeof e == "string",
num: (e) => typeof e == "number",
boo: (e) => typeof e == "boolean",
und: (e) => e === void 0,
nul: (e) => e === null,
arr: (e) => Array.isArray(e),
equ(e, t, { arrays: n = "shallow", objects: r = "reference", strict: i = !0 } = {}) {
if (typeof e != typeof t || !!e != !!t) return !1;
if (Yg.str(e) || Yg.num(e) || Yg.boo(e)) return e === t;
let a = Yg.obj(e);
if (a && r === "reference") return e === t;
let o = Yg.arr(e);
if (o && n === "reference") return e === t;
if ((o || a) && e === t) return !0;
let s;
for (s in e) if (!(s in t)) return !1;
if (a && n === "shallow" && r === "shallow") {
for (s in i ? t : e) if (!Yg.equ(e[s], t[s], {
strict: i,
objects: "reference"
})) return !1;
} else for (s in i ? t : e) if (e[s] !== t[s]) return !1;
if (Yg.und(s)) {
if (o && e.length === 0 && t.length === 0 || a && Object.keys(e).length === 0 && Object.keys(t).length === 0) return !0;
if (e !== t) return !1;
}
return !0;
}
};
function Xg(e) {
let t = {
nodes: {},
materials: {},
meshes: {}
};
return e && e.traverse((e) => {
e.name && (t.nodes[e.name] = e), e.material && !t.materials[e.material.name] && (t.materials[e.material.name] = e.material), e.isMesh && !t.meshes[e.name] && (t.meshes[e.name] = e);
}), t;
}
function Zg(e) {
e.type !== "Scene" && (e.dispose == null || e.dispose());
for (let t in e) {
let n = e[t];
(n == null ? void 0 : n.type) !== "Scene" && (n == null || n.dispose == null || n.dispose());
}
}
var Qg = [
"children",
"key",
"ref"
];
function $g(e) {
let t = {};
for (let n in e) Qg.includes(n) || (t[n] = e[n]);
return t;
}
function e_(e, t, n, r) {
let i = e, a = i == null ? void 0 : i.__r3f;
return a || (a = {
root: t,
type: n,
parent: null,
children: [],
props: $g(r),
object: i,
eventCount: 0,
handlers: {},
isHidden: !1
}, i && (i.__r3f = a)), a;
}
function t_(e, t) {
if (!t.includes("-") || t in e) return {
root: e,
key: t,
target: e[t]
};
let n = e, r = t.split("-");
for (let i of r) {
if (typeof n != "object" || !n) {
if (n !== void 0) {
let e = r.slice(r.indexOf(i)).join("-");
return {
root: n,
key: e,
target: void 0
};
}
return {
root: e,
key: t,
target: void 0
};
}
t = i, e = n, n = n[t];
}
return {
root: e,
key: t,
target: n
};
}
var n_ = /-\d+$/;
function r_(e, t) {
if (Yg.str(t.props.attach)) {
if (n_.test(t.props.attach)) {
let n = t.props.attach.replace(n_, ""), { root: r, key: i } = t_(e.object, n);
Array.isArray(r[i]) || (r[i] = []);
}
let { root: n, key: r } = t_(e.object, t.props.attach);
t.previousAttach = n[r], n[r] = t.object;
} else Yg.fun(t.props.attach) && (t.previousAttach = t.props.attach(e.object, t.object));
}
function i_(e, t) {
if (Yg.str(t.props.attach)) {
let { root: n, key: r } = t_(e.object, t.props.attach), i = t.previousAttach;
i === void 0 ? delete n[r] : n[r] = i;
} else t.previousAttach == null || t.previousAttach(e.object, t.object);
delete t.previousAttach;
}
var a_ = [
...Qg,
"args",
"dispose",
"attach",
"object",
"onUpdate",
"dispose"
], o_ = /* @__PURE__ */ new Map();
function s_(e) {
let t = o_.get(e.constructor);
try {
t || (t = new e.constructor(), o_.set(e.constructor, t));
} catch {}
return t;
}
function c_(e, t) {
let n = {};
for (let r in t) if (!a_.includes(r) && !Yg.equ(t[r], e.props[r])) {
n[r] = t[r];
for (let e in t) e.startsWith(`${r}-`) && (n[e] = t[e]);
}
for (let r in e.props) {
if (a_.includes(r) || t.hasOwnProperty(r)) continue;
let { root: i, key: a } = t_(e.object, r);
if (i.constructor && i.constructor.length === 0) {
let e = s_(i);
Yg.und(e) || (n[r] = e[a]);
} else n[r] = 0;
}
return n;
}
var l_ = [
"map",
"emissiveMap",
"sheenColorMap",
"specularColorMap",
"envMap"
], u_ = /^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;
function d_(e, t) {
var n;
let r = e.__r3f, i = r && Rg(r).getState(), a = r == null ? void 0 : r.eventCount;
for (let n in t) {
let a = t[n];
if (a_.includes(n)) continue;
if (r && u_.test(n)) {
typeof a == "function" ? r.handlers[n] = a : delete r.handlers[n], r.eventCount = Object.keys(r.handlers).length;
continue;
}
if (a === void 0) continue;
let { root: s, key: c, target: l } = t_(e, n);
if (l === void 0 && (typeof s != "object" || !s)) throw Error(`R3F: Cannot set "${n}". Ensure it is an object before setting "${c}".`);
if (l instanceof gr && a instanceof gr) l.mask = a.mask;
else if (l instanceof G && Vg(a)) l.set(a);
else if (typeof l == "object" && l && typeof l.set == "function" && typeof l.copy == "function" && a != null && a.constructor && l.constructor === a.constructor) l.copy(a);
else if (typeof l == "object" && l && typeof l.set == "function" && Array.isArray(a)) typeof l.fromArray == "function" ? l.fromArray(a) : l.set(...a);
else if (typeof l == "object" && l && typeof l.set == "function" && typeof a == "number") typeof l.setScalar == "function" ? l.setScalar(a) : l.set(a);
else if (s instanceof _l && c === "uniforms" && Yg.obj(a)) {
Yg.obj(s.uniforms) || (s.uniforms = {});
let e = s.uniforms, t = a;
for (let n in t) {
let r = t[n], i = e[n];
i ? Object.assign(i, r) : e[n] = { ...r };
}
} else {
var o;
s[c] = a, i && !i.linear && l_.includes(c) && (o = s[c]) != null && o.isTexture && s[c].format === 1023 && s[c].type === 1009 && (s[c].colorSpace = bt);
}
}
if (r != null && r.parent && i != null && i.internal && (n = r.object) != null && n.isObject3D && a !== r.eventCount) {
let e = r.object, t = i.internal.interaction.indexOf(e);
t > -1 && i.internal.interaction.splice(t, 1), r.eventCount && e.raycast !== null && i.internal.interaction.push(e);
}
return r && r.props.attach === void 0 && (r.object.isBufferGeometry ? r.props.attach = "geometry" : r.object.isMaterial && (r.props.attach = "material")), r && f_(r), e;
}
function f_(e) {
var t;
if (!e.parent) return;
e.props.onUpdate == null || e.props.onUpdate(e.object);
let n = (t = e.root) == null || t.getState == null ? void 0 : t.getState();
n && n.internal.frames === 0 && n.invalidate();
}
function p_(e, t) {
e.manual || (zg(e) ? (e.left = t.width / -2, e.right = t.width / 2, e.top = t.height / 2, e.bottom = t.height / -2) : e.aspect = t.width / t.height, e.updateProjectionMatrix());
}
var m_ = (e) => e == null ? void 0 : e.isObject3D;
function h_(e) {
return (e.eventObject || e.object).uuid + "/" + e.index + e.instanceId;
}
function g_(e, t, n, r) {
let i = n.get(t);
i && (n.delete(t), n.size === 0 && (e.delete(r), i.target.releasePointerCapture(r)));
}
function __(e, t, n) {
let { internal: r } = e.getState();
for (let e = 0; e < r.interaction.length; e++) r.interaction[e] === t && (r.interaction[e] = n);
for (let e = 0; e < r.initialHits.length; e++) r.initialHits[e] === t && (r.initialHits[e] = n);
r.hovered.forEach((e, i) => {
if (e.eventObject === t || e.object === t) {
r.hovered.delete(i);
let a = {
...e,
eventObject: e.eventObject === t ? n : e.eventObject,
object: e.object === t ? n : e.object
};
r.hovered.set(h_(a), a);
}
}), r.capturedMap.forEach((e) => {
let r = e.get(t);
r && (e.delete(t), e.set(n, r));
});
}
function v_(e, t) {
let { internal: n } = e.getState();
n.interaction = n.interaction.filter((e) => e !== t), n.initialHits = n.initialHits.filter((e) => e !== t), n.hovered.forEach((e, r) => {
(e.eventObject === t || e.object === t) && n.hovered.delete(r);
}), n.capturedMap.forEach((e, r) => {
g_(n.capturedMap, t, e, r);
});
}
function y_(e) {
function t(t) {
let { internal: n } = e.getState(), r = t.offsetX - n.initialClick[0], i = t.offsetY - n.initialClick[1];
return Math.round(Math.sqrt(r * r + i * i));
}
function n(e) {
return e.filter((e) => [
"Move",
"Over",
"Enter",
"Out",
"Leave"
].some((t) => {
var n;
return (n = e.__r3f) == null ? void 0 : n.handlers["onPointer" + t];
}));
}
function r(t, n) {
let r = e.getState(), i = /* @__PURE__ */ new Set(), a = [], o = n ? n(r.internal.interaction) : r.internal.interaction;
for (let e = 0; e < o.length; e++) {
let t = Jg(o[e]);
t && (t.raycaster.camera = void 0);
}
r.previousRoot || r.events.compute == null || r.events.compute(t, r);
function s(e) {
let n = Jg(e);
if (!n || !n.events.enabled || n.raycaster.camera === null) return [];
if (n.raycaster.camera === void 0) {
var r;
n.events.compute == null || n.events.compute(t, n, (r = n.previousRoot) == null ? void 0 : r.getState()), n.raycaster.camera === void 0 && (n.raycaster.camera = null);
}
return n.raycaster.camera ? n.raycaster.intersectObject(e, !0) : [];
}
let c = o.flatMap(s).sort((e, t) => {
let n = Jg(e.object), r = Jg(t.object);
return !n || !r ? e.distance - t.distance : r.events.priority - n.events.priority || e.distance - t.distance;
}).filter((e) => {
let t = h_(e);
return i.has(t) ? !1 : (i.add(t), !0);
});
r.events.filter && (c = r.events.filter(c, r));
for (let e of c) {
let t = e.object;
for (; t;) {
var l;
(l = t.__r3f) != null && l.eventCount && a.push({
...e,
eventObject: t
}), t = t.parent;
}
}
if ("pointerId" in t && r.internal.capturedMap.has(t.pointerId)) for (let e of r.internal.capturedMap.get(t.pointerId).values()) i.has(h_(e.intersection)) || a.push(e.intersection);
return a;
}
function i(e, t, n, r) {
if (e.length) {
let i = { stopped: !1 };
for (let o of e) {
let s = Jg(o.object);
if (s || o.object.traverseAncestors((e) => {
let t = Jg(e);
if (t) return s = t, !1;
}), s) {
let { raycaster: c, pointer: l, camera: u, internal: d } = s, f = new H(l.x, l.y, 0).unproject(u), p = (e) => {
var t, n;
return (t = (n = d.capturedMap.get(e)) == null ? void 0 : n.has(o.eventObject)) != null && t;
}, m = (e) => {
let n = {
intersection: o,
target: t.target
};
d.capturedMap.has(e) ? d.capturedMap.get(e).set(o.eventObject, n) : d.capturedMap.set(e, /* @__PURE__ */ new Map([[o.eventObject, n]])), t.target.setPointerCapture(e);
}, h = (e) => {
let t = d.capturedMap.get(e);
t && g_(d.capturedMap, o.eventObject, t, e);
}, g = {};
for (let e in t) {
let n = t[e];
typeof n != "function" && (g[e] = n);
}
let _ = {
...o,
...g,
pointer: l,
intersections: e,
stopped: i.stopped,
delta: n,
unprojectedPoint: f,
ray: c.ray,
camera: u,
stopPropagation() {
let n = "pointerId" in t && d.capturedMap.get(t.pointerId);
(!n || n.has(o.eventObject)) && (_.stopped = i.stopped = !0, d.hovered.size && Array.from(d.hovered.values()).find((e) => e.eventObject === o.eventObject) && a([...e.slice(0, e.indexOf(o)), o]));
},
target: {
hasPointerCapture: p,
setPointerCapture: m,
releasePointerCapture: h
},
currentTarget: {
hasPointerCapture: p,
setPointerCapture: m,
releasePointerCapture: h
},
nativeEvent: t
};
if (r(_), i.stopped === !0) break;
}
}
}
return e;
}
function a(t) {
let { internal: n } = e.getState();
for (let e of n.hovered.values()) if (!t.length || !t.find((t) => t.object === e.object && t.index === e.index && t.instanceId === e.instanceId)) {
let r = e.eventObject.__r3f;
if (n.hovered.delete(h_(e)), r != null && r.eventCount) {
let n = r.handlers, i = {
...e,
intersections: t
};
n.onPointerOut == null || n.onPointerOut(i), n.onPointerLeave == null || n.onPointerLeave(i);
}
}
}
function o(e, t) {
for (let n = 0; n < t.length; n++) {
let r = t[n].__r3f;
r == null || r.handlers.onPointerMissed == null || r.handlers.onPointerMissed(e);
}
}
function s(s) {
switch (s) {
case "onPointerLeave":
case "onPointerCancel": return () => a([]);
case "onLostPointerCapture": return (t) => {
let { internal: n } = e.getState();
"pointerId" in t && n.capturedMap.has(t.pointerId) && requestAnimationFrame(() => {
n.capturedMap.has(t.pointerId) && (n.capturedMap.delete(t.pointerId), a([]));
});
};
}
return function(c) {
let { onPointerMissed: l, internal: u } = e.getState();
u.lastEvent.current = c;
let d = s === "onPointerMove", f = s === "onClick" || s === "onContextMenu" || s === "onDoubleClick", p = r(c, d ? n : void 0), m = f ? t(c) : 0;
s === "onPointerDown" && (u.initialClick = [c.offsetX, c.offsetY], u.initialHits = p.map((e) => e.eventObject)), f && !p.length && m <= 2 && (o(c, u.interaction), l && l(c)), d && a(p);
function h(e) {
let t = e.eventObject, n = t.__r3f;
if (!(n != null && n.eventCount)) return;
let r = n.handlers;
if (d) {
if (r.onPointerOver || r.onPointerEnter || r.onPointerOut || r.onPointerLeave) {
let t = h_(e), n = u.hovered.get(t);
n ? n.stopped && e.stopPropagation() : (u.hovered.set(t, e), r.onPointerOver == null || r.onPointerOver(e), r.onPointerEnter == null || r.onPointerEnter(e));
}
r.onPointerMove == null || r.onPointerMove(e);
} else {
let n = r[s];
n ? (!f || u.initialHits.includes(t)) && (o(c, u.interaction.filter((e) => !u.initialHits.includes(e))), n(e)) : f && u.initialHits.includes(t) && o(c, u.interaction.filter((e) => !u.initialHits.includes(e)));
}
}
i(p, c, m, h);
};
}
return { handlePointer: s };
}
var b_ = (e) => !!(e != null && e.render), x_ = /* @__PURE__ */ c.createContext(null), S_ = (e, t) => {
let n = yg((n, r) => {
let i = new H(), a = new H(), o = new H();
function s(e = r().camera, t = a, n = r().size) {
let { width: s, height: c, top: l, left: u } = n, d = s / c;
t.isVector3 ? o.copy(t) : o.set(...t);
let f = e.getWorldPosition(i).distanceTo(o);
if (zg(e)) return {
width: s / e.zoom,
height: c / e.zoom,
top: l,
left: u,
factor: 1,
distance: f,
aspect: d
};
{
let t = e.fov * Math.PI / 180, n = 2 * Math.tan(t / 2) * f, r = s / c * n;
return {
width: r,
height: n,
top: l,
left: u,
factor: s / r,
distance: f,
aspect: d
};
}
}
let l, u = (e) => n((t) => ({ performance: {
...t.performance,
current: e
} })), d = new V();
return {
set: n,
get: r,
gl: null,
camera: null,
raycaster: null,
events: {
priority: 1,
enabled: !0,
connected: !1
},
scene: null,
xr: null,
invalidate: (t = 1) => e(r(), t),
advance: (e, n) => t(e, n, r()),
legacy: !1,
linear: !1,
flat: !1,
controls: null,
clock: new Kd(),
pointer: d,
mouse: d,
frameloop: "always",
onPointerMissed: void 0,
performance: {
current: 1,
min: .5,
max: 1,
debounce: 200,
regress: () => {
let e = r();
l && clearTimeout(l), e.performance.current !== e.performance.min && u(e.performance.min), l = setTimeout(() => u(r().performance.max), e.performance.debounce);
}
},
size: {
width: 0,
height: 0,
top: 0,
left: 0
},
viewport: {
initialDpr: 0,
dpr: 0,
width: 0,
height: 0,
top: 0,
left: 0,
aspect: 0,
distance: 0,
factor: 0,
getCurrentViewport: s
},
setEvents: (e) => n((t) => ({
...t,
events: {
...t.events,
...e
}
})),
setSize: (e, t, i = 0, o = 0) => {
let c = r().camera, l = {
width: e,
height: t,
top: i,
left: o
};
n((e) => ({
size: l,
viewport: {
...e.viewport,
...s(c, a, l)
}
}));
},
setDpr: (e) => n((t) => {
let n = qg(e);
return { viewport: {
...t.viewport,
dpr: n,
initialDpr: t.viewport.initialDpr || n
} };
}),
setFrameloop: (e = "always") => {
let t = r().clock;
t.stop(), t.elapsedTime = 0, e !== "never" && (t.start(), t.elapsedTime = 0), n(() => ({ frameloop: e }));
},
previousRoot: void 0,
internal: {
interaction: [],
hovered: /* @__PURE__ */ new Map(),
subscribers: [],
initialClick: [0, 0],
initialHits: [],
capturedMap: /* @__PURE__ */ new Map(),
lastEvent: /*#__PURE__*/ c.createRef(),
active: !1,
frames: 0,
priority: 0,
subscribe: (e, t, n) => {
let i = r().internal;
return i.priority += +(t > 0), i.subscribers.push({
ref: e,
priority: t,
store: n
}), i.subscribers = i.subscribers.sort((e, t) => e.priority - t.priority), () => {
let n = r().internal;
n != null && n.subscribers && (n.priority -= +(t > 0), n.subscribers = n.subscribers.filter((t) => t.ref !== e));
};
}
}
};
}), r = n.getState(), i = r.size, a = r.viewport.dpr, o = r.camera;
return n.subscribe(() => {
let { camera: e, size: t, viewport: r, gl: s, set: c } = n.getState();
if (t.width !== i.width || t.height !== i.height || r.dpr !== a) {
i = t, a = r.dpr, p_(e, t), r.dpr > 0 && s.setPixelRatio(r.dpr);
let n = typeof HTMLCanvasElement < "u" && s.domElement instanceof HTMLCanvasElement;
s.setSize(t.width, t.height, n);
}
e !== o && (o = e, c((t) => ({ viewport: {
...t.viewport,
...t.viewport.getCurrentViewport(e)
} })));
}), n.subscribe((t) => e(t)), n;
};
function C_() {
let e = c.useContext(x_);
if (!e) throw Error("R3F: Hooks can only be used within the Canvas component!");
return e;
}
function w_(e = (e) => e, t) {
return C_()(e, t);
}
function T_(e, t = 0) {
let n = C_(), r = n.getState().internal.subscribe, i = Ug(e);
return Hg(() => r(i, t, n), [
t,
r,
n
]), null;
}
var E_ = /* @__PURE__ */ new WeakMap(), D_ = (e) => {
var t;
return typeof e == "function" && (e == null || (t = e.prototype) == null ? void 0 : t.constructor) === e;
};
function O_(e, t) {
return function(n, ...r) {
let i;
return D_(n) ? (i = E_.get(n), i || (i = new n(), E_.set(n, i))) : i = n, e && e(i), Promise.all(r.map((e) => new Promise((n, r) => i.load(e, (e) => {
m_(e == null ? void 0 : e.scene) && Object.assign(e, Xg(e.scene)), n(e);
}, t, (t) => r(/* @__PURE__ */ Error(`Could not load ${e}: ${t == null ? void 0 : t.message}`))))));
};
}
function k_(e, t, n, r) {
let i = Array.isArray(t) ? t : [t], a = wg(O_(n, r), [e, ...i], { equal: Yg.equ });
return Array.isArray(t) ? a : a[0];
}
k_.preload = function(e, t, n) {
let r = Array.isArray(t) ? t : [t];
return Tg(O_(n), [e, ...r]);
}, k_.clear = function(e, t) {
return Eg([e, ...Array.isArray(t) ? t : [t]]);
};
var A_ = 1, j_ = 8, M_ = 32, N_ = 2, P_ = 268435456, F_ = {
name: "@react-three/fiber",
version: "9.7.0",
description: "A React renderer for Threejs",
keywords: [
"react",
"renderer",
"fiber",
"three",
"threejs"
],
author: "Paul Henschel (https://github.com/drcmda)",
license: "MIT",
maintainers: [
"Josh Ellis (https://github.com/joshuaellis)",
"Cody Bennett (https://github.com/codyjasonbennett)",
"Kris Baumgarter (https://github.com/krispya)"
],
bugs: { url: "https://github.com/pmndrs/react-three-fiber/issues" },
homepage: "https://github.com/pmndrs/react-three-fiber#readme",
repository: {
type: "git",
url: "git+https://github.com/pmndrs/react-three-fiber.git"
},
collective: {
type: "opencollective",
url: "https://opencollective.com/react-three-fiber"
},
main: "dist/react-three-fiber.cjs.js",
module: "dist/react-three-fiber.esm.js",
types: "dist/react-three-fiber.cjs.d.ts",
"react-native": "native/dist/react-three-fiber-native.cjs.js",
sideEffects: !1,
preconstruct: { entrypoints: ["index.tsx", "native.tsx"] },
scripts: { prebuild: "cp ../../readme.md readme.md" },
devDependencies: {
"@types/react-reconciler": "^0.32.3",
"react-reconciler": "^0.33.0"
},
dependencies: {
"@babel/runtime": "^7.17.8",
"@types/webxr": "*",
"base64-js": "^1.5.1",
buffer: "^6.0.3",
"its-fine": "^2.0.0",
"react-use-measure": "^2.1.7",
scheduler: "^0.27.0",
"suspend-react": "^0.1.3",
"use-sync-external-store": "^1.4.0",
zustand: "^5.0.3"
},
peerDependencies: {
expo: ">=43.0",
"expo-asset": ">=8.4",
"expo-file-system": ">=11.0",
"expo-gl": ">=11.0",
react: ">=19 <19.3",
"react-dom": ">=19 <19.3",
"react-native": ">=0.78",
three: ">=0.156"
},
peerDependenciesMeta: {
"react-dom": { optional: !0 },
"react-native": { optional: !0 },
expo: { optional: !0 },
"expo-asset": { optional: !0 },
"expo-file-system": { optional: !0 },
"expo-gl": { optional: !0 }
}
};
function I_(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var L_ = { exports: {} }, R_ = { exports: {} };
R_.exports;
var z_;
function B_() {
return z_ || (z_ = 1, function(e) {
e.exports = function(e) {
function t(e, t, n, r) {
return new sa(e, t, n, r);
}
function n() {}
function r(e) {
var t = "https://react.dev/errors/" + e;
if (1 < arguments.length) {
t += "?args[]=" + encodeURIComponent(arguments[1]);
for (var n = 2; n < arguments.length; n++) t += "&args[]=" + encodeURIComponent(arguments[n]);
}
return "Minified React error #" + e + "; visit " + t + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
}
function i(e) {
var t = e, n = e;
if (e.alternate) for (; t.return;) t = t.return;
else {
e = t;
do
t = e, t.flags & 4098 && (n = t.return), e = t.return;
while (e);
}
return t.tag === 3 ? n : null;
}
function a(e) {
if (i(e) !== e) throw Error(r(188));
}
function o(e) {
var t = e.alternate;
if (!t) {
if (t = i(e), t === null) throw Error(r(188));
return t === e ? e : null;
}
for (var n = e, o = t;;) {
var s = n.return;
if (s === null) break;
var c = s.alternate;
if (c === null) {
if (o = s.return, o !== null) {
n = o;
continue;
}
break;
}
if (s.child === c.child) {
for (c = s.child; c;) {
if (c === n) return a(s), e;
if (c === o) return a(s), t;
c = c.sibling;
}
throw Error(r(188));
}
if (n.return !== o.return) n = s, o = c;
else {
for (var l = !1, u = s.child; u;) {
if (u === n) {
l = !0, n = s, o = c;
break;
}
if (u === o) {
l = !0, o = s, n = c;
break;
}
u = u.sibling;
}
if (!l) {
for (u = c.child; u;) {
if (u === n) {
l = !0, n = c, o = s;
break;
}
if (u === o) {
l = !0, o = c, n = s;
break;
}
u = u.sibling;
}
if (!l) throw Error(r(189));
}
}
if (n.alternate !== o) throw Error(r(190));
}
if (n.tag !== 3) throw Error(r(188));
return n.stateNode.current === n ? e : t;
}
function s(e) {
var t = e.tag;
if (t === 5 || t === 26 || t === 27 || t === 6) return e;
for (e = e.child; e !== null;) {
if (t = s(e), t !== null) return t;
e = e.sibling;
}
return null;
}
function l(e) {
var t = e.tag;
if (t === 5 || t === 26 || t === 27 || t === 6) return e;
for (e = e.child; e !== null;) {
if (e.tag !== 4 && (t = l(e), t !== null)) return t;
e = e.sibling;
}
return null;
}
function u(e) {
return typeof e != "object" || !e ? null : (e = Ha && e[Ha] || e["@@iterator"], typeof e == "function" ? e : null);
}
function d(e) {
if (e == null) return null;
if (typeof e == "function") return e.$$typeof === Ua ? null : e.displayName || e.name || null;
if (typeof e == "string") return e;
switch (e) {
case Aa: return "Fragment";
case Ma: return "Profiler";
case ja: return "StrictMode";
case Ia: return "Suspense";
case La: return "SuspenseList";
case Ba: return "Activity";
}
if (typeof e == "object") switch (e.$$typeof) {
case ka: return "Portal";
case Pa: return e.displayName || "Context";
case Na: return (e._context.displayName || "Context") + ".Consumer";
case Fa:
var t = e.render;
return e = e.displayName, e || (e = t.displayName || t.name || "", e = e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
case Ra: return t = e.displayName || null, t === null ? d(e.type) || "Memo" : t;
case za:
t = e._payload, e = e._init;
try {
return d(e(t));
} catch {}
}
return null;
}
function f(e) {
return { current: e };
}
function p(e) {
0 > uc || (e.current = lc[uc], lc[uc] = null, uc--);
}
function m(e, t) {
uc++, lc[uc] = e.current, e.current = t;
}
function h(e) {
return e >>>= 0, e === 0 ? 32 : 31 - (pc(e) / mc | 0) | 0;
}
function g(e) {
var t = e & 42;
if (t !== 0) return t;
switch (e & -e) {
case 1: return 1;
case 2: return 2;
case 4: return 4;
case 8: return 8;
case 16: return 16;
case 32: return 32;
case 64: return 64;
case 128: return 128;
case 256:
case 512:
case 1024:
case 2048:
case 4096:
case 8192:
case 16384:
case 32768:
case 65536:
case 131072: return e & 261888;
case 262144:
case 524288:
case 1048576:
case 2097152: return e & 3932160;
case 4194304:
case 8388608:
case 16777216:
case 33554432: return e & 62914560;
case 67108864: return 67108864;
case 134217728: return 134217728;
case 268435456: return 268435456;
case 536870912: return 536870912;
case 1073741824: return 0;
default: return e;
}
}
function _(e, t, n) {
var r = e.pendingLanes;
if (r === 0) return 0;
var i = 0, a = e.suspendedLanes, o = e.pingedLanes;
e = e.warmLanes;
var s = r & 134217727;
return s === 0 ? (s = r & ~a, s === 0 ? o === 0 ? n || (n = r & ~e, n !== 0 && (i = g(n))) : i = g(o) : i = g(s)) : (r = s & ~a, r === 0 ? (o &= s, o === 0 ? n || (n = s & ~e, n !== 0 && (i = g(n))) : i = g(o)) : i = g(r)), i === 0 ? 0 : t !== 0 && t !== i && (t & a) === 0 && (a = i & -i, n = t & -t, a >= n || a === 32 && n & 4194048) ? t : i;
}
function v(e, t) {
return (e.pendingLanes & ~(e.suspendedLanes & ~e.pingedLanes) & t) === 0;
}
function y(e, t) {
switch (e) {
case 1:
case 2:
case 4:
case 8:
case 64: return t + 250;
case 16:
case 32:
case 128:
case 256:
case 512:
case 1024:
case 2048:
case 4096:
case 8192:
case 16384:
case 32768:
case 65536:
case 131072:
case 262144:
case 524288:
case 1048576:
case 2097152: return t + 5e3;
case 4194304:
case 8388608:
case 16777216:
case 33554432: return -1;
case 67108864:
case 134217728:
case 268435456:
case 536870912:
case 1073741824: return -1;
default: return -1;
}
}
function b() {
var e = _c;
return _c <<= 1, !(_c & 62914560) && (_c = 4194304), e;
}
function x(e) {
for (var t = [], n = 0; 31 > n; n++) t.push(e);
return t;
}
function S(e, t) {
e.pendingLanes |= t, t !== 268435456 && (e.suspendedLanes = 0, e.pingedLanes = 0, e.warmLanes = 0);
}
function C(e, t, n, r, i, a) {
var o = e.pendingLanes;
e.pendingLanes = n, e.suspendedLanes = 0, e.pingedLanes = 0, e.warmLanes = 0, e.expiredLanes &= n, e.entangledLanes &= n, e.errorRecoveryDisabledLanes &= n, e.shellSuspendCounter = 0;
var s = e.entanglements, c = e.expirationTimes, l = e.hiddenUpdates;
for (n = o & ~n; 0 < n;) {
var u = 31 - fc(n), d = 1 << u;
s[u] = 0, c[u] = -1;
var f = l[u];
if (f !== null) for (l[u] = null, u = 0; u < f.length; u++) {
var p = f[u];
p !== null && (p.lane &= -536870913);
}
n &= ~d;
}
r !== 0 && w(e, r, 0), a !== 0 && i === 0 && e.tag !== 0 && (e.suspendedLanes |= a & ~(o & ~t));
}
function w(e, t, n) {
e.pendingLanes |= t, e.suspendedLanes &= ~t;
var r = 31 - fc(t);
e.entangledLanes |= t, e.entanglements[r] = e.entanglements[r] | 1073741824 | n & 261930;
}
function T(e, t) {
var n = e.entangledLanes |= t;
for (e = e.entanglements; n;) {
var r = 31 - fc(n), i = 1 << r;
i & t | e[r] & t && (e[r] |= t), n &= ~i;
}
}
function E(e, t) {
var n = t & -t;
return n = n & 42 ? 1 : D(n), (n & (e.suspendedLanes | t)) === 0 ? n : 0;
}
function D(e) {
switch (e) {
case 2:
e = 1;
break;
case 8:
e = 4;
break;
case 32:
e = 16;
break;
case 256:
case 512:
case 1024:
case 2048:
case 4096:
case 8192:
case 16384:
case 32768:
case 65536:
case 131072:
case 262144:
case 524288:
case 1048576:
case 2097152:
case 4194304:
case 8388608:
case 16777216:
case 33554432:
e = 128;
break;
case 268435456:
e = 134217728;
break;
default: e = 0;
}
return e;
}
function O(e) {
return e &= -e, 2 < e ? 8 < e ? e & 134217727 ? 32 : 268435456 : 8 : 2;
}
function k(e) {
if (typeof Dc == "function" && Oc(e), Ac && typeof Ac.setStrictMode == "function") try {
Ac.setStrictMode(kc, e);
} catch {}
}
function A(e, t) {
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
}
function ee(e) {
if (Pc === void 0) try {
throw Error();
} catch (e) {
var t = e.stack.trim().match(/\n( *(at )?)/);
Pc = t && t[1] || "", Fc = -1 < e.stack.indexOf("\n at") ? " (<anonymous>)" : -1 < e.stack.indexOf("@") ? "@unknown:0:0" : "";
}
return "\n" + Pc + e + Fc;
}
function te(e, t) {
if (!e || Ic) return "";
Ic = !0;
var n = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
try {
var r = { DetermineComponentFrameRoot: function() {
try {
if (t) {
var n = function() {
throw Error();
};
if (Object.defineProperty(n.prototype, "props", { set: function() {
throw Error();
} }), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(n, []);
} catch (e) {
var r = e;
}
Reflect.construct(e, [], n);
} else {
try {
n.call();
} catch (e) {
r = e;
}
e.call(n.prototype);
}
} else {
try {
throw Error();
} catch (e) {
r = e;
}
(n = e()) && typeof n.catch == "function" && n.catch(function() {});
}
} catch (e) {
if (e && r && typeof e.stack == "string") return [e.stack, r.stack];
}
return [null, null];
} };
r.DetermineComponentFrameRoot.displayName = "DetermineComponentFrameRoot";
var i = Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot, "name");
i && i.configurable && Object.defineProperty(r.DetermineComponentFrameRoot, "name", { value: "DetermineComponentFrameRoot" });
var a = r.DetermineComponentFrameRoot(), o = a[0], s = a[1];
if (o && s) {
var c = o.split("\n"), l = s.split("\n");
for (i = r = 0; r < c.length && !c[r].includes("DetermineComponentFrameRoot");) r++;
for (; i < l.length && !l[i].includes("DetermineComponentFrameRoot");) i++;
if (r === c.length || i === l.length) for (r = c.length - 1, i = l.length - 1; 1 <= r && 0 <= i && c[r] !== l[i];) i--;
for (; 1 <= r && 0 <= i; r--, i--) if (c[r] !== l[i]) {
if (r !== 1 || i !== 1) do
if (r--, i--, 0 > i || c[r] !== l[i]) {
var u = "\n" + c[r].replace(" at new ", " at ");
return e.displayName && u.includes("<anonymous>") && (u = u.replace("<anonymous>", e.displayName)), u;
}
while (1 <= r && 0 <= i);
break;
}
}
} finally {
Ic = !1, Error.prepareStackTrace = n;
}
return (n = e ? e.displayName || e.name : "") ? ee(n) : "";
}
function ne(e, t) {
switch (e.tag) {
case 26:
case 27:
case 5: return ee(e.type);
case 16: return ee("Lazy");
case 13: return e.child !== t && t !== null ? ee("Suspense Fallback") : ee("Suspense");
case 19: return ee("SuspenseList");
case 0:
case 15: return te(e.type, !1);
case 11: return te(e.type.render, !1);
case 1: return te(e.type, !0);
case 31: return ee("Activity");
default: return "";
}
}
function j(e) {
try {
var t = "", n = null;
do
t += ne(e, n), n = e, e = e.return;
while (e);
return t;
} catch (e) {
return "\nError generating stack: " + e.message + "\n" + e.stack;
}
}
function M(e, t) {
if (typeof e == "object" && e) {
var n = Lc.get(e);
return n === void 0 ? (t = {
value: e,
source: t,
stack: j(t)
}, Lc.set(e, t), t) : n;
}
return {
value: e,
source: t,
stack: j(t)
};
}
function re(e, t) {
Rc[zc++] = Vc, Rc[zc++] = Bc, Bc = e, Vc = t;
}
function ie(e, t, n) {
Hc[Uc++] = Gc, Hc[Uc++] = Kc, Hc[Uc++] = Wc, Wc = e;
var r = Gc;
e = Kc;
var i = 32 - fc(r) - 1;
r &= ~(1 << i), n += 1;
var a = 32 - fc(t) + i;
if (30 < a) {
var o = i - i % 5;
a = (r & (1 << o) - 1).toString(32), r >>= o, i -= o, Gc = 1 << 32 - fc(t) + i | n << i | r, Kc = a + e;
} else Gc = 1 << a | n << i | r, Kc = e;
}
function ae(e) {
e.return !== null && (re(e, 1), ie(e, 1, 0));
}
function oe(e) {
for (; e === Bc;) Bc = Rc[--zc], Rc[zc] = null, Vc = Rc[--zc], Rc[zc] = null;
for (; e === Wc;) Wc = Hc[--Uc], Hc[Uc] = null, Kc = Hc[--Uc], Hc[Uc] = null, Gc = Hc[--Uc], Hc[Uc] = null;
}
function se(e, t) {
Hc[Uc++] = Gc, Hc[Uc++] = Kc, Hc[Uc++] = Wc, Gc = t.id, Kc = t.overflow, Wc = e;
}
function N(e, t) {
m(Yc, t), m(Jc, e), m(qc, null), e = Ya(t), p(qc), m(qc, e);
}
function ce() {
p(qc), p(Jc), p(Yc);
}
function le(e) {
e.memoizedState !== null && m(Xc, e);
var t = qc.current, n = Xa(t, e.type);
t !== n && (m(Jc, e), m(qc, n));
}
function ue(e) {
Jc.current === e && (p(qc), p(Jc)), Xc.current === e && (p(Xc), so ? Do._currentValue = Eo : Do._currentValue2 = Eo);
}
function de(e) {
throw _e(M(Error(r(418, 1 < arguments.length && arguments[1] !== void 0 && arguments[1] ? "text" : "HTML", "")), e)), nl;
}
function fe(e, t) {
if (!uo) throw Error(r(175));
ws(e.stateNode, e.type, e.memoizedProps, t, e) || de(e, !0);
}
function pe(e) {
for (Zc = e.return; Zc;) switch (Zc.tag) {
case 5:
case 31:
case 13:
tl = !1;
return;
case 27:
case 3:
tl = !0;
return;
default: Zc = Zc.return;
}
}
function me(e) {
if (!uo || e !== Zc) return !1;
if (!$c) return pe(e), $c = !0, !1;
var t = e.tag;
if (rc ? t !== 3 && t !== 27 && (t !== 5 || Bs(e.type) && !no(e.type, e.memoizedProps)) && Qc && de(e) : t !== 3 && (t !== 5 || Bs(e.type) && !no(e.type, e.memoizedProps)) && Qc && de(e), pe(e), t === 13) {
if (!uo) throw Error(r(316));
if (e = e.memoizedState, e = e === null ? null : e.dehydrated, !e) throw Error(r(317));
Qc = ks(e);
} else if (t === 31) {
if (e = e.memoizedState, e = e === null ? null : e.dehydrated, !e) throw Error(r(317));
Qc = Os(e);
} else Qc = rc && t === 27 ? ms(e.type, Qc) : Zc ? ps(e.stateNode) : null;
return !0;
}
function he() {
uo && (Qc = Zc = null, $c = !1);
}
function ge() {
var e = el;
return e !== null && (Lu === null ? Lu = e : Lu.push.apply(Lu, e), el = null), e;
}
function _e(e) {
el === null ? el = [e] : el.push(e);
}
function ve(e, t, n) {
so ? (m(rl, t._currentValue), t._currentValue = n) : (m(rl, t._currentValue2), t._currentValue2 = n);
}
function ye(e) {
var t = rl.current;
so ? e._currentValue = t : e._currentValue2 = t, p(rl);
}
function be(e, t, n) {
for (; e !== null;) {
var r = e.alternate;
if ((e.childLanes & t) === t ? r !== null && (r.childLanes & t) !== t && (r.childLanes |= t) : (e.childLanes |= t, r !== null && (r.childLanes |= t)), e === n) break;
e = e.return;
}
}
function xe(e, t, n, i) {
var a = e.child;
for (a !== null && (a.return = e); a !== null;) {
var o = a.dependencies;
if (o !== null) {
var s = a.child;
o = o.firstContext;
e: for (; o !== null;) {
var c = o;
o = a;
for (var l = 0; l < t.length; l++) if (c.context === t[l]) {
o.lanes |= n, c = o.alternate, c !== null && (c.lanes |= n), be(o.return, n, e), i || (s = null);
break e;
}
o = c.next;
}
} else if (a.tag === 18) {
if (s = a.return, s === null) throw Error(r(341));
s.lanes |= n, o = s.alternate, o !== null && (o.lanes |= n), be(s, n, e), s = null;
} else s = a.child;
if (s !== null) s.return = a;
else for (s = a; s !== null;) {
if (s === e) {
s = null;
break;
}
if (a = s.sibling, a !== null) {
a.return = s.return, s = a;
break;
}
s = s.return;
}
a = s;
}
}
function Se(e, t, n, i) {
e = null;
for (var a = t, o = !1; a !== null;) {
if (!o) {
if (a.flags & 524288) o = !0;
else if (a.flags & 262144) break;
}
if (a.tag === 10) {
var s = a.alternate;
if (s === null) throw Error(r(387));
if (s = s.memoizedProps, s !== null) {
var c = a.type;
jc(a.pendingProps.value, s.value) || (e === null ? e = [c] : e.push(c));
}
} else if (a === Xc.current) {
if (s = a.alternate, s === null) throw Error(r(387));
s.memoizedState.memoizedState !== a.memoizedState.memoizedState && (e === null ? e = [Do] : e.push(Do));
}
a = a.return;
}
e !== null && xe(t, e, n, i), t.flags |= 262144;
}
function Ce(e) {
for (e = e.firstContext; e !== null;) {
var t = e.context;
if (!jc(so ? t._currentValue : t._currentValue2, e.memoizedValue)) return !0;
e = e.next;
}
return !1;
}
function we(e) {
il = e, al = null, e = e.dependencies, e !== null && (e.firstContext = null);
}
function Te(e) {
return De(il, e);
}
function Ee(e, t) {
return il === null && we(e), De(e, t);
}
function De(e, t) {
var n = so ? t._currentValue : t._currentValue2;
if (t = {
context: t,
memoizedValue: n,
next: null
}, al === null) {
if (e === null) throw Error(r(308));
al = t, e.dependencies = {
lanes: 0,
firstContext: t
}, e.flags |= 524288;
} else al = al.next = t;
return n;
}
function Oe() {
return {
controller: new ol(),
data: /* @__PURE__ */ new Map(),
refCount: 0
};
}
function ke(e) {
e.refCount--, e.refCount === 0 && sl(cl, function() {
e.controller.abort();
});
}
function Ae() {}
function je(e) {
e !== dl && e.next === null && (dl === null ? ul = dl = e : dl = dl.next = e), pl = !0, fl || (fl = !0, Le());
}
function Me(e, t) {
if (!ml && pl) {
ml = !0;
do
for (var n = !1, r = ul; r !== null;) {
if (!t) if (e !== 0) {
var i = r.pendingLanes;
if (i === 0) var a = 0;
else {
var o = r.suspendedLanes, s = r.pingedLanes;
a = (1 << 31 - fc(42 | e) + 1) - 1, a &= i & ~(o & ~s), a = a & 201326741 ? a & 201326741 | 1 : a ? a | 2 : 0;
}
a !== 0 && (n = !0, Ie(r, a));
} else a = Z, a = _(r, r === Su ? a : 0, r.cancelPendingCommit !== null || r.timeoutHandle !== oo), !(a & 3) || v(r, a) || (n = !0, Ie(r, a));
r = r.next;
}
while (n);
ml = !1;
}
}
function Ne() {
Pe();
}
function Pe() {
pl = fl = !1;
var e = 0;
hl !== 0 && _o() && (e = hl);
for (var t = Sc(), n = null, r = ul; r !== null;) {
var i = r.next, a = P(r, t);
a === 0 ? (r.next = null, n === null ? ul = i : n.next = i, i === null && (dl = n)) : (n = r, (e !== 0 || a & 3) && (pl = !0)), r = i;
}
Wu !== 0 && Wu !== 5 || Me(e, !1), hl !== 0 && (hl = 0);
}
function P(e, t) {
for (var n = e.suspendedLanes, r = e.pingedLanes, i = e.expirationTimes, a = e.pendingLanes & -62914561; 0 < a;) {
var o = 31 - fc(a), s = 1 << o, c = i[o];
c === -1 ? ((s & n) === 0 || (s & r) !== 0) && (i[o] = y(s, t)) : c <= t && (e.expiredLanes |= s), a &= ~s;
}
if (t = Su, n = Z, n = _(e, e === t ? n : 0, e.cancelPendingCommit !== null || e.timeoutHandle !== oo), r = e.callbackNode, n === 0 || e === t && (wu === 2 || wu === 9) || e.cancelPendingCommit !== null) return r !== null && r !== null && yc(r), e.callbackNode = null, e.callbackPriority = 0;
if (!(n & 3) || v(e, n)) {
if (t = n & -n, t === e.callbackPriority) return t;
switch (r !== null && yc(r), O(n)) {
case 2:
case 8:
n = wc;
break;
case 32:
n = Tc;
break;
case 268435456:
n = Ec;
break;
default: n = Tc;
}
return r = Fe.bind(null, e), n = vc(n, r), e.callbackPriority = t, e.callbackNode = n, t;
}
return r !== null && r !== null && yc(r), e.callbackPriority = 2, e.callbackNode = null, 2;
}
function Fe(e, t) {
if (Wu !== 0 && Wu !== 5) return e.callbackNode = null, e.callbackPriority = 0, null;
var n = e.callbackNode;
if (Zi() && e.callbackNode !== n) return null;
var r = Z;
return r = _(e, e === Su ? r : 0, e.cancelPendingCommit !== null || e.timeoutHandle !== oo), r === 0 ? null : (Di(e, r, t), P(e, Sc()), e.callbackNode != null && e.callbackNode === n ? Fe.bind(null, e) : null);
}
function Ie(e, t) {
if (Zi()) return null;
Di(e, t, !0);
}
function Le() {
ko ? Ao(function() {
X & 6 ? vc(Cc, Ne) : Pe();
}) : vc(Cc, Ne);
}
function F() {
if (hl === 0) {
var e = vl;
e === 0 && (e = hc, hc <<= 1, !(hc & 261888) && (hc = 256)), hl = e;
}
return hl;
}
function Re(e, t) {
if (gl === null) {
var n = gl = [];
_l = 0, vl = F(), yl = {
status: "pending",
value: void 0,
then: function(e) {
n.push(e);
}
};
}
return _l++, t.then(I, I), t;
}
function I() {
if (--_l === 0 && gl !== null) {
yl !== null && (yl.status = "fulfilled");
var e = gl;
gl = null, vl = 0, yl = null;
for (var t = 0; t < e.length; t++) (0, e[t])();
}
}
function ze(e, t) {
var n = [], r = {
status: "pending",
value: null,
reason: null,
then: function(e) {
n.push(e);
}
};
return e.then(function() {
r.status = "fulfilled", r.value = t;
for (var e = 0; e < n.length; e++) (0, n[e])(t);
}, function(e) {
for (r.status = "rejected", r.reason = e, e = 0; e < n.length; e++) (0, n[e])(void 0);
}), r;
}
function Be() {
var e = xl.current;
return e === null ? Su.pooledCache : e;
}
function Ve(e, t) {
t === null ? m(xl, xl.current) : m(xl, t.pool);
}
function He() {
var e = Be();
return e === null ? null : {
parent: so ? ll._currentValue : ll._currentValue2,
pool: e
};
}
function Ue(e, t) {
if (jc(e, t)) return !0;
if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
var n = Object.keys(e), r = Object.keys(t);
if (n.length !== r.length) return !1;
for (r = 0; r < n.length; r++) {
var i = n[r];
if (!Nc.call(t, i) || !jc(e[i], t[i])) return !1;
}
return !0;
}
function We(e) {
return e = e.status, e === "fulfilled" || e === "rejected";
}
function Ge(e, t, n) {
switch (n = e[n], n === void 0 ? e.push(t) : n !== t && (t.then(Ae, Ae), t = n), t.status) {
case "fulfilled": return t.value;
case "rejected": throw e = t.reason, Je(e), e;
default:
if (typeof t.status == "string") t.then(Ae, Ae);
else {
if (e = Su, e !== null && 100 < e.shellSuspendCounter) throw Error(r(482));
e = t, e.status = "pending", e.then(function(e) {
if (t.status === "pending") {
var n = t;
n.status = "fulfilled", n.value = e;
}
}, function(e) {
if (t.status === "pending") {
var n = t;
n.status = "rejected", n.reason = e;
}
});
}
switch (t.status) {
case "fulfilled": return t.value;
case "rejected": throw e = t.reason, Je(e), e;
}
throw El = t, Sl;
}
}
function Ke(e) {
try {
var t = e._init;
return t(e._payload);
} catch (e) {
throw typeof e == "object" && e && typeof e.then == "function" ? (El = e, Sl) : e;
}
}
function qe() {
if (El === null) throw Error(r(459));
var e = El;
return El = null, e;
}
function Je(e) {
if (e === Sl || e === wl) throw Error(r(483));
}
function Ye(e) {
var t = Ol;
return Ol += 1, Dl === null && (Dl = []), Ge(Dl, e, t);
}
function Xe(e, t) {
t = t.props.ref, e.ref = t === void 0 ? null : t;
}
function Ze(e, t) {
throw t.$$typeof === Da ? Error(r(525)) : (e = Object.prototype.toString.call(t), Error(r(31, e === "[object Object]" ? "object with keys {" + Object.keys(t).join(", ") + "}" : e)));
}
function Qe(e) {
function n(t, n) {
if (e) {
var r = t.deletions;
r === null ? (t.deletions = [n], t.flags |= 16) : r.push(n);
}
}
function i(t, r) {
if (!e) return null;
for (; r !== null;) n(t, r), r = r.sibling;
return null;
}
function a(e) {
for (var t = /* @__PURE__ */ new Map(); e !== null;) e.key === null ? t.set(e.index, e) : t.set(e.key, e), e = e.sibling;
return t;
}
function o(e, t) {
return e = la(e, t), e.index = 0, e.sibling = null, e;
}
function s(t, n, r) {
return t.index = r, e ? (r = t.alternate, r === null ? (t.flags |= 67108866, n) : (r = r.index, r < n ? (t.flags |= 67108866, n) : r)) : (t.flags |= 1048576, n);
}
function c(t) {
return e && t.alternate === null && (t.flags |= 67108866), t;
}
function l(e, t, n, r) {
return t === null || t.tag !== 6 ? (t = pa(n, e.mode, r), t.return = e, t) : (t = o(t, n), t.return = e, t);
}
function d(e, t, n, r) {
var i = n.type;
return i === Aa ? p(e, t, n.props.children, r, n.key) : t !== null && (t.elementType === i || typeof i == "object" && i && i.$$typeof === za && Ke(i) === t.type) ? (t = o(t, n.props), Xe(t, n), t.return = e, t) : (t = da(n.type, n.key, n.props, null, e.mode, r), Xe(t, n), t.return = e, t);
}
function f(e, t, n, r) {
return t === null || t.tag !== 4 || t.stateNode.containerInfo !== n.containerInfo || t.stateNode.implementation !== n.implementation ? (t = ha(n, e.mode, r), t.return = e, t) : (t = o(t, n.children || []), t.return = e, t);
}
function p(e, t, n, r, i) {
return t === null || t.tag !== 7 ? (t = fa(n, e.mode, r, i), t.return = e, t) : (t = o(t, n), t.return = e, t);
}
function m(e, t, n) {
if (typeof t == "string" && t !== "" || typeof t == "number" || typeof t == "bigint") return t = pa("" + t, e.mode, n), t.return = e, t;
if (typeof t == "object" && t) {
switch (t.$$typeof) {
case Oa: return n = da(t.type, t.key, t.props, null, e.mode, n), Xe(n, t), n.return = e, n;
case ka: return t = ha(t, e.mode, n), t.return = e, t;
case za: return t = Ke(t), m(e, t, n);
}
if (Wa(t) || u(t)) return t = fa(t, e.mode, n, null), t.return = e, t;
if (typeof t.then == "function") return m(e, Ye(t), n);
if (t.$$typeof === Pa) return m(e, Ee(e, t), n);
Ze(e, t);
}
return null;
}
function h(e, t, n, r) {
var i = t === null ? null : t.key;
if (typeof n == "string" && n !== "" || typeof n == "number" || typeof n == "bigint") return i === null ? l(e, t, "" + n, r) : null;
if (typeof n == "object" && n) {
switch (n.$$typeof) {
case Oa: return n.key === i ? d(e, t, n, r) : null;
case ka: return n.key === i ? f(e, t, n, r) : null;
case za: return n = Ke(n), h(e, t, n, r);
}
if (Wa(n) || u(n)) return i === null ? p(e, t, n, r, null) : null;
if (typeof n.then == "function") return h(e, t, Ye(n), r);
if (n.$$typeof === Pa) return h(e, t, Ee(e, n), r);
Ze(e, n);
}
return null;
}
function g(e, t, n, r, i) {
if (typeof r == "string" && r !== "" || typeof r == "number" || typeof r == "bigint") return e = e.get(n) || null, l(t, e, "" + r, i);
if (typeof r == "object" && r) {
switch (r.$$typeof) {
case Oa: return e = e.get(r.key === null ? n : r.key) || null, d(t, e, r, i);
case ka: return e = e.get(r.key === null ? n : r.key) || null, f(t, e, r, i);
case za: return r = Ke(r), g(e, t, n, r, i);
}
if (Wa(r) || u(r)) return e = e.get(n) || null, p(t, e, r, i, null);
if (typeof r.then == "function") return g(e, t, n, Ye(r), i);
if (r.$$typeof === Pa) return g(e, t, n, Ee(t, r), i);
Ze(t, r);
}
return null;
}
function _(t, r, o, c) {
for (var l = null, u = null, d = r, f = r = 0, p = null; d !== null && f < o.length; f++) {
d.index > f ? (p = d, d = null) : p = d.sibling;
var _ = h(t, d, o[f], c);
if (_ === null) {
d === null && (d = p);
break;
}
e && d && _.alternate === null && n(t, d), r = s(_, r, f), u === null ? l = _ : u.sibling = _, u = _, d = p;
}
if (f === o.length) return i(t, d), $c && re(t, f), l;
if (d === null) {
for (; f < o.length; f++) d = m(t, o[f], c), d !== null && (r = s(d, r, f), u === null ? l = d : u.sibling = d, u = d);
return $c && re(t, f), l;
}
for (d = a(d); f < o.length; f++) p = g(d, t, f, o[f], c), p !== null && (e && p.alternate !== null && d.delete(p.key === null ? f : p.key), r = s(p, r, f), u === null ? l = p : u.sibling = p, u = p);
return e && d.forEach(function(e) {
return n(t, e);
}), $c && re(t, f), l;
}
function v(t, o, c, l) {
if (c == null) throw Error(r(151));
for (var u = null, d = null, f = o, p = o = 0, _ = null, v = c.next(); f !== null && !v.done; p++, v = c.next()) {
f.index > p ? (_ = f, f = null) : _ = f.sibling;
var y = h(t, f, v.value, l);
if (y === null) {
f === null && (f = _);
break;
}
e && f && y.alternate === null && n(t, f), o = s(y, o, p), d === null ? u = y : d.sibling = y, d = y, f = _;
}
if (v.done) return i(t, f), $c && re(t, p), u;
if (f === null) {
for (; !v.done; p++, v = c.next()) v = m(t, v.value, l), v !== null && (o = s(v, o, p), d === null ? u = v : d.sibling = v, d = v);
return $c && re(t, p), u;
}
for (f = a(f); !v.done; p++, v = c.next()) v = g(f, t, p, v.value, l), v !== null && (e && v.alternate !== null && f.delete(v.key === null ? p : v.key), o = s(v, o, p), d === null ? u = v : d.sibling = v, d = v);
return e && f.forEach(function(e) {
return n(t, e);
}), $c && re(t, p), u;
}
function y(e, t, a, s) {
if (typeof a == "object" && a && a.type === Aa && a.key === null && (a = a.props.children), typeof a == "object" && a) {
switch (a.$$typeof) {
case Oa:
e: {
for (var l = a.key; t !== null;) {
if (t.key === l) {
if (l = a.type, l === Aa) {
if (t.tag === 7) {
i(e, t.sibling), s = o(t, a.props.children), s.return = e, e = s;
break e;
}
} else if (t.elementType === l || typeof l == "object" && l && l.$$typeof === za && Ke(l) === t.type) {
i(e, t.sibling), s = o(t, a.props), Xe(s, a), s.return = e, e = s;
break e;
}
i(e, t);
break;
} else n(e, t);
t = t.sibling;
}
a.type === Aa ? (s = fa(a.props.children, e.mode, s, a.key), s.return = e, e = s) : (s = da(a.type, a.key, a.props, null, e.mode, s), Xe(s, a), s.return = e, e = s);
}
return c(e);
case ka:
e: {
for (l = a.key; t !== null;) {
if (t.key === l) if (t.tag === 4 && t.stateNode.containerInfo === a.containerInfo && t.stateNode.implementation === a.implementation) {
i(e, t.sibling), s = o(t, a.children || []), s.return = e, e = s;
break e;
} else {
i(e, t);
break;
}
else n(e, t);
t = t.sibling;
}
s = ha(a, e.mode, s), s.return = e, e = s;
}
return c(e);
case za: return a = Ke(a), y(e, t, a, s);
}
if (Wa(a)) return _(e, t, a, s);
if (u(a)) {
if (l = u(a), typeof l != "function") throw Error(r(150));
return a = l.call(a), v(e, t, a, s);
}
if (typeof a.then == "function") return y(e, t, Ye(a), s);
if (a.$$typeof === Pa) return y(e, t, Ee(e, a), s);
Ze(e, a);
}
return typeof a == "string" && a !== "" || typeof a == "number" || typeof a == "bigint" ? (a = "" + a, t !== null && t.tag === 6 ? (i(e, t.sibling), s = o(t, a), s.return = e, e = s) : (i(e, t), s = pa(a, e.mode, s), s.return = e, e = s), c(e)) : i(e, t);
}
return function(e, n, r, i) {
try {
Ol = 0;
var a = y(e, n, r, i);
return Dl = null, a;
} catch (n) {
if (n === Sl || n === wl) throw n;
var o = t(29, n, null, e.mode);
return o.lanes = i, o.return = e, o;
}
};
}
function $e() {
for (var e = Ml, t = Nl = Ml = 0; t < e;) {
var n = jl[t];
jl[t++] = null;
var r = jl[t];
jl[t++] = null;
var i = jl[t];
jl[t++] = null;
var a = jl[t];
if (jl[t++] = null, r !== null && i !== null) {
var o = r.pending;
o === null ? i.next = i : (i.next = o.next, o.next = i), r.pending = i;
}
a !== 0 && rt(n, i, a);
}
}
function et(e, t, n, r) {
jl[Ml++] = e, jl[Ml++] = t, jl[Ml++] = n, jl[Ml++] = r, Nl |= r, e.lanes |= r, e = e.alternate, e !== null && (e.lanes |= r);
}
function tt(e, t, n, r) {
return et(e, t, n, r), it(e);
}
function nt(e, t) {
return et(e, null, null, t), it(e);
}
function rt(e, t, n) {
e.lanes |= n;
var r = e.alternate;
r !== null && (r.lanes |= n);
for (var i = !1, a = e.return; a !== null;) a.childLanes |= n, r = a.alternate, r !== null && (r.childLanes |= n), a.tag === 22 && (e = a.stateNode, e === null || e._visibility & 1 || (i = !0)), e = a, a = a.return;
return e.tag === 3 ? (a = e.stateNode, i && t !== null && (i = 31 - fc(n), e = a.hiddenUpdates, r = e[i], r === null ? e[i] = [t] : r.push(t), t.lane = n | 536870912), a) : null;
}
function it(e) {
if (50 < Zu) throw Zu = 0, Qu = null, Error(r(185));
for (var t = e.return; t !== null;) e = t, t = e.return;
return e.tag === 3 ? e.stateNode : null;
}
function at(e) {
e.updateQueue = {
baseState: e.memoizedState,
firstBaseUpdate: null,
lastBaseUpdate: null,
shared: {
pending: null,
lanes: 0,
hiddenCallbacks: null
},
callbacks: null
};
}
function ot(e, t) {
e = e.updateQueue, t.updateQueue === e && (t.updateQueue = {
baseState: e.baseState,
firstBaseUpdate: e.firstBaseUpdate,
lastBaseUpdate: e.lastBaseUpdate,
shared: e.shared,
callbacks: null
});
}
function st(e) {
return {
lane: e,
tag: 0,
payload: null,
callback: null,
next: null
};
}
function ct(e, t, n) {
var r = e.updateQueue;
if (r === null) return null;
if (r = r.shared, X & 2) {
var i = r.pending;
return i === null ? t.next = t : (t.next = i.next, i.next = t), r.pending = t, t = it(e), rt(e, null, n), t;
}
return et(e, r, t, n), it(e);
}
function lt(e, t, n) {
if (t = t.updateQueue, t !== null && (t = t.shared, n & 4194048)) {
var r = t.lanes;
r &= e.pendingLanes, n |= r, t.lanes = n, T(e, n);
}
}
function ut(e, t) {
var n = e.updateQueue, r = e.alternate;
if (r !== null && (r = r.updateQueue, n === r)) {
var i = null, a = null;
if (n = n.firstBaseUpdate, n !== null) {
do {
var o = {
lane: n.lane,
tag: n.tag,
payload: n.payload,
callback: null,
next: null
};
a === null ? i = a = o : a = a.next = o, n = n.next;
} while (n !== null);
a === null ? i = a = t : a = a.next = t;
} else i = a = t;
n = {
baseState: r.baseState,
firstBaseUpdate: i,
lastBaseUpdate: a,
shared: r.shared,
callbacks: r.callbacks
}, e.updateQueue = n;
return;
}
e = n.lastBaseUpdate, e === null ? n.firstBaseUpdate = t : e.next = t, n.lastBaseUpdate = t;
}
function dt() {
if (Fl) {
var e = yl;
if (e !== null) throw e;
}
}
function ft(e, t, n, r) {
Fl = !1;
var i = e.updateQueue;
Pl = !1;
var a = i.firstBaseUpdate, o = i.lastBaseUpdate, s = i.shared.pending;
if (s !== null) {
i.shared.pending = null;
var c = s, l = c.next;
c.next = null, o === null ? a = l : o.next = l, o = c;
var u = e.alternate;
u !== null && (u = u.updateQueue, s = u.lastBaseUpdate, s !== o && (s === null ? u.firstBaseUpdate = l : s.next = l, u.lastBaseUpdate = c));
}
if (a !== null) {
var d = i.baseState;
o = 0, u = l = c = null, s = a;
do {
var f = s.lane & -536870913, p = f !== s.lane;
if (p ? (Z & f) === f : (r & f) === f) {
f !== 0 && f === vl && (Fl = !0), u !== null && (u = u.next = {
lane: 0,
tag: s.tag,
payload: s.payload,
callback: null,
next: null
});
e: {
var m = e, h = s;
f = t;
var g = n;
switch (h.tag) {
case 1:
if (m = h.payload, typeof m == "function") {
d = m.call(g, d, f);
break e;
}
d = m;
break e;
case 3: m.flags = m.flags & -65537 | 128;
case 0:
if (m = h.payload, f = typeof m == "function" ? m.call(g, d, f) : m, f == null) break e;
d = Ea({}, d, f);
break e;
case 2: Pl = !0;
}
}
f = s.callback, f !== null && (e.flags |= 64, p && (e.flags |= 8192), p = i.callbacks, p === null ? i.callbacks = [f] : p.push(f));
} else p = {
lane: f,
tag: s.tag,
payload: s.payload,
callback: s.callback,
next: null
}, u === null ? (l = u = p, c = d) : u = u.next = p, o |= f;
if (s = s.next, s === null) {
if (s = i.shared.pending, s === null) break;
p = s, s = p.next, p.next = null, i.lastBaseUpdate = p, i.shared.pending = null;
}
} while (!0);
u === null && (c = d), i.baseState = c, i.firstBaseUpdate = l, i.lastBaseUpdate = u, a === null && (i.shared.lanes = 0), ju |= o, e.lanes = o, e.memoizedState = d;
}
}
function pt(e, t) {
if (typeof e != "function") throw Error(r(191, e));
e.call(t);
}
function mt(e, t) {
var n = e.callbacks;
if (n !== null) for (e.callbacks = null, e = 0; e < n.length; e++) pt(n[e], t);
}
function ht(e, t) {
e = ku, m(Ll, e), m(Il, t), ku = e | t.baseLanes;
}
function gt() {
m(Ll, ku), m(Il, Il.current);
}
function _t() {
ku = Ll.current, p(Il), p(Ll);
}
function vt(e) {
var t = e.alternate;
m(Bl, Bl.current & 1), m(Rl, e), zl === null && (t === null || Il.current !== null || t.memoizedState !== null) && (zl = e);
}
function yt(e) {
m(Bl, Bl.current), m(Rl, e), zl === null && (zl = e);
}
function bt(e) {
e.tag === 22 ? (m(Bl, Bl.current), m(Rl, e), zl === null && (zl = e)) : xt();
}
function xt() {
m(Bl, Bl.current), m(Rl, Rl.current);
}
function St(e) {
p(Rl), zl === e && (zl = null), p(Bl);
}
function Ct(e) {
for (var t = e; t !== null;) {
if (t.tag === 13) {
var n = t.memoizedState;
if (n !== null && (n = n.dehydrated, n === null || ss(n) || cs(n))) return t;
} else if (t.tag === 19 && (t.memoizedProps.revealOrder === "forwards" || t.memoizedProps.revealOrder === "backwards" || t.memoizedProps.revealOrder === "unstable_legacy-backwards" || t.memoizedProps.revealOrder === "together")) {
if (t.flags & 128) return t;
} else if (t.child !== null) {
t.child.return = t, t = t.child;
continue;
}
if (t === e) break;
for (; t.sibling === null;) {
if (t.return === null || t.return === e) return null;
t = t.return;
}
t.sibling.return = t.return, t = t.sibling;
}
return null;
}
function wt() {
throw Error(r(321));
}
function Tt(e, t) {
if (t === null) return !1;
for (var n = 0; n < t.length && n < e.length; n++) if (!jc(e[n], t[n])) return !1;
return !0;
}
function Et(e, t, n, r, i, a) {
return Vl = a, Y = t, t.memoizedState = null, t.updateQueue = null, t.lanes = 0, J.H = e === null || e.memoizedState === null ? Ql : $l, Kl = !1, a = n(r, i), Kl = !1, Gl && (a = Ot(t, n, r, i)), Dt(e), a;
}
function Dt(e) {
J.H = Zl;
var t = Hl !== null && Hl.next !== null;
if (Vl = 0, Ul = Hl = Y = null, Wl = !1, Jl = 0, Yl = null, t) throw Error(r(300));
e === null || ru || (e = e.dependencies, e !== null && Ce(e) && (ru = !0));
}
function Ot(e, t, n, i) {
Y = e;
var a = 0;
do {
if (Gl && (Yl = null), Jl = 0, Gl = !1, 25 <= a) throw Error(r(301));
if (a += 1, Ul = Hl = null, e.updateQueue != null) {
var o = e.updateQueue;
o.lastEffect = null, o.events = null, o.stores = null, o.memoCache != null && (o.memoCache.index = 0);
}
J.H = eu, o = t(n, i);
} while (Gl);
return o;
}
function kt() {
var e = J.H, t = e.useState()[0];
return t = typeof t.then == "function" ? It(t) : t, e = e.useState()[0], (Hl === null ? null : Hl.memoizedState) !== e && (Y.flags |= 1024), t;
}
function At() {
var e = ql !== 0;
return ql = 0, e;
}
function jt(e, t, n) {
t.updateQueue = e.updateQueue, t.flags &= -2053, e.lanes &= ~n;
}
function Mt(e) {
if (Wl) {
for (e = e.memoizedState; e !== null;) {
var t = e.queue;
t !== null && (t.pending = null), e = e.next;
}
Wl = !1;
}
Vl = 0, Ul = Hl = Y = null, Gl = !1, Jl = ql = 0, Yl = null;
}
function Nt() {
var e = {
memoizedState: null,
baseState: null,
baseQueue: null,
queue: null,
next: null
};
return Ul === null ? Y.memoizedState = Ul = e : Ul = Ul.next = e, Ul;
}
function Pt() {
if (Hl === null) {
var e = Y.alternate;
e = e === null ? null : e.memoizedState;
} else e = Hl.next;
var t = Ul === null ? Y.memoizedState : Ul.next;
if (t !== null) Ul = t, Hl = e;
else {
if (e === null) throw Y.alternate === null ? Error(r(467)) : Error(r(310));
Hl = e, e = {
memoizedState: Hl.memoizedState,
baseState: Hl.baseState,
baseQueue: Hl.baseQueue,
queue: Hl.queue,
next: null
}, Ul === null ? Y.memoizedState = Ul = e : Ul = Ul.next = e;
}
return Ul;
}
function Ft() {
return {
lastEffect: null,
events: null,
stores: null,
memoCache: null
};
}
function It(e) {
var t = Jl;
return Jl += 1, Yl === null && (Yl = []), e = Ge(Yl, e, t), t = Y, (Ul === null ? t.memoizedState : Ul.next) === null && (t = t.alternate, J.H = t === null || t.memoizedState === null ? Ql : $l), e;
}
function Lt(e) {
if (typeof e == "object" && e) {
if (typeof e.then == "function") return It(e);
if (e.$$typeof === Pa) return Te(e);
}
throw Error(r(438, String(e)));
}
function Rt(e) {
var t = null, n = Y.updateQueue;
if (n !== null && (t = n.memoCache), t == null) {
var r = Y.alternate;
r !== null && (r = r.updateQueue, r !== null && (r = r.memoCache, r != null && (t = {
data: r.data.map(function(e) {
return e.slice();
}),
index: 0
})));
}
if (t == null && (t = {
data: [],
index: 0
}), n === null && (n = Ft(), Y.updateQueue = n), n.memoCache = t, n = t.data[t.index], n === void 0) for (n = t.data[t.index] = Array(e), r = 0; r < e; r++) n[r] = Va;
return t.index++, n;
}
function zt(e, t) {
return typeof t == "function" ? t(e) : t;
}
function Bt(e) {
return Vt(Pt(), Hl, e);
}
function Vt(e, t, n) {
var i = e.queue;
if (i === null) throw Error(r(311));
i.lastRenderedReducer = n;
var a = e.baseQueue, o = i.pending;
if (o !== null) {
if (a !== null) {
var s = a.next;
a.next = o.next, o.next = s;
}
t.baseQueue = a = o, i.pending = null;
}
if (o = e.baseState, a === null) e.memoizedState = o;
else {
t = a.next;
var c = s = null, l = null, u = t, d = !1;
do {
var f = u.lane & -536870913;
if (f === u.lane ? (Vl & f) === f : (Z & f) === f) {
var p = u.revertLane;
if (p === 0) l !== null && (l = l.next = {
lane: 0,
revertLane: 0,
gesture: null,
action: u.action,
hasEagerState: u.hasEagerState,
eagerState: u.eagerState,
next: null
}), f === vl && (d = !0);
else if ((Vl & p) === p) {
u = u.next, p === vl && (d = !0);
continue;
} else f = {
lane: 0,
revertLane: u.revertLane,
gesture: null,
action: u.action,
hasEagerState: u.hasEagerState,
eagerState: u.eagerState,
next: null
}, l === null ? (c = l = f, s = o) : l = l.next = f, Y.lanes |= p, ju |= p;
f = u.action, Kl && n(o, f), o = u.hasEagerState ? u.eagerState : n(o, f);
} else p = {
lane: f,
revertLane: u.revertLane,
gesture: u.gesture,
action: u.action,
hasEagerState: u.hasEagerState,
eagerState: u.eagerState,
next: null
}, l === null ? (c = l = p, s = o) : l = l.next = p, Y.lanes |= f, ju |= f;
u = u.next;
} while (u !== null && u !== t);
if (l === null ? s = o : l.next = c, !jc(o, e.memoizedState) && (ru = !0, d && (n = yl, n !== null))) throw n;
e.memoizedState = o, e.baseState = s, e.baseQueue = l, i.lastRenderedState = o;
}
return a === null && (i.lanes = 0), [e.memoizedState, i.dispatch];
}
function Ht(e) {
var t = Pt(), n = t.queue;
if (n === null) throw Error(r(311));
n.lastRenderedReducer = e;
var i = n.dispatch, a = n.pending, o = t.memoizedState;
if (a !== null) {
n.pending = null;
var s = a = a.next;
do
o = e(o, s.action), s = s.next;
while (s !== a);
jc(o, t.memoizedState) || (ru = !0), t.memoizedState = o, t.baseQueue === null && (t.baseState = o), n.lastRenderedState = o;
}
return [o, i];
}
function Ut(e, t, n) {
var i = Y, a = Pt(), o = $c;
if (o) {
if (n === void 0) throw Error(r(407));
n = n();
} else n = t();
var s = !jc((Hl || a).memoizedState, n);
if (s && (a.memoizedState = n, ru = !0), a = a.queue, pn(Kt.bind(null, i, a, e), [e]), a.getSnapshot !== t || s || Ul !== null && Ul.memoizedState.tag & 1) {
if (i.flags |= 2048, cn(9, { destroy: void 0 }, Gt.bind(null, i, a, n, t), null), Su === null) throw Error(r(349));
o || Vl & 127 || Wt(i, t, n);
}
return n;
}
function Wt(e, t, n) {
e.flags |= 16384, e = {
getSnapshot: t,
value: n
}, t = Y.updateQueue, t === null ? (t = Ft(), Y.updateQueue = t, t.stores = [e]) : (n = t.stores, n === null ? t.stores = [e] : n.push(e));
}
function Gt(e, t, n, r) {
t.value = n, t.getSnapshot = r, qt(t) && Jt(e);
}
function Kt(e, t, n) {
return n(function() {
qt(t) && Jt(e);
});
}
function qt(e) {
var t = e.getSnapshot;
e = e.value;
try {
var n = t();
return !jc(e, n);
} catch {
return !0;
}
}
function Jt(e) {
var t = nt(e, 2);
t !== null && Ei(t, e, 2);
}
function Yt(e) {
var t = Nt();
if (typeof e == "function") {
var n = e;
if (e = n(), Kl) {
k(!0);
try {
n();
} finally {
k(!1);
}
}
}
return t.memoizedState = t.baseState = e, t.queue = {
pending: null,
lanes: 0,
dispatch: null,
lastRenderedReducer: zt,
lastRenderedState: e
}, t;
}
function Xt(e, t, n, r) {
return e.baseState = n, Vt(e, Hl, typeof r == "function" ? r : zt);
}
function Zt(e, t, n, i, a) {
if (B(e)) throw Error(r(485));
if (e = t.action, e !== null) {
var o = {
payload: a,
action: e,
next: null,
isTransition: !0,
status: "pending",
value: null,
reason: null,
listeners: [],
then: function(e) {
o.listeners.push(e);
}
};
J.T === null ? o.isTransition = !1 : n(!0), i(o), n = t.pending, n === null ? (o.next = t.pending = o, Qt(t, o)) : (o.next = n.next, t.pending = n.next = o);
}
}
function Qt(e, t) {
var n = t.action, r = t.payload, i = e.state;
if (t.isTransition) {
var a = J.T, o = {};
J.T = o;
try {
var s = n(i, r), c = J.S;
c !== null && c(o, s), $t(e, t, s);
} catch (n) {
tn(e, t, n);
} finally {
a !== null && o.types !== null && (a.types = o.types), J.T = a;
}
} else try {
a = n(i, r), $t(e, t, a);
} catch (n) {
tn(e, t, n);
}
}
function $t(e, t, n) {
typeof n == "object" && n && typeof n.then == "function" ? n.then(function(n) {
en(e, t, n);
}, function(n) {
return tn(e, t, n);
}) : en(e, t, n);
}
function en(e, t, n) {
t.status = "fulfilled", t.value = n, nn(t), e.state = n, t = e.pending, t !== null && (n = t.next, n === t ? e.pending = null : (n = n.next, t.next = n, Qt(e, n)));
}
function tn(e, t, n) {
var r = e.pending;
if (e.pending = null, r !== null) {
r = r.next;
do
t.status = "rejected", t.reason = n, nn(t), t = t.next;
while (t !== r);
}
e.action = null;
}
function nn(e) {
e = e.listeners;
for (var t = 0; t < e.length; t++) (0, e[t])();
}
function rn(e, t) {
return t;
}
function an(e, t) {
if ($c) {
var n = Su.formState;
if (n !== null) {
e: {
var r = Y;
if ($c) {
if (Qc) {
var i = ds(Qc, tl);
if (i) {
Qc = ps(i), r = fs(i);
break e;
}
}
de(r);
}
r = !1;
}
r && (t = n[0]);
}
}
n = Nt(), n.memoizedState = n.baseState = t, r = {
pending: null,
lanes: 0,
dispatch: null,
lastRenderedReducer: rn,
lastRenderedState: t
}, n.queue = r, n = jn.bind(null, Y, r), r.dispatch = n, r = Yt(!1);
var a = Nn.bind(null, Y, !1, r.queue);
return r = Nt(), i = {
state: t,
dispatch: null,
action: e,
pending: null
}, r.queue = i, n = Zt.bind(null, Y, i, a, n), i.dispatch = n, r.memoizedState = e, [
t,
n,
!1
];
}
function L(e) {
return R(Pt(), Hl, e);
}
function R(e, t, n) {
if (t = Vt(e, t, rn)[0], e = Bt(zt)[0], typeof t == "object" && t && typeof t.then == "function") try {
var r = It(t);
} catch (e) {
throw e === Sl ? wl : e;
}
else r = t;
t = Pt();
var i = t.queue, a = i.dispatch;
return n !== t.memoizedState && (Y.flags |= 2048, cn(9, { destroy: void 0 }, on.bind(null, i, n), null)), [
r,
a,
e
];
}
function on(e, t) {
e.action = t;
}
function sn(e) {
var t = Pt(), n = Hl;
if (n !== null) return R(t, n, e);
Pt(), t = t.memoizedState, n = Pt();
var r = n.queue.dispatch;
return n.memoizedState = e, [
t,
r,
!1
];
}
function cn(e, t, n, r) {
return e = {
tag: e,
create: n,
deps: r,
inst: t,
next: null
}, t = Y.updateQueue, t === null && (t = Ft(), Y.updateQueue = t), n = t.lastEffect, n === null ? t.lastEffect = e.next = e : (r = n.next, n.next = e, e.next = r, t.lastEffect = e), e;
}
function ln() {
return Pt().memoizedState;
}
function un(e, t, n, r) {
var i = Nt();
Y.flags |= e, i.memoizedState = cn(1 | t, { destroy: void 0 }, n, r === void 0 ? null : r);
}
function dn(e, t, n, r) {
var i = Pt();
r = r === void 0 ? null : r;
var a = i.memoizedState.inst;
Hl !== null && r !== null && Tt(r, Hl.memoizedState.deps) ? i.memoizedState = cn(t, a, n, r) : (Y.flags |= e, i.memoizedState = cn(1 | t, a, n, r));
}
function fn(e, t) {
un(8390656, 8, e, t);
}
function pn(e, t) {
dn(2048, 8, e, t);
}
function mn(e) {
Y.flags |= 4;
var t = Y.updateQueue;
if (t === null) t = Ft(), Y.updateQueue = t, t.events = [e];
else {
var n = t.events;
n === null ? t.events = [e] : n.push(e);
}
}
function z(e) {
var t = Pt().memoizedState;
return mn({
ref: t,
nextImpl: e
}), function() {
if (X & 2) throw Error(r(440));
return t.impl.apply(void 0, arguments);
};
}
function hn(e, t) {
return dn(4, 2, e, t);
}
function gn(e, t) {
return dn(4, 4, e, t);
}
function _n(e, t) {
if (typeof t == "function") {
e = e();
var n = t(e);
return function() {
typeof n == "function" ? n() : t(null);
};
}
if (t != null) return e = e(), t.current = e, function() {
t.current = null;
};
}
function vn(e, t, n) {
n = n == null ? null : n.concat([e]), dn(4, 4, _n.bind(null, t, e), n);
}
function yn() {}
function bn(e, t) {
var n = Pt();
t = t === void 0 ? null : t;
var r = n.memoizedState;
return t !== null && Tt(t, r[1]) ? r[0] : (n.memoizedState = [e, t], e);
}
function xn(e, t) {
var n = Pt();
t = t === void 0 ? null : t;
var r = n.memoizedState;
if (t !== null && Tt(t, r[1])) return r[0];
if (r = e(), Kl) {
k(!0);
try {
e();
} finally {
k(!1);
}
}
return n.memoizedState = [r, t], r;
}
function Sn(e, t, n) {
return n === void 0 || Vl & 1073741824 && !(Z & 261930) ? e.memoizedState = t : (e.memoizedState = n, e = Ti(), Y.lanes |= e, ju |= e, n);
}
function Cn(e, t, n, r) {
return jc(n, t) ? n : Il.current === null ? !(Vl & 42) || Vl & 1073741824 && !(Z & 261930) ? (ru = !0, e.memoizedState = n) : (e = Ti(), Y.lanes |= e, ju |= e, t) : (e = Sn(e, n, r), jc(e, t) || (ru = !0), e);
}
function wn(e, t, n, r, i) {
var a = ho();
mo(a !== 0 && 8 > a ? a : 8);
var o = J.T, s = {};
J.T = s, Nn(e, !1, t, n);
try {
var c = i(), l = J.S;
l !== null && l(s, c), typeof c == "object" && c && typeof c.then == "function" ? Mn(e, t, ze(c, r), wi(e)) : Mn(e, t, r, wi(e));
} catch (n) {
Mn(e, t, {
then: function() {},
status: "rejected",
reason: n
}, wi());
} finally {
mo(a), o !== null && s.types !== null && (o.types = s.types), J.T = o;
}
}
function Tn(e) {
var t = e.memoizedState;
if (t !== null) return t;
t = {
memoizedState: Eo,
baseState: Eo,
baseQueue: null,
queue: {
pending: null,
lanes: 0,
dispatch: null,
lastRenderedReducer: zt,
lastRenderedState: Eo
},
next: null
};
var n = {};
return t.next = {
memoizedState: n,
baseState: n,
baseQueue: null,
queue: {
pending: null,
lanes: 0,
dispatch: null,
lastRenderedReducer: zt,
lastRenderedState: n
},
next: null
}, e.memoizedState = t, e = e.alternate, e !== null && (e.memoizedState = t), t;
}
function En() {
return Te(Do);
}
function Dn() {
return Pt().memoizedState;
}
function On() {
return Pt().memoizedState;
}
function kn(e) {
for (var t = e.return; t !== null;) {
switch (t.tag) {
case 24:
case 3:
var n = wi();
e = st(n);
var r = ct(t, e, n);
r !== null && (Ei(r, t, n), lt(r, t, n)), t = { cache: Oe() }, e.payload = t;
return;
}
t = t.return;
}
}
function An(e, t, n) {
var r = wi();
n = {
lane: r,
revertLane: 0,
gesture: null,
action: n,
hasEagerState: !1,
eagerState: null,
next: null
}, B(e) ? Pn(t, n) : (n = tt(e, t, n, r), n !== null && (Ei(n, e, r), V(n, t, r)));
}
function jn(e, t, n) {
Mn(e, t, n, wi());
}
function Mn(e, t, n, r) {
var i = {
lane: r,
revertLane: 0,
gesture: null,
action: n,
hasEagerState: !1,
eagerState: null,
next: null
};
if (B(e)) Pn(t, i);
else {
var a = e.alternate;
if (e.lanes === 0 && (a === null || a.lanes === 0) && (a = t.lastRenderedReducer, a !== null)) try {
var o = t.lastRenderedState, s = a(o, n);
if (i.hasEagerState = !0, i.eagerState = s, jc(s, o)) return et(e, t, i, 0), Su === null && $e(), !1;
} catch {}
if (n = tt(e, t, i, r), n !== null) return Ei(n, e, r), V(n, t, r), !0;
}
return !1;
}
function Nn(e, t, n, i) {
if (i = {
lane: 2,
revertLane: F(),
gesture: null,
action: i,
hasEagerState: !1,
eagerState: null,
next: null
}, B(e)) {
if (t) throw Error(r(479));
} else t = tt(e, n, i, 2), t !== null && Ei(t, e, 2);
}
function B(e) {
var t = e.alternate;
return e === Y || t !== null && t === Y;
}
function Pn(e, t) {
Gl = Wl = !0;
var n = e.pending;
n === null ? t.next = t : (t.next = n.next, n.next = t), e.pending = t;
}
function V(e, t, n) {
if (n & 4194048) {
var r = t.lanes;
r &= e.pendingLanes, n |= r, t.lanes = n, T(e, n);
}
}
function Fn(e, t, n, r) {
t = e.memoizedState, n = n(r, t), n = n == null ? t : Ea({}, t, n), e.memoizedState = n, e.lanes === 0 && (e.updateQueue.baseState = n);
}
function H(e, t, n, r, i, a, o) {
return e = e.stateNode, typeof e.shouldComponentUpdate == "function" ? e.shouldComponentUpdate(r, a, o) : t.prototype && t.prototype.isPureReactComponent ? !Ue(n, r) || !Ue(i, a) : !0;
}
function In(e, t, n, r) {
e = t.state, typeof t.componentWillReceiveProps == "function" && t.componentWillReceiveProps(n, r), typeof t.UNSAFE_componentWillReceiveProps == "function" && t.UNSAFE_componentWillReceiveProps(n, r), t.state !== e && tu.enqueueReplaceState(t, t.state, null);
}
function Ln(e, t) {
var n = t;
if ("ref" in t) for (var r in n = {}, t) r !== "ref" && (n[r] = t[r]);
if (e = e.defaultProps) for (var i in n === t && (n = Ea({}, n)), e) n[i] === void 0 && (n[i] = e[i]);
return n;
}
function U(e, t) {
try {
var n = e.onUncaughtError;
n(t.value, { componentStack: t.stack });
} catch (e) {
setTimeout(function() {
throw e;
});
}
}
function Rn(e, t, n) {
try {
var r = e.onCaughtError;
r(n.value, {
componentStack: n.stack,
errorBoundary: t.tag === 1 ? t.stateNode : null
});
} catch (e) {
setTimeout(function() {
throw e;
});
}
}
function zn(e, t, n) {
return n = st(n), n.tag = 3, n.payload = { element: null }, n.callback = function() {
U(e, t);
}, n;
}
function Bn(e) {
return e = st(e), e.tag = 3, e;
}
function Vn(e, t, n, r) {
var i = n.type.getDerivedStateFromError;
if (typeof i == "function") {
var a = r.value;
e.payload = function() {
return i(a);
}, e.callback = function() {
Rn(t, n, r);
};
}
var o = n.stateNode;
o !== null && typeof o.componentDidCatch == "function" && (e.callback = function() {
Rn(t, n, r), typeof i != "function" && (Uu === null ? Uu = /* @__PURE__ */ new Set([this]) : Uu.add(this));
var e = r.stack;
this.componentDidCatch(r.value, { componentStack: e === null ? "" : e });
});
}
function Hn(e, t, n, i, a) {
if (n.flags |= 32768, typeof i == "object" && i && typeof i.then == "function") {
if (t = n.alternate, t !== null && Se(t, n, a, !0), n = Rl.current, n !== null) {
switch (n.tag) {
case 31:
case 13: return zl === null ? Li() : n.alternate === null && Au === 0 && (Au = 3), n.flags &= -257, n.flags |= 65536, n.lanes = a, i === Tl ? n.flags |= 16384 : (t = n.updateQueue, t === null ? n.updateQueue = /* @__PURE__ */ new Set([i]) : t.add(i), ta(e, i, a)), !1;
case 22: return n.flags |= 65536, i === Tl ? n.flags |= 16384 : (t = n.updateQueue, t === null ? (t = {
transitions: null,
markerInstances: null,
retryQueue: /* @__PURE__ */ new Set([i])
}, n.updateQueue = t) : (n = t.retryQueue, n === null ? t.retryQueue = /* @__PURE__ */ new Set([i]) : n.add(i)), ta(e, i, a)), !1;
}
throw Error(r(435, n.tag));
}
return ta(e, i, a), Li(), !1;
}
if ($c) return t = Rl.current, t === null ? (i !== nl && (t = Error(r(423), { cause: i }), _e(M(t, n))), e = e.current.alternate, e.flags |= 65536, a &= -a, e.lanes |= a, i = M(i, n), a = zn(e.stateNode, i, a), ut(e, a), Au !== 4 && (Au = 2)) : (!(t.flags & 65536) && (t.flags |= 256), t.flags |= 65536, t.lanes = a, i !== nl && (e = Error(r(422), { cause: i }), _e(M(e, n)))), !1;
var o = Error(r(520), { cause: i });
if (o = M(o, n), Iu === null ? Iu = [o] : Iu.push(o), Au !== 4 && (Au = 2), t === null) return !0;
i = M(i, n), n = t;
do {
switch (n.tag) {
case 3: return n.flags |= 65536, e = a & -a, n.lanes |= e, e = zn(n.stateNode, i, e), ut(n, e), !1;
case 1: if (t = n.type, o = n.stateNode, !(n.flags & 128) && (typeof t.getDerivedStateFromError == "function" || o !== null && typeof o.componentDidCatch == "function" && (Uu === null || !Uu.has(o)))) return n.flags |= 65536, a &= -a, n.lanes |= a, a = Bn(a), Vn(a, e, n, i), ut(n, a), !1;
}
n = n.return;
} while (n !== null);
return !1;
}
function Un(e, t, n, r) {
t.child = e === null ? Al(t, null, n, r) : kl(t, e.child, n, r);
}
function Wn(e, t, n, r, i) {
n = n.render;
var a = t.ref;
if ("ref" in r) {
var o = {};
for (var s in r) s !== "ref" && (o[s] = r[s]);
} else o = r;
return we(t), r = Et(e, t, n, o, a, i), s = At(), e !== null && !ru ? (jt(e, t, i), fr(e, t, i)) : ($c && s && ae(t), t.flags |= 1, Un(e, t, r, i), t.child);
}
function Gn(e, t, n, r, i) {
if (e === null) {
var a = n.type;
return typeof a == "function" && !ca(a) && a.defaultProps === void 0 && n.compare === null ? (t.tag = 15, t.type = a, Kn(e, t, a, r, i)) : (e = da(n.type, null, r, t, t.mode, i), e.ref = t.ref, e.return = t, t.child = e);
}
if (a = e.child, !pr(e, i)) {
var o = a.memoizedProps;
if (n = n.compare, n = n === null ? Ue : n, n(o, r) && e.ref === t.ref) return fr(e, t, i);
}
return t.flags |= 1, e = la(a, r), e.ref = t.ref, e.return = t, t.child = e;
}
function Kn(e, t, n, r, i) {
if (e !== null) {
var a = e.memoizedProps;
if (Ue(a, r) && e.ref === t.ref) if (ru = !1, t.pendingProps = r = a, pr(e, i)) e.flags & 131072 && (ru = !0);
else return t.lanes = e.lanes, fr(e, t, i);
}
return er(e, t, n, r, i);
}
function qn(e, t, n, r) {
var i = r.children, a = e === null ? null : e.memoizedState;
if (e === null && t.stateNode === null && (t.stateNode = {
_visibility: 1,
_pendingMarkers: null,
_retryCache: null,
_transitions: null
}), r.mode === "hidden") {
if (t.flags & 128) {
if (a = a === null ? n : a.baseLanes | n, e !== null) {
for (r = t.child = e.child, i = 0; r !== null;) i = i | r.lanes | r.childLanes, r = r.sibling;
r = i & ~a;
} else r = 0, t.child = null;
return Yn(e, t, a, n, r);
}
if (n & 536870912) t.memoizedState = {
baseLanes: 0,
cachePool: null
}, e !== null && Ve(t, a === null ? null : a.cachePool), a === null ? gt() : ht(t, a), bt(t);
else return r = t.lanes = 536870912, Yn(e, t, a === null ? n : a.baseLanes | n, n, r);
} else a === null ? (e !== null && Ve(t, null), gt(), xt()) : (Ve(t, a.cachePool), ht(t, a), xt(), t.memoizedState = null);
return Un(e, t, i, n), t.child;
}
function Jn(e, t) {
return e !== null && e.tag === 22 || t.stateNode !== null || (t.stateNode = {
_visibility: 1,
_pendingMarkers: null,
_retryCache: null,
_transitions: null
}), t.sibling;
}
function Yn(e, t, n, r, i) {
var a = Be();
return a = a === null ? null : {
parent: so ? ll._currentValue : ll._currentValue2,
pool: a
}, t.memoizedState = {
baseLanes: n,
cachePool: a
}, e !== null && Ve(t, null), gt(), bt(t), e !== null && Se(e, t, r, !0), t.childLanes = i, null;
}
function Xn(e, t) {
return t = sr({
mode: t.mode,
children: t.children
}, e.mode), t.ref = e.ref, e.child = t, t.return = e, t;
}
function Zn(e, t, n) {
return kl(t, e.child, null, n), e = Xn(t, t.pendingProps), e.flags |= 2, St(t), t.memoizedState = null, e;
}
function Qn(e, t, n) {
var i = t.pendingProps, a = (t.flags & 128) != 0;
if (t.flags &= -129, e === null) {
if ($c) {
if (i.mode === "hidden") return e = Xn(t, i), t.lanes = 536870912, Jn(null, e);
if (yt(t), (e = Qc) ? (e = Ss(e, tl), e !== null && (t.memoizedState = {
dehydrated: e,
treeContext: Wc === null ? null : {
id: Gc,
overflow: Kc
},
retryLane: 536870912,
hydrationErrors: null
}, n = ma(e), n.return = t, t.child = n, Zc = t, Qc = null)) : e = null, e === null) throw de(t);
return t.lanes = 536870912, null;
}
return Xn(t, i);
}
var o = e.memoizedState;
if (o !== null) {
var s = o.dehydrated;
if (yt(t), a) if (t.flags & 256) t.flags &= -257, t = Zn(e, t, n);
else if (t.memoizedState !== null) t.child = e.child, t.flags |= 128, t = null;
else throw Error(r(558));
else if (ru || Se(e, t, n, !1), a = (n & e.childLanes) !== 0, ru || a) {
if (i = Su, i !== null && (s = E(i, n), s !== 0 && s !== o.retryLane)) throw o.retryLane = s, nt(e, s), Ei(i, e, s), nu;
Li(), t = Zn(e, t, n);
} else e = o.treeContext, uo && (Qc = _s(s), Zc = t, $c = !0, el = null, tl = !1, e !== null && se(t, e)), t = Xn(t, i), t.flags |= 4096;
return t;
}
return e = la(e.child, {
mode: i.mode,
children: i.children
}), e.ref = t.ref, t.child = e, e.return = t, e;
}
function $n(e, t) {
var n = t.ref;
if (n === null) e !== null && e.ref !== null && (t.flags |= 4194816);
else {
if (typeof n != "function" && typeof n != "object") throw Error(r(284));
(e === null || e.ref !== n) && (t.flags |= 4194816);
}
}
function er(e, t, n, r, i) {
return we(t), n = Et(e, t, n, r, void 0, i), r = At(), e !== null && !ru ? (jt(e, t, i), fr(e, t, i)) : ($c && r && ae(t), t.flags |= 1, Un(e, t, n, i), t.child);
}
function tr(e, t, n, r, i, a) {
return we(t), t.updateQueue = null, n = Ot(t, r, n, i), Dt(e), r = At(), e !== null && !ru ? (jt(e, t, a), fr(e, t, a)) : ($c && r && ae(t), t.flags |= 1, Un(e, t, n, a), t.child);
}
function nr(e, t, n, r, i) {
if (we(t), t.stateNode === null) {
var a = dc, o = n.contextType;
typeof o == "object" && o && (a = Te(o)), a = new n(r, a), t.memoizedState = a.state !== null && a.state !== void 0 ? a.state : null, a.updater = tu, t.stateNode = a, a._reactInternals = t, a = t.stateNode, a.props = r, a.state = t.memoizedState, a.refs = {}, at(t), o = n.contextType, a.context = typeof o == "object" && o ? Te(o) : dc, a.state = t.memoizedState, o = n.getDerivedStateFromProps, typeof o == "function" && (Fn(t, n, o, r), a.state = t.memoizedState), typeof n.getDerivedStateFromProps == "function" || typeof a.getSnapshotBeforeUpdate == "function" || typeof a.UNSAFE_componentWillMount != "function" && typeof a.componentWillMount != "function" || (o = a.state, typeof a.componentWillMount == "function" && a.componentWillMount(), typeof a.UNSAFE_componentWillMount == "function" && a.UNSAFE_componentWillMount(), o !== a.state && tu.enqueueReplaceState(a, a.state, null), ft(t, r, a, i), dt(), a.state = t.memoizedState), typeof a.componentDidMount == "function" && (t.flags |= 4194308), r = !0;
} else if (e === null) {
a = t.stateNode;
var s = t.memoizedProps, c = Ln(n, s);
a.props = c;
var l = a.context, u = n.contextType;
o = dc, typeof u == "object" && u && (o = Te(u));
var d = n.getDerivedStateFromProps;
u = typeof d == "function" || typeof a.getSnapshotBeforeUpdate == "function", s = t.pendingProps !== s, u || typeof a.UNSAFE_componentWillReceiveProps != "function" && typeof a.componentWillReceiveProps != "function" || (s || l !== o) && In(t, a, r, o), Pl = !1;
var f = t.memoizedState;
a.state = f, ft(t, r, a, i), dt(), l = t.memoizedState, s || f !== l || Pl ? (typeof d == "function" && (Fn(t, n, d, r), l = t.memoizedState), (c = Pl || H(t, n, c, r, f, l, o)) ? (u || typeof a.UNSAFE_componentWillMount != "function" && typeof a.componentWillMount != "function" || (typeof a.componentWillMount == "function" && a.componentWillMount(), typeof a.UNSAFE_componentWillMount == "function" && a.UNSAFE_componentWillMount()), typeof a.componentDidMount == "function" && (t.flags |= 4194308)) : (typeof a.componentDidMount == "function" && (t.flags |= 4194308), t.memoizedProps = r, t.memoizedState = l), a.props = r, a.state = l, a.context = o, r = c) : (typeof a.componentDidMount == "function" && (t.flags |= 4194308), r = !1);
} else {
a = t.stateNode, ot(e, t), o = t.memoizedProps, u = Ln(n, o), a.props = u, d = t.pendingProps, f = a.context, l = n.contextType, c = dc, typeof l == "object" && l && (c = Te(l)), s = n.getDerivedStateFromProps, (l = typeof s == "function" || typeof a.getSnapshotBeforeUpdate == "function") || typeof a.UNSAFE_componentWillReceiveProps != "function" && typeof a.componentWillReceiveProps != "function" || (o !== d || f !== c) && In(t, a, r, c), Pl = !1, f = t.memoizedState, a.state = f, ft(t, r, a, i), dt();
var p = t.memoizedState;
o !== d || f !== p || Pl || e !== null && e.dependencies !== null && Ce(e.dependencies) ? (typeof s == "function" && (Fn(t, n, s, r), p = t.memoizedState), (u = Pl || H(t, n, u, r, f, p, c) || e !== null && e.dependencies !== null && Ce(e.dependencies)) ? (l || typeof a.UNSAFE_componentWillUpdate != "function" && typeof a.componentWillUpdate != "function" || (typeof a.componentWillUpdate == "function" && a.componentWillUpdate(r, p, c), typeof a.UNSAFE_componentWillUpdate == "function" && a.UNSAFE_componentWillUpdate(r, p, c)), typeof a.componentDidUpdate == "function" && (t.flags |= 4), typeof a.getSnapshotBeforeUpdate == "function" && (t.flags |= 1024)) : (typeof a.componentDidUpdate != "function" || o === e.memoizedProps && f === e.memoizedState || (t.flags |= 4), typeof a.getSnapshotBeforeUpdate != "function" || o === e.memoizedProps && f === e.memoizedState || (t.flags |= 1024), t.memoizedProps = r, t.memoizedState = p), a.props = r, a.state = p, a.context = c, r = u) : (typeof a.componentDidUpdate != "function" || o === e.memoizedProps && f === e.memoizedState || (t.flags |= 4), typeof a.getSnapshotBeforeUpdate != "function" || o === e.memoizedProps && f === e.memoizedState || (t.flags |= 1024), r = !1);
}
return a = r, $n(e, t), r = (t.flags & 128) != 0, a || r ? (a = t.stateNode, n = r && typeof n.getDerivedStateFromError != "function" ? null : a.render(), t.flags |= 1, e !== null && r ? (t.child = kl(t, e.child, null, i), t.child = kl(t, null, n, i)) : Un(e, t, n, i), t.memoizedState = a.state, e = t.child) : e = fr(e, t, i), e;
}
function rr(e, t, n, r) {
return he(), t.flags |= 256, Un(e, t, n, r), t.child;
}
function ir(e) {
return {
baseLanes: e,
cachePool: He()
};
}
function ar(e, t, n) {
return e = e === null ? 0 : e.childLanes & ~n, t && (e |= Pu), e;
}
function W(e, t, n) {
var i = t.pendingProps, a = !1, o = (t.flags & 128) != 0, s;
if ((s = o) || (s = e !== null && e.memoizedState === null ? !1 : (Bl.current & 2) != 0), s && (a = !0, t.flags &= -129), s = (t.flags & 32) != 0, t.flags &= -33, e === null) {
if ($c) {
if (a ? vt(t) : xt(), (e = Qc) ? (e = Cs(e, tl), e !== null && (t.memoizedState = {
dehydrated: e,
treeContext: Wc === null ? null : {
id: Gc,
overflow: Kc
},
retryLane: 536870912,
hydrationErrors: null
}, n = ma(e), n.return = t, t.child = n, Zc = t, Qc = null)) : e = null, e === null) throw de(t);
return cs(e) ? t.lanes = 32 : t.lanes = 536870912, null;
}
var c = i.children;
return i = i.fallback, a ? (xt(), a = t.mode, c = sr({
mode: "hidden",
children: c
}, a), i = fa(i, a, n, null), c.return = t, i.return = t, c.sibling = i, t.child = c, i = t.child, i.memoizedState = ir(n), i.childLanes = ar(e, s, n), t.memoizedState = iu, Jn(null, i)) : (vt(t), or(t, c));
}
var l = e.memoizedState;
if (l !== null && (c = l.dehydrated, c !== null)) {
if (o) t.flags & 256 ? (vt(t), t.flags &= -257, t = cr(e, t, n)) : t.memoizedState === null ? (xt(), c = i.fallback, a = t.mode, i = sr({
mode: "visible",
children: i.children
}, a), c = fa(c, a, n, null), c.flags |= 2, i.return = t, c.return = t, i.sibling = c, t.child = i, kl(t, e.child, null, n), i = t.child, i.memoizedState = ir(n), i.childLanes = ar(e, s, n), t.memoizedState = iu, t = Jn(null, i)) : (xt(), t.child = e.child, t.flags |= 128, t = null);
else if (vt(t), cs(c)) s = ls(c).digest, i = Error(r(419)), i.stack = "", i.digest = s, _e({
value: i,
source: null,
stack: null
}), t = cr(e, t, n);
else if (ru || Se(e, t, n, !1), s = (n & e.childLanes) !== 0, ru || s) {
if (s = Su, s !== null && (i = E(s, n), i !== 0 && i !== l.retryLane)) throw l.retryLane = i, nt(e, i), Ei(s, e, i), nu;
ss(c) || Li(), t = cr(e, t, n);
} else ss(c) ? (t.flags |= 192, t.child = e.child, t = null) : (e = l.treeContext, uo && (Qc = vs(c), Zc = t, $c = !0, el = null, tl = !1, e !== null && se(t, e)), t = or(t, i.children), t.flags |= 4096);
return t;
}
return a ? (xt(), c = i.fallback, a = t.mode, l = e.child, o = l.sibling, i = la(l, {
mode: "hidden",
children: i.children
}), i.subtreeFlags = l.subtreeFlags & 65011712, o === null ? (c = fa(c, a, n, null), c.flags |= 2) : c = la(o, c), c.return = t, i.return = t, i.sibling = c, t.child = i, Jn(null, i), i = t.child, c = e.child.memoizedState, c === null ? c = ir(n) : (a = c.cachePool, a === null ? a = He() : (l = so ? ll._currentValue : ll._currentValue2, a = a.parent === l ? a : {
parent: l,
pool: l
}), c = {
baseLanes: c.baseLanes | n,
cachePool: a
}), i.memoizedState = c, i.childLanes = ar(e, s, n), t.memoizedState = iu, Jn(e.child, i)) : (vt(t), n = e.child, e = n.sibling, n = la(n, {
mode: "visible",
children: i.children
}), n.return = t, n.sibling = null, e !== null && (s = t.deletions, s === null ? (t.deletions = [e], t.flags |= 16) : s.push(e)), t.child = n, t.memoizedState = null, n);
}
function or(e, t) {
return t = sr({
mode: "visible",
children: t
}, e.mode), t.return = e, e.child = t;
}
function sr(e, n) {
return e = t(22, e, null, n), e.lanes = 0, e;
}
function cr(e, t, n) {
return kl(t, e.child, null, n), e = or(t, t.pendingProps.children), e.flags |= 2, t.memoizedState = null, e;
}
function lr(e, t, n) {
e.lanes |= t;
var r = e.alternate;
r !== null && (r.lanes |= t), be(e.return, t, n);
}
function ur(e, t, n, r, i, a) {
var o = e.memoizedState;
o === null ? e.memoizedState = {
isBackwards: t,
rendering: null,
renderingStartTime: 0,
last: r,
tail: n,
tailMode: i,
treeForkCount: a
} : (o.isBackwards = t, o.rendering = null, o.renderingStartTime = 0, o.last = r, o.tail = n, o.tailMode = i, o.treeForkCount = a);
}
function dr(e, t, n) {
var r = t.pendingProps, i = r.revealOrder, a = r.tail;
r = r.children;
var o = Bl.current, s = (o & 2) != 0;
if (s ? (o = o & 1 | 2, t.flags |= 128) : o &= 1, m(Bl, o), Un(e, t, r, n), r = $c ? Vc : 0, !s && e !== null && e.flags & 128) e: for (e = t.child; e !== null;) {
if (e.tag === 13) e.memoizedState !== null && lr(e, n, t);
else if (e.tag === 19) lr(e, n, t);
else if (e.child !== null) {
e.child.return = e, e = e.child;
continue;
}
if (e === t) break e;
for (; e.sibling === null;) {
if (e.return === null || e.return === t) break e;
e = e.return;
}
e.sibling.return = e.return, e = e.sibling;
}
switch (i) {
case "forwards":
for (n = t.child, i = null; n !== null;) e = n.alternate, e !== null && Ct(e) === null && (i = n), n = n.sibling;
n = i, n === null ? (i = t.child, t.child = null) : (i = n.sibling, n.sibling = null), ur(t, !1, i, n, a, r);
break;
case "backwards":
case "unstable_legacy-backwards":
for (n = null, i = t.child, t.child = null; i !== null;) {
if (e = i.alternate, e !== null && Ct(e) === null) {
t.child = i;
break;
}
e = i.sibling, i.sibling = n, n = i, i = e;
}
ur(t, !0, n, null, a, r);
break;
case "together":
ur(t, !1, null, null, void 0, r);
break;
default: t.memoizedState = null;
}
return t.child;
}
function fr(e, t, n) {
if (e !== null && (t.dependencies = e.dependencies), ju |= t.lanes, (n & t.childLanes) === 0) if (e !== null) {
if (Se(e, t, n, !1), (n & t.childLanes) === 0) return null;
} else return null;
if (e !== null && t.child !== e.child) throw Error(r(153));
if (t.child !== null) {
for (e = t.child, n = la(e, e.pendingProps), t.child = n, n.return = t; e.sibling !== null;) e = e.sibling, n = n.sibling = la(e, e.pendingProps), n.return = t;
n.sibling = null;
}
return t.child;
}
function pr(e, t) {
return (e.lanes & t) === 0 ? (e = e.dependencies, !!(e !== null && Ce(e))) : !0;
}
function mr(e, t, n) {
switch (t.tag) {
case 3:
N(t, t.stateNode.containerInfo), ve(t, ll, e.memoizedState.cache), he();
break;
case 27:
case 5:
le(t);
break;
case 4:
N(t, t.stateNode.containerInfo);
break;
case 10:
ve(t, t.type, t.memoizedProps.value);
break;
case 31:
if (t.memoizedState !== null) return t.flags |= 128, yt(t), null;
break;
case 13:
var r = t.memoizedState;
if (r !== null) return r.dehydrated === null ? (n & t.child.childLanes) === 0 ? (vt(t), e = fr(e, t, n), e === null ? null : e.sibling) : W(e, t, n) : (vt(t), t.flags |= 128, null);
vt(t);
break;
case 19:
var i = (e.flags & 128) != 0;
if (r = (n & t.childLanes) !== 0, r || (Se(e, t, n, !1), r = (n & t.childLanes) !== 0), i) {
if (r) return dr(e, t, n);
t.flags |= 128;
}
if (i = t.memoizedState, i !== null && (i.rendering = null, i.tail = null, i.lastEffect = null), m(Bl, Bl.current), r) break;
return null;
case 22: return t.lanes = 0, qn(e, t, n, t.pendingProps);
case 24: ve(t, ll, e.memoizedState.cache);
}
return fr(e, t, n);
}
function hr(e, t, n) {
if (e !== null) if (e.memoizedProps !== t.pendingProps) ru = !0;
else {
if (!pr(e, n) && !(t.flags & 128)) return ru = !1, mr(e, t, n);
ru = (e.flags & 131072) != 0;
}
else ru = !1, $c && t.flags & 1048576 && ie(t, Vc, t.index);
switch (t.lanes = 0, t.tag) {
case 16:
e: {
var i = t.pendingProps;
if (e = Ke(t.elementType), t.type = e, typeof e == "function") ca(e) ? (i = Ln(e, i), t.tag = 1, t = nr(null, t, e, i, n)) : (t.tag = 0, t = er(null, t, e, i, n));
else {
if (e != null) {
var a = e.$$typeof;
if (a === Fa) {
t.tag = 11, t = Wn(null, t, e, i, n);
break e;
} else if (a === Ra) {
t.tag = 14, t = Gn(null, t, e, i, n);
break e;
}
}
throw t = d(e) || e, Error(r(306, t, ""));
}
}
return t;
case 0: return er(e, t, t.type, t.pendingProps, n);
case 1: return i = t.type, a = Ln(i, t.pendingProps), nr(e, t, i, a, n);
case 3:
e: {
if (N(t, t.stateNode.containerInfo), e === null) throw Error(r(387));
var o = t.pendingProps;
a = t.memoizedState, i = a.element, ot(e, t), ft(t, o, null, n);
var s = t.memoizedState;
if (o = s.cache, ve(t, ll, o), o !== a.cache && xe(t, [ll], n, !0), dt(), o = s.element, uo && a.isDehydrated) if (a = {
element: o,
isDehydrated: !1,
cache: s.cache
}, t.updateQueue.baseState = a, t.memoizedState = a, t.flags & 256) {
t = rr(e, t, o, n);
break e;
} else if (o !== i) {
i = M(Error(r(424)), t), _e(i), t = rr(e, t, o, n);
break e;
} else for (uo && (Qc = gs(t.stateNode.containerInfo), Zc = t, $c = !0, el = null, tl = !0), n = Al(t, null, o, n), t.child = n; n;) n.flags = n.flags & -3 | 4096, n = n.sibling;
else {
if (he(), o === i) {
t = fr(e, t, n);
break e;
}
Un(e, t, o, n);
}
t = t.child;
}
return t;
case 26: if (Us) return $n(e, t), e === null ? (n = Ks(t.type, null, t.pendingProps, null)) ? t.memoizedState = n : $c || (t.stateNode = Qs(t.type, t.pendingProps, Yc.current, t)) : t.memoizedState = Ks(t.type, e.memoizedProps, t.pendingProps, e.memoizedState), null;
case 27: if (rc) return le(t), e === null && rc && $c && (i = t.stateNode = ic(t.type, t.pendingProps, Yc.current, qc.current, !1), Zc = t, tl = !0, Qc = ys(t.type, i, Qc)), Un(e, t, t.pendingProps.children, n), $n(e, t), e === null && (t.flags |= 4194304), t.child;
case 5: return e === null && $c && (Vs(t.type, t.pendingProps, qc.current), (a = i = Qc) && (i = bs(i, t.type, t.pendingProps, tl), i === null ? a = !1 : (t.stateNode = i, Zc = t, Qc = hs(i), tl = !1, a = !0)), a || de(t)), le(t), a = t.type, o = t.pendingProps, s = e === null ? null : e.memoizedProps, i = o.children, no(a, o) ? i = null : s !== null && no(a, s) && (t.flags |= 32), t.memoizedState !== null && (a = Et(e, t, kt, null, null, n), so ? Do._currentValue = a : Do._currentValue2 = a), $n(e, t), Un(e, t, i, n), t.child;
case 6: return e === null && $c && (Hs(t.pendingProps, qc.current), (e = n = Qc) && (n = xs(n, t.pendingProps, tl), n === null ? e = !1 : (t.stateNode = n, Zc = t, Qc = null, e = !0)), e || de(t)), null;
case 13: return W(e, t, n);
case 4: return N(t, t.stateNode.containerInfo), i = t.pendingProps, e === null ? t.child = kl(t, null, i, n) : Un(e, t, i, n), t.child;
case 11: return Wn(e, t, t.type, t.pendingProps, n);
case 7: return Un(e, t, t.pendingProps, n), t.child;
case 8: return Un(e, t, t.pendingProps.children, n), t.child;
case 12: return Un(e, t, t.pendingProps.children, n), t.child;
case 10: return i = t.pendingProps, ve(t, t.type, i.value), Un(e, t, i.children, n), t.child;
case 9: return a = t.type._context, i = t.pendingProps.children, we(t), a = Te(a), i = i(a), t.flags |= 1, Un(e, t, i, n), t.child;
case 14: return Gn(e, t, t.type, t.pendingProps, n);
case 15: return Kn(e, t, t.type, t.pendingProps, n);
case 19: return dr(e, t, n);
case 31: return Qn(e, t, n);
case 22: return qn(e, t, n, t.pendingProps);
case 24: return we(t), i = Te(ll), e === null ? (a = Be(), a === null && (a = Su, o = Oe(), a.pooledCache = o, o.refCount++, o !== null && (a.pooledCacheLanes |= n), a = o), t.memoizedState = {
parent: i,
cache: a
}, at(t), ve(t, ll, a)) : ((e.lanes & n) !== 0 && (ot(e, t), ft(t, null, null, n), dt()), a = e.memoizedState, o = t.memoizedState, a.parent === i ? (i = o.cache, ve(t, ll, i), i !== a.cache && xe(t, [ll], n, !0)) : (a = {
parent: i,
cache: i
}, t.memoizedState = a, t.lanes === 0 && (t.memoizedState = t.updateQueue.baseState = a), ve(t, ll, i))), Un(e, t, t.pendingProps.children, n), t.child;
case 29: throw t.pendingProps;
}
throw Error(r(156, t.tag));
}
function gr(e) {
e.flags |= 4;
}
function _r(e) {
lo && (e.flags |= 8);
}
function vr(e, t) {
if (e !== null && e.child === t.child) return !1;
if (t.flags & 16) return !0;
for (e = t.child; e !== null;) {
if (e.flags & 8218 || e.subtreeFlags & 8218) return !0;
e = e.sibling;
}
return !1;
}
function yr(e, t, n, r) {
if (co) for (n = t.child; n !== null;) {
if (n.tag === 5 || n.tag === 6) eo(e, n.stateNode);
else if (!(n.tag === 4 || rc && n.tag === 27) && n.child !== null) {
n.child.return = n, n = n.child;
continue;
}
if (n === t) break;
for (; n.sibling === null;) {
if (n.return === null || n.return === t) return;
n = n.return;
}
n.sibling.return = n.return, n = n.sibling;
}
else if (lo) for (var i = t.child; i !== null;) {
if (i.tag === 5) {
var a = i.stateNode;
n && r && (a = as(a, i.type, i.memoizedProps)), eo(e, a);
} else if (i.tag === 6) a = i.stateNode, n && r && (a = os(a, i.memoizedProps)), eo(e, a);
else if (i.tag !== 4) {
if (i.tag === 22 && i.memoizedState !== null) a = i.child, a !== null && (a.return = i), yr(e, i, !0, !0);
else if (i.child !== null) {
i.child.return = i, i = i.child;
continue;
}
}
if (i === t) break;
for (; i.sibling === null;) {
if (i.return === null || i.return === t) return;
i = i.return;
}
i.sibling.return = i.return, i = i.sibling;
}
}
function br(e, t, n, r) {
var i = !1;
if (lo) for (var a = t.child; a !== null;) {
if (a.tag === 5) {
var o = a.stateNode;
n && r && (o = as(o, a.type, a.memoizedProps)), ns(e, o);
} else if (a.tag === 6) o = a.stateNode, n && r && (o = os(o, a.memoizedProps)), ns(e, o);
else if (a.tag !== 4) {
if (a.tag === 22 && a.memoizedState !== null) i = a.child, i !== null && (i.return = a), br(e, a, !0, !0), i = !0;
else if (a.child !== null) {
a.child.return = a, a = a.child;
continue;
}
}
if (a === t) break;
for (; a.sibling === null;) {
if (a.return === null || a.return === t) return i;
a = a.return;
}
a.sibling.return = a.return, a = a.sibling;
}
return i;
}
function xr(e, t) {
if (lo && vr(e, t)) {
e = t.stateNode;
var n = e.containerInfo, r = ts();
br(r, t, !1, !1), e.pendingChildren = r, gr(t), rs(n, r);
}
}
function Sr(e, t, n, r) {
if (co) e.memoizedProps !== r && gr(t);
else if (lo) {
var i = e.stateNode, a = e.memoizedProps;
if ((e = vr(e, t)) || a !== r) {
var o = qc.current;
a = es(i, n, a, r, !e, null), a === i ? t.stateNode = i : (_r(t), to(a, n, r, o) && gr(t), t.stateNode = a, e && yr(a, t, !1, !1));
} else t.stateNode = i;
}
}
function Cr(e, t, n, r, i) {
if (e.mode & 32 && (n === null ? yo(t, r) : bo(t, n, r))) {
if (e.flags |= 16777216, (i & 335544128) === i || xo(t, r)) if (So(e.stateNode, t, r)) e.flags |= 8192;
else if (Fi()) e.flags |= 8192;
else throw El = Tl, Cl;
} else e.flags &= -16777217;
}
function wr(e, t) {
if (ec(t)) {
if (e.flags |= 16777216, !tc(t)) if (Fi()) e.flags |= 8192;
else throw El = Tl, Cl;
} else e.flags &= -16777217;
}
function Tr(e, t) {
t !== null && (e.flags |= 4), e.flags & 16384 && (t = e.tag === 22 ? 536870912 : b(), e.lanes |= t, Fu |= t);
}
function Er(e, t) {
if (!$c) switch (e.tailMode) {
case "hidden":
t = e.tail;
for (var n = null; t !== null;) t.alternate !== null && (n = t), t = t.sibling;
n === null ? e.tail = null : n.sibling = null;
break;
case "collapsed":
n = e.tail;
for (var r = null; n !== null;) n.alternate !== null && (r = n), n = n.sibling;
r === null ? t || e.tail === null ? e.tail = null : e.tail.sibling = null : r.sibling = null;
}
}
function Dr(e) {
var t = e.alternate !== null && e.alternate.child === e.child, n = 0, r = 0;
if (t) for (var i = e.child; i !== null;) n |= i.lanes | i.childLanes, r |= i.subtreeFlags & 65011712, r |= i.flags & 65011712, i.return = e, i = i.sibling;
else for (i = e.child; i !== null;) n |= i.lanes | i.childLanes, r |= i.subtreeFlags, r |= i.flags, i.return = e, i = i.sibling;
return e.subtreeFlags |= r, e.childLanes = n, t;
}
function Or(e, t, n) {
var i = t.pendingProps;
switch (oe(t), t.tag) {
case 16:
case 15:
case 0:
case 11:
case 7:
case 8:
case 12:
case 9:
case 14: return Dr(t), null;
case 1: return Dr(t), null;
case 3: return n = t.stateNode, i = null, e !== null && (i = e.memoizedState.cache), t.memoizedState.cache !== i && (t.flags |= 2048), ye(ll), ce(), n.pendingContext && (n.context = n.pendingContext, n.pendingContext = null), (e === null || e.child === null) && (me(t) ? gr(t) : e === null || e.memoizedState.isDehydrated && !(t.flags & 256) || (t.flags |= 1024, ge())), xr(e, t), Dr(t), null;
case 26: if (Us) {
var a = t.type, o = t.memoizedState;
return e === null ? (gr(t), o === null ? (Dr(t), Cr(t, a, null, i, n)) : (Dr(t), wr(t, o))) : o ? o === e.memoizedState ? (Dr(t), t.flags &= -16777217) : (gr(t), Dr(t), wr(t, o)) : (o = e.memoizedProps, co ? o !== i && gr(t) : Sr(e, t, a, i), Dr(t), Cr(t, a, o, i, n)), null;
}
case 27: if (rc) {
if (ue(t), n = Yc.current, a = t.type, e !== null && t.stateNode != null) co ? e.memoizedProps !== i && gr(t) : Sr(e, t, a, i);
else {
if (!i) {
if (t.stateNode === null) throw Error(r(166));
return Dr(t), null;
}
e = qc.current, me(t) ? fe(t, e) : (e = ic(a, i, n, e, !0), t.stateNode = e, gr(t));
}
return Dr(t), null;
}
case 5:
if (ue(t), a = t.type, e !== null && t.stateNode != null) Sr(e, t, a, i);
else {
if (!i) {
if (t.stateNode === null) throw Error(r(166));
return Dr(t), null;
}
if (o = qc.current, me(t)) fe(t, o), Ps(t.stateNode, a, i, o) && (t.flags |= 64);
else {
var s = $a(a, i, Yc.current, o, t);
_r(t), yr(s, t, !1, !1), t.stateNode = s, to(s, a, i, o) && gr(t);
}
}
return Dr(t), Cr(t, t.type, e === null ? null : e.memoizedProps, t.pendingProps, n), null;
case 6:
if (e && t.stateNode != null) n = e.memoizedProps, co ? n !== i && gr(t) : lo && (n === i ? t.stateNode = e.stateNode : (e = Yc.current, n = qc.current, _r(t), t.stateNode = ro(i, e, n, t)));
else {
if (typeof i != "string" && t.stateNode === null) throw Error(r(166));
if (e = Yc.current, n = qc.current, me(t)) {
if (!uo) throw Error(r(176));
if (e = t.stateNode, n = t.memoizedProps, i = null, a = Zc, a !== null) switch (a.tag) {
case 27:
case 5: i = a.memoizedProps;
}
Ts(e, n, t, i) || de(t, !0);
} else _r(t), t.stateNode = ro(i, e, n, t);
}
return Dr(t), null;
case 31:
if (n = t.memoizedState, e === null || e.memoizedState !== null) {
if (i = me(t), n !== null) {
if (e === null) {
if (!i) throw Error(r(318));
if (!uo) throw Error(r(556));
if (e = t.memoizedState, e = e === null ? null : e.dehydrated, !e) throw Error(r(557));
Es(e, t);
} else he(), !(t.flags & 128) && (t.memoizedState = null), t.flags |= 4;
Dr(t), e = !1;
} else n = ge(), e !== null && e.memoizedState !== null && (e.memoizedState.hydrationErrors = n), e = !0;
if (!e) return t.flags & 256 ? (St(t), t) : (St(t), null);
if (t.flags & 128) throw Error(r(558));
}
return Dr(t), null;
case 13:
if (i = t.memoizedState, e === null || e.memoizedState !== null && e.memoizedState.dehydrated !== null) {
if (a = me(t), i !== null && i.dehydrated !== null) {
if (e === null) {
if (!a) throw Error(r(318));
if (!uo) throw Error(r(344));
if (a = t.memoizedState, a = a === null ? null : a.dehydrated, !a) throw Error(r(317));
Ds(a, t);
} else he(), !(t.flags & 128) && (t.memoizedState = null), t.flags |= 4;
Dr(t), a = !1;
} else a = ge(), e !== null && e.memoizedState !== null && (e.memoizedState.hydrationErrors = a), a = !0;
if (!a) return t.flags & 256 ? (St(t), t) : (St(t), null);
}
return St(t), t.flags & 128 ? (t.lanes = n, t) : (n = i !== null, e = e !== null && e.memoizedState !== null, n && (i = t.child, a = null, i.alternate !== null && i.alternate.memoizedState !== null && i.alternate.memoizedState.cachePool !== null && (a = i.alternate.memoizedState.cachePool.pool), o = null, i.memoizedState !== null && i.memoizedState.cachePool !== null && (o = i.memoizedState.cachePool.pool), o !== a && (i.flags |= 2048)), n !== e && n && (t.child.flags |= 8192), Tr(t, t.updateQueue), Dr(t), null);
case 4: return ce(), xr(e, t), e === null && po(t.stateNode.containerInfo), Dr(t), null;
case 10: return ye(t.type), Dr(t), null;
case 19:
if (p(Bl), i = t.memoizedState, i === null) return Dr(t), null;
if (a = (t.flags & 128) != 0, o = i.rendering, o === null) if (a) Er(i, !1);
else {
if (Au !== 0 || e !== null && e.flags & 128) for (e = t.child; e !== null;) {
if (o = Ct(e), o !== null) {
for (t.flags |= 128, Er(i, !1), e = o.updateQueue, t.updateQueue = e, Tr(t, e), t.subtreeFlags = 0, e = n, n = t.child; n !== null;) ua(n, e), n = n.sibling;
return m(Bl, Bl.current & 1 | 2), $c && re(t, i.treeForkCount), t.child;
}
e = e.sibling;
}
i.tail !== null && Sc() > Vu && (t.flags |= 128, a = !0, Er(i, !1), t.lanes = 4194304);
}
else {
if (!a) if (e = Ct(o), e !== null) {
if (t.flags |= 128, a = !0, e = e.updateQueue, t.updateQueue = e, Tr(t, e), Er(i, !0), i.tail === null && i.tailMode === "hidden" && !o.alternate && !$c) return Dr(t), null;
} else 2 * Sc() - i.renderingStartTime > Vu && n !== 536870912 && (t.flags |= 128, a = !0, Er(i, !1), t.lanes = 4194304);
i.isBackwards ? (o.sibling = t.child, t.child = o) : (e = i.last, e === null ? t.child = o : e.sibling = o, i.last = o);
}
return i.tail === null ? (Dr(t), null) : (e = i.tail, i.rendering = e, i.tail = e.sibling, i.renderingStartTime = Sc(), e.sibling = null, n = Bl.current, m(Bl, a ? n & 1 | 2 : n & 1), $c && re(t, i.treeForkCount), e);
case 22:
case 23: return St(t), _t(), i = t.memoizedState !== null, e === null ? i && (t.flags |= 8192) : e.memoizedState !== null !== i && (t.flags |= 8192), i ? n & 536870912 && !(t.flags & 128) && (Dr(t), t.subtreeFlags & 6 && (t.flags |= 8192)) : Dr(t), n = t.updateQueue, n !== null && Tr(t, n.retryQueue), n = null, e !== null && e.memoizedState !== null && e.memoizedState.cachePool !== null && (n = e.memoizedState.cachePool.pool), i = null, t.memoizedState !== null && t.memoizedState.cachePool !== null && (i = t.memoizedState.cachePool.pool), i !== n && (t.flags |= 2048), e !== null && p(xl), null;
case 24: return n = null, e !== null && (n = e.memoizedState.cache), t.memoizedState.cache !== n && (t.flags |= 2048), ye(ll), Dr(t), null;
case 25: return null;
case 30: return null;
}
throw Error(r(156, t.tag));
}
function kr(e, t) {
switch (oe(t), t.tag) {
case 1: return e = t.flags, e & 65536 ? (t.flags = e & -65537 | 128, t) : null;
case 3: return ye(ll), ce(), e = t.flags, e & 65536 && !(e & 128) ? (t.flags = e & -65537 | 128, t) : null;
case 26:
case 27:
case 5: return ue(t), null;
case 31:
if (t.memoizedState !== null) {
if (St(t), t.alternate === null) throw Error(r(340));
he();
}
return e = t.flags, e & 65536 ? (t.flags = e & -65537 | 128, t) : null;
case 13:
if (St(t), e = t.memoizedState, e !== null && e.dehydrated !== null) {
if (t.alternate === null) throw Error(r(340));
he();
}
return e = t.flags, e & 65536 ? (t.flags = e & -65537 | 128, t) : null;
case 19: return p(Bl), null;
case 4: return ce(), null;
case 10: return ye(t.type), null;
case 22:
case 23: return St(t), _t(), e !== null && p(xl), e = t.flags, e & 65536 ? (t.flags = e & -65537 | 128, t) : null;
case 24: return ye(ll), null;
case 25: return null;
default: return null;
}
}
function Ar(e, t) {
switch (oe(t), t.tag) {
case 3:
ye(ll), ce();
break;
case 26:
case 27:
case 5:
ue(t);
break;
case 4:
ce();
break;
case 31:
t.memoizedState !== null && St(t);
break;
case 13:
St(t);
break;
case 19:
p(Bl);
break;
case 10:
ye(t.type);
break;
case 22:
case 23:
St(t), _t(), e !== null && p(xl);
break;
case 24: ye(ll);
}
}
function jr(e, t) {
try {
var n = t.updateQueue, r = n === null ? null : n.lastEffect;
if (r !== null) {
var i = r.next;
n = i;
do {
if ((n.tag & e) === e) {
r = void 0;
var a = n.create, o = n.inst;
r = a(), o.destroy = r;
}
n = n.next;
} while (n !== i);
}
} catch (e) {
ea(t, t.return, e);
}
}
function Mr(e, t, n) {
try {
var r = t.updateQueue, i = r === null ? null : r.lastEffect;
if (i !== null) {
var a = i.next;
r = a;
do {
if ((r.tag & e) === e) {
var o = r.inst, s = o.destroy;
if (s !== void 0) {
o.destroy = void 0, i = t;
var c = n, l = s;
try {
l();
} catch (e) {
ea(i, c, e);
}
}
}
r = r.next;
} while (r !== a);
}
} catch (e) {
ea(t, t.return, e);
}
}
function Nr(e) {
var t = e.updateQueue;
if (t !== null) {
var n = e.stateNode;
try {
mt(t, n);
} catch (t) {
ea(e, e.return, t);
}
}
}
function Pr(e, t, n) {
n.props = Ln(e.type, e.memoizedProps), n.state = e.memoizedState;
try {
n.componentWillUnmount();
} catch (n) {
ea(e, t, n);
}
}
function Fr(e, t) {
try {
var n = e.ref;
if (n !== null) {
switch (e.tag) {
case 26:
case 27:
case 5:
var r = Ja(e.stateNode);
break;
case 30:
r = e.stateNode;
break;
default: r = e.stateNode;
}
typeof n == "function" ? e.refCleanup = n(r) : n.current = r;
}
} catch (n) {
ea(e, t, n);
}
}
function Ir(e, t) {
var n = e.ref, r = e.refCleanup;
if (n !== null) if (typeof r == "function") try {
r();
} catch (n) {
ea(e, t, n);
} finally {
e.refCleanup = null, e = e.alternate, e != null && (e.refCleanup = null);
}
else if (typeof n == "function") try {
n(null);
} catch (n) {
ea(e, t, n);
}
else n.current = null;
}
function Lr(e) {
var t = e.type, n = e.memoizedProps, r = e.stateNode;
try {
Ho(r, t, n, e);
} catch (t) {
ea(e, e.return, t);
}
}
function Rr(e, t, n) {
try {
Uo(e.stateNode, e.type, n, t, e);
} catch (t) {
ea(e, e.return, t);
}
}
function zr(e) {
return e.tag === 5 || e.tag === 3 || (Us ? e.tag === 26 : !1) || (rc ? e.tag === 27 && cc(e.type) : !1) || e.tag === 4;
}
function G(e) {
e: for (;;) {
for (; e.sibling === null;) {
if (e.return === null || zr(e.return)) return null;
e = e.return;
}
for (e.sibling.return = e.return, e = e.sibling; e.tag !== 5 && e.tag !== 6 && e.tag !== 18;) {
if (rc && e.tag === 27 && cc(e.type) || e.flags & 2 || e.child === null || e.tag === 4) continue e;
e.child.return = e, e = e.child;
}
if (!(e.flags & 2)) return e.stateNode;
}
}
function Br(e, t, n) {
var r = e.tag;
if (r === 5 || r === 6) e = e.stateNode, t ? Go(n, e, t) : Bo(n, e);
else if (r !== 4 && (rc && r === 27 && cc(e.type) && (n = e.stateNode, t = null), e = e.child, e !== null)) for (Br(e, t, n), e = e.sibling; e !== null;) Br(e, t, n), e = e.sibling;
}
function Vr(e, t, n) {
var r = e.tag;
if (r === 5 || r === 6) e = e.stateNode, t ? Wo(n, e, t) : zo(n, e);
else if (r !== 4 && (rc && r === 27 && cc(e.type) && (n = e.stateNode), e = e.child, e !== null)) for (Vr(e, t, n), e = e.sibling; e !== null;) Vr(e, t, n), e = e.sibling;
}
function Hr(e, t, n) {
e = e.containerInfo;
try {
is(e, n);
} catch (e) {
ea(t, t.return, e);
}
}
function Ur(e) {
var t = e.stateNode, n = e.memoizedProps;
try {
ac(e.type, n, t, e);
} catch (t) {
ea(e, e.return, t);
}
}
function Wr(e, t) {
for (Za(e.containerInfo), lu = t; lu !== null;) if (e = lu, t = e.child, e.subtreeFlags & 1028 && t !== null) t.return = e, lu = t;
else for (; lu !== null;) {
e = lu;
var n = e.alternate;
switch (t = e.flags, e.tag) {
case 0:
if (t & 4 && (t = e.updateQueue, t = t === null ? null : t.events, t !== null)) for (var i = 0; i < t.length; i++) {
var a = t[i];
a.ref.impl = a.nextImpl;
}
break;
case 11:
case 15: break;
case 1:
if (t & 1024 && n !== null) {
t = void 0, i = e, a = n.memoizedProps, n = n.memoizedState;
var o = i.stateNode;
try {
var s = Ln(i.type, a);
t = o.getSnapshotBeforeUpdate(s, n), o.__reactInternalSnapshotBeforeUpdate = t;
} catch (e) {
ea(i, i.return, e);
}
}
break;
case 3:
t & 1024 && co && $o(e.stateNode.containerInfo);
break;
case 5:
case 26:
case 27:
case 6:
case 4:
case 17: break;
default: if (t & 1024) throw Error(r(163));
}
if (t = e.sibling, t !== null) {
t.return = e.return, lu = t;
break;
}
lu = e.return;
}
}
function Gr(e, t, n) {
var r = n.flags;
switch (n.tag) {
case 0:
case 11:
case 15:
ri(e, n), r & 4 && jr(5, n);
break;
case 1:
if (ri(e, n), r & 4) if (e = n.stateNode, t === null) try {
e.componentDidMount();
} catch (e) {
ea(n, n.return, e);
}
else {
var i = Ln(n.type, t.memoizedProps);
t = t.memoizedState;
try {
e.componentDidUpdate(i, t, e.__reactInternalSnapshotBeforeUpdate);
} catch (e) {
ea(n, n.return, e);
}
}
r & 64 && Nr(n), r & 512 && Fr(n, n.return);
break;
case 3:
if (ri(e, n), r & 64 && (r = n.updateQueue, r !== null)) {
if (e = null, n.child !== null) switch (n.child.tag) {
case 27:
case 5:
e = Ja(n.child.stateNode);
break;
case 1: e = n.child.stateNode;
}
try {
mt(r, e);
} catch (e) {
ea(n, n.return, e);
}
}
break;
case 27: rc && t === null && r & 4 && Ur(n);
case 26:
case 5:
if (ri(e, n), t === null) {
if (r & 4) Lr(n);
else if (r & 64) {
e = n.type, t = n.memoizedProps, i = n.stateNode;
try {
As(i, e, t, n);
} catch (e) {
ea(n, n.return, e);
}
}
}
r & 512 && Fr(n, n.return);
break;
case 12:
ri(e, n);
break;
case 31:
ri(e, n), r & 4 && Yr(e, n);
break;
case 13:
ri(e, n), r & 4 && Xr(e, n), r & 64 && (r = n.memoizedState, r !== null && (r = r.dehydrated, r !== null && (n = ia.bind(null, n), us(r, n))));
break;
case 22:
if (r = n.memoizedState !== null || au, !r) {
t = t !== null && t.memoizedState !== null || ou, i = au;
var a = ou;
au = r, (ou = t) && !a ? ai(e, n, (n.subtreeFlags & 8772) != 0) : ri(e, n), au = i, ou = a;
}
break;
case 30: break;
default: ri(e, n);
}
}
function Kr(e) {
var t = e.alternate;
t !== null && (e.alternate = null, Kr(t)), e.child = null, e.deletions = null, e.sibling = null, e.tag === 5 && (t = e.stateNode, t !== null && vo(t)), e.stateNode = null, e.return = null, e.dependencies = null, e.memoizedProps = null, e.memoizedState = null, e.pendingProps = null, e.stateNode = null, e.updateQueue = null;
}
function qr(e, t, n) {
for (n = n.child; n !== null;) Jr(e, t, n), n = n.sibling;
}
function Jr(e, t, n) {
if (Ac && typeof Ac.onCommitFiberUnmount == "function") try {
Ac.onCommitFiberUnmount(kc, n);
} catch {}
switch (n.tag) {
case 26: if (Us) {
ou || Ir(n, t), qr(e, t, n), n.memoizedState ? Js(n.memoizedState) : n.stateNode && Zs(n.stateNode);
break;
}
case 27: if (rc) {
ou || Ir(n, t);
var r = uu, i = du;
cc(n.type) && (uu = n.stateNode, du = !1), qr(e, t, n), oc(n.stateNode), uu = r, du = i;
break;
}
case 5: ou || Ir(n, t);
case 6:
if (co) {
if (r = uu, i = du, uu = null, qr(e, t, n), uu = r, du = i, uu !== null) if (du) try {
qo(uu, n.stateNode);
} catch (e) {
ea(n, t, e);
}
else try {
Ko(uu, n.stateNode);
} catch (e) {
ea(n, t, e);
}
} else qr(e, t, n);
break;
case 18:
co && uu !== null && (du ? Ls(uu, n.stateNode) : Is(uu, n.stateNode));
break;
case 4:
co ? (r = uu, i = du, uu = n.stateNode.containerInfo, du = !0, qr(e, t, n), uu = r, du = i) : (lo && Hr(n.stateNode, n, ts()), qr(e, t, n));
break;
case 0:
case 11:
case 14:
case 15:
Mr(2, n, t), ou || Mr(4, n, t), qr(e, t, n);
break;
case 1:
ou || (Ir(n, t), r = n.stateNode, typeof r.componentWillUnmount == "function" && Pr(n, t, r)), qr(e, t, n);
break;
case 21:
qr(e, t, n);
break;
case 22:
ou = (r = ou) || n.memoizedState !== null, qr(e, t, n), ou = r;
break;
default: qr(e, t, n);
}
}
function Yr(e, t) {
if (uo && t.memoizedState === null && (e = t.alternate, e !== null && (e = e.memoizedState, e !== null))) {
e = e.dehydrated;
try {
Ms(e);
} catch (e) {
ea(t, t.return, e);
}
}
}
function Xr(e, t) {
if (uo && t.memoizedState === null && (e = t.alternate, e !== null && (e = e.memoizedState, e !== null && (e = e.dehydrated, e !== null)))) try {
Ns(e);
} catch (e) {
ea(t, t.return, e);
}
}
function Zr(e) {
switch (e.tag) {
case 31:
case 13:
case 19:
var t = e.stateNode;
return t === null && (t = e.stateNode = new cu()), t;
case 22: return e = e.stateNode, t = e._retryCache, t === null && (t = e._retryCache = new cu()), t;
default: throw Error(r(435, e.tag));
}
}
function Qr(e, t) {
var n = Zr(e);
t.forEach(function(t) {
if (!n.has(t)) {
n.add(t);
var r = aa.bind(null, e, t);
t.then(r, r);
}
});
}
function $r(e, t) {
var n = t.deletions;
if (n !== null) for (var i = 0; i < n.length; i++) {
var a = n[i], o = e, s = t;
if (co) {
var c = s;
e: for (; c !== null;) {
switch (c.tag) {
case 27: if (rc) {
if (cc(c.type)) {
uu = c.stateNode, du = !1;
break e;
}
break;
}
case 5:
uu = c.stateNode, du = !1;
break e;
case 3:
case 4:
uu = c.stateNode.containerInfo, du = !0;
break e;
}
c = c.return;
}
if (uu === null) throw Error(r(160));
Jr(o, s, a), uu = null, du = !1;
} else Jr(o, s, a);
o = a.alternate, o !== null && (o.return = null), a.return = null;
}
if (t.subtreeFlags & 13886) for (t = t.child; t !== null;) ei(t, e), t = t.sibling;
}
function ei(e, t) {
var n = e.alternate, i = e.flags;
switch (e.tag) {
case 0:
case 11:
case 14:
case 15:
$r(t, e), ti(e), i & 4 && (Mr(3, e, e.return), jr(3, e), Mr(5, e, e.return));
break;
case 1:
$r(t, e), ti(e), i & 512 && (ou || n === null || Ir(n, n.return)), i & 64 && au && (e = e.updateQueue, e !== null && (i = e.callbacks, i !== null && (n = e.shared.hiddenCallbacks, e.shared.hiddenCallbacks = n === null ? i : n.concat(i))));
break;
case 26: if (Us) {
var a = fu;
if ($r(t, e), ti(e), i & 512 && (ou || n === null || Ir(n, n.return)), i & 4) {
i = n === null ? null : n.memoizedState;
var o = e.memoizedState;
n === null ? o === null ? e.stateNode === null ? e.stateNode = Ys(a, e.type, e.memoizedProps, e) : Xs(a, e.type, e.stateNode) : e.stateNode = qs(a, o, e.memoizedProps) : i === o ? o === null && e.stateNode !== null && Rr(e, e.memoizedProps, n.memoizedProps) : (i === null ? n.stateNode !== null && Zs(n.stateNode) : Js(i), o === null ? Xs(a, e.type, e.stateNode) : qs(a, o, e.memoizedProps));
}
break;
}
case 27: if (rc) {
$r(t, e), ti(e), i & 512 && (ou || n === null || Ir(n, n.return)), n !== null && i & 4 && Rr(e, e.memoizedProps, n.memoizedProps);
break;
}
case 5:
if ($r(t, e), ti(e), i & 512 && (ou || n === null || Ir(n, n.return)), co) {
if (e.flags & 32) {
a = e.stateNode;
try {
Jo(a);
} catch (t) {
ea(e, e.return, t);
}
}
i & 4 && e.stateNode != null && (a = e.memoizedProps, Rr(e, a, n === null ? a : n.memoizedProps)), i & 1024 && (su = !0);
} else lo && e.alternate !== null && (e.alternate.stateNode = e.stateNode);
break;
case 6:
if ($r(t, e), ti(e), i & 4 && co) {
if (e.stateNode === null) throw Error(r(162));
i = e.memoizedProps, n = n === null ? i : n.memoizedProps, a = e.stateNode;
try {
Vo(a, n, i);
} catch (t) {
ea(e, e.return, t);
}
}
break;
case 3:
if (Us ? ($s(), a = fu, fu = Gs(t.containerInfo), $r(t, e), fu = a) : $r(t, e), ti(e), i & 4) {
if (co && uo && n !== null && n.memoizedState.isDehydrated) try {
js(t.containerInfo);
} catch (t) {
ea(e, e.return, t);
}
if (lo) {
i = t.containerInfo, n = t.pendingChildren;
try {
is(i, n);
} catch (t) {
ea(e, e.return, t);
}
}
}
su && (su = !1, ni(e));
break;
case 4:
Us ? (n = fu, fu = Gs(e.stateNode.containerInfo), $r(t, e), ti(e), fu = n) : ($r(t, e), ti(e)), i & 4 && lo && Hr(e.stateNode, e, e.stateNode.pendingChildren);
break;
case 12:
$r(t, e), ti(e);
break;
case 31:
$r(t, e), ti(e), i & 4 && (i = e.updateQueue, i !== null && (e.updateQueue = null, Qr(e, i)));
break;
case 13:
$r(t, e), ti(e), e.child.flags & 8192 && e.memoizedState !== null != (n !== null && n.memoizedState !== null) && (zu = Sc()), i & 4 && (i = e.updateQueue, i !== null && (e.updateQueue = null, Qr(e, i)));
break;
case 22:
a = e.memoizedState !== null;
var s = n !== null && n.memoizedState !== null, c = au, l = ou;
if (au = c || a, ou = l || s, $r(t, e), ou = l, au = c, ti(e), i & 8192 && (t = e.stateNode, t._visibility = a ? t._visibility & -2 : t._visibility | 1, a && (n === null || s || au || ou || ii(e)), co)) {
e: if (n = null, co) for (t = e;;) {
if (t.tag === 5 || Us && t.tag === 26) {
if (n === null) {
s = n = t;
try {
o = s.stateNode, a ? Yo(o) : Zo(s.stateNode, s.memoizedProps);
} catch (e) {
ea(s, s.return, e);
}
}
} else if (t.tag === 6) {
if (n === null) {
s = t;
try {
var u = s.stateNode;
a ? Xo(u) : Qo(u, s.memoizedProps);
} catch (e) {
ea(s, s.return, e);
}
}
} else if (t.tag === 18) {
if (n === null) {
s = t;
try {
var d = s.stateNode;
a ? Rs(d) : zs(s.stateNode);
} catch (e) {
ea(s, s.return, e);
}
}
} else if ((t.tag !== 22 && t.tag !== 23 || t.memoizedState === null || t === e) && t.child !== null) {
t.child.return = t, t = t.child;
continue;
}
if (t === e) break e;
for (; t.sibling === null;) {
if (t.return === null || t.return === e) break e;
n === t && (n = null), t = t.return;
}
n === t && (n = null), t.sibling.return = t.return, t = t.sibling;
}
}
i & 4 && (i = e.updateQueue, i !== null && (n = i.retryQueue, n !== null && (i.retryQueue = null, Qr(e, n))));
break;
case 19:
$r(t, e), ti(e), i & 4 && (i = e.updateQueue, i !== null && (e.updateQueue = null, Qr(e, i)));
break;
case 30: break;
case 21: break;
default: $r(t, e), ti(e);
}
}
function ti(e) {
var t = e.flags;
if (t & 2) {
try {
for (var n, i = e.return; i !== null;) {
if (zr(i)) {
n = i;
break;
}
i = i.return;
}
if (co) {
if (n == null) throw Error(r(160));
switch (n.tag) {
case 27: if (rc) {
var a = n.stateNode;
Vr(e, G(e), a);
break;
}
case 5:
var o = n.stateNode;
n.flags & 32 && (Jo(o), n.flags &= -33), Vr(e, G(e), o);
break;
case 3:
case 4:
var s = n.stateNode.containerInfo;
Br(e, G(e), s);
break;
default: throw Error(r(161));
}
}
} catch (t) {
ea(e, e.return, t);
}
e.flags &= -3;
}
t & 4096 && (e.flags &= -4097);
}
function ni(e) {
if (e.subtreeFlags & 1024) for (e = e.child; e !== null;) {
var t = e;
ni(t), t.tag === 5 && t.flags & 1024 && Oo(t.stateNode), e = e.sibling;
}
}
function ri(e, t) {
if (t.subtreeFlags & 8772) for (t = t.child; t !== null;) Gr(e, t.alternate, t), t = t.sibling;
}
function ii(e) {
for (e = e.child; e !== null;) {
var t = e;
switch (t.tag) {
case 0:
case 11:
case 14:
case 15:
Mr(4, t, t.return), ii(t);
break;
case 1:
Ir(t, t.return);
var n = t.stateNode;
typeof n.componentWillUnmount == "function" && Pr(t, t.return, n), ii(t);
break;
case 27: rc && oc(t.stateNode);
case 26:
case 5:
Ir(t, t.return), ii(t);
break;
case 22:
t.memoizedState === null && ii(t);
break;
case 30:
ii(t);
break;
default: ii(t);
}
e = e.sibling;
}
}
function ai(e, t, n) {
for (n = n && (t.subtreeFlags & 8772) != 0, t = t.child; t !== null;) {
var r = t.alternate, i = e, a = t, o = a.flags;
switch (a.tag) {
case 0:
case 11:
case 15:
ai(i, a, n), jr(4, a);
break;
case 1:
if (ai(i, a, n), r = a, i = r.stateNode, typeof i.componentDidMount == "function") try {
i.componentDidMount();
} catch (e) {
ea(r, r.return, e);
}
if (r = a, i = r.updateQueue, i !== null) {
var s = r.stateNode;
try {
var c = i.shared.hiddenCallbacks;
if (c !== null) for (i.shared.hiddenCallbacks = null, i = 0; i < c.length; i++) pt(c[i], s);
} catch (e) {
ea(r, r.return, e);
}
}
n && o & 64 && Nr(a), Fr(a, a.return);
break;
case 27: rc && Ur(a);
case 26:
case 5:
ai(i, a, n), n && r === null && o & 4 && Lr(a), Fr(a, a.return);
break;
case 12:
ai(i, a, n);
break;
case 31:
ai(i, a, n), n && o & 4 && Yr(i, a);
break;
case 13:
ai(i, a, n), n && o & 4 && Xr(i, a);
break;
case 22:
a.memoizedState === null && ai(i, a, n), Fr(a, a.return);
break;
case 30: break;
default: ai(i, a, n);
}
t = t.sibling;
}
}
function oi(e, t) {
var n = null;
e !== null && e.memoizedState !== null && e.memoizedState.cachePool !== null && (n = e.memoizedState.cachePool.pool), e = null, t.memoizedState !== null && t.memoizedState.cachePool !== null && (e = t.memoizedState.cachePool.pool), e !== n && (e != null && e.refCount++, n != null && ke(n));
}
function si(e, t) {
e = null, t.alternate !== null && (e = t.alternate.memoizedState.cache), t = t.memoizedState.cache, t !== e && (t.refCount++, e != null && ke(e));
}
function ci(e, t, n, r) {
if (t.subtreeFlags & 10256) for (t = t.child; t !== null;) li(e, t, n, r), t = t.sibling;
}
function li(e, t, n, r) {
var i = t.flags;
switch (t.tag) {
case 0:
case 11:
case 15:
ci(e, t, n, r), i & 2048 && jr(9, t);
break;
case 1:
ci(e, t, n, r);
break;
case 3:
ci(e, t, n, r), i & 2048 && (e = null, t.alternate !== null && (e = t.alternate.memoizedState.cache), t = t.memoizedState.cache, t !== e && (t.refCount++, e != null && ke(e)));
break;
case 12:
if (i & 2048) {
ci(e, t, n, r), e = t.stateNode;
try {
var a = t.memoizedProps, o = a.id, s = a.onPostCommit;
typeof s == "function" && s(o, t.alternate === null ? "mount" : "update", e.passiveEffectDuration, -0);
} catch (e) {
ea(t, t.return, e);
}
} else ci(e, t, n, r);
break;
case 31:
ci(e, t, n, r);
break;
case 13:
ci(e, t, n, r);
break;
case 23: break;
case 22:
a = t.stateNode, o = t.alternate, t.memoizedState === null ? a._visibility & 2 ? ci(e, t, n, r) : (a._visibility |= 2, ui(e, t, n, r, (t.subtreeFlags & 10256) != 0 || !1)) : a._visibility & 2 ? ci(e, t, n, r) : di(e, t), i & 2048 && oi(o, t);
break;
case 24:
ci(e, t, n, r), i & 2048 && si(t.alternate, t);
break;
default: ci(e, t, n, r);
}
}
function ui(e, t, n, r, i) {
for (i = i && ((t.subtreeFlags & 10256) != 0 || !1), t = t.child; t !== null;) {
var a = e, o = t, s = n, c = r, l = o.flags;
switch (o.tag) {
case 0:
case 11:
case 15:
ui(a, o, s, c, i), jr(8, o);
break;
case 23: break;
case 22:
var u = o.stateNode;
o.memoizedState === null ? (u._visibility |= 2, ui(a, o, s, c, i)) : u._visibility & 2 ? ui(a, o, s, c, i) : di(a, o), i && l & 2048 && oi(o.alternate, o);
break;
case 24:
ui(a, o, s, c, i), i && l & 2048 && si(o.alternate, o);
break;
default: ui(a, o, s, c, i);
}
t = t.sibling;
}
}
function di(e, t) {
if (t.subtreeFlags & 10256) for (t = t.child; t !== null;) {
var n = e, r = t, i = r.flags;
switch (r.tag) {
case 22:
di(n, r), i & 2048 && oi(r.alternate, r);
break;
case 24:
di(n, r), i & 2048 && si(r.alternate, r);
break;
default: di(n, r);
}
t = t.sibling;
}
}
function fi(e, t, n) {
if (e.subtreeFlags & pu) for (e = e.child; e !== null;) pi(e, t, n), e = e.sibling;
}
function pi(e, t, n) {
switch (e.tag) {
case 26:
if (fi(e, t, n), e.flags & pu) if (e.memoizedState !== null) nc(n, fu, e.memoizedState, e.memoizedProps);
else {
var r = e.stateNode, i = e.type;
e = e.memoizedProps, ((t & 335544128) === t || xo(i, e)) && wo(n, r, i, e);
}
break;
case 5:
fi(e, t, n), e.flags & pu && (r = e.stateNode, i = e.type, e = e.memoizedProps, ((t & 335544128) === t || xo(i, e)) && wo(n, r, i, e));
break;
case 3:
case 4:
Us ? (r = fu, fu = Gs(e.stateNode.containerInfo), fi(e, t, n), fu = r) : fi(e, t, n);
break;
case 22:
e.memoizedState === null && (r = e.alternate, r !== null && r.memoizedState !== null ? (r = pu, pu = 16777216, fi(e, t, n), pu = r) : fi(e, t, n));
break;
default: fi(e, t, n);
}
}
function mi(e) {
var t = e.alternate;
if (t !== null && (e = t.child, e !== null)) {
t.child = null;
do
t = e.sibling, e.sibling = null, e = t;
while (e !== null);
}
}
function hi(e) {
var t = e.deletions;
if (e.flags & 16) {
if (t !== null) for (var n = 0; n < t.length; n++) {
var r = t[n];
lu = r, vi(r, e);
}
mi(e);
}
if (e.subtreeFlags & 10256) for (e = e.child; e !== null;) gi(e), e = e.sibling;
}
function gi(e) {
switch (e.tag) {
case 0:
case 11:
case 15:
hi(e), e.flags & 2048 && Mr(9, e, e.return);
break;
case 3:
hi(e);
break;
case 12:
hi(e);
break;
case 22:
var t = e.stateNode;
e.memoizedState !== null && t._visibility & 2 && (e.return === null || e.return.tag !== 13) ? (t._visibility &= -3, _i(e)) : hi(e);
break;
default: hi(e);
}
}
function _i(e) {
var t = e.deletions;
if (e.flags & 16) {
if (t !== null) for (var n = 0; n < t.length; n++) {
var r = t[n];
lu = r, vi(r, e);
}
mi(e);
}
for (e = e.child; e !== null;) {
switch (t = e, t.tag) {
case 0:
case 11:
case 15:
Mr(8, t, t.return), _i(t);
break;
case 22:
n = t.stateNode, n._visibility & 2 && (n._visibility &= -3, _i(t));
break;
default: _i(t);
}
e = e.sibling;
}
}
function vi(e, t) {
for (; lu !== null;) {
var n = lu;
switch (n.tag) {
case 0:
case 11:
case 15:
Mr(8, n, t);
break;
case 23:
case 22:
if (n.memoizedState !== null && n.memoizedState.cachePool !== null) {
var r = n.memoizedState.cachePool.pool;
r != null && r.refCount++;
}
break;
case 24: ke(n.memoizedState.cache);
}
if (r = n.child, r !== null) r.return = n, lu = r;
else e: for (n = e; lu !== null;) {
r = lu;
var i = r.sibling, a = r.return;
if (Kr(r), r === n) {
lu = null;
break e;
}
if (i !== null) {
i.return = a, lu = i;
break e;
}
lu = a;
}
}
}
function yi(e) {
var t = fo(e);
if (t != null) {
if (typeof t.memoizedProps["data-testname"] != "string") throw Error(r(364));
return t;
}
if (e = Mo(e), e === null) throw Error(r(362));
return e.stateNode.current;
}
function bi(e, t) {
var n = e.tag;
switch (t.$$typeof) {
case hu:
if (e.type === t.value) return !0;
break;
case gu:
e: {
for (t = t.value, e = [e, 0], n = 0; n < e.length;) {
var i = e[n++], a = i.tag, o = e[n++], s = t[o];
if (a !== 5 && a !== 26 && a !== 27 || !Fo(i)) {
for (; s != null && bi(i, s);) o++, s = t[o];
if (o === t.length) {
t = !0;
break e;
} else for (i = i.child; i !== null;) e.push(i, o), i = i.sibling;
}
}
t = !1;
}
return t;
case _u:
if ((n === 5 || n === 26 || n === 27) && Io(e.stateNode, t.value)) return !0;
break;
case yu:
if ((n === 5 || n === 6 || n === 26 || n === 27) && (e = Po(e), e !== null && 0 <= e.indexOf(t.value))) return !0;
break;
case vu:
if ((n === 5 || n === 26 || n === 27) && (e = e.memoizedProps["data-testname"], typeof e == "string" && e.toLowerCase() === t.value.toLowerCase())) return !0;
break;
default: throw Error(r(365));
}
return !1;
}
function xi(e) {
switch (e.$$typeof) {
case hu: return "<" + (d(e.value) || "Unknown") + ">";
case gu: return ":has(" + (xi(e) || "") + ")";
case _u: return "[role=\"" + e.value + "\"]";
case yu: return "\"" + e.value + "\"";
case vu: return "[data-testname=\"" + e.value + "\"]";
default: throw Error(r(365));
}
}
function Si(e, t) {
var n = [];
e = [e, 0];
for (var r = 0; r < e.length;) {
var i = e[r++], a = i.tag, o = e[r++], s = t[o];
if (a !== 5 && a !== 26 && a !== 27 || !Fo(i)) {
for (; s != null && bi(i, s);) o++, s = t[o];
if (o === t.length) n.push(i);
else for (i = i.child; i !== null;) e.push(i, o), i = i.sibling;
}
}
return n;
}
function Ci(e, t) {
if (!jo) throw Error(r(363));
e = yi(e), e = Si(e, t), t = [], e = Array.from(e);
for (var n = 0; n < e.length;) {
var i = e[n++], a = i.tag;
if (a === 5 || a === 26 || a === 27) Fo(i) || t.push(i.stateNode);
else for (i = i.child; i !== null;) e.push(i), i = i.sibling;
}
return t;
}
function wi() {
return X & 2 && Z !== 0 ? Z & -Z : J.T === null ? go() : F();
}
function Ti() {
if (Pu === 0) if (!(Z & 536870912) || $c) {
var e = gc;
gc <<= 1, !(gc & 3932160) && (gc = 262144), Pu = e;
} else Pu = 536870912;
return e = Rl.current, e !== null && (e.flags |= 32), Pu;
}
function Ei(e, t, n) {
(e === Su && (wu === 2 || wu === 9) || e.cancelPendingCommit !== null) && (Ni(e, 0), Ai(e, Z, Pu, !1)), S(e, n), (!(X & 2) || e !== Su) && (e === Su && (!(X & 2) && (Mu |= n), Au === 4 && Ai(e, Z, Pu, !1)), je(e));
}
function Di(e, t, n) {
if (X & 6) throw Error(r(327));
var i = !n && (t & 127) == 0 && (t & e.expiredLanes) === 0 || v(e, t), a = i ? Bi(e, t) : Ri(e, t, !0), o = i;
do {
if (a === 0) {
Du && !i && Ai(e, t, 0, !1);
break;
} else {
if (n = e.current.alternate, o && !ki(n)) {
a = Ri(e, t, !1), o = !1;
continue;
}
if (a === 2) {
if (o = t, e.errorRecoveryDisabledLanes & o) var s = 0;
else s = e.pendingLanes & -536870913, s = s === 0 ? s & 536870912 ? 536870912 : 0 : s;
if (s !== 0) {
t = s;
e: {
var c = e;
a = Iu;
var l = uo && c.current.memoizedState.isDehydrated;
if (l && (Ni(c, s).flags |= 256), s = Ri(c, s, !1), s !== 2) {
if (Ou && !l) {
c.errorRecoveryDisabledLanes |= o, Mu |= o, a = 4;
break e;
}
o = Lu, Lu = a, o !== null && (Lu === null ? Lu = o : Lu.push.apply(Lu, o));
}
a = s;
}
if (o = !1, a !== 2) continue;
}
}
if (a === 1) {
Ni(e, 0), Ai(e, t, 0, !0);
break;
}
e: {
switch (i = e, o = a, o) {
case 0:
case 1: throw Error(r(345));
case 4: if ((t & 4194048) !== t) break;
case 6:
Ai(i, t, Pu, !Eu);
break e;
case 2:
Lu = null;
break;
case 3:
case 5: break;
default: throw Error(r(329));
}
if ((t & 62914560) === t && (a = zu + 300 - Sc(), 10 < a)) {
if (Ai(i, t, Pu, !Eu), _(i, 0, !0) !== 0) break e;
qu = t, i.timeoutHandle = io(Oi.bind(null, i, n, Lu, Hu, Ru, t, Pu, Mu, Fu, Eu, o, "Throttled", -0, 0), a);
break e;
}
Oi(i, n, Lu, Hu, Ru, t, Pu, Mu, Fu, Eu, o, null, -0, 0);
}
}
break;
} while (!0);
je(e);
}
function Oi(e, t, n, r, i, a, o, s, c, l, u, d, f, p) {
if (e.timeoutHandle = oo, d = t.subtreeFlags, d & 8192 || (d & 16785408) == 16785408) {
d = Co(), pi(t, a, d);
var m = (a & 62914560) === a ? zu - Sc() : (a & 4194048) === a ? Bu - Sc() : 0;
if (m = To(d, m), m !== null) {
qu = a, e.cancelPendingCommit = m(q.bind(null, e, t, a, n, r, i, o, s, c, u, d, null, f, p)), Ai(e, a, o, !l);
return;
}
}
q(e, t, a, n, r, i, o, s, c);
}
function ki(e) {
for (var t = e;;) {
var n = t.tag;
if ((n === 0 || n === 11 || n === 15) && t.flags & 16384 && (n = t.updateQueue, n !== null && (n = n.stores, n !== null))) for (var r = 0; r < n.length; r++) {
var i = n[r], a = i.getSnapshot;
i = i.value;
try {
if (!jc(a(), i)) return !1;
} catch {
return !1;
}
}
if (n = t.child, t.subtreeFlags & 16384 && n !== null) n.return = t, t = n;
else {
if (t === e) break;
for (; t.sibling === null;) {
if (t.return === null || t.return === e) return !0;
t = t.return;
}
t.sibling.return = t.return, t = t.sibling;
}
}
return !0;
}
function Ai(e, t, n, r) {
t &= ~Nu, t &= ~Mu, e.suspendedLanes |= t, e.pingedLanes &= ~t, r && (e.warmLanes |= t), r = e.expirationTimes;
for (var i = t; 0 < i;) {
var a = 31 - fc(i), o = 1 << a;
r[a] = -1, i &= ~o;
}
n !== 0 && w(e, n, t);
}
function ji() {
return X & 6 ? !0 : (Me(0, !1), !1);
}
function Mi() {
if (Cu !== null) {
if (wu === 0) var e = Cu.return;
else e = Cu, al = il = null, Mt(e), Dl = null, Ol = 0, e = Cu;
for (; e !== null;) Ar(e.alternate, e), e = e.return;
Cu = null;
}
}
function Ni(e, t) {
var n = e.timeoutHandle;
n !== oo && (e.timeoutHandle = oo, ao(n)), n = e.cancelPendingCommit, n !== null && (e.cancelPendingCommit = null, n()), qu = 0, Mi(), Su = e, Cu = n = la(e.current, null), Z = t, wu = 0, Tu = null, Eu = !1, Du = v(e, t), Ou = !1, Fu = Pu = Nu = Mu = ju = Au = 0, Lu = Iu = null, Ru = !1, t & 8 && (t |= t & 32);
var r = e.entangledLanes;
if (r !== 0) for (e = e.entanglements, r &= t; 0 < r;) {
var i = 31 - fc(r), a = 1 << i;
t |= e[i], r &= ~a;
}
return ku = t, $e(), n;
}
function Pi(e, t) {
Y = null, J.H = Zl, t === Sl || t === wl ? (t = qe(), wu = 3) : t === Cl ? (t = qe(), wu = 4) : wu = t === nu ? 8 : typeof t == "object" && t && typeof t.then == "function" ? 6 : 1, Tu = t, Cu === null && (Au = 1, U(e, M(t, e.current)));
}
function Fi() {
var e = Rl.current;
return e === null ? !0 : (Z & 4194048) === Z ? zl === null : (Z & 62914560) === Z || Z & 536870912 ? e === zl : !1;
}
function K() {
var e = J.H;
return J.H = Zl, e === null ? Zl : e;
}
function Ii() {
var e = J.A;
return J.A = mu, e;
}
function Li() {
Au = 4, Eu || (Z & 4194048) !== Z && Rl.current !== null || (Du = !0), !(ju & 134217727) && !(Mu & 134217727) || Su === null || Ai(Su, Z, Pu, !1);
}
function Ri(e, t, n) {
var r = X;
X |= 2;
var i = K(), a = Ii();
(Su !== e || Z !== t) && (Hu = null, Ni(e, t)), t = !1;
var o = Au;
e: do
try {
if (wu !== 0 && Cu !== null) {
var s = Cu, c = Tu;
switch (wu) {
case 8:
Mi(), o = 6;
break e;
case 3:
case 2:
case 9:
case 6:
Rl.current === null && (t = !0);
var l = wu;
if (wu = 0, Tu = null, Wi(e, s, c, l), n && Du) {
o = 0;
break e;
}
break;
default: l = wu, wu = 0, Tu = null, Wi(e, s, c, l);
}
}
zi(), o = Au;
break;
} catch (t) {
Pi(e, t);
}
while (!0);
return t && e.shellSuspendCounter++, al = il = null, X = r, J.H = i, J.A = a, Cu === null && (Su = null, Z = 0, $e()), o;
}
function zi() {
for (; Cu !== null;) Hi(Cu);
}
function Bi(e, t) {
var n = X;
X |= 2;
var i = K(), a = Ii();
Su !== e || Z !== t ? (Hu = null, Vu = Sc() + 500, Ni(e, t)) : Du = v(e, t);
e: do
try {
if (wu !== 0 && Cu !== null) {
t = Cu;
var o = Tu;
n: switch (wu) {
case 1:
wu = 0, Tu = null, Wi(e, t, o, 1);
break;
case 2:
case 9:
if (We(o)) {
wu = 0, Tu = null, Ui(t);
break;
}
t = function() {
wu !== 2 && wu !== 9 || Su !== e || (wu = 7), je(e);
}, o.then(t, t);
break e;
case 3:
wu = 7;
break e;
case 4:
wu = 5;
break e;
case 7:
We(o) ? (wu = 0, Tu = null, Ui(t)) : (wu = 0, Tu = null, Wi(e, t, o, 7));
break;
case 5:
var s = null;
switch (Cu.tag) {
case 26: s = Cu.memoizedState;
case 5:
case 27:
var c = Cu, l = c.type, u = c.pendingProps;
if (s ? tc(s) : So(c.stateNode, l, u)) {
wu = 0, Tu = null;
var d = c.sibling;
if (d !== null) Cu = d;
else {
var f = c.return;
f === null ? Cu = null : (Cu = f, Gi(f));
}
break n;
}
}
wu = 0, Tu = null, Wi(e, t, o, 5);
break;
case 6:
wu = 0, Tu = null, Wi(e, t, o, 6);
break;
case 8:
Mi(), Au = 6;
break e;
default: throw Error(r(462));
}
}
Vi();
break;
} catch (t) {
Pi(e, t);
}
while (!0);
return al = il = null, J.H = i, J.A = a, X = n, Cu === null ? (Su = null, Z = 0, $e(), Au) : 0;
}
function Vi() {
for (; Cu !== null && !bc();) Hi(Cu);
}
function Hi(e) {
var t = hr(e.alternate, e, ku);
e.memoizedProps = e.pendingProps, t === null ? Gi(e) : Cu = t;
}
function Ui(e) {
var t = e, n = t.alternate;
switch (t.tag) {
case 15:
case 0:
t = tr(n, t, t.pendingProps, t.type, void 0, Z);
break;
case 11:
t = tr(n, t, t.pendingProps, t.type.render, t.ref, Z);
break;
case 5: Mt(t);
default: Ar(n, t), t = Cu = ua(t, ku), t = hr(n, t, ku);
}
e.memoizedProps = e.pendingProps, t === null ? Gi(e) : Cu = t;
}
function Wi(e, t, n, r) {
al = il = null, Mt(t), Dl = null, Ol = 0;
var i = t.return;
try {
if (Hn(e, i, t, n, Z)) {
Au = 1, U(e, M(n, e.current)), Cu = null;
return;
}
} catch (t) {
if (i !== null) throw Cu = i, t;
Au = 1, U(e, M(n, e.current)), Cu = null;
return;
}
t.flags & 32768 ? ($c || r === 1 ? e = !0 : Du || Z & 536870912 ? e = !1 : (Eu = e = !0, (r === 2 || r === 9 || r === 3 || r === 6) && (r = Rl.current, r !== null && r.tag === 13 && (r.flags |= 16384))), Ki(t, e)) : Gi(t);
}
function Gi(e) {
var t = e;
do {
if (t.flags & 32768) {
Ki(t, Eu);
return;
}
e = t.return;
var n = Or(t.alternate, t, ku);
if (n !== null) {
Cu = n;
return;
}
if (t = t.sibling, t !== null) {
Cu = t;
return;
}
Cu = t = e;
} while (t !== null);
Au === 0 && (Au = 5);
}
function Ki(e, t) {
do {
var n = kr(e.alternate, e);
if (n !== null) {
n.flags &= 32767, Cu = n;
return;
}
if (n = e.return, n !== null && (n.flags |= 32768, n.subtreeFlags = 0, n.deletions = null), !t && (e = e.sibling, e !== null)) {
Cu = e;
return;
}
Cu = e = n;
} while (e !== null);
Au = 6, Cu = null;
}
function q(e, t, n, i, a, o, s, c, l) {
e.cancelPendingCommit = null;
do
Zi();
while (Wu !== 0);
if (X & 6) throw Error(r(327));
if (t !== null) {
if (t === e.current) throw Error(r(177));
if (o = t.lanes | t.childLanes, o |= Nl, C(e, n, o, s, c, l), e === Su && (Cu = Su = null, Z = 0), Ku = t, Gu = e, qu = n, Ju = o, Yu = a, Xu = i, t.subtreeFlags & 10256 || t.flags & 10256 ? (e.callbackNode = null, e.callbackPriority = 0, oa(Tc, function() {
return Qi(), null;
})) : (e.callbackNode = null, e.callbackPriority = 0), i = (t.flags & 13878) != 0, t.subtreeFlags & 13878 || i) {
i = J.T, J.T = null, a = ho(), mo(2), s = X, X |= 4;
try {
Wr(e, t, n);
} finally {
X = s, mo(a), J.T = i;
}
}
Wu = 1, qi(), Ji(), Yi();
}
}
function qi() {
if (Wu === 1) {
Wu = 0;
var e = Gu, t = Ku, n = (t.flags & 13878) != 0;
if (t.subtreeFlags & 13878 || n) {
n = J.T, J.T = null;
var r = ho();
mo(2);
var i = X;
X |= 4;
try {
ei(t, e), Qa(e.containerInfo);
} finally {
X = i, mo(r), J.T = n;
}
}
e.current = t, Wu = 2;
}
}
function Ji() {
if (Wu === 2) {
Wu = 0;
var e = Gu, t = Ku, n = (t.flags & 8772) != 0;
if (t.subtreeFlags & 8772 || n) {
n = J.T, J.T = null;
var r = ho();
mo(2);
var i = X;
X |= 4;
try {
Gr(e, t.alternate, t);
} finally {
X = i, mo(r), J.T = n;
}
}
Wu = 3;
}
}
function Yi() {
if (Wu === 4 || Wu === 3) {
Wu = 0, xc();
var e = Gu, t = Ku, n = qu, r = Xu;
t.subtreeFlags & 10256 || t.flags & 10256 ? Wu = 5 : (Wu = 0, Ku = Gu = null, Xi(e, e.pendingLanes));
var i = e.pendingLanes;
if (i === 0 && (Uu = null), O(n), t = t.stateNode, Ac && typeof Ac.onCommitFiberRoot == "function") try {
Ac.onCommitFiberRoot(kc, t, void 0, (t.current.flags & 128) == 128);
} catch {}
if (r !== null) {
t = J.T, i = ho(), mo(2), J.T = null;
try {
for (var a = e.onRecoverableError, o = 0; o < r.length; o++) {
var s = r[o];
a(s.value, { componentStack: s.stack });
}
} finally {
J.T = t, mo(i);
}
}
qu & 3 && Zi(), je(e), i = e.pendingLanes, n & 261930 && i & 42 ? e === Qu ? Zu++ : (Zu = 0, Qu = e) : Zu = 0, uo && Fs(), Me(0, !1);
}
}
function Xi(e, t) {
(e.pooledCacheLanes &= t) === 0 && (t = e.pooledCache, t != null && (e.pooledCache = null, ke(t)));
}
function Zi() {
return qi(), Ji(), Yi(), Qi();
}
function Qi() {
if (Wu !== 5) return !1;
var e = Gu, t = Ju;
Ju = 0;
var n = O(qu), i = 32 > n ? 32 : n;
n = J.T;
var a = ho();
try {
mo(i), J.T = null, i = Yu, Yu = null;
var o = Gu, s = qu;
if (Wu = 0, Ku = Gu = null, qu = 0, X & 6) throw Error(r(331));
var c = X;
if (X |= 4, gi(o.current), li(o, o.current, s, i), X = c, Me(0, !1), Ac && typeof Ac.onPostCommitFiberRoot == "function") try {
Ac.onPostCommitFiberRoot(kc, o);
} catch {}
return !0;
} finally {
mo(a), J.T = n, Xi(e, t);
}
}
function $i(e, t, n) {
t = M(n, t), t = zn(e.stateNode, t, 2), e = ct(e, t, 2), e !== null && (S(e, 2), je(e));
}
function ea(e, t, n) {
if (e.tag === 3) $i(e, e, n);
else for (; t !== null;) {
if (t.tag === 3) {
$i(t, e, n);
break;
} else if (t.tag === 1) {
var r = t.stateNode;
if (typeof t.type.getDerivedStateFromError == "function" || typeof r.componentDidCatch == "function" && (Uu === null || !Uu.has(r))) {
e = M(n, e), n = Bn(2), r = ct(t, n, 2), r !== null && (Vn(n, r, t, e), S(r, 2), je(r));
break;
}
}
t = t.return;
}
}
function ta(e, t, n) {
var r = e.pingCache;
if (r === null) {
r = e.pingCache = new xu();
var i = /* @__PURE__ */ new Set();
r.set(t, i);
} else i = r.get(t), i === void 0 && (i = /* @__PURE__ */ new Set(), r.set(t, i));
i.has(n) || (Ou = !0, i.add(n), e = na.bind(null, e, t, n), t.then(e, e));
}
function na(e, t, n) {
var r = e.pingCache;
r !== null && r.delete(t), e.pingedLanes |= e.suspendedLanes & n, e.warmLanes &= ~n, Su === e && (Z & n) === n && (Au === 4 || Au === 3 && (Z & 62914560) === Z && 300 > Sc() - zu ? !(X & 2) && Ni(e, 0) : Nu |= n, Fu === Z && (Fu = 0)), je(e);
}
function ra(e, t) {
t === 0 && (t = b()), e = nt(e, t), e !== null && (S(e, t), je(e));
}
function ia(e) {
var t = e.memoizedState, n = 0;
t !== null && (n = t.retryLane), ra(e, n);
}
function aa(e, t) {
var n = 0;
switch (e.tag) {
case 31:
case 13:
var i = e.stateNode, a = e.memoizedState;
a !== null && (n = a.retryLane);
break;
case 19:
i = e.stateNode;
break;
case 22:
i = e.stateNode._retryCache;
break;
default: throw Error(r(314));
}
i !== null && i.delete(t), ra(e, n);
}
function oa(e, t) {
return vc(e, t);
}
function sa(e, t, n, r) {
this.tag = e, this.key = n, this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null, this.index = 0, this.refCleanup = this.ref = null, this.pendingProps = t, this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null, this.mode = r, this.subtreeFlags = this.flags = 0, this.deletions = null, this.childLanes = this.lanes = 0, this.alternate = null;
}
function ca(e) {
return e = e.prototype, !(!e || !e.isReactComponent);
}
function la(e, n) {
var r = e.alternate;
return r === null ? (r = t(e.tag, n, e.key, e.mode), r.elementType = e.elementType, r.type = e.type, r.stateNode = e.stateNode, r.alternate = e, e.alternate = r) : (r.pendingProps = n, r.type = e.type, r.flags = 0, r.subtreeFlags = 0, r.deletions = null), r.flags = e.flags & 65011712, r.childLanes = e.childLanes, r.lanes = e.lanes, r.child = e.child, r.memoizedProps = e.memoizedProps, r.memoizedState = e.memoizedState, r.updateQueue = e.updateQueue, n = e.dependencies, r.dependencies = n === null ? null : {
lanes: n.lanes,
firstContext: n.firstContext
}, r.sibling = e.sibling, r.index = e.index, r.ref = e.ref, r.refCleanup = e.refCleanup, r;
}
function ua(e, t) {
e.flags &= 65011714;
var n = e.alternate;
return n === null ? (e.childLanes = 0, e.lanes = t, e.child = null, e.subtreeFlags = 0, e.memoizedProps = null, e.memoizedState = null, e.updateQueue = null, e.dependencies = null, e.stateNode = null) : (e.childLanes = n.childLanes, e.lanes = n.lanes, e.child = n.child, e.subtreeFlags = 0, e.deletions = null, e.memoizedProps = n.memoizedProps, e.memoizedState = n.memoizedState, e.updateQueue = n.updateQueue, e.type = n.type, t = n.dependencies, e.dependencies = t === null ? null : {
lanes: t.lanes,
firstContext: t.firstContext
}), e;
}
function da(e, n, i, a, o, s) {
var c = 0;
if (a = e, typeof e == "function") ca(e) && (c = 1);
else if (typeof e == "string") c = Us && rc ? Ws(e, i, qc.current) ? 26 : sc(e) ? 27 : 5 : Us ? Ws(e, i, qc.current) ? 26 : 5 : rc && sc(e) ? 27 : 5;
else e: switch (e) {
case Ba: return e = t(31, i, n, o), e.elementType = Ba, e.lanes = s, e;
case Aa: return fa(i.children, o, s, n);
case ja:
c = 8, o |= 24;
break;
case Ma: return e = t(12, i, n, o | 2), e.elementType = Ma, e.lanes = s, e;
case Ia: return e = t(13, i, n, o), e.elementType = Ia, e.lanes = s, e;
case La: return e = t(19, i, n, o), e.elementType = La, e.lanes = s, e;
default:
if (typeof e == "object" && e) switch (e.$$typeof) {
case Pa:
c = 10;
break e;
case Na:
c = 9;
break e;
case Fa:
c = 11;
break e;
case Ra:
c = 14;
break e;
case za:
c = 16, a = null;
break e;
}
c = 29, i = Error(r(130, e === null ? "null" : typeof e, "")), a = null;
}
return n = t(c, i, n, o), n.elementType = e, n.type = a, n.lanes = s, n;
}
function fa(e, n, r, i) {
return e = t(7, e, i, n), e.lanes = r, e;
}
function pa(e, n, r) {
return e = t(6, e, null, n), e.lanes = r, e;
}
function ma(e) {
var n = t(18, null, null, 0);
return n.stateNode = e, n;
}
function ha(e, n, r) {
return n = t(4, e.children === null ? [] : e.children, e.key, n), n.lanes = r, n.stateNode = {
containerInfo: e.containerInfo,
pendingChildren: null,
implementation: e.implementation
}, n;
}
function ga(e, t, n, r, i, a, o, s, c) {
this.tag = 1, this.containerInfo = e, this.pingCache = this.current = this.pendingChildren = null, this.timeoutHandle = oo, this.callbackNode = this.next = this.pendingContext = this.context = this.cancelPendingCommit = null, this.callbackPriority = 0, this.expirationTimes = x(-1), this.entangledLanes = this.shellSuspendCounter = this.errorRecoveryDisabledLanes = this.expiredLanes = this.warmLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0, this.entanglements = x(0), this.hiddenUpdates = x(null), this.identifierPrefix = r, this.onUncaughtError = i, this.onCaughtError = a, this.onRecoverableError = o, this.pooledCache = null, this.pooledCacheLanes = 0, this.formState = c, this.incompleteTransitions = /* @__PURE__ */ new Map();
}
function _a(e, n, r, i, a, o, s, c, l, u, d, f) {
return e = new ga(e, n, r, s, l, u, d, f, c), n = 1, o === !0 && (n |= 24), o = t(3, null, null, n), e.current = o, o.stateNode = e, n = Oe(), n.refCount++, e.pooledCache = n, n.refCount++, o.memoizedState = {
element: i,
isDehydrated: r,
cache: n
}, at(o), e;
}
function va(e) {
return e ? (e = dc, e) : dc;
}
function ya(e) {
var t = e._reactInternals;
if (t === void 0) throw typeof e.render == "function" ? Error(r(188)) : (e = Object.keys(e).join(","), Error(r(268, e)));
return e = o(t), e = e === null ? null : s(e), e === null ? null : Ja(e.stateNode);
}
function ba(e, t, n, r, i, a) {
i = va(i), r.context === null ? r.context = i : r.pendingContext = i, r = st(t), r.payload = { element: n }, a = a === void 0 ? null : a, a !== null && (r.callback = a), n = ct(e, r, t), n !== null && (Ei(n, e, t), lt(n, e, t));
}
function xa(e, t) {
if (e = e.memoizedState, e !== null && e.dehydrated !== null) {
var n = e.retryLane;
e.retryLane = n !== 0 && n < t ? n : t;
}
}
function Sa(e, t) {
xa(e, t), (e = e.alternate) && xa(e, t);
}
var Ca = {}, wa = c.default, Ta = Og.default, Ea = Object.assign, Da = Symbol.for("react.element"), Oa = Symbol.for("react.transitional.element"), ka = Symbol.for("react.portal"), Aa = Symbol.for("react.fragment"), ja = Symbol.for("react.strict_mode"), Ma = Symbol.for("react.profiler"), Na = Symbol.for("react.consumer"), Pa = Symbol.for("react.context"), Fa = Symbol.for("react.forward_ref"), Ia = Symbol.for("react.suspense"), La = Symbol.for("react.suspense_list"), Ra = Symbol.for("react.memo"), za = Symbol.for("react.lazy"), Ba = Symbol.for("react.activity"), Va = Symbol.for("react.memo_cache_sentinel"), Ha = Symbol.iterator, Ua = Symbol.for("react.client.reference"), Wa = Array.isArray, J = wa.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Ga = e.rendererVersion, Ka = e.rendererPackageName, qa = e.extraDevToolsConfig, Ja = e.getPublicInstance, Ya = e.getRootHostContext, Xa = e.getChildHostContext, Za = e.prepareForCommit, Qa = e.resetAfterCommit, $a = e.createInstance;
e.cloneMutableInstance;
var eo = e.appendInitialChild, to = e.finalizeInitialChildren, no = e.shouldSetTextContent, ro = e.createTextInstance;
e.cloneMutableTextInstance;
var io = e.scheduleTimeout, ao = e.cancelTimeout, oo = e.noTimeout, so = e.isPrimaryRenderer;
e.warnsIfNotActing;
var co = e.supportsMutation, lo = e.supportsPersistence, uo = e.supportsHydration, fo = e.getInstanceFromNode;
e.beforeActiveInstanceBlur;
var po = e.preparePortalMount;
e.prepareScopeUpdate, e.getInstanceFromScope;
var mo = e.setCurrentUpdatePriority, ho = e.getCurrentUpdatePriority, go = e.resolveUpdatePriority;
e.trackSchedulerEvent, e.resolveEventType, e.resolveEventTimeStamp;
var _o = e.shouldAttemptEagerTransition, vo = e.detachDeletedInstance;
e.requestPostPaintCallback;
var yo = e.maySuspendCommit, bo = e.maySuspendCommitOnUpdate, xo = e.maySuspendCommitInSyncRender, So = e.preloadInstance, Co = e.startSuspendingCommit, wo = e.suspendInstance;
e.suspendOnActiveViewTransition;
var To = e.waitForCommitToBeReady;
e.getSuspendedCommitReason;
var Eo = e.NotPendingTransition, Do = e.HostTransitionContext, Oo = e.resetFormInstance;
e.bindToConsole;
var ko = e.supportsMicrotasks, Ao = e.scheduleMicrotask, jo = e.supportsTestSelectors, Mo = e.findFiberRoot, No = e.getBoundingRect, Po = e.getTextContent, Fo = e.isHiddenSubtree, Io = e.matchAccessibilityRole, Lo = e.setFocusIfFocusable, Ro = e.setupIntersectionObserver, zo = e.appendChild, Bo = e.appendChildToContainer, Vo = e.commitTextUpdate, Ho = e.commitMount, Uo = e.commitUpdate, Wo = e.insertBefore, Go = e.insertInContainerBefore, Ko = e.removeChild, qo = e.removeChildFromContainer, Jo = e.resetTextContent, Yo = e.hideInstance, Xo = e.hideTextInstance, Zo = e.unhideInstance, Qo = e.unhideTextInstance;
e.cancelViewTransitionName, e.cancelRootViewTransitionName, e.restoreRootViewTransitionName, e.cloneRootViewTransitionContainer, e.removeRootViewTransitionClone, e.measureClonedInstance, e.hasInstanceChanged, e.hasInstanceAffectedParent, e.startViewTransition, e.startGestureTransition, e.stopViewTransition, e.getCurrentGestureOffset, e.createViewTransitionInstance;
var $o = e.clearContainer;
e.createFragmentInstance, e.updateFragmentInstanceFiber, e.commitNewChildToFragmentInstance, e.deleteChildFromFragmentInstance;
var es = e.cloneInstance, ts = e.createContainerChildSet, ns = e.appendChildToContainerChildSet, rs = e.finalizeContainerChildren, is = e.replaceContainerChildren, as = e.cloneHiddenInstance, os = e.cloneHiddenTextInstance, ss = e.isSuspenseInstancePending, cs = e.isSuspenseInstanceFallback, ls = e.getSuspenseInstanceFallbackErrorDetails, us = e.registerSuspenseInstanceRetry, ds = e.canHydrateFormStateMarker, fs = e.isFormStateMarkerMatching, ps = e.getNextHydratableSibling, ms = e.getNextHydratableSiblingAfterSingleton, hs = e.getFirstHydratableChild, gs = e.getFirstHydratableChildWithinContainer, _s = e.getFirstHydratableChildWithinActivityInstance, vs = e.getFirstHydratableChildWithinSuspenseInstance, ys = e.getFirstHydratableChildWithinSingleton, bs = e.canHydrateInstance, xs = e.canHydrateTextInstance, Ss = e.canHydrateActivityInstance, Cs = e.canHydrateSuspenseInstance, ws = e.hydrateInstance, Ts = e.hydrateTextInstance, Es = e.hydrateActivityInstance, Ds = e.hydrateSuspenseInstance, Os = e.getNextHydratableInstanceAfterActivityInstance, ks = e.getNextHydratableInstanceAfterSuspenseInstance, As = e.commitHydratedInstance, js = e.commitHydratedContainer, Ms = e.commitHydratedActivityInstance, Ns = e.commitHydratedSuspenseInstance, Ps = e.finalizeHydratedChildren, Fs = e.flushHydrationEvents;
e.clearActivityBoundary;
var Is = e.clearSuspenseBoundary;
e.clearActivityBoundaryFromContainer;
var Ls = e.clearSuspenseBoundaryFromContainer, Rs = e.hideDehydratedBoundary, zs = e.unhideDehydratedBoundary, Bs = e.shouldDeleteUnhydratedTailInstances;
e.diffHydratedPropsForDevWarnings, e.diffHydratedTextForDevWarnings, e.describeHydratableInstanceForDevWarnings;
var Vs = e.validateHydratableInstance, Hs = e.validateHydratableTextInstance, Us = e.supportsResources, Ws = e.isHostHoistableType, Gs = e.getHoistableRoot, Ks = e.getResource, qs = e.acquireResource, Js = e.releaseResource, Ys = e.hydrateHoistable, Xs = e.mountHoistable, Zs = e.unmountHoistable, Qs = e.createHoistableInstance, $s = e.prepareToCommitHoistables, ec = e.mayResourceSuspendCommit, tc = e.preloadResource, nc = e.suspendResource, rc = e.supportsSingletons, ic = e.resolveSingletonInstance, ac = e.acquireSingletonInstance, oc = e.releaseSingletonInstance, sc = e.isHostSingletonType, cc = e.isSingletonScope, lc = [], uc = -1, dc = {}, fc = Math.clz32 ? Math.clz32 : h, pc = Math.log, mc = Math.LN2, hc = 256, gc = 262144, _c = 4194304, vc = Ta.unstable_scheduleCallback, yc = Ta.unstable_cancelCallback, bc = Ta.unstable_shouldYield, xc = Ta.unstable_requestPaint, Sc = Ta.unstable_now, Cc = Ta.unstable_ImmediatePriority, wc = Ta.unstable_UserBlockingPriority, Tc = Ta.unstable_NormalPriority, Ec = Ta.unstable_IdlePriority, Dc = Ta.log, Oc = Ta.unstable_setDisableYieldValue, kc = null, Ac = null, jc = typeof Object.is == "function" ? Object.is : A, Mc = typeof reportError == "function" ? reportError : function(e) {
if (typeof window == "object" && typeof window.ErrorEvent == "function") {
var t = new window.ErrorEvent("error", {
bubbles: !0,
cancelable: !0,
message: typeof e == "object" && e && typeof e.message == "string" ? String(e.message) : String(e),
error: e
});
if (!window.dispatchEvent(t)) return;
} else if (typeof process == "object" && typeof process.emit == "function") {
process.emit("uncaughtException", e);
return;
}
console.error(e);
}, Nc = Object.prototype.hasOwnProperty, Pc, Fc, Ic = !1, Lc = /* @__PURE__ */ new WeakMap(), Rc = [], zc = 0, Bc = null, Vc = 0, Hc = [], Uc = 0, Wc = null, Gc = 1, Kc = "", qc = f(null), Jc = f(null), Yc = f(null), Xc = f(null), Zc = null, Qc = null, $c = !1, el = null, tl = !1, nl = Error(r(519)), rl = f(null), il = null, al = null, ol = typeof AbortController < "u" ? AbortController : function() {
var e = [], t = this.signal = {
aborted: !1,
addEventListener: function(t, n) {
e.push(n);
}
};
this.abort = function() {
t.aborted = !0, e.forEach(function(e) {
return e();
});
};
}, sl = Ta.unstable_scheduleCallback, cl = Ta.unstable_NormalPriority, ll = {
$$typeof: Pa,
Consumer: null,
Provider: null,
_currentValue: null,
_currentValue2: null,
_threadCount: 0
}, ul = null, dl = null, fl = !1, pl = !1, ml = !1, hl = 0, gl = null, _l = 0, vl = 0, yl = null, bl = J.S;
J.S = function(e, t) {
Bu = Sc(), typeof t == "object" && t && typeof t.then == "function" && Re(e, t), bl !== null && bl(e, t);
};
var xl = f(null), Sl = Error(r(460)), Cl = Error(r(474)), wl = Error(r(542)), Tl = { then: function() {} }, El = null, Dl = null, Ol = 0, kl = Qe(!0), Al = Qe(!1), jl = [], Ml = 0, Nl = 0, Pl = !1, Fl = !1, Il = f(null), Ll = f(0), Rl = f(null), zl = null, Bl = f(0), Vl = 0, Y = null, Hl = null, Ul = null, Wl = !1, Gl = !1, Kl = !1, ql = 0, Jl = 0, Yl = null, Xl = 0, Zl = {
readContext: Te,
use: Lt,
useCallback: wt,
useContext: wt,
useEffect: wt,
useImperativeHandle: wt,
useLayoutEffect: wt,
useInsertionEffect: wt,
useMemo: wt,
useReducer: wt,
useRef: wt,
useState: wt,
useDebugValue: wt,
useDeferredValue: wt,
useTransition: wt,
useSyncExternalStore: wt,
useId: wt,
useHostTransitionStatus: wt,
useFormState: wt,
useActionState: wt,
useOptimistic: wt,
useMemoCache: wt,
useCacheRefresh: wt
};
Zl.useEffectEvent = wt;
var Ql = {
readContext: Te,
use: Lt,
useCallback: function(e, t) {
return Nt().memoizedState = [e, t === void 0 ? null : t], e;
},
useContext: Te,
useEffect: fn,
useImperativeHandle: function(e, t, n) {
n = n == null ? null : n.concat([e]), un(4194308, 4, _n.bind(null, t, e), n);
},
useLayoutEffect: function(e, t) {
return un(4194308, 4, e, t);
},
useInsertionEffect: function(e, t) {
un(4, 2, e, t);
},
useMemo: function(e, t) {
var n = Nt();
t = t === void 0 ? null : t;
var r = e();
if (Kl) {
k(!0);
try {
e();
} finally {
k(!1);
}
}
return n.memoizedState = [r, t], r;
},
useReducer: function(e, t, n) {
var r = Nt();
if (n !== void 0) {
var i = n(t);
if (Kl) {
k(!0);
try {
n(t);
} finally {
k(!1);
}
}
} else i = t;
return r.memoizedState = r.baseState = i, e = {
pending: null,
lanes: 0,
dispatch: null,
lastRenderedReducer: e,
lastRenderedState: i
}, r.queue = e, e = e.dispatch = An.bind(null, Y, e), [r.memoizedState, e];
},
useRef: function(e) {
var t = Nt();
return e = { current: e }, t.memoizedState = e;
},
useState: function(e) {
e = Yt(e);
var t = e.queue, n = jn.bind(null, Y, t);
return t.dispatch = n, [e.memoizedState, n];
},
useDebugValue: yn,
useDeferredValue: function(e, t) {
return Sn(Nt(), e, t);
},
useTransition: function() {
var e = Yt(!1);
return e = wn.bind(null, Y, e.queue, !0, !1), Nt().memoizedState = e, [!1, e];
},
useSyncExternalStore: function(e, t, n) {
var i = Y, a = Nt();
if ($c) {
if (n === void 0) throw Error(r(407));
n = n();
} else {
if (n = t(), Su === null) throw Error(r(349));
Z & 127 || Wt(i, t, n);
}
a.memoizedState = n;
var o = {
value: n,
getSnapshot: t
};
return a.queue = o, fn(Kt.bind(null, i, o, e), [e]), i.flags |= 2048, cn(9, { destroy: void 0 }, Gt.bind(null, i, o, n, t), null), n;
},
useId: function() {
var e = Nt(), t = Su.identifierPrefix;
if ($c) {
var n = Kc, r = Gc;
n = (r & ~(1 << 32 - fc(r) - 1)).toString(32) + n, t = "_" + t + "R_" + n, n = ql++, 0 < n && (t += "H" + n.toString(32)), t += "_";
} else n = Xl++, t = "_" + t + "r_" + n.toString(32) + "_";
return e.memoizedState = t;
},
useHostTransitionStatus: En,
useFormState: an,
useActionState: an,
useOptimistic: function(e) {
var t = Nt();
t.memoizedState = t.baseState = e;
var n = {
pending: null,
lanes: 0,
dispatch: null,
lastRenderedReducer: null,
lastRenderedState: null
};
return t.queue = n, t = Nn.bind(null, Y, !0, n), n.dispatch = t, [e, t];
},
useMemoCache: Rt,
useCacheRefresh: function() {
return Nt().memoizedState = kn.bind(null, Y);
},
useEffectEvent: function(e) {
var t = Nt(), n = { impl: e };
return t.memoizedState = n, function() {
if (X & 2) throw Error(r(440));
return n.impl.apply(void 0, arguments);
};
}
}, $l = {
readContext: Te,
use: Lt,
useCallback: bn,
useContext: Te,
useEffect: pn,
useImperativeHandle: vn,
useInsertionEffect: hn,
useLayoutEffect: gn,
useMemo: xn,
useReducer: Bt,
useRef: ln,
useState: function() {
return Bt(zt);
},
useDebugValue: yn,
useDeferredValue: function(e, t) {
return Cn(Pt(), Hl.memoizedState, e, t);
},
useTransition: function() {
var e = Bt(zt)[0], t = Pt().memoizedState;
return [typeof e == "boolean" ? e : It(e), t];
},
useSyncExternalStore: Ut,
useId: Dn,
useHostTransitionStatus: En,
useFormState: L,
useActionState: L,
useOptimistic: function(e, t) {
return Xt(Pt(), Hl, e, t);
},
useMemoCache: Rt,
useCacheRefresh: On
};
$l.useEffectEvent = z;
var eu = {
readContext: Te,
use: Lt,
useCallback: bn,
useContext: Te,
useEffect: pn,
useImperativeHandle: vn,
useInsertionEffect: hn,
useLayoutEffect: gn,
useMemo: xn,
useReducer: Ht,
useRef: ln,
useState: function() {
return Ht(zt);
},
useDebugValue: yn,
useDeferredValue: function(e, t) {
var n = Pt();
return Hl === null ? Sn(n, e, t) : Cn(n, Hl.memoizedState, e, t);
},
useTransition: function() {
var e = Ht(zt)[0], t = Pt().memoizedState;
return [typeof e == "boolean" ? e : It(e), t];
},
useSyncExternalStore: Ut,
useId: Dn,
useHostTransitionStatus: En,
useFormState: sn,
useActionState: sn,
useOptimistic: function(e, t) {
var n = Pt();
return Hl === null ? (n.baseState = e, [e, n.queue.dispatch]) : Xt(n, Hl, e, t);
},
useMemoCache: Rt,
useCacheRefresh: On
};
eu.useEffectEvent = z;
var tu = {
enqueueSetState: function(e, t, n) {
e = e._reactInternals;
var r = wi(), i = st(r);
i.payload = t, n != null && (i.callback = n), t = ct(e, i, r), t !== null && (Ei(t, e, r), lt(t, e, r));
},
enqueueReplaceState: function(e, t, n) {
e = e._reactInternals;
var r = wi(), i = st(r);
i.tag = 1, i.payload = t, n != null && (i.callback = n), t = ct(e, i, r), t !== null && (Ei(t, e, r), lt(t, e, r));
},
enqueueForceUpdate: function(e, t) {
e = e._reactInternals;
var n = wi(), r = st(n);
r.tag = 2, t != null && (r.callback = t), t = ct(e, r, n), t !== null && (Ei(t, e, n), lt(t, e, n));
}
}, nu = Error(r(461)), ru = !1, iu = {
dehydrated: null,
treeContext: null,
retryLane: 0,
hydrationErrors: null
}, au = !1, ou = !1, su = !1, cu = typeof WeakSet == "function" ? WeakSet : Set, lu = null, uu = null, du = !1, fu = null, pu = 8192, mu = {
getCacheForType: function(e) {
var t = Te(ll), n = t.data.get(e);
return n === void 0 && (n = e(), t.data.set(e, n)), n;
},
cacheSignal: function() {
return Te(ll).controller.signal;
}
}, hu = 0, gu = 1, _u = 2, vu = 3, yu = 4;
if (typeof Symbol == "function" && Symbol.for) {
var bu = Symbol.for;
hu = bu("selector.component"), gu = bu("selector.has_pseudo_class"), _u = bu("selector.role"), vu = bu("selector.test_id"), yu = bu("selector.text");
}
var xu = typeof WeakMap == "function" ? WeakMap : Map, X = 0, Su = null, Cu = null, Z = 0, wu = 0, Tu = null, Eu = !1, Du = !1, Ou = !1, ku = 0, Au = 0, ju = 0, Mu = 0, Nu = 0, Pu = 0, Fu = 0, Iu = null, Lu = null, Ru = !1, zu = 0, Bu = 0, Vu = Infinity, Hu = null, Uu = null, Wu = 0, Gu = null, Ku = null, qu = 0, Ju = 0, Yu = null, Xu = null, Zu = 0, Qu = null;
return Ca.attemptContinuousHydration = function(e) {
if (e.tag === 13 || e.tag === 31) {
var t = nt(e, 67108864);
t !== null && Ei(t, e, 67108864), Sa(e, 67108864);
}
}, Ca.attemptHydrationAtCurrentPriority = function(e) {
if (e.tag === 13 || e.tag === 31) {
var t = wi();
t = D(t);
var n = nt(e, t);
n !== null && Ei(n, e, t), Sa(e, t);
}
}, Ca.attemptSynchronousHydration = function(e) {
switch (e.tag) {
case 3:
if (e = e.stateNode, e.current.memoizedState.isDehydrated) {
var t = g(e.pendingLanes);
if (t !== 0) {
for (e.pendingLanes |= 2, e.entangledLanes |= 2; t;) {
var n = 1 << 31 - fc(t);
e.entanglements[1] |= n, t &= ~n;
}
je(e), !(X & 6) && (Vu = Sc() + 500, Me(0, !1));
}
}
break;
case 31:
case 13: t = nt(e, 2), t !== null && Ei(t, e, 2), ji(), Sa(e, 2);
}
}, Ca.batchedUpdates = function(e, t) {
return e(t);
}, Ca.createComponentSelector = function(e) {
return {
$$typeof: hu,
value: e
};
}, Ca.createContainer = function(e, t, n, r, i, a, o, s, c, l) {
return _a(e, t, !1, null, n, r, a, null, o, s, c, l);
}, Ca.createHasPseudoClassSelector = function(e) {
return {
$$typeof: gu,
value: e
};
}, Ca.createHydrationContainer = function(e, t, n, r, i, a, o, s, c, l, u, d, f, p) {
var m;
return e = _a(n, r, !0, e, i, a, s, p, c, l, u, d), e.context = va(null), n = e.current, r = wi(), r = D(r), i = st(r), i.callback = (m = t) == null ? null : m, ct(n, i, r), t = r, e.current.lanes = t, S(e, t), je(e), e;
}, Ca.createPortal = function(e, t, n) {
var r = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
return {
$$typeof: ka,
key: r == null ? null : "" + r,
children: e,
containerInfo: t,
implementation: n
};
}, Ca.createRoleSelector = function(e) {
return {
$$typeof: _u,
value: e
};
}, Ca.createTestNameSelector = function(e) {
return {
$$typeof: vu,
value: e
};
}, Ca.createTextSelector = function(e) {
return {
$$typeof: yu,
value: e
};
}, Ca.defaultOnCaughtError = function(e) {
console.error(e);
}, Ca.defaultOnRecoverableError = function(e) {
Mc(e);
}, Ca.defaultOnUncaughtError = function(e) {
Mc(e);
}, Ca.deferredUpdates = function(e) {
var t = J.T, n = ho();
try {
return mo(32), J.T = null, e();
} finally {
mo(n), J.T = t;
}
}, Ca.discreteUpdates = function(e, t, n, r, i) {
var a = J.T, o = ho();
try {
return mo(2), J.T = null, e(t, n, r, i);
} finally {
mo(o), J.T = a, X === 0 && (Vu = Sc() + 500);
}
}, Ca.findAllNodes = Ci, Ca.findBoundingRects = function(e, t) {
if (!jo) throw Error(r(363));
t = Ci(e, t), e = [];
for (var n = 0; n < t.length; n++) e.push(No(t[n]));
for (t = e.length - 1; 0 < t; t--) {
n = e[t];
for (var i = n.x, a = i + n.width, o = n.y, s = o + n.height, c = t - 1; 0 <= c; c--) if (t !== c) {
var l = e[c], u = l.x, d = u + l.width, f = l.y, p = f + l.height;
if (i >= u && o >= f && a <= d && s <= p) {
e.splice(t, 1);
break;
} else if (i !== u || n.width !== l.width || p < o || f > s) {
if (!(o !== f || n.height !== l.height || d < i || u > a)) {
u > i && (l.width += u - i, l.x = i), d < a && (l.width = a - u), e.splice(t, 1);
break;
}
} else {
f > o && (l.height += f - o, l.y = o), p < s && (l.height = s - f), e.splice(t, 1);
break;
}
}
}
return e;
}, Ca.findHostInstance = ya, Ca.findHostInstanceWithNoPortals = function(e) {
return e = o(e), e = e === null ? null : l(e), e === null ? null : Ja(e.stateNode);
}, Ca.findHostInstanceWithWarning = function(e) {
return ya(e);
}, Ca.flushPassiveEffects = Zi, Ca.flushSyncFromReconciler = function(e) {
var t = X;
X |= 1;
var n = J.T, r = ho();
try {
if (mo(2), J.T = null, e) return e();
} finally {
mo(r), J.T = n, X = t, !(X & 6) && Me(0, !1);
}
}, Ca.flushSyncWork = ji, Ca.focusWithin = function(e, t) {
if (!jo) throw Error(r(363));
for (e = yi(e), t = Si(e, t), t = Array.from(t), e = 0; e < t.length;) {
var n = t[e++], i = n.tag;
if (!Fo(n)) {
if ((i === 5 || i === 26 || i === 27) && Lo(n.stateNode)) return !0;
for (n = n.child; n !== null;) t.push(n), n = n.sibling;
}
}
return !1;
}, Ca.getFindAllNodesFailureDescription = function(e, t) {
if (!jo) throw Error(r(363));
var n = 0, i = [];
e = [yi(e), 0];
for (var a = 0; a < e.length;) {
var o = e[a++], s = o.tag, c = e[a++], l = t[c];
if ((s !== 5 && s !== 26 && s !== 27 || !Fo(o)) && (bi(o, l) && (i.push(xi(l)), c++, c > n && (n = c)), c < t.length)) for (o = o.child; o !== null;) e.push(o, c), o = o.sibling;
}
if (n < t.length) {
for (e = []; n < t.length; n++) e.push(xi(t[n]));
return "findAllNodes was able to match part of the selector:\n " + (i.join(" > ") + "\n\nNo matching component was found for:\n ") + e.join(" > ");
}
return null;
}, Ca.getPublicRootInstance = function(e) {
if (e = e.current, !e.child) return null;
switch (e.child.tag) {
case 27:
case 5: return Ja(e.child.stateNode);
default: return e.child.stateNode;
}
}, Ca.injectIntoDevTools = function() {
var e = {
bundleType: 0,
version: Ga,
rendererPackageName: Ka,
currentDispatcherRef: J,
reconcilerVersion: "19.2.0"
};
if (qa !== null && (e.rendererConfig = qa), typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ > "u") e = !1;
else {
var t = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (t.isDisabled || !t.supportsFiber) e = !0;
else {
try {
kc = t.inject(e), Ac = t;
} catch {}
e = !!t.checkDCE;
}
}
return e;
}, Ca.isAlreadyRendering = function() {
return (X & 6) != 0;
}, Ca.observeVisibleRects = function(e, t, n, i) {
if (!jo) throw Error(r(363));
e = Ci(e, t);
var a = Ro(e, n, i).disconnect;
return { disconnect: function() {
a();
} };
}, Ca.shouldError = function() {
return null;
}, Ca.shouldSuspend = function() {
return !1;
}, Ca.startHostTransition = function(e, t, i, a) {
if (e.tag !== 5) throw Error(r(476));
var o = Tn(e).queue;
wn(e, o, t, Eo, i === null ? n : function() {
var t = Tn(e);
return t.next === null && (t = e.alternate.memoizedState), Mn(e, t.next.queue, {}, wi()), i(a);
});
}, Ca.updateContainer = function(e, t, n, r) {
var i = t.current, a = wi();
return ba(i, a, e, t, n, r), a;
}, Ca.updateContainerSync = function(e, t, n, r) {
return ba(t.current, 2, e, t, n, r), 2;
}, Ca;
}, e.exports.default = e.exports, Object.defineProperty(e.exports, "__esModule", { value: !0 });
}(R_)), R_.exports;
}
({ exports: {} }).exports;
var V_;
function H_() {
return V_ || (V_ = 1, L_.exports = B_()), L_.exports;
}
var U_ = I_(H_());
function W_(e) {
let t = U_(e);
return t.injectIntoDevTools(), t;
}
var G_ = 0, K_ = {}, q_ = /^three(?=[A-Z])/, J_ = (e) => `${e[0].toUpperCase()}${e.slice(1)}`, Y_ = 0, X_ = (e) => typeof e == "function";
function Z_(e) {
if (X_(e)) {
let t = `${Y_++}`;
return K_[t] = e, t;
} else Object.assign(K_, e);
}
function Q_(e, t) {
let n = J_(e), r = K_[n];
if (e !== "primitive" && !r) throw Error(`R3F: ${n} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);
if (e === "primitive" && !t.object) throw Error("R3F: Primitives without 'object' are invalid!");
if (t.args !== void 0 && !Array.isArray(t.args)) throw Error("R3F: The args prop must be an array!");
}
function $_(e, t, n) {
var r;
return e = J_(e) in K_ ? e : e.replace(q_, ""), Q_(e, t), e === "primitive" && (r = t.object) != null && r.__r3f && delete t.object.__r3f, e_(t.object, n, e, t);
}
function ev(e) {
if (!e.isHidden) {
var t;
e.props.attach && (t = e.parent) != null && t.object ? i_(e.parent, e) : m_(e.object) && (e.object.visible = !1), e.isHidden = !0, f_(e);
}
}
function tv(e) {
if (e.isHidden) {
var t;
e.props.attach && (t = e.parent) != null && t.object ? r_(e.parent, e) : m_(e.object) && e.props.visible !== !1 && (e.object.visible = !0), e.isHidden = !1, f_(e);
}
}
function nv(e, t, n) {
let r = t.root.getState();
if (!(!e.parent && e.object !== r.scene)) {
if (!t.object) {
var i, a;
let e = K_[J_(t.type)];
t.object = (i = t.props.object) == null ? new e(...(a = t.props.args) == null ? [] : a) : i, t.object.__r3f = t;
}
if (d_(t.object, t.props), t.props.attach) r_(e, t);
else if (m_(t.object) && m_(e.object)) {
let r = e.object.children.indexOf(n == null ? void 0 : n.object);
if (n && r !== -1) {
let n = e.object.children.indexOf(t.object);
if (n !== -1) {
e.object.children.splice(n, 1);
let i = n < r ? r - 1 : r;
e.object.children.splice(i, 0, t.object);
} else t.object.parent = e.object, e.object.children.splice(r, 0, t.object), t.object.dispatchEvent({ type: "added" }), e.object.dispatchEvent({
type: "childadded",
child: t.object
});
} else e.object.add(t.object);
}
for (let e of t.children) nv(t, e);
f_(t);
}
}
function rv(e, t) {
if (t) {
if (t.parent === e) {
let n = e.children.indexOf(t);
n !== -1 && e.children.splice(n, 1);
}
t.parent = e, e.children.push(t), nv(e, t);
}
}
function iv(e, t, n) {
if (!t || !n) return;
if (t.parent === e) {
let n = e.children.indexOf(t);
n !== -1 && e.children.splice(n, 1);
}
t.parent = e;
let r = e.children.indexOf(n);
r === -1 ? e.children.push(t) : e.children.splice(r, 0, t), nv(e, t, n);
}
function av(e) {
if (typeof e.dispose == "function") {
let t = () => {
try {
e.dispose();
} catch {}
};
typeof IS_REACT_ACT_ENVIRONMENT < "u" ? t() : (0, Og.unstable_scheduleCallback)(Og.unstable_IdlePriority, t);
}
}
function ov(e, t, n) {
if (!t) return;
t.parent = null;
let r = e.children.indexOf(t);
r !== -1 && e.children.splice(r, 1), t.props.attach ? i_(e, t) : m_(t.object) && m_(e.object) && (e.object.remove(t.object), v_(Rg(t), t.object));
let i = t.props.dispose !== null && n !== !1;
for (let e = t.children.length - 1; e >= 0; e--) {
let n = t.children[e];
ov(t, n, i);
}
t.children.length = 0, delete t.object.__r3f, i && t.type !== "primitive" && t.object.type !== "Scene" && av(t.object), n === void 0 && f_(t);
}
function sv(e, t) {
for (let n of [e, e.alternate]) if (n !== null) if (typeof n.ref == "function") {
n.refCleanup == null || n.refCleanup();
let e = n.ref(t);
typeof e == "function" && (n.refCleanup = e);
} else n.ref && (n.ref.current = t);
}
var cv = [];
function lv() {
if (cv.length !== 0) try {
uv();
} finally {
cv.length = 0;
}
}
function uv() {
for (let [e] of cv) {
let t = e.parent;
if (t) {
e.props.attach ? i_(t, e) : m_(e.object) && m_(t.object) && t.object.remove(e.object);
for (let t of e.children) t.props.attach ? i_(e, t) : m_(t.object) && m_(e.object) && e.object.remove(t.object);
}
e.isHidden && tv(e), e.object.__r3f && delete e.object.__r3f, e.type !== "primitive" && av(e.object);
}
for (let [n, r, i] of cv) {
n.props = r;
let a = n.parent;
if (a) {
var e, t;
let r = K_[J_(n.type)], o = n.object;
n.object = (e = n.props.object) == null ? new r(...(t = n.props.args) == null ? [] : t) : e, n.object.__r3f = n, sv(i, n.object), __(Rg(n), o, n.object), d_(n.object, n.props), n.props.attach ? r_(a, n) : m_(n.object) && m_(a.object) && a.object.add(n.object);
for (let e of n.children) e.props.attach ? r_(n, e) : m_(e.object) && m_(n.object) && n.object.add(e.object);
f_(n);
}
}
}
var dv = () => {}, fv = {}, pv = G_;
function mv(e) {
switch (e) {
case "beforetoggle":
case "cancel":
case "click":
case "close":
case "contextmenu":
case "copy":
case "cut":
case "auxclick":
case "dblclick":
case "dragend":
case "dragstart":
case "drop":
case "focusin":
case "focusout":
case "input":
case "invalid":
case "keydown":
case "keypress":
case "keyup":
case "mousedown":
case "mouseup":
case "paste":
case "pause":
case "play":
case "pointercancel":
case "pointerdown":
case "pointerup":
case "ratechange":
case "reset":
case "resize":
case "seeked":
case "submit":
case "touchcancel":
case "touchend":
case "touchstart":
case "volumechange":
case "change":
case "selectionchange":
case "compositionstart":
case "compositionend":
case "compositionupdate":
case "beforeinput":
case "blur":
case "fullscreenchange":
case "focus":
case "hashchange":
case "popstate":
case "select":
case "selectstart": return N_;
case "drag":
case "dragenter":
case "dragexit":
case "dragleave":
case "dragover":
case "mousemove":
case "mouseout":
case "mouseover":
case "pointermove":
case "pointerout":
case "pointerover":
case "scroll":
case "touchmove":
case "wheel":
case "mouseenter":
case "mouseleave":
case "pointerenter":
case "pointerleave": return j_;
case "message": switch ((0, Og.unstable_getCurrentPriorityLevel)()) {
case Og.unstable_ImmediatePriority: return N_;
case Og.unstable_UserBlockingPriority: return j_;
case Og.unstable_NormalPriority:
case Og.unstable_LowPriority: return M_;
case Og.unstable_IdlePriority: return P_;
default: return M_;
}
default: return M_;
}
}
function hv(e) {
typeof queueMicrotask == "function" ? queueMicrotask(e) : typeof Promise < "u" ? Promise.resolve().then(e).catch((e) => {
setTimeout(() => {
throw e;
});
}) : setTimeout(e);
}
var gv = /* @__PURE__ */ W_({
isPrimaryRenderer: !1,
warnsIfNotActing: !1,
supportsMutation: !0,
supportsPersistence: !1,
supportsHydration: !1,
createInstance: $_,
removeChild: ov,
appendChild: rv,
appendInitialChild: rv,
insertBefore: iv,
appendChildToContainer(e, t) {
let n = e.getState().scene.__r3f;
!t || !n || rv(n, t);
},
removeChildFromContainer(e, t) {
let n = e.getState().scene.__r3f;
!t || !n || ov(n, t);
},
insertInContainerBefore(e, t, n) {
let r = e.getState().scene.__r3f;
!t || !n || !r || iv(r, t, n);
},
getRootHostContext: () => fv,
getChildHostContext: () => fv,
commitUpdate(e, t, n, r, i) {
var a, o, s;
Q_(t, r);
let c = !1;
if (e.type === "primitive" && n.object !== r.object ? c = !0 : ((a = r.args) == null ? void 0 : a.length) === ((o = n.args) == null ? void 0 : o.length) ? (s = r.args) != null && s.some((e, t) => {
var r;
return e !== ((r = n.args) == null ? void 0 : r[t]);
}) && (c = !0) : c = !0, c) cv.push([
e,
$g(r),
i
]);
else {
let t = c_(e, r), n = e.props.attach;
e.props = $g(r), n === void 0 ? delete e.props.attach : e.props.attach = n, Object.keys(t).length && d_(e.object, t);
}
},
finalizeInitialChildren: () => !1,
commitMount() {},
getPublicInstance: (e) => e == null ? void 0 : e.object,
prepareForCommit: () => null,
preparePortalMount: (e) => e_(e.getState().scene, e, "", {}),
resetAfterCommit: lv,
shouldSetTextContent: () => !1,
clearContainer: () => !1,
hideInstance: ev,
unhideInstance: tv,
createTextInstance: dv,
hideTextInstance: dv,
unhideTextInstance: dv,
supportsMicrotasks: !0,
scheduleMicrotask: hv,
scheduleTimeout: typeof setTimeout == "function" ? setTimeout : void 0,
cancelTimeout: typeof clearTimeout == "function" ? clearTimeout : void 0,
noTimeout: -1,
getInstanceFromNode: () => null,
beforeActiveInstanceBlur() {},
afterActiveInstanceBlur() {},
detachDeletedInstance() {},
prepareScopeUpdate() {},
getInstanceFromScope: () => null,
shouldAttemptEagerTransition: () => !1,
trackSchedulerEvent: () => {},
resolveEventType: () => null,
resolveEventTimeStamp: () => -1.1,
requestPostPaintCallback() {},
maySuspendCommit: () => !1,
preloadInstance: () => !0,
suspendInstance() {},
waitForCommitToBeReady: () => null,
NotPendingTransition: null,
HostTransitionContext: /* @__PURE__ */ c.createContext(null),
setCurrentUpdatePriority(e) {
pv = e;
},
getCurrentUpdatePriority() {
return pv;
},
resolveUpdatePriority() {
var e;
if (pv !== G_) return pv;
let t = typeof window < "u" ? (e = window.event) == null ? void 0 : e.type : void 0;
return t === void 0 ? M_ : mv(t);
},
resetFormInstance() {},
rendererPackageName: "@react-three/fiber",
rendererVersion: F_.version,
applyViewTransitionName(e, t, n) {},
restoreViewTransitionName(e, t) {},
cancelViewTransitionName(e, t, n) {},
cancelRootViewTransitionName(e) {},
restoreRootViewTransitionName(e) {},
InstanceMeasurement: null,
measureInstance: (e) => null,
wasInstanceInViewport: (e) => !0,
hasInstanceChanged: (e, t) => !1,
hasInstanceAffectedParent: (e, t) => !1,
suspendOnActiveViewTransition(e, t) {},
startGestureTransition: () => null,
startViewTransition: () => null,
stopViewTransition(e) {},
createViewTransitionInstance: (e) => null,
getCurrentGestureOffset(e) {
throw Error("startGestureTransition is not yet supported in react-three-fiber.");
},
cloneMutableInstance(e, t) {
return e;
},
cloneMutableTextInstance(e) {
return e;
},
cloneRootViewTransitionContainer(e) {
throw Error("Not implemented.");
},
removeRootViewTransitionClone(e, t) {
throw Error("Not implemented.");
},
createFragmentInstance: (e) => null,
updateFragmentInstanceFiber(e, t) {},
commitNewChildToFragmentInstance(e, t) {},
deleteChildFromFragmentInstance(e, t) {},
measureClonedInstance: (e) => null,
maySuspendCommitOnUpdate: (e, t, n) => !1,
maySuspendCommitInSyncRender: (e, t) => !1,
startSuspendingCommit: () => null,
getSuspendedCommitReason: (e, t) => null
}), _v = /* @__PURE__ */ new Map(), vv = {
objects: "shallow",
strict: !1
};
function yv(e, t) {
if (!t && typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement && e.parentElement) {
let { width: t, height: n, top: r, left: i } = e.parentElement.getBoundingClientRect();
return {
width: t,
height: n,
top: r,
left: i
};
} else if (!t && typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas) return {
width: e.width,
height: e.height,
top: 0,
left: 0
};
return {
width: 0,
height: 0,
top: 0,
left: 0,
...t
};
}
function bv(e) {
let t = _v.get(e), n = t == null ? void 0 : t.fiber, r = t == null ? void 0 : t.store;
t && console.warn("R3F.createRoot should only be called once!");
let i = typeof reportError == "function" ? reportError : console.error, a = r || S_(zv, Bv), o = n || gv.createContainer(a, A_, null, !1, null, "", i, i, i, null);
t || _v.set(e, {
fiber: o,
store: a
});
let s, c, l = !1, u = null;
return {
async configure(t = {}) {
let n;
u = new Promise((e) => n = e);
let { gl: r, size: i, scene: o, events: d, onCreated: f, shadows: p = !1, linear: m = !1, flat: h = !1, legacy: g = !1, orthographic: _ = !1, frameloop: v = "always", dpr: y = [1, 2], performance: b, raycaster: x, camera: S, onPointerMissed: C } = t, w = a.getState(), T = w.gl;
if (!w.gl) {
let t = {
canvas: e,
powerPreference: "high-performance",
antialias: !0,
alpha: !0
}, n = typeof r == "function" ? await r(t) : r;
T = b_(n) ? n : new cg({
...t,
...r
}), w.set({ gl: T });
}
let E = w.raycaster;
E || w.set({ raycaster: E = new Ud() });
let { params: D, ...O } = x || {};
if (Yg.equ(O, E, vv) || d_(E, { ...O }), Yg.equ(D, E.params, vv) || d_(E, { params: {
...E.params,
...D
} }), !w.camera || w.camera === c && !Yg.equ(c, S, vv)) {
c = S;
let e = S == null ? void 0 : S.isCamera, t = e ? S : _ ? new Ou(0, 0, 0, 0, .1, 1e3) : new Z(75, 0, .1, 1e3);
e || (t.position.z = 5, S && (d_(t, S), t.manual || ("aspect" in S || "left" in S || "right" in S || "bottom" in S || "top" in S) && (t.manual = !0, t.updateProjectionMatrix())), !w.camera && !(S != null && S.rotation) && t.lookAt(0, 0, 0)), w.set({ camera: t }), E.camera = t;
}
if (!w.scene) {
let e;
o != null && o.isScene ? (e = o, e_(e, a, "", {})) : (e = new Ur(), e_(e, a, "", {}), o && d_(e, o)), w.set({ scene: e });
}
d && !w.events.handlers && w.set({ events: d(a) });
let k = yv(e, i);
if (Yg.equ(k, w.size, vv) || w.setSize(k.width, k.height, k.top, k.left), y && w.viewport.dpr !== qg(y) && w.setDpr(y), w.frameloop !== v && w.setFrameloop(v), w.onPointerMissed || w.set({ onPointerMissed: C }), b && !Yg.equ(b, w.performance, vv) && w.set((e) => ({ performance: {
...e.performance,
...b
} })), !w.xr) {
var A;
let e = (e, t) => {
let n = a.getState();
n.frameloop !== "never" && Bv(e, !0, n, t);
}, t = () => {
let t = a.getState();
t.gl.xr.enabled = t.gl.xr.isPresenting, t.gl.xr.setAnimationLoop(t.gl.xr.isPresenting ? e : null), t.gl.xr.isPresenting || zv(t);
}, n = {
connect() {
let e = a.getState().gl;
e.xr.addEventListener("sessionstart", t), e.xr.addEventListener("sessionend", t);
},
disconnect() {
let e = a.getState().gl;
e.xr.removeEventListener("sessionstart", t), e.xr.removeEventListener("sessionend", t);
}
};
typeof ((A = T.xr) == null ? void 0 : A.addEventListener) == "function" && n.connect(), w.set({ xr: n });
}
if (T.shadowMap) {
let e = T.shadowMap.enabled, t = T.shadowMap.type;
if (T.shadowMap.enabled = !!p, Yg.boo(p)) T.shadowMap.type = 2;
else if (Yg.str(p)) {
var ee;
let e = {
basic: 0,
percentage: 1,
soft: 2,
variance: 3
};
T.shadowMap.type = (ee = e[p]) == null ? 2 : ee;
} else Yg.obj(p) && Object.assign(T.shadowMap, p);
(e !== T.shadowMap.enabled || t !== T.shadowMap.type) && (T.shadowMap.needsUpdate = !0);
}
return Hn.enabled = !g, l || (T.outputColorSpace = m ? xt : bt, T.toneMapping = h ? 0 : 4), w.legacy !== g && w.set(() => ({ legacy: g })), w.linear !== m && w.set(() => ({ linear: m })), w.flat !== h && w.set(() => ({ flat: h })), r && !Yg.fun(r) && !b_(r) && !Yg.equ(r, T, vv) && d_(T, r), s = f, l = !0, n(), this;
},
render(t) {
return !l && !u && this.configure(), u.then(() => {
gv.updateContainer(/*#__PURE__*/ (0, Dg.jsx)(xv, {
store: a,
children: t,
onCreated: s,
rootElement: e
}), o, null, () => void 0);
}), a;
},
unmount() {
Sv(e);
}
};
}
function xv({ store: e, children: t, onCreated: n, rootElement: r }) {
return Hg(() => {
let t = e.getState();
t.set((e) => ({ internal: {
...e.internal,
active: !0
} })), n && n(t), e.getState().events.connected || t.events.connect == null || t.events.connect(r);
}, []), /*#__PURE__*/ (0, Dg.jsx)(x_.Provider, {
value: e,
children: t
});
}
function Sv(e, t) {
let n = _v.get(e), r = n == null ? void 0 : n.fiber;
if (r) {
let i = n == null ? void 0 : n.store.getState();
i && (i.internal.active = !1), gv.updateContainer(null, r, null, () => {
i && setTimeout(() => {
try {
var n, r, a, o;
i.events.disconnect == null || i.events.disconnect(), (n = i.gl) == null || (r = n.renderLists) == null || r.dispose == null || r.dispose(), (a = i.gl) == null || a.forceContextLoss == null || a.forceContextLoss(), (o = i.gl) != null && o.xr && i.xr.disconnect(), Zg(i.scene), _v.delete(e), t && t(e);
} catch {}
}, 500);
});
}
}
function Cv(e, t) {
let n = { callback: e };
return t.add(n), () => void t.delete(n);
}
var wv = /* @__PURE__ */ new Set(), Tv = /* @__PURE__ */ new Set(), Ev = /* @__PURE__ */ new Set(), Dv = (e) => Cv(e, Tv);
function Ov(e, t) {
if (e.size) for (let { callback: n } of e.values()) n(t);
}
function kv(e, t) {
switch (e) {
case "before": return Ov(wv, t);
case "after": return Ov(Tv, t);
case "tail": return Ov(Ev, t);
}
}
var Av, jv;
function Mv(e, t, n) {
let r = t.clock.getDelta();
t.frameloop === "never" && typeof e == "number" && (r = e - t.clock.elapsedTime, t.clock.oldTime = t.clock.elapsedTime, t.clock.elapsedTime = e), Av = t.internal.subscribers;
for (let e = 0; e < Av.length; e++) jv = Av[e], jv.ref.current(jv.store.getState(), r, n);
return !t.internal.priority && t.gl.render && t.gl.render(t.scene, t.camera), t.internal.frames = Math.max(0, t.internal.frames - 1), t.frameloop === "always" ? 1 : t.internal.frames;
}
var Nv = !1, Pv = !1, Fv, Iv, Lv;
function Rv(e) {
Iv = requestAnimationFrame(Rv), Nv = !0, Fv = 0, kv("before", e), Pv = !0;
for (let n of _v.values()) {
var t;
Lv = n.store.getState(), Lv.internal.active && (Lv.frameloop === "always" || Lv.internal.frames > 0) && !((t = Lv.gl.xr) != null && t.isPresenting) && (Fv += Mv(e, Lv));
}
if (Pv = !1, kv("after", e), Fv === 0) return kv("tail", e), Nv = !1, cancelAnimationFrame(Iv);
}
function zv(e, t = 1) {
var n;
if (!e) return _v.forEach((e) => zv(e.store.getState(), t));
(n = e.gl.xr) != null && n.isPresenting || !e.internal.active || e.frameloop === "never" || (t > 1 ? e.internal.frames = Math.min(60, e.internal.frames + t) : Pv ? e.internal.frames = 2 : e.internal.frames = 1, Nv || (Nv = !0, requestAnimationFrame(Rv)));
}
function Bv(e, t = !0, n, r) {
if (t && kv("before", e), n) Mv(e, n, r);
else for (let t of _v.values()) Mv(e, t.store.getState());
t && kv("after", e);
}
var Vv = {
onClick: ["click", !1],
onContextMenu: ["contextmenu", !1],
onDoubleClick: ["dblclick", !1],
onWheel: ["wheel", !0],
onPointerDown: ["pointerdown", !0],
onPointerUp: ["pointerup", !0],
onPointerLeave: ["pointerleave", !0],
onPointerMove: ["pointermove", !0],
onPointerCancel: ["pointercancel", !0],
onLostPointerCapture: ["lostpointercapture", !0]
};
function Hv(e) {
let { handlePointer: t } = y_(e);
return {
priority: 1,
enabled: !0,
compute(e, t, n) {
t.pointer.set(e.offsetX / t.size.width * 2 - 1, -(e.offsetY / t.size.height) * 2 + 1), t.raycaster.setFromCamera(t.pointer, t.camera);
},
connected: void 0,
handlers: Object.keys(Vv).reduce((e, n) => ({
...e,
[n]: t(n)
}), {}),
update: () => {
var t;
let { events: n, internal: r } = e.getState();
(t = r.lastEvent) != null && t.current && n.handlers && n.handlers.onPointerMove(r.lastEvent.current);
},
connect: (t) => {
let { set: n, events: r } = e.getState();
if (r.disconnect == null || r.disconnect(), n((e) => ({ events: {
...e.events,
connected: t
} })), r.handlers) for (let e in r.handlers) {
let n = r.handlers[e], [i, a] = Vv[e];
t.addEventListener(i, n, { passive: a });
}
},
disconnect: () => {
let { set: t, events: n } = e.getState();
if (n.connected) {
if (n.handlers) for (let e in n.handlers) {
let t = n.handlers[e], [r] = Vv[e];
n.connected.removeEventListener(r, t);
}
t((e) => ({ events: {
...e.events,
connected: void 0
} }));
}
}
};
}
//#endregion
//#region ../renderer/src/debug/debug-context.ts
var Uv = ug(), Wv = (0, c.createContext)(null), Gv = () => (0, c.use)(Wv), Kv = (0, c.createContext)(null), qv = () => {};
function Jv() {
let e = (0, Uv.c)(6), t = (0, c.use)(Kv), n;
e[0] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ new Set(), e[0] = n) : n = e[0];
let r = (0, c.useRef)(n), i, a;
if (e[1] === t ? (i = e[2], a = e[3]) : (i = () => {
if (!t) return;
let e = r.current;
return () => e.forEach((e) => t.remove(e));
}, a = [t], e[1] = t, e[2] = i, e[3] = a), (0, c.useEffect)(i, a), !t) return qv;
let o;
return e[4] === t ? o = e[5] : (o = (e, n) => {
r.current.add(e), t.set(e, n);
}, e[4] = t, e[5] = o), o;
}
//#endregion
export { co as $, Tt as $t, Ro as A, E as At, Xa as B, jd as Bt, Q as C, Tl as Ct, Xh as D, w as Dt, cg as E, yl as Et, xu as F, po as Ft, K as G, we as Gt, Au as H, Gl as Ht, ps as I, Xc as It, Nr as J, wa as Jt, N as K, xe as Kt, C as L, Du as Lt, ii as M, Mr as Mt, Di as N, Ou as Nt, Kf as O, T as Ot, q as P, Z as Pt, Bd as Q, S as Qt, G as R, is as Rt, ug as S, al as Sn, Ta as St, $ as T, bl as Tt, Mt as U, _t as Ut, hs as V, Fn as Vt, iu as W, ge as Wt, eo as X, ye as Xt, Ku as Y, Ud as Yt, Ru as Z, be as Zt, Hg as _, V as _n, Zi as _t, Gg as a, Jn as an, ct as at, w_ as b, ql as bn, W as bt, Dv as c, Tu as cn, zo as ct, bv as d, Qn as dn, A as dt, bt as en, oe as et, Z_ as f, du as fn, ne as ft, T_ as g, ae as gn, Lu as gt, Wg as h, se as hn, tu as ht, Gv as i, Ja as in, st as it, Ya as j, Ul as jt, Jl as k, O as kt, Bv as l, fa as ln, Qo as lt, Sv as m, M as mn, xt as mt, Wv as n, _l as nn, Yi as nt, Kg as o, zi as on, qo as ot, Bg as p, ml as pn, ee as pt, _o as q, Se as qt, Jv as r, $a as rn, Il as rt, _v as s, qd as sn, of as st, Kv as t, Ur as tn, qi as tt, Hv as u, Qi as un, Zo as ut, Ug as v, H as vn, Pn as vt, Yf as w, El as wt, Mg as x, tr as xn, La as xt, C_ as y, $n as yn, U as yt, Hn as z, $o as zt };